summaryrefslogtreecommitdiffstats
path: root/libdimension/texture.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2011-05-16 16:42:35 -0600
committerTavian Barnes <tavianator@gmail.com>2011-05-16 16:42:35 -0600
commit0f9bef055788c60cd4f6621a46b047abb86bc193 (patch)
tree2d97e7d7ead0f9f2c545c800c9789b30070b3aa6 /libdimension/texture.c
parent0a51cc868eafe72a98d64e48d8b2ba30a7d8f5dc (diff)
downloaddimension-0f9bef055788c60cd4f6621a46b047abb86bc193.tar.xz
Consolidate reference counting code.
Diffstat (limited to 'libdimension/texture.c')
-rw-r--r--libdimension/texture.c17
1 files changed, 6 insertions, 11 deletions
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);
}
}