X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=common%2Fdlmalloc.c;h=2276532da7a8441c500c39b1716e23a2806a8c21;hb=000b6dc6edfcb83c4fff9376f9a2a4af67f3fc83;hp=4a185620f98203d74c7bfdc30f2c669d7c8391da;hpb=7772c13ba07eaabd42499998f3713b23350fc119;p=oweals%2Fu-boot.git diff --git a/common/dlmalloc.c b/common/dlmalloc.c index 4a185620f9..2276532da7 100644 --- a/common/dlmalloc.c +++ b/common/dlmalloc.c @@ -1494,6 +1494,7 @@ static mbinptr av_[NAV * 2 + 2] = { IAV(120), IAV(121), IAV(122), IAV(123), IAV(124), IAV(125), IAV(126), IAV(127) }; +#ifndef CONFIG_RELOC_FIXUP_WORKS void malloc_bin_reloc (void) { unsigned long *p = (unsigned long *)(&av_[2]); @@ -1502,7 +1503,33 @@ void malloc_bin_reloc (void) *p++ += gd->reloc_off; } } - +#endif + +ulong mem_malloc_start = 0; +ulong mem_malloc_end = 0; +ulong mem_malloc_brk = 0; + +void *sbrk(ptrdiff_t increment) +{ + ulong old = mem_malloc_brk; + ulong new = old + increment; + + if ((new < mem_malloc_start) || (new > mem_malloc_end)) + return (void *)MORECORE_FAILURE; + + mem_malloc_brk = new; + + return (void *)old; +} + +void mem_malloc_init(ulong start, ulong size) +{ + mem_malloc_start = start; + mem_malloc_end = start + size; + mem_malloc_brk = start; + + memset((void *)mem_malloc_start, 0, size); +} /* field-extraction macros */ @@ -2152,6 +2179,12 @@ Void_t* mALLOc(bytes) size_t bytes; INTERNAL_SIZE_T nb; + /* check if mem_malloc_init() was run */ + if ((mem_malloc_start == 0) && (mem_malloc_end == 0)) { + /* not initialized yet */ + return 0; + } + if ((long)bytes < 0) return 0; nb = request2size(bytes); /* padded request size; */