summaryrefslogtreecommitdiffstats
path: root/libdimension
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2014-05-30 15:07:35 -0400
committerTavian Barnes <tavianator@tavianator.com>2014-05-30 15:07:35 -0400
commit77f880207d4fc37f82299d78d04be13623d9da0a (patch)
tree1da61bc0b17e803a14ef42b068b089a262302f53 /libdimension
parent2b546944a1f0c5646936f2ab047345769e3a2471 (diff)
downloaddimension-77f880207d4fc37f82299d78d04be13623d9da0a.tar.xz
scene: Use pool.
Diffstat (limited to 'libdimension')
-rw-r--r--libdimension/dimension/scene.h5
-rw-r--r--libdimension/scene.c5
-rw-r--r--libdimension/tests/render.c8
3 files changed, 10 insertions, 8 deletions
diff --git a/libdimension/dimension/scene.h b/libdimension/dimension/scene.h
index 875c1bb..321fac2 100644
--- a/libdimension/dimension/scene.h
+++ b/libdimension/dimension/scene.h
@@ -1,5 +1,5 @@
/*************************************************************************
- * Copyright (C) 2010-2011 Tavian Barnes <tavianator@tavianator.com> *
+ * Copyright (C) 2010-2014 Tavian Barnes <tavianator@tavianator.com> *
* *
* This file is part of The Dimension Library. *
* *
@@ -83,9 +83,10 @@ typedef struct dmnsn_scene {
/**
* Create a scene.
+ * @param[in] pool The memory pool to allocate from.
* @return A new empty scene.
*/
-dmnsn_scene *dmnsn_new_scene(void);
+dmnsn_scene *dmnsn_new_scene(dmnsn_pool *pool);
/**
* Delete a scene.
diff --git a/libdimension/scene.c b/libdimension/scene.c
index 9f8104b..2d25602 100644
--- a/libdimension/scene.c
+++ b/libdimension/scene.c
@@ -28,9 +28,9 @@
/* Allocate an empty scene */
dmnsn_scene *
-dmnsn_new_scene(void)
+dmnsn_new_scene(dmnsn_pool *pool)
{
- dmnsn_scene *scene = DMNSN_MALLOC(dmnsn_scene);
+ dmnsn_scene *scene = DMNSN_PALLOC(pool, dmnsn_scene);
scene->background = NULL;
scene->default_texture = dmnsn_new_texture();
@@ -71,7 +71,6 @@ dmnsn_delete_scene(dmnsn_scene *scene)
dmnsn_delete_interior(scene->default_interior);
dmnsn_delete_texture(scene->default_texture);
dmnsn_delete_pigment(scene->background);
- dmnsn_free(scene);
}
}
diff --git a/libdimension/tests/render.c b/libdimension/tests/render.c
index 0192d35..e68dcc4 100644
--- a/libdimension/tests/render.c
+++ b/libdimension/tests/render.c
@@ -301,9 +301,9 @@ dmnsn_test_scene_add_objects(dmnsn_scene *scene)
* Test scene
*/
static dmnsn_scene *
-dmnsn_new_test_scene(void)
+dmnsn_new_test_scene(dmnsn_pool *pool)
{
- dmnsn_scene *scene = dmnsn_new_scene();
+ dmnsn_scene *scene = dmnsn_new_scene(pool);
dmnsn_test_scene_set_defaults(scene);
dmnsn_test_scene_add_canvas(scene);
dmnsn_test_scene_add_camera(scene);
@@ -320,7 +320,8 @@ main(void)
dmnsn_die_on_warnings(true);
/* Create the test scene */
- dmnsn_scene *scene = dmnsn_new_test_scene();
+ dmnsn_pool *pool = dmnsn_new_pool();
+ dmnsn_scene *scene = dmnsn_new_test_scene(pool);
/* Optimize the canvas for PNG export */
bool have_png = true;
@@ -422,5 +423,6 @@ main(void)
dmnsn_delete_display(display);
dmnsn_delete_scene(scene);
+ dmnsn_delete_pool(pool);
return EXIT_SUCCESS;
}