summaryrefslogtreecommitdiffstats
path: root/libdimension/dimension/refcount.h
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@gmail.com>2011-05-28 18:16:04 -0600
committerTavian Barnes <tavianator@gmail.com>2011-05-28 18:16:04 -0600
commit4479d25609e26253c4e5fcfc78b093c0b45cefb8 (patch)
tree4f931d4d1d78e4915f99134e563a9d14faba7a33 /libdimension/dimension/refcount.h
parentefd3c1c2b42ffda0c8f7e5cd9b03fba07eead1ea (diff)
downloaddimension-4479d25609e26253c4e5fcfc78b093c0b45cefb8.tar.xz
Don't allocate reference counts on the heap.
Diffstat (limited to 'libdimension/dimension/refcount.h')
-rw-r--r--libdimension/dimension/refcount.h29
1 files changed, 7 insertions, 22 deletions
diff --git a/libdimension/dimension/refcount.h b/libdimension/dimension/refcount.h
index 9d2c304..4431cbc 100644
--- a/libdimension/dimension/refcount.h
+++ b/libdimension/dimension/refcount.h
@@ -24,35 +24,20 @@
*/
/**
- * Increment a reference count.
- * @param[in,out] object The reference-counted object to acquire.
- */
-#define DMNSN_INCREF(obj) ((void)++(*(obj)->refcount))
-
-/**
- * @internal
- * Decrement a reference count.
- * @param[in,out] object The reference-counted object to release.
- * @return Whether the object is now garbage.
- */
-#define DMNSN_DECREF(obj) (*(obj)->refcount == 0 || --(*(obj)->refcount) == 0)
-
-/**
* Reference counter.
*/
typedef unsigned int dmnsn_refcount;
/**
- * @internal
- * Create a reference count.
- * @return A new reference counter, initialized to zero (a "borrowed" reference,
- * which will be garbage-collected the first time it is deleted).
+ * Increment a reference count.
+ * @param[in,out] object The reference-counted object to acquire.
*/
-dmnsn_refcount *dmnsn_new_refcount(void);
+#define DMNSN_INCREF(obj) ((void)++(obj)->refcount)
/**
* @internal
- * Delete a reference count. Raises an error if the reference count wasn't
- * zero.
+ * Decrement a reference count.
+ * @param[in,out] object The reference-counted object to release.
+ * @return Whether the object is now garbage.
*/
-void dmnsn_delete_refcount(dmnsn_refcount *refcount);
+#define DMNSN_DECREF(obj) ((obj)->refcount == 0 || --(obj)->refcount == 0)