From 1de647b9d38528b640f8da473d50c04ef0674c58 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Fri, 30 May 2014 20:24:03 -0400 Subject: scene: Get rid of dmnsn_delete_scene(). --- libdimension/scene.c | 32 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 17 deletions(-) (limited to 'libdimension/scene.c') diff --git a/libdimension/scene.c b/libdimension/scene.c index 6500707..610b8f9 100644 --- a/libdimension/scene.c +++ b/libdimension/scene.c @@ -26,11 +26,25 @@ #include "dimension-internal.h" #include +static void +dmnsn_scene_cleanup(void *ptr) +{ + dmnsn_scene *scene = ptr; + DMNSN_ARRAY_FOREACH (dmnsn_object **, object, scene->objects) { + dmnsn_delete_object(*object); + } + + dmnsn_delete_array(scene->lights); + dmnsn_delete_array(scene->objects); + dmnsn_delete_texture(scene->default_texture); + dmnsn_delete_pigment(scene->background); +} + /* Allocate an empty scene */ dmnsn_scene * dmnsn_new_scene(dmnsn_pool *pool) { - dmnsn_scene *scene = DMNSN_PALLOC(pool, dmnsn_scene); + dmnsn_scene *scene = DMNSN_PALLOC_TIDY(pool, dmnsn_scene, dmnsn_scene_cleanup); scene->background = NULL; scene->default_texture = dmnsn_new_texture(); @@ -52,22 +66,6 @@ dmnsn_new_scene(dmnsn_pool *pool) return scene; } -/* Free a scene */ -void -dmnsn_delete_scene(dmnsn_scene *scene) -{ - if (scene) { - DMNSN_ARRAY_FOREACH (dmnsn_object **, object, scene->objects) { - dmnsn_delete_object(*object); - } - - dmnsn_delete_array(scene->lights); - dmnsn_delete_array(scene->objects); - dmnsn_delete_texture(scene->default_texture); - dmnsn_delete_pigment(scene->background); - } -} - void dmnsn_scene_initialize(dmnsn_scene *scene) { -- cgit v1.2.3