Skip to content

Commit

Permalink
[zdx_simple_arena] Update comment on why arena_calloc memset's to 0 i…
Browse files Browse the repository at this point in the history
…n DEBUG mode
  • Loading branch information
zeusdeux committed May 29, 2024
1 parent 4e7449a commit 2edf46f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions zdx_simple_arena.h
Original file line number Diff line number Diff line change
Expand Up @@ -411,8 +411,9 @@ void *arena_calloc(arena_t *const ar, const size_t count, const size_t sz)

/*
* not zeroing memory before returning as unix, linux and macos return zero-filled memory on MAP_ANONYMOUS
* unless DEBUG is set as arena_create() memset's the whole arena to 0xcd in DEBUG mode
* and this function is guarded for those OS-es
* unless DEBUG is set as arena_create() memset's the whole arena to 0 in DEBUG mode as arena_create()
* in debug mode memset's the whole arena to SA_DEBUG_BYTE which is 0xcd by default. If we don't memset to 0
* functions that rely on arena_calloc zero-ing memory, will fail in DEBUG mode.
*/
#if defined(DEBUG)
memset(ptr, 0, total_size);
Expand Down

0 comments on commit 2edf46f

Please sign in to comment.