summaryrefslogtreecommitdiffstats
path: root/libdimension/pigment.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2014-05-27 13:46:51 -0400
committerTavian Barnes <tavianator@tavianator.com>2014-05-27 13:50:29 -0400
commitdf33e223baa85b600863fc1b38850a5c37680632 (patch)
treeefc2444caebb69980702559d4e4ec99610016f9d /libdimension/pigment.c
parent3c2e6050b579c8e3c16d980e2ce70436d87e3a2d (diff)
downloaddimension-df33e223baa85b600863fc1b38850a5c37680632.tar.xz
pigment: Kill ->ptr field.
Diffstat (limited to 'libdimension/pigment.c')
-rw-r--r--libdimension/pigment.c30
1 files changed, 20 insertions, 10 deletions
diff --git a/libdimension/pigment.c b/libdimension/pigment.c
index 6134c2b..e392d7b 100644
--- a/libdimension/pigment.c
+++ b/libdimension/pigment.c
@@ -25,19 +25,32 @@
#include "dimension-internal.h"
+static void
+dmnsn_default_pigment_free_fn(dmnsn_pigment *pigment)
+{
+ dmnsn_free(pigment);
+}
+
/* Allocate a dummy pigment */
dmnsn_pigment *
dmnsn_new_pigment(void)
{
dmnsn_pigment *pigment = DMNSN_MALLOC(dmnsn_pigment);
- pigment->pigment_fn = NULL;
+ dmnsn_init_pigment(pigment);
+ return pigment;
+}
+
+/* Initialize a pigment */
+void
+dmnsn_init_pigment(dmnsn_pigment *pigment)
+{
+ pigment->pigment_fn = NULL;
pigment->initialize_fn = NULL;
- pigment->free_fn = NULL;
- pigment->trans = dmnsn_identity_matrix();
- pigment->quick_color = DMNSN_TCOLOR(dmnsn_black);
- pigment->initialized = false;
+ pigment->free_fn = dmnsn_default_pigment_free_fn;
+ pigment->trans = dmnsn_identity_matrix();
+ pigment->quick_color = DMNSN_TCOLOR(dmnsn_black);
+ pigment->initialized = false;
DMNSN_REFCOUNT_INIT(pigment);
- return pigment;
}
/* Free a pigment */
@@ -45,10 +58,7 @@ void
dmnsn_delete_pigment(dmnsn_pigment *pigment)
{
if (DMNSN_DECREF(pigment)) {
- if (pigment->free_fn) {
- pigment->free_fn(pigment->ptr);
- }
- dmnsn_free(pigment);
+ pigment->free_fn(pigment);
}
}