* [U-Boot] Memset 0 in heap initialization? @ 2010-12-09 16:14 Dirk Behme 2011-01-18 5:17 ` Dirk Behme 0 siblings, 1 reply; 3+ messages in thread From: Dirk Behme @ 2010-12-09 16:14 UTC (permalink / raw) To: u-boot 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 [1] http://git.denx.de/?p=u-boot.git;a=blob;f=common/dlmalloc.c;h=e9bab09b8eac7c0ec4900a3685f15a807b448c31;hb=refs/heads/master#l1529 ^ permalink raw reply [flat|nested] 3+ messages in thread
* [U-Boot] Memset 0 in heap initialization? 2010-12-09 16:14 [U-Boot] Memset 0 in heap initialization? Dirk Behme @ 2011-01-18 5:17 ` Dirk Behme 2011-01-18 5:55 ` Kumar Gala 0 siblings, 1 reply; 3+ messages in thread From: Dirk Behme @ 2011-01-18 5:17 UTC (permalink / raw) To: u-boot On 09.12.2010 17:14, Dirk Behme wrote: > > 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 > > [1] > http://git.denx.de/?p=u-boot.git;a=blob;f=common/dlmalloc.c;h=e9bab09b8eac7c0ec4900a3685f15a807b448c31;hb=refs/heads/master#l1529 Any idea regarding this? Thanks Dirk ^ permalink raw reply [flat|nested] 3+ messages in thread
* [U-Boot] Memset 0 in heap initialization? 2011-01-18 5:17 ` Dirk Behme @ 2011-01-18 5:55 ` Kumar Gala 0 siblings, 0 replies; 3+ messages in thread From: Kumar Gala @ 2011-01-18 5:55 UTC (permalink / raw) To: u-boot On Jan 17, 2011, at 11:17 PM, Dirk Behme wrote: > On 09.12.2010 17:14, Dirk Behme wrote: >> >> 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 >> >> [1] >> http://git.denx.de/?p=u-boot.git;a=blob;f=common/dlmalloc.c;h=e9bab09b8eac7c0ec4900a3685f15a807b448c31;hb=refs/heads/master#l1529 > > Any idea regarding this? Part of this is because we define MORECORE_CLEARS 1 which does assume memory is zero'd out. - k ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-01-18 5:55 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2010-12-09 16:14 [U-Boot] Memset 0 in heap initialization? Dirk Behme 2011-01-18 5:17 ` Dirk Behme 2011-01-18 5:55 ` Kumar Gala
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox