diff options
author | Tavian Barnes <tavianator@gmail.com> | 2011-05-16 16:42:35 -0600 |
---|---|---|
committer | Tavian Barnes <tavianator@gmail.com> | 2011-05-16 16:42:35 -0600 |
commit | 0f9bef055788c60cd4f6621a46b047abb86bc193 (patch) | |
tree | 2d97e7d7ead0f9f2c545c800c9789b30070b3aa6 /libdimension/interior.c | |
parent | 0a51cc868eafe72a98d64e48d8b2ba30a7d8f5dc (diff) | |
download | dimension-0f9bef055788c60cd4f6621a46b047abb86bc193.tar.xz |
Consolidate reference counting code.
Diffstat (limited to 'libdimension/interior.c')
-rw-r--r-- | libdimension/interior.c | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/libdimension/interior.c b/libdimension/interior.c index 939bd4f..0eec274 100644 --- a/libdimension/interior.c +++ b/libdimension/interior.c @@ -33,8 +33,7 @@ dmnsn_new_interior(void) dmnsn_interior *interior = dmnsn_malloc(sizeof(dmnsn_interior)); interior->ior = 1.0; interior->free_fn = NULL; - interior->refcount = dmnsn_malloc(sizeof(unsigned int)); - *interior->refcount = 1; + interior->refcount = dmnsn_new_refcount(); return interior; } @@ -42,15 +41,11 @@ dmnsn_new_interior(void) void dmnsn_delete_interior(dmnsn_interior *interior) { - if (interior) { - if (*interior->refcount <= 1) { - if (interior->free_fn) { - interior->free_fn(interior->ptr); - } - dmnsn_free(interior->refcount); - dmnsn_free(interior); - } else { - --*interior->refcount; + if (interior && DMNSN_DECREF(interior)) { + if (interior->free_fn) { + interior->free_fn(interior->ptr); } + dmnsn_delete_refcount(interior->refcount); + dmnsn_free(interior); } } |