]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - common/dlmalloc.c
Merge branch 'master' of git://git.denx.de/u-boot-samsung
[karo-tx-uboot.git] / common / dlmalloc.c
index ae5702dd52ae178d0e0e16d46a173dbdd927d75c..e9bab09b8eac7c0ec4900a3685f15a807b448c31 100644 (file)
@@ -1152,7 +1152,7 @@ struct malloc_chunk
   INTERNAL_SIZE_T size;      /* Size in bytes, including overhead. */
   struct malloc_chunk* fd;   /* double links -- used only if free. */
   struct malloc_chunk* bk;
-};
+} __attribute__((__may_alias__)) ;
 
 typedef struct malloc_chunk* mchunkptr;
 
@@ -1491,7 +1491,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 +1511,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;