From 250c28ccdef5f238677b34f21ec7fab06588a127 Mon Sep 17 00:00:00 2001
From: Tavian Barnes <tavianator@gmail.com>
Date: Thu, 28 Jul 2011 21:34:45 -0600
Subject: Make the checker pattern a singleton.

---
 libdimension/dimension/pattern.h  | 12 ------------
 libdimension/dimension/refcount.h |  9 ++++++++-
 2 files changed, 8 insertions(+), 13 deletions(-)

(limited to 'libdimension/dimension')

diff --git a/libdimension/dimension/pattern.h b/libdimension/dimension/pattern.h
index de37286..596ed35 100644
--- a/libdimension/dimension/pattern.h
+++ b/libdimension/dimension/pattern.h
@@ -40,9 +40,6 @@ struct dmnsn_pattern {
   dmnsn_pattern_fn *pattern_fn; /**< The pattern callback. */
   dmnsn_free_fn    *free_fn;    /**< The destructor callback. */
 
-  dmnsn_matrix trans;     /**< The transformation matrix of the pattern. */
-  dmnsn_matrix trans_inv; /**< The inverse of the transformation matrix. */
-
   void *ptr; /**< Generic pointer. */
 
   dmnsn_refcount refcount; /**< @internal Reference count. */
@@ -60,15 +57,6 @@ dmnsn_pattern *dmnsn_new_pattern(void);
  */
 void dmnsn_delete_pattern(dmnsn_pattern *pattern);
 
-/**
- * Initialize a pattern.  This precomputes some values that are used during
- * ray-tracing; the pattern will not work until it has been initialized, but
- * should not be modified after it has been initialized.  Patterns are generally
- * initialized for you.
- * @param[in,out] pattern  The pattern to initialize.
- */
-void dmnsn_initialize_pattern(dmnsn_pattern *pattern);
-
 /**
  * Invoke the pattern callback with the right transformation.
  * @param[in] pattern  The pattern to evaluate.
diff --git a/libdimension/dimension/refcount.h b/libdimension/dimension/refcount.h
index 5ffde4c..a0f5b6e 100644
--- a/libdimension/dimension/refcount.h
+++ b/libdimension/dimension/refcount.h
@@ -32,7 +32,14 @@ typedef unsigned int dmnsn_refcount;
  * Increment a reference count.
  * @param[in,out] object  The reference-counted object to acquire.
  */
-#define DMNSN_INCREF(object) ((void)((object) && ++(object)->refcount))
+#define DMNSN_INCREF(object)                                            \
+  do {                                                                  \
+    /* Suppress "address will always evaluate to true" warning */       \
+    void *testptr = (object);                                           \
+    if (testptr) {                                                      \
+      ++(object)->refcount;                                             \
+    }                                                                   \
+  } while (0)
 
 /**
  * @internal
-- 
cgit v1.2.3