diff options
Diffstat (limited to 'src/common/memarea.c')
-rw-r--r-- | src/common/memarea.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/common/memarea.c b/src/common/memarea.c index 194deb8d2c..6893639a6e 100644 --- a/src/common/memarea.c +++ b/src/common/memarea.c @@ -30,12 +30,18 @@ #endif #ifdef USE_SENTINELS +/** Magic value that we stick at the end of a memarea so we can make sure + * there are no run-off-the-end bugs. */ #define SENTINEL_VAL 0x90806622u +/** How many bytes per area do we devote to the sentinel? */ #define SENTINEL_LEN sizeof(uint32_t) +/** Given a mem_area_chunk_t with SENTINEL_LEN extra bytes allocated at the + * end, set those bytes. */ #define SET_SENTINEL(chunk) \ STMT_BEGIN \ set_uint32( &(chunk)->u.mem[chunk->mem_size], SENTINEL_VAL ); \ STMT_END +/** Assert that the sentinel on a memarea is set correctly. */ #define CHECK_SENTINEL(chunk) \ STMT_BEGIN \ uint32_t sent_val = get_uint32(&(chunk)->u.mem[chunk->mem_size]); \ @@ -73,8 +79,11 @@ typedef struct memarea_chunk_t { } u; } memarea_chunk_t; +/** How many bytes are needed for overhead before we get to the memory part + * of a chunk? */ #define CHUNK_HEADER_SIZE STRUCT_OFFSET(memarea_chunk_t, u) +/** What's the smallest that we'll allocate a chunk? */ #define CHUNK_SIZE 4096 /** A memarea_t is an allocation region for a set of small memory requests |