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/bench | |
parent | 74323fa54010d29737281579e4f3b4038da94989 (diff) | |
download | dimension-180714c96505c53d380e2f205034f587cab0466d.tar.xz |
object: Use pool.
Diffstat (limited to 'libdimension/bench')
-rw-r--r-- | libdimension/bench/prtree.c | 22 | ||||
-rw-r--r-- | libdimension/bench/triangle.c | 9 |
2 files changed, 15 insertions, 16 deletions
diff --git a/libdimension/bench/prtree.c b/libdimension/bench/prtree.c index f05f04c..c09a701 100644 --- a/libdimension/bench/prtree.c +++ b/libdimension/bench/prtree.c @@ -58,13 +58,13 @@ dmnsn_randomize_bounding_box(dmnsn_object *object) } static dmnsn_object * -dmnsn_new_fake_object(void) +dmnsn_new_fake_object(dmnsn_pool *pool) { - dmnsn_object *object = dmnsn_new_object(); + dmnsn_object *object = dmnsn_new_object(pool); /* Generate a bounding box in (-1, -1, -1), (1, 1, 1) */ dmnsn_randomize_bounding_box(object); object->intersection_fn = dmnsn_fake_intersection_fn; - object->inside_fn = dmnsn_fake_inside_fn; + object->inside_fn = dmnsn_fake_inside_fn; return object; } @@ -79,13 +79,13 @@ main(void) return EXIT_FAILURE; } - dmnsn_array *objects = DMNSN_NEW_ARRAY(dmnsn_object *); - dmnsn_texture *texture = dmnsn_new_texture(); - texture->pigment = dmnsn_new_pigment(); + dmnsn_pool *pool = dmnsn_new_pool(); + dmnsn_array *objects = DMNSN_PALLOC_ARRAY(pool, dmnsn_object *); + dmnsn_texture *texture = dmnsn_new_texture(pool); + texture->pigment = dmnsn_new_pigment(pool); for (size_t i = 0; i < nobjects; ++i) { - dmnsn_object *object = dmnsn_new_fake_object(); + dmnsn_object *object = dmnsn_new_fake_object(pool); object->texture = texture; - DMNSN_INCREF(object->texture); dmnsn_object_initialize(object); dmnsn_array_push(objects, &object); } @@ -121,10 +121,6 @@ main(void) /* Cleanup */ dmnsn_delete_bvh(bvh); - DMNSN_ARRAY_FOREACH (dmnsn_object **, object, objects) { - dmnsn_delete_object(*object); - } - dmnsn_delete_texture(texture); - dmnsn_delete_array(objects); + dmnsn_delete_pool(pool); return EXIT_SUCCESS; } diff --git a/libdimension/bench/triangle.c b/libdimension/bench/triangle.c index 18944e8..39b9322 100644 --- a/libdimension/bench/triangle.c +++ b/libdimension/bench/triangle.c @@ -30,13 +30,16 @@ main(void) return EXIT_FAILURE; } + dmnsn_pool *pool = dmnsn_new_pool(); + dmnsn_object *triangle = dmnsn_new_flat_triangle( + pool, dmnsn_new_vector(1.0, 0.0, 0.0), dmnsn_new_vector(2.0, 2.0, 1.0), dmnsn_new_vector(3.0, 0.0, 2.0) ); - triangle->texture = dmnsn_new_texture(); - triangle->texture->pigment = dmnsn_new_pigment(); + triangle->texture = dmnsn_new_texture(pool); + triangle->texture->pigment = dmnsn_new_pigment(pool); dmnsn_object_initialize(triangle); dmnsn_intersection intersection; @@ -59,7 +62,7 @@ main(void) dmnsn_assert(!intersected, "Intersected"); printf("dmnsn_triangle_intersection(false): %ld\n", sandglass.grains); - dmnsn_delete_object(triangle); + dmnsn_delete_pool(pool); return EXIT_SUCCESS; } |