1.1 --- a/memory_incremental.cc Sat Mar 20 16:53:21 2021 +0100
1.2 +++ b/memory_incremental.cc Sat Mar 20 17:05:31 2021 +0100
1.3 @@ -1,5 +1,7 @@
1.4 #include "memory_incremental.h"
1.5
1.6 +#include <stdlib.h>
1.7 +
1.8 /* Initialise the memory pool with an optional 'limit' in pages. */
1.9
1.10 MemoryIncremental::MemoryIncremental(unsigned int limit, offset_t region_size)
1.11 @@ -14,6 +16,24 @@
1.12 _limited = false;
1.13 }
1.14
1.15 +/* Allocate a block of the given 'size'. */
1.16 +
1.17 +Region *MemoryIncremental::allocate(offset_t size)
1.18 +{
1.19 + /* Attempt to allocate aligned memory. */
1.20 +
1.21 + void *current;
1.22 +
1.23 + /* Make the size appropriate for the invocation. */
1.24 +
1.25 + size = round_multiple(size, PAGE_SIZE);
1.26 +
1.27 + if (posix_memalign(¤t, size, size))
1.28 + return NULL;
1.29 +
1.30 + return new Region((offset_t) current, (offset_t) current + size);
1.31 +}
1.32 +
1.33 /* Allocate a new region of the configured size rounded to the nearest page. */
1.34
1.35 Region *MemoryIncremental::region()