diff options
Diffstat (limited to 'libdimension/dimension/refcount.h')
-rw-r--r-- | libdimension/dimension/refcount.h | 9 |
1 files changed, 8 insertions, 1 deletions
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 |