Mercurial > dovecot > core-2.2
changeset 20098:d30ebb5a7e3a
lib: Use p_malloc() explicitly in first buffer_alloc()
Although there is now code in p_realloc() that it should be just as
efficient, this makes profiling somewhat nicer since it can better
distinguish between actual reallocs and initial allocs.
author | Timo Sirainen <timo.sirainen@dovecot.fi> |
---|---|
date | Fri, 29 Apr 2016 12:55:52 +0300 |
parents | a875ab6a2911 |
children | c89167e445fd |
files | src/lib/buffer.c |
diffstat | 1 files changed, 4 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/src/lib/buffer.c Fri Apr 29 12:54:46 2016 +0300 +++ b/src/lib/buffer.c Fri Apr 29 12:55:52 2016 +0300 @@ -30,7 +30,10 @@ i_assert(size > buf->alloc); - buf->w_buffer = p_realloc(buf->pool, buf->w_buffer, buf->alloc, size); + if (buf->w_buffer == NULL) + buf->w_buffer = p_malloc(buf->pool, size); + else + buf->w_buffer = p_realloc(buf->pool, buf->w_buffer, buf->alloc, size); buf->alloc = size; buf->r_buffer = buf->w_buffer;