Merge branch 'master' of git://git.denx.de/u-boot-cfi-flash
[platform/kernel/u-boot.git] / common / dlmalloc.c
index ca088a1..205fc40 100644 (file)
@@ -1522,11 +1522,6 @@ void *sbrk(ptrdiff_t increment)
        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;
@@ -1535,7 +1530,6 @@ void mem_malloc_init(ulong start, ulong size)
 
        memset((void *)mem_malloc_start, 0, size);
 }
-#endif
 
 /* field-extraction macros */
 
@@ -2185,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; */