#define POOL_BLOCK_DATA(block) \
((char *) (block) + SIZEOF_POOLBLOCK)
+static const char *pool_alloconly_get_name(pool_t pool);
static void pool_alloconly_ref(pool_t pool);
static void pool_alloconly_unref(pool_t pool);
static void *pool_alloconly_malloc(pool_t pool, size_t size);
static void block_alloc(struct alloconly_pool *pool, size_t size);
static struct pool static_alloconly_pool = {
+ pool_alloconly_get_name,
+
pool_alloconly_ref,
pool_alloconly_unref,
free(apool);
}
+static const char *pool_alloconly_get_name(pool_t pool)
+{
+ struct alloconly_pool *apool = (struct alloconly_pool *) pool;
+
+ return apool->name;
+}
+
static void pool_alloconly_ref(pool_t pool)
{
struct alloconly_pool *apool = (struct alloconly_pool *) pool;
#include <stdlib.h>
+static const char *pool_data_stack_get_name(pool_t pool);
static void pool_data_stack_ref(pool_t pool);
static void pool_data_stack_unref(pool_t pool);
static void *pool_data_stack_malloc(pool_t pool, size_t size);
static void pool_data_stack_clear(pool_t pool);
static struct pool static_data_stack_pool = {
+ pool_data_stack_get_name,
+
pool_data_stack_ref,
pool_data_stack_unref,
pool_t data_stack_pool = &static_data_stack_pool;
+static const char *pool_data_stack_get_name(pool_t pool __attr_unused__)
+{
+ return "data stack";
+}
+
static void pool_data_stack_ref(pool_t pool __attr_unused__)
{
}
#include <stdlib.h>
+static const char *pool_system_get_name(pool_t pool);
static void pool_system_ref(pool_t pool);
static void pool_system_unref(pool_t pool);
static void *pool_system_malloc(pool_t pool, size_t size);
static void pool_system_clear(pool_t pool);
static struct pool static_system_pool = {
+ pool_system_get_name,
+
pool_system_ref,
pool_system_unref,
pool_t system_pool = &static_system_pool;
+static const char *pool_system_get_name(pool_t pool __attr_unused__)
+{
+ return "system";
+}
+
static void pool_system_ref(pool_t pool __attr_unused__)
{
}
typedef struct pool *pool_t;
struct pool {
+ const char *(*get_name)(pool_t pool);
+
void (*ref)(pool_t pool);
void (*unref)(pool_t pool);
pool_t pool_alloconly_create(const char *name, size_t size);
/* Pools should be used through these macros: */
+#define pool_get_name(pool) (pool)->get_name(pool)
#define pool_ref(pool) (pool)->ref(pool)
#define pool_unref(pool) (pool)->unref(pool)