From: Timo Sirainen Date: Mon, 19 May 2003 09:50:24 +0000 (+0300) Subject: Added pool_get_name(), for debugging mostly. X-Git-Tag: 1.1.alpha1~4617 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ad0ef8f436c41037e9f1d70286f7054e400fad92;p=thirdparty%2Fdovecot%2Fcore.git Added pool_get_name(), for debugging mostly. --HG-- branch : HEAD --- diff --git a/src/lib/mempool-alloconly.c b/src/lib/mempool-alloconly.c index dc3f898633..33910a687b 100644 --- a/src/lib/mempool-alloconly.c +++ b/src/lib/mempool-alloconly.c @@ -57,6 +57,7 @@ struct pool_block { #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); @@ -68,6 +69,8 @@ static void pool_alloconly_clear(pool_t pool); 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, @@ -112,6 +115,13 @@ static void pool_alloconly_destroy(struct alloconly_pool *apool) 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; diff --git a/src/lib/mempool-datastack.c b/src/lib/mempool-datastack.c index 94929593f1..7dfcbee4b8 100644 --- a/src/lib/mempool-datastack.c +++ b/src/lib/mempool-datastack.c @@ -28,6 +28,7 @@ #include +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); @@ -37,6 +38,8 @@ static void *pool_data_stack_realloc(pool_t pool, void *mem, 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, @@ -52,6 +55,11 @@ static struct pool static_data_stack_pool = { 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__) { } diff --git a/src/lib/mempool-system.c b/src/lib/mempool-system.c index b55fc8ec96..aef33e3759 100644 --- a/src/lib/mempool-system.c +++ b/src/lib/mempool-system.c @@ -30,6 +30,7 @@ #include +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); @@ -39,6 +40,8 @@ static void *pool_system_realloc(pool_t pool, void *mem, static void pool_system_clear(pool_t pool); static struct pool static_system_pool = { + pool_system_get_name, + pool_system_ref, pool_system_unref, @@ -54,6 +57,11 @@ static struct pool static_system_pool = { 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__) { } diff --git a/src/lib/mempool.h b/src/lib/mempool.h index 519c1548a9..53c84bc339 100644 --- a/src/lib/mempool.h +++ b/src/lib/mempool.h @@ -12,6 +12,8 @@ typedef struct pool *pool_t; struct pool { + const char *(*get_name)(pool_t pool); + void (*ref)(pool_t pool); void (*unref)(pool_t pool); @@ -40,6 +42,7 @@ extern pool_t data_stack_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)