diff options
-rw-r--r-- | dimension/common.declarations | 2 | ||||
-rw-r--r-- | dimension/common.rules | 6 | ||||
-rw-r--r-- | dimension/lexer.l | 2 | ||||
-rw-r--r-- | dimension/main.c | 4 | ||||
-rw-r--r-- | dimension/parse.c | 8 | ||||
-rw-r--r-- | dimension/tokenize.c | 14 | ||||
-rw-r--r-- | libdimension/camera.c | 2 | ||||
-rw-r--r-- | libdimension/canvas.c | 6 | ||||
-rw-r--r-- | libdimension/csg.c | 2 | ||||
-rw-r--r-- | libdimension/dimension/array.h | 4 | ||||
-rw-r--r-- | libdimension/dimension/list.h | 4 | ||||
-rw-r--r-- | libdimension/dimension/malloc.h | 1 | ||||
-rw-r--r-- | libdimension/finish_combination.c | 2 | ||||
-rw-r--r-- | libdimension/gl.c | 6 | ||||
-rw-r--r-- | libdimension/interior.c | 4 | ||||
-rw-r--r-- | libdimension/light.c | 2 | ||||
-rw-r--r-- | libdimension/list.c | 2 | ||||
-rw-r--r-- | libdimension/malloc.c | 6 | ||||
-rw-r--r-- | libdimension/object.c | 2 | ||||
-rw-r--r-- | libdimension/png.c | 26 | ||||
-rw-r--r-- | libdimension/progress.c | 10 | ||||
-rw-r--r-- | libdimension/prtree.c | 6 | ||||
-rw-r--r-- | libdimension/raytrace.c | 6 | ||||
-rw-r--r-- | libdimension/scene.c | 2 | ||||
-rw-r--r-- | libdimension/texture.c | 8 | ||||
-rw-r--r-- | libdimension/threads.c | 2 | ||||
-rw-r--r-- | tests/libdimension/tests.c | 2 |
27 files changed, 74 insertions, 67 deletions
diff --git a/dimension/common.declarations b/dimension/common.declarations index a181923..2e3fadb 100644 --- a/dimension/common.declarations +++ b/dimension/common.declarations @@ -29,5 +29,5 @@ %lex-param {dmnsn_symbol_table *symtable} %lex-param {void *yyscanner} -%destructor { free($$); } <value> +%destructor { dmnsn_free($$); } <value> %destructor { dmnsn_delete_astnode($$); } <astnode> diff --git a/dimension/common.rules b/dimension/common.rules index e5e6543..d91cac3 100644 --- a/dimension/common.rules +++ b/dimension/common.rules @@ -30,7 +30,7 @@ IDENTIFIER: "identifier" { } $$ = dmnsn_new_astnode(DMNSN_AST_IDENTIFIER, @$); $$.ptr = dmnsn_strdup(id); - free($1); + dmnsn_free($1); } ; @@ -604,13 +604,13 @@ FLOAT_LITERAL: "integer" { $$ = dmnsn_new_astnode(DMNSN_AST_INTEGER, @$); $$.ptr = dmnsn_malloc(sizeof(long)); *(long *)$$.ptr = strtol($1, NULL, 0); - free($1); + dmnsn_free($1); } | "float" { $$ = dmnsn_new_astnode(DMNSN_AST_FLOAT, @$); $$.ptr = dmnsn_malloc(sizeof(double)); *(double *)$$.ptr = strtod($1, NULL); - free($1); + dmnsn_free($1); } ; diff --git a/dimension/lexer.l b/dimension/lexer.l index 190acb0..dd25363 100644 --- a/dimension/lexer.l +++ b/dimension/lexer.l @@ -420,7 +420,7 @@ dmnsn_tokenize(FILE *file, const char *filename) static void dmnsn_delete_token(dmnsn_token token) { - free(token.value); + dmnsn_free(token.value); } void diff --git a/dimension/main.c b/dimension/main.c index 951f126..bb44df5 100644 --- a/dimension/main.c +++ b/dimension/main.c @@ -275,7 +275,7 @@ main(int argc, char **argv) strcpy(output, base); ext = output + len; } - free(input_copy); + dmnsn_free(input_copy); strcpy(ext, ".png"); free_output = true; } @@ -283,7 +283,7 @@ main(int argc, char **argv) /* Open the output file */ FILE *output_file = fopen(output, "wb"); if (free_output) - free(output); + dmnsn_free(output); if (!output_file) { fprintf(stderr, "Couldn't open output file!"); return EXIT_FAILURE; diff --git a/dimension/parse.c b/dimension/parse.c index 93edb84..4e748cc 100644 --- a/dimension/parse.c +++ b/dimension/parse.c @@ -39,7 +39,7 @@ static void dmnsn_delete_patricia_trie(dmnsn_patricia_trie *trie) { if (trie) { - free(trie->prefix); + dmnsn_free(trie->prefix); if (trie->leaf) dmnsn_delete_astnode(trie->value); @@ -51,7 +51,7 @@ dmnsn_delete_patricia_trie(dmnsn_patricia_trie *trie) } dmnsn_delete_array(trie->children); - free(trie); + dmnsn_free(trie); } } @@ -455,9 +455,9 @@ dmnsn_delete_astnode(dmnsn_astnode astnode) if (astnode.free_fn) { (*astnode.free_fn)(astnode.ptr); } else { - free(astnode.ptr); + dmnsn_free(astnode.ptr); } - free(astnode.refcount); + dmnsn_free(astnode.refcount); } else { --*astnode.refcount; } diff --git a/dimension/tokenize.c b/dimension/tokenize.c index 7315a60..78c0de8 100644 --- a/dimension/tokenize.c +++ b/dimension/tokenize.c @@ -71,11 +71,11 @@ dmnsn_delete_token_buffer(void *ptr) dmnsn_token_buffer *tbuffer = ptr; if (tbuffer) { DMNSN_ARRAY_FOREACH (dmnsn_buffered_token *, buffered, tbuffer->buffered) { - free(buffered->lval.value); + dmnsn_free(buffered->lval.value); } dmnsn_delete_array(tbuffer->buffered); - free(tbuffer); + dmnsn_free(tbuffer); } } @@ -238,13 +238,13 @@ dmnsn_include_buffer(int token, dmnsn_token_buffer *prev, strcpy(local_include, localdir); strcat(local_include, "/"); strcat(local_include, include); - free(filename_copy); + dmnsn_free(filename_copy); FILE *file = fopen(local_include, "r"); if (!file) { dmnsn_diagnostic(*llocp, "Couldn't open include file '%s'", include); dmnsn_undef_symbol(symtable, "$include"); - free(local_include); + dmnsn_free(local_include); dmnsn_delete_token_buffer(tbuffer); return NULL; } @@ -256,7 +256,7 @@ dmnsn_include_buffer(int token, dmnsn_token_buffer *prev, include); dmnsn_undef_symbol(symtable, "$include"); fclose(file); - free(local_include); + dmnsn_free(local_include); dmnsn_delete_token_buffer(tbuffer); return NULL; } @@ -273,7 +273,7 @@ dmnsn_include_buffer(int token, dmnsn_token_buffer *prev, "$includes has wrong type."); dmnsn_astnode fnode = dmnsn_new_ast_string(local_include); - free(local_include); + dmnsn_free(local_include); tbuffer->filename = fnode.ptr; dmnsn_array_push(includes->children, &fnode); @@ -502,7 +502,7 @@ dmnsn_if_buffer(int token, dmnsn_token_buffer *prev, if (cond) { dmnsn_array_push(tbuffer->buffered, &buffered); } else { - free(buffered.lval.value); + dmnsn_free(buffered.lval.value); } } 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; } diff --git a/tests/libdimension/tests.c b/tests/libdimension/tests.c index 3e97238..9d1d38c 100644 --- a/tests/libdimension/tests.c +++ b/tests/libdimension/tests.c @@ -128,7 +128,7 @@ dmnsn_delete_display(dmnsn_display *display) if (display->dpy) XCloseDisplay(display->dpy); - free(display); + dmnsn_free(display); } } |