From f8fd49938d7002cf62f44ebd6fff55044ed19221 Mon Sep 17 00:00:00 2001 From: Georg Hopp Date: Wed, 28 Aug 2013 15:39:51 +0100 Subject: [PATCH] now allocate only a multiple of pagesize --- src/utils/memory.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/utils/memory.c b/src/utils/memory.c index 08a31d3..59db11c 100644 --- a/src/utils/memory.c +++ b/src/utils/memory.c @@ -51,9 +51,14 @@ #include #include #include +#include #include "utils/memory.h" + +#define PAGE_SIZE = 32 + + enum rbColor {rbBlack=1, rbRed=2}; @@ -75,6 +80,12 @@ struct memSegment struct memSegment * newElement(size_t size) { + long psize = sysconf(_SC_PAGESIZE); + + /* allocate only blocks of a multiple of pagesize, similar to cbuf */ + size = (0 >= size)? 1 : (0 != size%psize)? (size/psize)+1 : size/psize; + size *= psize; + struct memSegment * element = malloc(size + sizeof(struct memSegment)); element->size = size;