From 614ff8b708cf9b83b00aa996392d3d64fd898b14 Mon Sep 17 00:00:00 2001 From: Sascha Hauer Date: Thu, 5 Jul 2007 18:02:02 +0200 Subject: svn_rev_532 - Do not zero memory in mem_malloc_init because it takes a long time with big memory. Instead zero it when we actually need the memory. - Add sbrk_no_zero() function to allocate memory without zeroing it. This is usefull for scratch mem devices which occupy large chunks of memory --- common/misc.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) (limited to 'common/misc.c') diff --git a/common/misc.c b/common/misc.c index 30631182d3..ab7a53e93f 100644 --- a/common/misc.c +++ b/common/misc.c @@ -14,12 +14,9 @@ void mem_malloc_init (void *start, void *end) mem_malloc_start = (ulong)start; mem_malloc_end = (ulong)end; mem_malloc_brk = mem_malloc_start; - - memset ((void *) mem_malloc_start, 0, - mem_malloc_end - mem_malloc_start); } -void *sbrk (ptrdiff_t increment) +void *sbrk_no_zero(ptrdiff_t increment) { ulong old = mem_malloc_brk; ulong new = old + increment; @@ -27,11 +24,22 @@ void *sbrk (ptrdiff_t increment) if ((new < mem_malloc_start) || (new > mem_malloc_end)) { return (NULL); } + + memset ((void *)old, 0, increment); mem_malloc_brk = new; return ((void *) old); } +void *sbrk (ptrdiff_t increment) +{ + void *old = sbrk_no_zero(increment); + + memset (old, 0, increment); + + return old; +} + int errno; #ifndef CONFIG_ERRNO_MESSAGES -- cgit v1.2.3