summaryrefslogtreecommitdiff
path: root/lib/pool_alloc.h
diff options
context:
space:
mode:
authorJ.W. Schultz <jw@samba.org>2004-02-10 03:26:41 +0000
committerJ.W. Schultz <jw@samba.org>2004-02-10 03:26:41 +0000
commit7efdcf3218fe580476608f3b3c53bce35fc5a2a9 (patch)
treec9365434916715e1ef525674979072ec64c303b7 /lib/pool_alloc.h
parent9935066b704bcf2e6e48dac85cb1b4047d8f439d (diff)
downloadrsync-7efdcf3218fe580476608f3b3c53bce35fc5a2a9.tar.gz
rsync-7efdcf3218fe580476608f3b3c53bce35fc5a2a9.tar.bz2
rsync-7efdcf3218fe580476608f3b3c53bce35fc5a2a9.zip
Added allocation pool code.
Diffstat (limited to 'lib/pool_alloc.h')
-rw-r--r--lib/pool_alloc.h20
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/pool_alloc.h b/lib/pool_alloc.h
new file mode 100644
index 00000000..a4ab761c
--- /dev/null
+++ b/lib/pool_alloc.h
@@ -0,0 +1,20 @@
+#include <stddef.h>
+
+#define POOL_CLEAR (1<<0) /* zero fill allocations */
+#define POOL_QALIGN (1<<1) /* align data to quanta */
+#define POOL_INTERN (1<<2) /* Allocate extent structures */
+#define POOL_APPEND (1<<3) /* or appended to extent data */
+
+typedef void *alloc_pool_t;
+
+alloc_pool_t pool_create(size_t size, size_t quantum, void (*bomb)(char *), int flags);
+void pool_destroy(alloc_pool_t pool);
+void *pool_alloc(alloc_pool_t pool, size_t size, char *bomb);
+void pool_free(alloc_pool_t pool, size_t size, void *addr);
+
+#define pool_talloc(pool, type, count, bomb) \
+ ((type *)pool_alloc(pool, sizeof(type) * count, bomb))
+
+#define pool_tfree(pool, type, count, addr) \
+ (pool_free(pool, sizeof(type) * count, addr))
+