]> git.sur5r.net Git - u-boot/blobdiff - common/dlmalloc.c
Merge branch 'master' of ../master
[u-boot] / common / dlmalloc.c
index 241db8cd3e061f1c18788763dfa0b522ca7c5af8..2276532da7a8441c500c39b1716e23a2806a8c21 100644 (file)
@@ -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,6 +1503,7 @@ void malloc_bin_reloc (void)
                *p++ += gd->reloc_off;
        }
 }
+#endif
 
 ulong mem_malloc_start = 0;
 ulong mem_malloc_end = 0;
@@ -1513,18 +1515,13 @@ void *sbrk(ptrdiff_t increment)
        ulong new = old + increment;
 
        if ((new < mem_malloc_start) || (new > mem_malloc_end))
-               return NULL;
+               return (void *)MORECORE_FAILURE;
 
        mem_malloc_brk = new;
 
        return (void *)old;
 }
 
-#ifndef CONFIG_X86
-/*
- * x86 boards use a slightly different init sequence thus they implement
- * their own version of mem_malloc_init()
- */
 void mem_malloc_init(ulong start, ulong size)
 {
        mem_malloc_start = start;
@@ -1533,7 +1530,6 @@ void mem_malloc_init(ulong start, ulong size)
 
        memset((void *)mem_malloc_start, 0, size);
 }
-#endif
 
 /* field-extraction macros */
 
@@ -2183,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; */