]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - common/dlmalloc.c
mxs: rename regs-clkctrl.h to regs-clkctrl-mx28.h
[karo-tx-uboot.git] / common / dlmalloc.c
index fce7a762b1ed177906f03968c2ca0f4a8dcacbbf..c645d7314bfe3a517e1273f7dce349a2dac0c1da 100644 (file)
@@ -286,13 +286,6 @@ extern "C" {
 
 */
 
-#ifdef DEBUG
-#include <assert.h>
-#else
-#define assert(x) ((void)0)
-#endif
-
-
 /*
   INTERNAL_SIZE_T is the word-size used for internal bookkeeping
   of chunk sizes. On a 64-bit machine, you can reduce malloc
@@ -1491,7 +1484,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
+#ifdef CONFIG_NEEDS_MANUAL_RELOC
 void malloc_bin_reloc (void)
 {
        unsigned long *p = (unsigned long *)(&av_[2]);
@@ -1511,6 +1504,13 @@ void *sbrk(ptrdiff_t increment)
        ulong old = mem_malloc_brk;
        ulong new = old + increment;
 
+       /*
+        * if we are giving memory back make sure we clear it out since
+        * we set MORECORE_CLEARS to 1
+        */
+       if (increment < 0)
+               memset((void *)new, 0, -increment);
+
        if ((new < mem_malloc_start) || (new > mem_malloc_end))
                return (void *)MORECORE_FAILURE;
 
@@ -1647,9 +1647,7 @@ static void do_check_chunk(mchunkptr p)
 static void do_check_chunk(p) mchunkptr p;
 #endif
 {
-#if 0  /* causes warnings because assert() is off */
   INTERNAL_SIZE_T sz = p->size & ~PREV_INUSE;
-#endif /* 0 */
 
   /* No checkable chunk is mmapped */
   assert(!chunk_is_mmapped(p));
@@ -1671,9 +1669,7 @@ static void do_check_free_chunk(p) mchunkptr p;
 #endif
 {
   INTERNAL_SIZE_T sz = p->size & ~PREV_INUSE;
-#if 0  /* causes warnings because assert() is off */
   mchunkptr next = chunk_at_offset(p, sz);
-#endif /* 0 */
 
   do_check_chunk(p);
 
@@ -1737,10 +1733,8 @@ static void do_check_malloced_chunk(mchunkptr p, INTERNAL_SIZE_T s)
 static void do_check_malloced_chunk(p, s) mchunkptr p; INTERNAL_SIZE_T s;
 #endif
 {
-#if 0  /* causes warnings because assert() is off */
   INTERNAL_SIZE_T sz = p->size & ~PREV_INUSE;
   long room = sz - s;
-#endif /* 0 */
 
   do_check_inuse_chunk(p);