]> Git Repo - J-u-boot.git/blobdiff - common/dlmalloc.c
Merge branch 'master' of https://source.denx.de/u-boot/custodians/u-boot-sunxi
[J-u-boot.git] / common / dlmalloc.c
index 9549c59f3585f44bbdb0f57dceae522b03881f7b..62e8557daa70ebeadc724feeee63558570c1cb9d 100644 (file)
@@ -53,7 +53,6 @@ static inline void MALLOC_COPY(void *dest, const void *src, size_t sz) { memcpy(
   Thanks to Martin Fong and others for supplying this.
 */
 
-
 #ifdef WIN32
 
 #define AlignPage(add) (((add) + (malloc_getpagesize-1)) & \
@@ -155,7 +154,6 @@ void* findRegion (void* start_address, unsigned long size)
 
 }
 
-
 void* wsbrk (long size)
 {
        void* tmp;
@@ -236,13 +234,10 @@ gAllocatedSize))
 
 #endif
 
-
-
 /*
   Type declarations
 */
 
-
 struct malloc_chunk
 {
   INTERNAL_SIZE_T prev_size; /* Size of previous chunk (if free). */
@@ -270,7 +265,6 @@ typedef struct malloc_chunk* mchunkptr;
 
     An allocated chunk looks like this:
 
-
     chunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
            |             Size of previous chunk, if allocated            | |
            +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -284,7 +278,6 @@ nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
            |             Size of chunk                                     |
            +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 
-
     Where "chunk" is the front of the chunk for the purpose of most of
     the malloc code, but "mem" is the pointer that is returned to the
     user.  "Nextchunk" is the beginning of the next contiguous chunk.
@@ -401,14 +394,10 @@ nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 
 #define aligned_OK(m)    (((unsigned long)((m)) & (MALLOC_ALIGN_MASK)) == 0)
 
-
-
-
 /*
   Physical chunk operations
 */
 
-
 /* size field is or'ed with PREV_INUSE when previous adjacent chunk in use */
 
 #define PREV_INUSE 0x1
@@ -421,7 +410,6 @@ nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 
 #define SIZE_BITS (PREV_INUSE|IS_MMAPPED)
 
-
 /* Ptr to next physical malloc_chunk. */
 
 #define next_chunk(p) ((mchunkptr)( ((char*)(p)) + ((p)->size & ~PREV_INUSE) ))
@@ -431,14 +419,10 @@ nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 #define prev_chunk(p)\
    ((mchunkptr)( ((char*)(p)) - ((p)->prev_size) ))
 
-
 /* Treat space at ptr + offset as a chunk */
 
 #define chunk_at_offset(p, s)  ((mchunkptr)(((char*)(p)) + (s)))
 
-
-
-
 /*
   Dealing with use bits
 */
@@ -475,9 +459,6 @@ nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 #define clear_inuse_bit_at_offset(p, s)\
  (((mchunkptr)(((char*)(p)) + (s)))->size &= ~(PREV_INUSE))
 
-
-
-
 /*
   Dealing with size fields
 */
@@ -498,10 +479,6 @@ nextchunk-> +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
 
 #define set_foot(p, s)   (((mchunkptr)((char*)(p) + (s)))->prev_size = (s))
 
-
-
-
-
 /*
    Bins
 
@@ -555,7 +532,6 @@ typedef struct malloc_chunk* mbinptr;
 #define top            (av_[2])          /* The topmost chunk */
 #define last_remainder (bin_at(1))       /* remainder from last split */
 
-
 /*
    Because top initially points to its own bin with initial
    zero size, thus forcing extension on the first malloc request,
@@ -671,8 +647,6 @@ void mem_malloc_init(ulong start, ulong size)
 
 #define is_small_request(nb) (nb < MAX_SMALLBIN_SIZE - SMALLBIN_WIDTH)
 
-
-
 /*
     To help compensate for the large number of bins, a one-level index
     structure is used for bin-by-bin searching.  `binblocks' is a
@@ -694,10 +668,6 @@ void mem_malloc_init(ulong start, ulong size)
 #define mark_binblock(ii)   (binblocks_w = (mbinptr)(binblocks_r | idx2binblock(ii)))
 #define clear_binblock(ii)  (binblocks_w = (mbinptr)(binblocks_r & ~(idx2binblock(ii))))
 
-
-
-
-
 /*  Other static bookkeeping data */
 
 /* variables holding tunable values */
@@ -770,7 +740,6 @@ static void malloc_init(void)
 
 #ifdef DEBUG
 
-
 /*
   These routines make a number of assertions about the states
   of data structures that should be true at all times. If any
@@ -799,7 +768,6 @@ static void do_check_chunk(p) mchunkptr p;
 
 }
 
-
 #if __STD_C
 static void do_check_free_chunk(mchunkptr p)
 #else
@@ -885,13 +853,11 @@ static void do_check_malloced_chunk(p, s) mchunkptr p; INTERNAL_SIZE_T s;
   /* ... and alignment */
   assert(aligned_OK(chunk2mem(p)));
 
-
   /* ... and was allocated at front of an available chunk */
   assert(prev_inuse(p));
 
 }
 
-
 #define check_free_chunk(P)  do_check_free_chunk(P)
 #define check_inuse_chunk(P) do_check_inuse_chunk(P)
 #define check_chunk(P) do_check_chunk(P)
@@ -903,13 +869,10 @@ static void do_check_malloced_chunk(p, s) mchunkptr p; INTERNAL_SIZE_T s;
 #define check_malloced_chunk(P,N)
 #endif
 
-
-
 /*
   Macro-based internal utilities
 */
 
-
 /*
   Linking chunks in bin lists.
   Call these only with variables, not arbitrary expressions, as arguments.
@@ -920,7 +883,6 @@ static void do_check_malloced_chunk(p, s) mchunkptr p; INTERNAL_SIZE_T s;
   putting it ahead of others of same size.
 */
 
-
 #define frontlink(P, S, IDX, BK, FD)                                          \
 {                                                                             \
   if (S < MAX_SMALLBIN_SIZE)                                                  \
@@ -950,7 +912,6 @@ static void do_check_malloced_chunk(p, s) mchunkptr p; INTERNAL_SIZE_T s;
   }                                                                           \
 }
 
-
 /* take a chunk off a list */
 
 #define unlink(P, BK, FD)                                                     \
@@ -974,10 +935,6 @@ static void do_check_malloced_chunk(p, s) mchunkptr p; INTERNAL_SIZE_T s;
 #define clear_last_remainder \
   (last_remainder->fd = last_remainder->bk = last_remainder)
 
-
-
-
-
 /* Routines dealing with mmap(). */
 
 #if HAVE_MMAP
@@ -1219,12 +1176,8 @@ static void malloc_extend_top(nb) INTERNAL_SIZE_T nb;
   assert(((unsigned long)((char*)top + top_size) & (pagesz - 1)) == 0);
 }
 
-
-
-
 /* Main public routines */
 
-
 /*
   Malloc Algorthim:
 
@@ -1275,7 +1228,6 @@ static void malloc_extend_top(nb) INTERNAL_SIZE_T nb;
         contiguous memory. Thus, it should be safe to intersperse
         mallocs with other sbrk calls.
 
-
       All allocations are made from the the `lowest' part of any found
       chunk. (The implementation invariant is that prev_inuse is
       always true of any allocated chunk; i.e., that each allocated
@@ -1514,7 +1466,6 @@ Void_t* mALLOc_impl(bytes) size_t bytes;
     }
   }
 
-
   /* Try to use top chunk */
 
   /* Require that there be a remainder, ensuring top always exists  */
@@ -1545,9 +1496,6 @@ Void_t* mALLOc_impl(bytes) size_t bytes;
 
 }
 
-
-
-
 /*
 
   free() algorithm :
@@ -1569,7 +1517,6 @@ Void_t* mALLOc_impl(bytes) size_t bytes;
 
 */
 
-
 STATIC_IF_MCHECK
 #if __STD_C
 void fREe_impl(Void_t* mem)
@@ -1665,17 +1612,12 @@ void fREe_impl(mem) Void_t* mem;
       unlink(next, bck, fwd);
   }
 
-
   set_head(p, sz | PREV_INUSE);
   set_foot(p, sz);
   if (!islr)
     frontlink(p, sz, idx, bck, fwd);
 }
 
-
-
-
-
 /*
 
   Realloc algorithm:
@@ -1708,10 +1650,8 @@ void fREe_impl(mem) Void_t* mem;
     and allowing it would also allow too many other incorrect
     usages of realloc to be sensible.
 
-
 */
 
-
 STATIC_IF_MCHECK
 #if __STD_C
 Void_t* rEALLOc_impl(Void_t* oldmem, size_t bytes)
@@ -1762,7 +1702,6 @@ Void_t* rEALLOc_impl(oldmem, bytes) Void_t* oldmem; size_t bytes;
   newp    = oldp    = mem2chunk(oldmem);
   newsize = oldsize = chunksize(oldp);
 
-
   nb = request2size(bytes);
 
 #if HAVE_MMAP
@@ -1910,7 +1849,6 @@ Void_t* rEALLOc_impl(oldmem, bytes) Void_t* oldmem; size_t bytes;
     VALGRIND_MAKE_MEM_DEFINED(oldmem, bytes);
   }
 
-
  split:  /* split off extra room in old or expanded chunk */
 
   if (newsize - nb >= MINSIZE) /* split off remainder */
@@ -1934,9 +1872,6 @@ Void_t* rEALLOc_impl(oldmem, bytes) Void_t* oldmem; size_t bytes;
   return chunk2mem(newp);
 }
 
-
-
-
 /*
 
   memalign algorithm:
@@ -1955,7 +1890,6 @@ Void_t* rEALLOc_impl(oldmem, bytes) Void_t* oldmem; size_t bytes;
 
 */
 
-
 STATIC_IF_MCHECK
 #if __STD_C
 Void_t* mEMALIGn_impl(size_t alignment, size_t bytes)
@@ -2104,9 +2038,6 @@ Void_t* mEMALIGn_impl(alignment, bytes) size_t alignment; size_t bytes;
 
 }
 
-
-
-
 /*
     valloc just invokes memalign with alignment argument equal
     to the page size of the system (or as near to this as can
@@ -2127,7 +2058,6 @@ Void_t* vALLOc(bytes) size_t bytes;
   that will accommodate request
 */
 
-
 #if __STD_C
 Void_t* pvALLOc(size_t bytes)
 #else
@@ -2156,7 +2086,6 @@ Void_t* cALLOc_impl(n, elem_size) size_t n; size_t elem_size;
 
   INTERNAL_SIZE_T sz = n * elem_size;
 
-
   /* check if expand_top called, in which case don't need to clear */
 #if CONFIG_IS_ENABLED(SYS_MALLOC_CLEAR_ON_INIT)
 #if MORECORE_CLEARS
@@ -2182,7 +2111,6 @@ Void_t* cALLOc_impl(n, elem_size) size_t n; size_t elem_size;
 
     /* Two optional cases in which clearing not necessary */
 
-
 #if HAVE_MMAP
     if (chunk_is_mmapped(p)) return mem;
 #endif
@@ -2223,7 +2151,6 @@ void cfree(mem) Void_t *mem;
 }
 #endif
 
-
 #ifdef MCHECK_HEAP_PROTECTION
  #include "mcheck_core.inc.h"
  #if !__STD_C
@@ -2308,7 +2235,6 @@ enum mcheck_status mprobe(void *__ptr) { return mcheck_mprobe(__ptr); }
 // mcheck API }
 #endif
 
-
 /*
 
     Malloc_trim gives memory back to the system (via negative
@@ -2388,8 +2314,6 @@ int malloc_trim(pad) size_t pad;
   }
 }
 
-
-
 /*
   malloc_usable_size:
 
@@ -2423,9 +2347,6 @@ size_t malloc_usable_size(mem) Void_t* mem;
   }
 }
 
-
-
-
 /* Utility to update current_mallinfo for malloc_stats and mallinfo() */
 
 #ifdef DEBUG
@@ -2468,8 +2389,6 @@ static void malloc_update_mallinfo(void)
 }
 #endif /* DEBUG */
 
-
-
 /*
 
   malloc_stats:
@@ -2514,9 +2433,6 @@ struct mallinfo mALLINFo(void)
 }
 #endif /* DEBUG */
 
-
-
-
 /*
   mallopt:
 
This page took 0.0377 seconds and 4 git commands to generate.