summaryrefslogtreecommitdiffstats
path: root/libdimension
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2010-09-26 00:46:34 -0400
committerTavian Barnes <tavianator@gmail.com>2010-09-26 00:46:34 -0400
commit725bd4f0b4cc067fc2770f7f8ffd9c815c745239 (patch)
tree2bf8c049473d27057ce8cbac2a08eb2be05443b6 /libdimension
parent46bf25a9bed9eec6aaa8c4cad8144c7df629da30 (diff)
downloaddimension-725bd4f0b4cc067fc2770f7f8ffd9c815c745239.tar.xz
Add dmnsn_free() to match dmnsn_malloc().
Diffstat (limited to 'libdimension')
-rw-r--r--libdimension/camera.c2
-rw-r--r--libdimension/canvas.c6
-rw-r--r--libdimension/csg.c2
-rw-r--r--libdimension/dimension/array.h4
-rw-r--r--libdimension/dimension/list.h4
-rw-r--r--libdimension/dimension/malloc.h1
-rw-r--r--libdimension/finish_combination.c2
-rw-r--r--libdimension/gl.c6
-rw-r--r--libdimension/interior.c4
-rw-r--r--libdimension/light.c2
-rw-r--r--libdimension/list.c2
-rw-r--r--libdimension/malloc.c6
-rw-r--r--libdimension/object.c2
-rw-r--r--libdimension/png.c26
-rw-r--r--libdimension/progress.c10
-rw-r--r--libdimension/prtree.c6
-rw-r--r--libdimension/raytrace.c6
-rw-r--r--libdimension/scene.c2
-rw-r--r--libdimension/texture.c8
-rw-r--r--libdimension/threads.c2
20 files changed, 55 insertions, 48 deletions
diff --git a/libdimension/camera.c b/libdimension/camera.c
index ba5a1aa..08c4e1a 100644
--- a/libdimension/camera.c
+++ b/libdimension/camera.c
@@ -38,6 +38,6 @@ dmnsn_delete_camera(dmnsn_camera *camera)
if (camera->free_fn) {
(*camera->free_fn)(camera->ptr);
}
- free(camera);
+ dmnsn_free(camera);
}
}
diff --git a/libdimension/canvas.c b/libdimension/canvas.c
index 7da63f8..da4f1aa 100644
--- a/libdimension/canvas.c
+++ b/libdimension/canvas.c
@@ -19,7 +19,7 @@
*************************************************************************/
#include "dimension.h"
-#include <stdlib.h> /* For free() */
+#include <stdlib.h> /* For dmnsn_free() */
/* Allocate a new canvas, of width x and height y */
dmnsn_canvas *
@@ -55,8 +55,8 @@ dmnsn_delete_canvas(dmnsn_canvas *canvas)
dmnsn_delete_array(canvas->optimizers);
/* Free the pixels and canvas */
- free(canvas->pixels);
- free(canvas);
+ dmnsn_free(canvas->pixels);
+ dmnsn_free(canvas);
}
}
diff --git a/libdimension/csg.c b/libdimension/csg.c
index a3c1218..cfce242 100644
--- a/libdimension/csg.c
+++ b/libdimension/csg.c
@@ -101,7 +101,7 @@ dmnsn_csg_free_fn(void *ptr)
dmnsn_object **params = ptr;
dmnsn_delete_object(params[1]);
dmnsn_delete_object(params[0]);
- free(ptr);
+ dmnsn_free(ptr);
}
/* Generic CSG intersection function */
diff --git a/libdimension/dimension/array.h b/libdimension/dimension/array.h
index fd78deb..85543cc 100644
--- a/libdimension/dimension/array.h
+++ b/libdimension/dimension/array.h
@@ -40,8 +40,8 @@ DMNSN_INLINE void
dmnsn_delete_array(dmnsn_array *array)
{
if (array) {
- free(array->ptr);
- free(array);
+ dmnsn_free(array->ptr);
+ dmnsn_free(array);
}
}
diff --git a/libdimension/dimension/list.h b/libdimension/dimension/list.h
index bac9740..dba18dc 100644
--- a/libdimension/dimension/list.h
+++ b/libdimension/dimension/list.h
@@ -54,8 +54,8 @@ DMNSN_INLINE void
dmnsn_delete_list_iterator(dmnsn_list_iterator *i)
{
if (i) {
- free(i->ptr);
- free(i);
+ dmnsn_free(i->ptr);
+ dmnsn_free(i);
}
}
diff --git a/libdimension/dimension/malloc.h b/libdimension/dimension/malloc.h
index 881f208..3c9e84b 100644
--- a/libdimension/dimension/malloc.h
+++ b/libdimension/dimension/malloc.h
@@ -29,3 +29,4 @@
void *dmnsn_malloc(size_t size);
void *dmnsn_realloc(void *ptr, size_t size);
char *dmnsn_strdup(const char *s);
+void dmnsn_free(void *ptr);
diff --git a/libdimension/finish_combination.c b/libdimension/finish_combination.c
index 12eefa8..1a54d22 100644
--- a/libdimension/finish_combination.c
+++ b/libdimension/finish_combination.c
@@ -112,7 +112,7 @@ dmnsn_finish_combination_free_fn(void *ptr)
dmnsn_finish **params = ptr;
dmnsn_delete_finish(params[0]);
dmnsn_delete_finish(params[1]);
- free(ptr);
+ dmnsn_free(ptr);
}
dmnsn_finish *
diff --git a/libdimension/gl.c b/libdimension/gl.c
index ca4daa4..f8bdd58 100644
--- a/libdimension/gl.c
+++ b/libdimension/gl.c
@@ -114,7 +114,7 @@ dmnsn_gl_write_canvas(const dmnsn_canvas *canvas)
glDrawPixels(width, height, GL_RGBA, GL_UNSIGNED_SHORT, pixels);
- free(pixels);
+ dmnsn_free(pixels);
return glGetError() == GL_NO_ERROR ? 0 : 1;
}
@@ -135,7 +135,7 @@ dmnsn_gl_read_canvas(size_t x0, size_t y0,
glReadPixels(x0, y0, width, height, GL_RGBA, GL_UNSIGNED_SHORT, pixels);
if (glGetError() != GL_NO_ERROR) {
- free(pixels);
+ dmnsn_free(pixels);
dmnsn_delete_canvas(canvas);
return NULL;
}
@@ -154,7 +154,7 @@ dmnsn_gl_read_canvas(size_t x0, size_t y0,
}
}
- free(pixels);
+ dmnsn_free(pixels);
return canvas;
}
diff --git a/libdimension/interior.c b/libdimension/interior.c
index 0accb79..6bf76e4 100644
--- a/libdimension/interior.c
+++ b/libdimension/interior.c
@@ -42,8 +42,8 @@ dmnsn_delete_interior(dmnsn_interior *interior)
if (interior->free_fn) {
(*interior->free_fn)(interior->ptr);
}
- free(interior->refcount);
- free(interior);
+ dmnsn_free(interior->refcount);
+ dmnsn_free(interior);
} else {
--*interior->refcount;
}
diff --git a/libdimension/light.c b/libdimension/light.c
index 06628c1..4e0f850 100644
--- a/libdimension/light.c
+++ b/libdimension/light.c
@@ -40,6 +40,6 @@ dmnsn_delete_light(dmnsn_light *light)
if (light->free_fn) {
(*light->free_fn)(light->ptr);
}
- free(light);
+ dmnsn_free(light);
}
}
diff --git a/libdimension/list.c b/libdimension/list.c
index fc2fc37..15051d6 100644
--- a/libdimension/list.c
+++ b/libdimension/list.c
@@ -54,7 +54,7 @@ dmnsn_delete_list(dmnsn_list *list)
while (list->first) {
dmnsn_list_remove(list, list->first);
}
- free(list);
+ dmnsn_free(list);
}
}
diff --git a/libdimension/malloc.c b/libdimension/malloc.c
index 746f9ab..605de8b 100644
--- a/libdimension/malloc.c
+++ b/libdimension/malloc.c
@@ -49,3 +49,9 @@ dmnsn_strdup(const char *s)
strcpy(copy, s);
return copy;
}
+
+void
+dmnsn_free(void *ptr)
+{
+ free(ptr);
+}
diff --git a/libdimension/object.c b/libdimension/object.c
index d87eb12..97fa45d 100644
--- a/libdimension/object.c
+++ b/libdimension/object.c
@@ -60,7 +60,7 @@ dmnsn_delete_object(dmnsn_object *object)
if (object->free_fn) {
(*object->free_fn)(object->ptr);
}
- free(object);
+ dmnsn_free(object);
}
}
diff --git a/libdimension/png.c b/libdimension/png.c
index c5dfeca..189c998 100644
--- a/libdimension/png.c
+++ b/libdimension/png.c
@@ -194,7 +194,7 @@ dmnsn_png_write_canvas_thread(void *ptr)
if (!payload->file) {
/* file was NULL */
errno = EINVAL;
- free(payload);
+ dmnsn_free(payload);
return -1;
}
@@ -207,7 +207,7 @@ dmnsn_png_write_canvas_thread(void *ptr)
= png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
if (!png_ptr) {
/* Couldn't create libpng write struct */
- free(payload);
+ dmnsn_free(payload);
return -1;
}
@@ -215,7 +215,7 @@ dmnsn_png_write_canvas_thread(void *ptr)
if (!info_ptr) {
/* Couldn't create libpng info struct */
png_destroy_write_struct(&png_ptr, NULL);
- free(payload);
+ dmnsn_free(payload);
return -1;
}
@@ -223,9 +223,9 @@ dmnsn_png_write_canvas_thread(void *ptr)
uint16_t *row = NULL;
if (setjmp(png_jmpbuf(png_ptr))) {
/* libpng error */
- free(row);
+ dmnsn_free(row);
png_destroy_write_struct(&png_ptr, &info_ptr);
- free(payload);
+ dmnsn_free(payload);
return -1;
}
@@ -264,7 +264,7 @@ dmnsn_png_write_canvas_thread(void *ptr)
/* Finish the PNG file */
png_write_end(png_ptr, info_ptr);
png_destroy_write_struct(&png_ptr, &info_ptr);
- free(payload);
+ dmnsn_free(payload);
return 0;
}
}
@@ -323,9 +323,9 @@ dmnsn_png_write_canvas_thread(void *ptr)
/* Finish the PNG file */
png_write_end(png_ptr, info_ptr);
- free(row);
+ dmnsn_free(row);
png_destroy_write_struct(&png_ptr, &info_ptr);
- free(payload);
+ dmnsn_free(payload);
return 0;
}
@@ -409,8 +409,8 @@ dmnsn_png_read_canvas_thread(void *ptr)
png_bytep *row_pointers = NULL;
if (setjmp(png_jmpbuf(png_ptr))) {
/* libpng error */
- free(row_pointers);
- free(image);
+ dmnsn_free(row_pointers);
+ dmnsn_free(image);
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
return -1;
}
@@ -559,10 +559,10 @@ dmnsn_png_read_canvas_thread(void *ptr)
}
}
- free(row_pointers);
- free(image);
+ dmnsn_free(row_pointers);
+ dmnsn_free(image);
png_read_end(png_ptr, NULL);
png_destroy_read_struct(&png_ptr, &info_ptr, NULL);
- free(payload);
+ dmnsn_free(payload);
return 0;
}
diff --git a/libdimension/progress.c b/libdimension/progress.c
index 835f150..aeac2ac 100644
--- a/libdimension/progress.c
+++ b/libdimension/progress.c
@@ -80,11 +80,11 @@ dmnsn_delete_progress(dmnsn_progress *progress)
dmnsn_error(DMNSN_SEVERITY_LOW, "Leaking condition variable.");
}
- free(progress->rwlock);
- free(progress->mutex);
- free(progress->cond);
+ dmnsn_free(progress->rwlock);
+ dmnsn_free(progress->mutex);
+ dmnsn_free(progress->cond);
dmnsn_delete_array(progress->elements);
- free(progress);
+ dmnsn_free(progress);
}
}
@@ -102,7 +102,7 @@ dmnsn_finish_progress(dmnsn_progress *progress)
dmnsn_error(DMNSN_SEVERITY_MEDIUM, "Joining worker thread failed.");
} else if (ptr) {
retval = *(int *)ptr;
- free(ptr);
+ dmnsn_free(ptr);
/* Wake up all waiters */
dmnsn_done_progress(progress);
}
diff --git a/libdimension/prtree.c b/libdimension/prtree.c
index 95f0eaa..479f3cb 100644
--- a/libdimension/prtree.c
+++ b/libdimension/prtree.c
@@ -357,7 +357,7 @@ dmnsn_delete_pseudo_prtree(dmnsn_pseudo_prtree *pseudo)
dmnsn_delete_pseudo_prtree(pseudo->pseudo.node.left);
dmnsn_delete_pseudo_prtree(pseudo->pseudo.node.right);
}
- free(pseudo);
+ dmnsn_free(pseudo);
}
}
@@ -526,7 +526,7 @@ dmnsn_delete_prtree_node(dmnsn_prtree_node *node)
dmnsn_delete_prtree_node(node->children[i]);
}
}
- free(node);
+ dmnsn_free(node);
}
}
@@ -537,7 +537,7 @@ dmnsn_delete_prtree(dmnsn_prtree *tree)
if (tree) {
dmnsn_delete_prtree_node(tree->root);
dmnsn_delete_array(tree->unbounded);
- free(tree);
+ dmnsn_free(tree);
}
}
diff --git a/libdimension/raytrace.c b/libdimension/raytrace.c
index 6cb0ac6..3430678 100644
--- a/libdimension/raytrace.c
+++ b/libdimension/raytrace.c
@@ -123,10 +123,10 @@ dmnsn_raytrace_scene_thread(void *ptr)
}
}
- free(threads);
- free(payloads);
+ dmnsn_free(threads);
+ dmnsn_free(payloads);
dmnsn_delete_prtree(payload->prtree);
- free(payload);
+ dmnsn_free(payload);
return 0;
}
diff --git a/libdimension/scene.c b/libdimension/scene.c
index d80a8b8..6d17cea 100644
--- a/libdimension/scene.c
+++ b/libdimension/scene.c
@@ -56,6 +56,6 @@ dmnsn_delete_scene(dmnsn_scene *scene)
dmnsn_delete_canvas(scene->canvas);
dmnsn_delete_camera(scene->camera);
dmnsn_delete_texture(scene->default_texture);
- free(scene);
+ dmnsn_free(scene);
}
}
diff --git a/libdimension/texture.c b/libdimension/texture.c
index 0ca5b98..1d0f3cd 100644
--- a/libdimension/texture.c
+++ b/libdimension/texture.c
@@ -39,7 +39,7 @@ dmnsn_delete_pigment(dmnsn_pigment *pigment)
if (pigment->free_fn) {
(*pigment->free_fn)(pigment->ptr);
}
- free(pigment);
+ dmnsn_free(pigment);
}
}
@@ -71,7 +71,7 @@ dmnsn_delete_finish(dmnsn_finish *finish)
if (finish->free_fn) {
(*finish->free_fn)(finish->ptr);
}
- free(finish);
+ dmnsn_free(finish);
}
}
@@ -96,8 +96,8 @@ dmnsn_delete_texture(dmnsn_texture *texture)
if (*texture->refcount <= 1) {
dmnsn_delete_finish(texture->finish);
dmnsn_delete_pigment(texture->pigment);
- free(texture->refcount);
- free(texture);
+ dmnsn_free(texture->refcount);
+ dmnsn_free(texture);
} else {
--*texture->refcount;
}
diff --git a/libdimension/threads.c b/libdimension/threads.c
index 3078465..22a5b9a 100644
--- a/libdimension/threads.c
+++ b/libdimension/threads.c
@@ -42,7 +42,7 @@ dmnsn_thread(void *arg)
ret = dmnsn_malloc(sizeof(int));
*ret = (*payload->thread_fn)(payload->arg);
pthread_cleanup_pop(1);
- free(payload);
+ dmnsn_free(payload);
return ret;
}