summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libdimension/dimension/refcount.h9
-rw-r--r--libdimension/finish.c9
2 files changed, 5 insertions, 13 deletions
diff --git a/libdimension/dimension/refcount.h b/libdimension/dimension/refcount.h
index 337147f..d0f688e 100644
--- a/libdimension/dimension/refcount.h
+++ b/libdimension/dimension/refcount.h
@@ -33,11 +33,4 @@
* Increment a reference count.
* @param[in,out] object The reference-counted object to acquire.
*/
-#define DMNSN_INCREF(object) \
- do { \
- /* Suppress "address will always evaluate to true" warning */ \
- void *testptr = (object); \
- if (testptr) { \
- ++(object)->DMNSN_REFCOUNT_FIELD; \
- } \
- } while (0)
+#define DMNSN_INCREF(object) (++(object)->DMNSN_REFCOUNT_FIELD)
diff --git a/libdimension/finish.c b/libdimension/finish.c
index e5ba88e..620487e 100644
--- a/libdimension/finish.c
+++ b/libdimension/finish.c
@@ -140,25 +140,24 @@ dmnsn_finish_incref(dmnsn_finish *finish)
if (finish->reflection) {
DMNSN_INCREF(finish->reflection);
}
-
}
void
dmnsn_finish_cascade(const dmnsn_finish *default_finish, dmnsn_finish *finish)
{
- if (!finish->ambient) {
+ if (!finish->ambient && default_finish->ambient) {
finish->ambient = default_finish->ambient;
DMNSN_INCREF(finish->ambient);
}
- if (!finish->diffuse) {
+ if (!finish->diffuse && default_finish->diffuse) {
finish->diffuse = default_finish->diffuse;
DMNSN_INCREF(finish->diffuse);
}
- if (!finish->specular) {
+ if (!finish->specular && default_finish->specular) {
finish->specular = default_finish->specular;
DMNSN_INCREF(finish->specular);
}
- if (!finish->reflection) {
+ if (!finish->reflection && default_finish->reflection) {
finish->reflection = default_finish->reflection;
DMNSN_INCREF(finish->reflection);
}