summaryrefslogtreecommitdiffstats
path: root/libdimension/object.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2011-05-16 23:25:53 -0600
committerTavian Barnes <tavianator@gmail.com>2011-05-16 23:25:53 -0600
commitd374841194f24c7cb1cdc52fc631fcb2982af358 (patch)
treefa92504fb50c6a4195317dad653ed3ab72fa6f27 /libdimension/object.c
parent719fea8f97320814835408fad6ce2a4647674c11 (diff)
downloaddimension-d374841194f24c7cb1cdc52fc631fcb2982af358.tar.xz
Add a refcount to objects.
Diffstat (limited to 'libdimension/object.c')
-rw-r--r--libdimension/object.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/libdimension/object.c b/libdimension/object.c
index 7c4a714..f73ea02 100644
--- a/libdimension/object.c
+++ b/libdimension/object.c
@@ -39,6 +39,7 @@ dmnsn_new_object(void)
object->inside_fn = NULL;
object->initialize_fn = NULL;
object->free_fn = NULL;
+ object->refcount = dmnsn_new_refcount();
return object;
}
@@ -46,7 +47,8 @@ dmnsn_new_object(void)
void
dmnsn_delete_object(dmnsn_object *object)
{
- if (object) {
+ if (object && DMNSN_DECREF(object)) {
+ dmnsn_delete_refcount(object->refcount);
DMNSN_ARRAY_FOREACH (dmnsn_object **, child, object->children) {
dmnsn_delete_object(*child);
}