9
0
Fork 0

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
This commit is contained in:
Sascha Hauer 2007-07-05 18:02:02 +02:00 committed by Sascha Hauer
parent 634b6ac8b9
commit 614ff8b708
1 changed files with 12 additions and 4 deletions

View File

@ -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