From 0f9bef055788c60cd4f6621a46b047abb86bc193 Mon Sep 17 00:00:00 2001 From: Tavian Barnes Date: Mon, 16 May 2011 16:42:35 -0600 Subject: Consolidate reference counting code. --- libdimension/texture.c | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) (limited to 'libdimension/texture.c') diff --git a/libdimension/texture.c b/libdimension/texture.c index d0c1944..5f3b98d 100644 --- a/libdimension/texture.c +++ b/libdimension/texture.c @@ -33,8 +33,7 @@ dmnsn_new_texture(void) texture->pigment = NULL; texture->finish = NULL; texture->trans = dmnsn_identity_matrix(); - texture->refcount = dmnsn_malloc(sizeof(unsigned int)); - *texture->refcount = 1; + texture->refcount = dmnsn_new_refcount(); texture->should_init = true; return texture; } @@ -43,15 +42,11 @@ dmnsn_new_texture(void) void dmnsn_delete_texture(dmnsn_texture *texture) { - if (texture) { - if (*texture->refcount <= 1) { - dmnsn_delete_finish(texture->finish); - dmnsn_delete_pigment(texture->pigment); - dmnsn_free(texture->refcount); - dmnsn_free(texture); - } else { - --*texture->refcount; - } + if (texture && DMNSN_DECREF(texture)) { + dmnsn_delete_finish(texture->finish); + dmnsn_delete_pigment(texture->pigment); + dmnsn_delete_refcount(texture->refcount); + dmnsn_free(texture); } } -- cgit v1.2.3