From 8f01c5394dcce8f5d4e7102dacfcdea9d1f7b021 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Thu, 16 Jul 2009 01:16:09 +0000 Subject: Add destructor callbacks for polymorphic C types, and use their base dmnsn_delete_*() function. --- libdimension/texture.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'libdimension/texture.c') diff --git a/libdimension/texture.c b/libdimension/texture.c index 511c6b0..f232cbc 100644 --- a/libdimension/texture.c +++ b/libdimension/texture.c @@ -25,7 +25,11 @@ dmnsn_pigment * dmnsn_new_pigment() { - return malloc(sizeof(dmnsn_pigment)); + dmnsn_pigment *pigment = malloc(sizeof(dmnsn_pigment)); + if (pigment) { + pigment->free_fn = NULL; + } + return pigment; } /* Free a dummy pigment */ @@ -39,7 +43,11 @@ dmnsn_delete_pigment(dmnsn_pigment *pigment) dmnsn_texture * dmnsn_new_texture() { - return malloc(sizeof(dmnsn_texture)); + dmnsn_texture *texture = malloc(sizeof(dmnsn_texture)); + if (texture) { + texture->pigment = NULL; + } + return texture; } /* Free a dummy texture */ -- cgit v1.2.3