From 250c28ccdef5f238677b34f21ec7fab06588a127 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Thu, 28 Jul 2011 21:34:45 -0600 Subject: Make the checker pattern a singleton. --- libdimension/dimension/refcount.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'libdimension/dimension/refcount.h') 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