From d374841194f24c7cb1cdc52fc631fcb2982af358 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Mon, 16 May 2011 23:25:53 -0600 Subject: Add a refcount to objects. --- libdimension/object.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'libdimension/object.c') 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); } -- cgit v1.2.3