summaryrefslogtreecommitdiffstats
path: root/libdimension/object.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2009-07-16 01:16:09 +0000
committerTavian Barnes <tavianator@gmail.com>2009-07-16 01:16:09 +0000
commit8f01c5394dcce8f5d4e7102dacfcdea9d1f7b021 (patch)
tree4092a281882e34ac53ec15d582dcbf2cb0d408c0 /libdimension/object.c
parent1928016fe7aa439d4bfb61d3a7e7b7399ca7a229 (diff)
downloaddimension-8f01c5394dcce8f5d4e7102dacfcdea9d1f7b021.tar.xz
Add destructor callbacks for polymorphic C types, and use their base
dmnsn_delete_*() function.
Diffstat (limited to 'libdimension/object.c')
-rw-r--r--libdimension/object.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/libdimension/object.c b/libdimension/object.c
index 0556921..6b248ff 100644
--- a/libdimension/object.c
+++ b/libdimension/object.c
@@ -28,7 +28,8 @@ dmnsn_new_object()
dmnsn_object *object = malloc(sizeof(dmnsn_object));
if (object) {
object->texture = NULL;
- object->trans = dmnsn_identity_matrix();
+ object->trans = dmnsn_identity_matrix();
+ object->free_fn = NULL;
}
return object;
}
@@ -37,5 +38,10 @@ dmnsn_new_object()
void
dmnsn_delete_object(dmnsn_object *object)
{
- free(object);
+ if (object) {
+ if (object->free_fn) {
+ (*object->free_fn)(object->ptr);
+ }
+ free(object);
+ }
}