]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib: Use p_malloc() explicitly in first buffer_alloc()
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 29 Apr 2016 09:55:52 +0000 (12:55 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 29 Apr 2016 11:14:38 +0000 (14:14 +0300)
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.

src/lib/buffer.c

index d7430c0fbff0b69f821d15400543f9c5dd3e0951..7fb29076f413053e45cc6285d9c6dc71ad4c8957 100644 (file)
@@ -30,7 +30,10 @@ static void buffer_alloc(struct real_buffer *buf, size_t size)
 
        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;