summaryrefslogtreecommitdiffstats
path: root/libdimension/dimension
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2014-05-30 15:40:46 -0400
committerTavian Barnes <tavianator@tavianator.com>2014-05-30 15:40:46 -0400
commitf61c7c75c3c7ff4a329315700d3efa1d77bafa6d (patch)
tree9fc9bab72b12644aed948a82602638273cc82d62 /libdimension/dimension
parent77f880207d4fc37f82299d78d04be13623d9da0a (diff)
downloaddimension-f61c7c75c3c7ff4a329315700d3efa1d77bafa6d.tar.xz
pool: Separate dmnsn_palloc and dmnsn_palloc_tidy() APIs.
Diffstat (limited to 'libdimension/dimension')
-rw-r--r--libdimension/dimension/pool.h23
1 files changed, 20 insertions, 3 deletions
diff --git a/libdimension/dimension/pool.h b/libdimension/dimension/pool.h
index 33f1dd7..164bbbc 100644
--- a/libdimension/dimension/pool.h
+++ b/libdimension/dimension/pool.h
@@ -40,18 +40,35 @@ dmnsn_pool *dmnsn_new_pool(void);
* Allocate some memory from a pool.
* @param[in] pool The memory pool to allocate from.
* @param[in] size The size of the memory block to allocate.
- * @param[in] callback An optional callback to invoke before the memory is freed.
* @return The allocated memory area.
*/
-void *dmnsn_palloc(dmnsn_pool *pool, size_t size, dmnsn_callback_fn *callback);
+void *dmnsn_palloc(dmnsn_pool *pool, size_t size);
+
+/**
+ * Allocate some memory from a pool.
+ * @param[in] pool The memory pool to allocate from.
+ * @param[in] size The size of the memory block to allocate.
+ * @param[in] cleanup_fn A callback to invoke before the memory is freed.
+ * @return The allocated memory area.
+ */
+void *dmnsn_palloc_tidy(dmnsn_pool *pool, size_t size, dmnsn_callback_fn *cleanup_fn);
+
+/**
+ * Allocate some memory from a pool.
+ * @param[in] pool The memory pool to allocate from.
+ * @param[in] type The type of the memory block to allocate.
+ * @return The allocated memory area.
+ */
+#define DMNSN_PALLOC(pool, type) ((type *)dmnsn_palloc((pool), sizeof(type)))
/**
* Allocate some memory from a pool.
* @param[in] pool The memory pool to allocate from.
* @param[in] type The type of the memory block to allocate.
+ * @param[in] cleanup_fn A callback to invoke before the memory is freed.
* @return The allocated memory area.
*/
-#define DMNSN_PALLOC(pool, type) ((type *)dmnsn_palloc((pool), sizeof(type), NULL))
+#define DMNSN_PALLOC_TIDY(pool, type, cleanup_fn) ((type *)dmnsn_palloc_tidy((pool), sizeof(type), (cleanup_fn)))
/**
* Free a memory pool and all associated allocations.