[dovecot-cvs]
dovecot/src/lib Makefile.am, 1.48, 1.49 buffer.c, 1.25,
1.26 istream-file.c, 1.20, 1.21 mempool.c, 1.4, 1.5 mempool.h,
1.16, 1.17 ostream-file.c, 1.44, 1.45
cras at dovecot.org
cras at dovecot.org
Sun Mar 27 16:51:57 EEST 2005
- Previous message: [dovecot-cvs] dovecot/src/lib mempool-alloconly.c, 1.29,
1.30 mempool-datastack.c, 1.10, 1.11 mempool-system.c, 1.16,
1.17 mempool-unsafe-datastack.c, 1.1, 1.2 mempool.h, 1.15, 1.16
- Next message: [dovecot-cvs] dovecot/src/lib compat.c, 1.21, 1.22 compat.h, 1.27,
1.28
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Update of /var/lib/cvs/dovecot/src/lib
In directory talvi:/tmp/cvs-serv18283
Modified Files:
Makefile.am buffer.c istream-file.c mempool.h ostream-file.c
Added Files:
mempool.c
Log Message:
Added pool_get_exp_grown_size(). Use it for buffers, istreams and ostreams
when buffer needs to grow. Optimizes memory usage a bit.
Index: Makefile.am
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/Makefile.am,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- Makefile.am 12 Mar 2005 18:15:48 -0000 1.48
+++ Makefile.am 27 Mar 2005 13:51:54 -0000 1.49
@@ -35,6 +35,7 @@
lib-signals.c \
md4.c \
md5.c \
+ mempool.c \
mempool-alloconly.c \
mempool-datastack.c \
mempool-system.c \
Index: buffer.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/buffer.c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- buffer.c 12 Mar 2005 12:24:28 -0000 1.25
+++ buffer.c 27 Mar 2005 13:51:54 -0000 1.26
@@ -54,7 +54,8 @@
buf->pool->get_name(buf->pool));
}
- buffer_alloc(buf, nearest_power(new_size));
+ buffer_alloc(buf, pool_get_exp_grown_size(buf->pool, buf->alloc,
+ new_size));
}
if (new_size > buf->used)
Index: istream-file.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/istream-file.c,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -d -r1.20 -r1.21
--- istream-file.c 22 Aug 2004 12:09:25 -0000 1.20
+++ istream-file.c 27 Mar 2005 13:51:54 -0000 1.21
@@ -58,8 +58,11 @@
stream->buffer_size = stream->pos + bytes;
if (stream->buffer_size <= I_STREAM_MIN_SIZE)
stream->buffer_size = I_STREAM_MIN_SIZE;
- else
- stream->buffer_size = nearest_power(stream->buffer_size);
+ else {
+ stream->buffer_size =
+ pool_get_exp_grown_size(stream->iostream.pool,
+ old_size, stream->buffer_size);
+ }
if (fstream->max_buffer_size > 0 &&
stream->buffer_size > fstream->max_buffer_size)
Index: mempool.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/mempool.h,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- mempool.h 27 Mar 2005 13:29:30 -0000 1.16
+++ mempool.h 27 Mar 2005 13:51:54 -0000 1.17
@@ -50,6 +50,11 @@
that the stack frame is the same. This should make it quite safe to use. */
pool_t pool_datastack_create(void);
+/* Similar to nearest_power(), but try not to exceed buffer's easy
+ allocation size. If you don't have any explicit minimum size, use
+ old_size + 1. */
+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)
Index: ostream-file.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib/ostream-file.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- ostream-file.c 17 Dec 2004 13:31:19 -0000 1.44
+++ ostream-file.c 27 Mar 2005 13:51:54 -0000 1.45
@@ -298,7 +298,9 @@
{
size_t size, new_size, end_size;
- size = nearest_power(fstream->buffer_size + bytes);
+ size = pool_get_exp_grown_size(fstream->ostream.iostream.pool,
+ fstream->buffer_size,
+ fstream->buffer_size + bytes);
if (size > fstream->max_buffer_size) {
/* limit the size */
size = fstream->max_buffer_size;
- Previous message: [dovecot-cvs] dovecot/src/lib mempool-alloconly.c, 1.29,
1.30 mempool-datastack.c, 1.10, 1.11 mempool-system.c, 1.16,
1.17 mempool-unsafe-datastack.c, 1.1, 1.2 mempool.h, 1.15, 1.16
- Next message: [dovecot-cvs] dovecot/src/lib compat.c, 1.21, 1.22 compat.h, 1.27,
1.28
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the dovecot-cvs
mailing list