diff options
author | Sascha Hauer <s.hauer@pengutronix.de> | 2007-07-05 18:02:02 +0200 |
---|---|---|
committer | Sascha Hauer <sha@octopus.labnet.pengutronix.de> | 2007-07-05 18:02:02 +0200 |
commit | 614ff8b708cf9b83b00aa996392d3d64fd898b14 (patch) | |
tree | ddb22b9ae818f646aca4ab7b6185788b2160fd84 /common | |
parent | 634b6ac8b9c56865603e1699a40788e97a90d444 (diff) | |
download | barebox-614ff8b708cf9b83b00aa996392d3d64fd898b14.tar.gz barebox-614ff8b708cf9b83b00aa996392d3d64fd898b14.tar.xz |
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
Diffstat (limited to 'common')
-rw-r--r-- | common/misc.c | 16 |
1 files changed, 12 insertions, 4 deletions
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 |