From ed0b48040c41d2080e4abaa311a158d7115ef842 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 19 May 2010 23:29:13 +0200 Subject: [PATCH] pcm_buffer: 8 kB alignment instead of 64 kB Reduce the overhead. Most buffers used by MPD are around 2 to 4 kB. 8 kB seems large enough to keep heap fragmentation low. Additionally, this patch fixes an off-by-one error in the alignment formula. --- src/pcm_buffer.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pcm_buffer.h b/src/pcm_buffer.h index 0046b7470..626851990 100644 --- a/src/pcm_buffer.h +++ b/src/pcm_buffer.h @@ -65,8 +65,8 @@ pcm_buffer_get(struct pcm_buffer *buffer, size_t size) /* free the old buffer */ g_free(buffer->buffer); - /* allocate a new buffer; align at 64kB boundaries */ - buffer->size = (size | 0xffff) + 1; + /* allocate a new buffer; align at 8 kB boundaries */ + buffer->size = ((size - 1) | 0x1fff) + 1; buffer->buffer = g_malloc(buffer->size); }