Memset 0 in heap initialization?
In common/dlmalloc.c in the heap initialization mem_malloc_init() [1] it looks like the whole heap is initialized with zero:
memset((void *)mem_malloc_start, 0, size);
What's the reason for doing this? I know that the .bss segment has to be zeroed at system start up, but why doing this for the heap, too? It was my understanding that one could make no assumption about the initial content of memory returned by malloc() (?).
Sorry if I miss the obvious ;)
Thanks
Dirk
Quoted 11 lines · Dirk Behme
In
common/dlmalloc.cin the heap initializationmem_malloc_init()[1] it looks like the whole heap is initialized with zero:
memset((void *)mem_malloc_start, 0, size);What's the reason for doing this? I know that the .bss segment has to be zeroed at system start up, but why doing this for the heap, too? It was my understanding that one could make no assumption about the initial content of memory returned by
malloc()(?).
Quoted 8 lines
Sorry if I miss the obvious ;)
Thanks
Dirk
Any idea regarding this?
Thanks
Dirk
Quoted 14 lines · Dirk Behme
Quoted 13 lines · Dirk Behme
In
common/dlmalloc.cin the heap initializationmem_malloc_init()[1] it looks like the whole heap is initialized with zero:
memset((void *)mem_malloc_start, 0, size);What's the reason for doing this? I know that the .bss segment has to be zeroed at system start up, but why doing this for the heap, too? It was my understanding that one could make no assumption about the initial content of memory returned by
malloc()(?).Sorry if I miss the obvious ;)
Quoted 8 lines
Quoted 6 lines
Thanks
Dirk
Any idea regarding this?
Part of this is because we define MORECORE_CLEARS 1 which does assume memory is zero'd out.
- k