summaryrefslogtreecommitdiffstats
path: root/libdimension/dimension/refcount.h
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2011-06-12 02:37:51 -0600
committerTavian Barnes <tavianator@gmail.com>2011-06-13 00:16:06 -0600
commit7acd8ea6673b7a90ed4041408ccf1b024b8a007a (patch)
treed52199dd7c58e0217bfd1a74e7601d739ad333f5 /libdimension/dimension/refcount.h
parent066261810c2fca192677c5c1c01c91d6ecec65a0 (diff)
downloaddimension-7acd8ea6673b7a90ed4041408ccf1b024b8a007a.tar.xz
Vast libdimension API and internals improvements.
Couldn't really do these while I was trying to be POV-Ray compatible, 'cause they would've broken compatibility.
Diffstat (limited to 'libdimension/dimension/refcount.h')
-rw-r--r--libdimension/dimension/refcount.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/libdimension/dimension/refcount.h b/libdimension/dimension/refcount.h
index 4431cbc..be437a8 100644
--- a/libdimension/dimension/refcount.h
+++ b/libdimension/dimension/refcount.h
@@ -32,7 +32,7 @@ typedef unsigned int dmnsn_refcount;
* Increment a reference count.
* @param[in,out] object The reference-counted object to acquire.
*/
-#define DMNSN_INCREF(obj) ((void)++(obj)->refcount)
+#define DMNSN_INCREF(obj) ((void)((obj) && ++(obj)->refcount))
/**
* @internal
@@ -40,4 +40,5 @@ typedef unsigned int dmnsn_refcount;
* @param[in,out] object The reference-counted object to release.
* @return Whether the object is now garbage.
*/
-#define DMNSN_DECREF(obj) ((obj)->refcount == 0 || --(obj)->refcount == 0)
+#define DMNSN_DECREF(obj) \
+ ((obj) && ((obj)->refcount == 0 || --(obj)->refcount == 0))