[dovecot-cvs] dovecot/src/lib mempool-alloconly.c, 1.39, 1.40 mempool-datastack.c, 1.12, 1.13 mempool-system.c, 1.20, 1.21 mempool-unsafe-datastack.c, 1.3, 1.4 mempool.h, 1.23, 1.24
tss at dovecot.org
tss at dovecot.org
Thu Jan 18 15:33:39 UTC 2007
- Previous message: [dovecot-cvs] dovecot/src/lib mempool-alloconly.c, 1.35.2.4, 1.35.2.5 mempool-datastack.c, 1.12, 1.12.2.1 mempool-system.c, 1.18.2.1, 1.18.2.2 mempool-unsafe-datastack.c, 1.3, 1.3.2.1 mempool.h, 1.18.2.1, 1.18.2.2
- Next message: [dovecot-cvs] dovecot/src/lib-index mail-cache-compress.c, 1.42.2.3, 1.42.2.4
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /var/lib/cvs/dovecot/src/lib
In directory talvi:/tmp/cvs-serv19056
Modified Files:
mempool-alloconly.c mempool-datastack.c mempool-system.c
mempool-unsafe-datastack.c mempool.h
Log Message:
Don't keep the memory pool virtual functions in the pool structure itself,
rather access them via a pointer to a shared virtual function struct.
Reduces memory usage a bit.
Index: mempool-alloconly.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/mempool-alloconly.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- mempool-alloconly.c 28 Dec 2006 23:21:06 -0000 1.39
+++ mempool-alloconly.c 18 Jan 2007 15:33:36 -0000 1.40
@@ -56,7 +56,7 @@
static void block_alloc(struct alloconly_pool *pool, size_t size);
-static struct pool static_alloconly_pool = {
+static const struct pool_vfuncs static_alloconly_pool_vfuncs = {
pool_alloconly_get_name,
pool_alloconly_ref,
@@ -68,10 +68,14 @@
pool_alloconly_realloc,
pool_alloconly_clear,
- pool_alloconly_get_max_easy_alloc_size,
+ pool_alloconly_get_max_easy_alloc_size
+};
- TRUE,
- FALSE
+static const struct pool static_alloconly_pool = {
+ MEMBER(v) &static_alloconly_pool_vfuncs,
+
+ MEMBER(alloconly_pool) TRUE,
+ MEMBER(datastack_pool) FALSE
};
#ifdef DEBUG
Index: mempool-datastack.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/mempool-datastack.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- mempool-datastack.c 14 Jan 2006 17:23:22 -0000 1.12
+++ mempool-datastack.c 18 Jan 2007 15:33:36 -0000 1.13
@@ -15,7 +15,7 @@
static void pool_data_stack_clear(pool_t pool);
static size_t pool_data_stack_get_max_easy_alloc_size(pool_t pool);
-static struct pool static_data_stack_pool = {
+static struct pool_vfuncs static_data_stack_pool_vfuncs = {
pool_data_stack_get_name,
pool_data_stack_ref,
@@ -27,10 +27,14 @@
pool_data_stack_realloc,
pool_data_stack_clear,
- pool_data_stack_get_max_easy_alloc_size,
+ pool_data_stack_get_max_easy_alloc_size
+};
- TRUE,
- TRUE
+static const struct pool static_data_stack_pool = {
+ MEMBER(v) &static_data_stack_pool_vfuncs,
+
+ MEMBER(alloconly_pool) TRUE,
+ MEMBER(datastack_pool) TRUE
};
struct datastack_pool {
Index: mempool-system.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/mempool-system.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- mempool-system.c 18 Nov 2006 14:06:35 -0000 1.20
+++ mempool-system.c 18 Jan 2007 15:33:36 -0000 1.21
@@ -23,7 +23,7 @@
static void pool_system_clear(pool_t pool);
static size_t pool_system_get_max_easy_alloc_size(pool_t pool);
-static struct pool static_system_pool = {
+static struct pool_vfuncs static_system_pool_vfuncs = {
pool_system_get_name,
pool_system_ref,
@@ -35,12 +35,17 @@
pool_system_realloc,
pool_system_clear,
- pool_system_get_max_easy_alloc_size,
+ pool_system_get_max_easy_alloc_size
+};
- FALSE,
- FALSE
+static struct pool static_system_pool = {
+ MEMBER(v) &static_system_pool_vfuncs,
+
+ MEMBER(alloconly_pool) FALSE,
+ MEMBER(datastack_pool) FALSE
};
+
pool_t system_pool = &static_system_pool;
static const char *pool_system_get_name(pool_t pool __attr_unused__)
Index: mempool-unsafe-datastack.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/mempool-unsafe-datastack.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- mempool-unsafe-datastack.c 14 Jan 2006 17:23:22 -0000 1.3
+++ mempool-unsafe-datastack.c 18 Jan 2007 15:33:36 -0000 1.4
@@ -15,7 +15,7 @@
static void pool_unsafe_data_stack_clear(pool_t pool);
static size_t pool_unsafe_data_stack_get_max_easy_alloc_size(pool_t pool);
-static struct pool static_unsafe_data_stack_pool = {
+static struct pool_vfuncs static_unsafe_data_stack_pool_vfuncs = {
pool_unsafe_data_stack_get_name,
pool_unsafe_data_stack_ref,
@@ -27,10 +27,14 @@
pool_unsafe_data_stack_realloc,
pool_unsafe_data_stack_clear,
- pool_unsafe_data_stack_get_max_easy_alloc_size,
+ pool_unsafe_data_stack_get_max_easy_alloc_size
+};
- TRUE,
- TRUE
+static struct pool static_unsafe_data_stack_pool = {
+ MEMBER(v) &static_unsafe_data_stack_pool_vfuncs,
+
+ MEMBER(alloconly_pool) TRUE,
+ MEMBER(datastack_pool) TRUE
};
pool_t unsafe_data_stack_pool = &static_unsafe_data_stack_pool;
Index: mempool.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/mempool.h,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- mempool.h 28 Dec 2006 23:21:06 -0000 1.23
+++ mempool.h 18 Jan 2007 15:33:36 -0000 1.24
@@ -16,7 +16,7 @@
typedef struct pool *pool_t;
-struct pool {
+struct pool_vfuncs {
const char *(*get_name)(pool_t pool);
void (*ref)(pool_t pool);
@@ -37,6 +37,10 @@
/* Returns the maximum amount of bytes that can be allocated with
minimal trouble. If there's no such concept, always returns 0. */
size_t (*get_max_easy_alloc_size)(pool_t pool);
+};
+
+struct pool {
+ const struct pool_vfuncs *v;
unsigned int alloconly_pool:1;
unsigned int datastack_pool:1;
@@ -69,16 +73,16 @@
size_t pool_get_exp_grown_size(pool_t pool, size_t old_size, size_t min_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))
+#define pool_get_name(pool) (pool)->v->get_name(pool)
+#define pool_ref(pool) (pool)->v->ref(pool)
+#define pool_unref(pool) (pool)->v->unref(&(pool))
#define p_new(pool, type, count) \
((type *) p_malloc(pool, sizeof(type) * (count)))
-#define p_malloc(pool, size) (pool)->malloc(pool, size)
+#define p_malloc(pool, size) (pool)->v->malloc(pool, size)
#define p_realloc(pool, mem, old_size, new_size) \
- (pool)->realloc(pool, mem, old_size, new_size)
+ (pool)->v->realloc(pool, mem, old_size, new_size)
/* Free the memory. Currently it also sets memory to NULL, but that shouldn't
be relied on as it's only an extra safety check. It might as well be later
@@ -86,15 +90,16 @@
in some "optimization".. */
#define p_free(pool, mem) \
STMT_START { \
- (pool)->free(pool, mem); \
+ (pool)->v->free(pool, mem); \
(mem) = NULL; \
} STMT_END
/* A macro that's guaranteed to set mem = NULL. */
#define p_free_and_null(pool, mem) p_free(pool, mem)
-#define p_clear(pool) (pool)->clear(pool)
+#define p_clear(pool) (pool)->v->clear(pool)
-#define p_get_max_easy_alloc_size(pool) (pool)->get_max_easy_alloc_size(pool)
+#define p_get_max_easy_alloc_size(pool) \
+ (pool)->v->get_max_easy_alloc_size(pool)
#endif
- Previous message: [dovecot-cvs] dovecot/src/lib mempool-alloconly.c, 1.35.2.4, 1.35.2.5 mempool-datastack.c, 1.12, 1.12.2.1 mempool-system.c, 1.18.2.1, 1.18.2.2 mempool-unsafe-datastack.c, 1.3, 1.3.2.1 mempool.h, 1.18.2.1, 1.18.2.2
- Next message: [dovecot-cvs] dovecot/src/lib-index mail-cache-compress.c, 1.42.2.3, 1.42.2.4
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the dovecot-cvs
mailing list