diff options
author | Tavian Barnes <tavianator@tavianator.com> | 2014-05-31 15:34:59 -0400 |
---|---|---|
committer | Tavian Barnes <tavianator@tavianator.com> | 2014-05-31 15:34:59 -0400 |
commit | 180714c96505c53d380e2f205034f587cab0466d (patch) | |
tree | 62d1c654189abc715f2499e82345305417d31565 /libdimension/object.c | |
parent | 74323fa54010d29737281579e4f3b4038da94989 (diff) | |
download | dimension-180714c96505c53d380e2f205034f587cab0466d.tar.xz |
object: Use pool.
Diffstat (limited to 'libdimension/object.c')
-rw-r--r-- | libdimension/object.c | 31 |
1 files changed, 5 insertions, 26 deletions
diff --git a/libdimension/object.c b/libdimension/object.c index 674eea8..432e473 100644 --- a/libdimension/object.c +++ b/libdimension/object.c @@ -26,50 +26,29 @@ #include "dimension-internal.h" #include <stdlib.h> -static void -dmnsn_default_object_free_fn(dmnsn_object *object) -{ - dmnsn_free(object); -} - /* Allocate a dummy object */ dmnsn_object * -dmnsn_new_object(void) +dmnsn_new_object(dmnsn_pool *pool) { - dmnsn_object *object = DMNSN_MALLOC(dmnsn_object); - dmnsn_init_object(object); + dmnsn_object *object = DMNSN_PALLOC(pool, dmnsn_object); + dmnsn_init_object(pool, object); return object; } /* Initialize a dmnsn_object field */ void -dmnsn_init_object(dmnsn_object *object) +dmnsn_init_object(dmnsn_pool *pool, dmnsn_object *object) { object->texture = NULL; object->interior = NULL; object->trans = dmnsn_identity_matrix(); object->intrinsic_trans = dmnsn_identity_matrix(); - object->children = DMNSN_NEW_ARRAY(dmnsn_object *); + object->children = DMNSN_PALLOC_ARRAY(pool, dmnsn_object *); object->split_children = false; object->intersection_fn = NULL; object->inside_fn = NULL; object->initialize_fn = NULL; - object->free_fn = dmnsn_default_object_free_fn; object->initialized = false; - DMNSN_REFCOUNT_INIT(object); -} - -/* Free a dmnsn_object */ -void -dmnsn_delete_object(dmnsn_object *object) -{ - if (DMNSN_DECREF(object)) { - DMNSN_ARRAY_FOREACH (dmnsn_object **, child, object->children) { - dmnsn_delete_object(*child); - } - dmnsn_delete_array(object->children); - object->free_fn(object); - } } /** Recursively initialize objects. */ |