ucx/allocator.h

changeset 1
1bcaac272cdf
child 5
88625853ae74
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ucx/allocator.h	Fri Nov 30 21:18:13 2012 +0100
@@ -0,0 +1,33 @@
+#ifndef ALLOCATOR_H
+#define	ALLOCATOR_H
+
+#include "ucx.h"
+
+#ifdef	__cplusplus
+extern "C" {
+#endif
+
+typedef void*(*ucx_allocator_malloc)(void *pool, size_t n);
+typedef void*(*ucx_allocator_calloc)(void *pool, size_t n, size_t size);
+typedef void*(*ucx_allocator_realloc)(void *pool, void *data, size_t n);
+
+typedef struct {
+    void *pool;
+    ucx_allocator_malloc malloc;
+    ucx_allocator_calloc calloc;
+    ucx_allocator_realloc realloc;
+} UcxAllocator;
+
+void *ucx_default_malloc(void *ignore, size_t n);
+void *ucx_default_calloc(void *ignore, size_t n, size_t size);
+void *ucx_default_realloc(void *ignore, void *data, size_t n);
+
+#define UCX_ALLOCATOR_DEFAULT {NULL, \
+        ucx_default_malloc, ucx_default_calloc, ucx_default_realloc}
+
+#ifdef	__cplusplus
+}
+#endif
+
+#endif	/* ALLOCATOR_H */
+

mercurial