diff options
author | Thomas Voss <mail@thomasvoss.com> | 2024-06-24 02:23:02 +0200 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2024-06-24 02:23:02 +0200 |
commit | 88394eae61a017d2b56c91e4658d0bcd9a65eb2e (patch) | |
tree | 0116137f75d44c168461020d91081972e281e769 /src | |
parent | 0384a21f7b796299f5eba3c86a4354ee0fa46a5e (diff) |
Begin adding infrastructure for testing
Diffstat (limited to 'src')
-rw-r--r-- | src/alloc.h | 8 | ||||
-rw-r--r-- | src/arena.c | 8 |
2 files changed, 9 insertions, 7 deletions
diff --git a/src/alloc.h b/src/alloc.h index bc4bd69..8ac1f1f 100644 --- a/src/alloc.h +++ b/src/alloc.h @@ -6,6 +6,14 @@ #include "common.h" +/* Callers should not modify _ARENA_DFLT_CAP. This is included here so + that it can be accessed from the automated tests. */ +#if DEBUG +# define _ARENA_DFLT_CAP (8) +#else +# define _ARENA_DFLT_CAP (2 * 1024) +#endif + typedef struct _arena *arena_t; typedef struct { void *p; diff --git a/src/arena.c b/src/arena.c index 525acfe..20083b5 100644 --- a/src/arena.c +++ b/src/arena.c @@ -16,12 +16,6 @@ # error "System not supported (missing MAP_ANON)" #endif -#if DEBUG -# define ARENA_DFLT_CAP (8) -#else -# define ARENA_DFLT_CAP (2048) -#endif - #define MAX(x, y) ((x) > (y) ? (x) : (y)) #define IS_POW_2(n) ((n) != 0 && ((n) & ((n)-1)) == 0) @@ -68,7 +62,7 @@ arena_alloc(struct _arena **a, size_t nmemb, size_t size, size_t align) } /* No page exists with enough space */ - struct _arena *p = mkblk(MAX(size, ARENA_DFLT_CAP)); + struct _arena *p = mkblk(MAX(size, _ARENA_DFLT_CAP)); p->next = *a; *a = p; p->free = (char *)p->data + size; |