From 7acd8ea6673b7a90ed4041408ccf1b024b8a007a Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Sun, 12 Jun 2011 02:37:51 -0600 Subject: 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. --- libdimension/dimension/refcount.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'libdimension/dimension/refcount.h') 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)) -- cgit v1.2.3