Atmel Software Framework

dlmalloc.c File Reference
#include "dlmalloc.h"
#include <stdio.h>
#include <errno.h>
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
#include <fcntl.h>
#include <unistd.h>
#include <sys/param.h>

Data Structures

struct  malloc_chunk
 
struct  malloc_params
 
struct  malloc_segment
 
struct  malloc_state
 
struct  malloc_tree_chunk
 

Macros

#define ACQUIRE_MAGIC_INIT_LOCK()
 
#define ACQUIRE_MORECORE_LOCK()
 
#define align_as_chunk(A)   (mchunkptr)((A) + align_offset(chunk2mem(A)))
 
#define align_offset(A)
 
#define assert(x)
 
#define bit_for_tree_index(i)   (i == NTREEBINS-1)? (SIZE_T_BITSIZE-1) : (((i) >> 1) + TREEBIN_SHIFT - 2)
 
#define CALL_MMAP(s)   mmap(0, (s), MMAP_PROT, MMAP_FLAGS, -1, 0)
 
#define CALL_MORECORE(S)   MORECORE(S)
 
#define CALL_MREMAP(addr, osz, nsz, mv)   MFAIL
 
#define CALL_MUNMAP(a, s)   munmap((a), (s))
 
#define calloc_must_clear(p)   (!is_mmapped(p))
 
#define check_free_chunk(M, P)
 
#define check_inuse_chunk(M, P)
 
#define check_malloc_state(M)
 
#define check_malloced_chunk(M, P, N)
 
#define check_mmapped_chunk(M, P)
 
#define check_top_chunk(M, P)
 
#define chunk2mem(p)   ((void*)((char*)(p) + TWO_SIZE_T_SIZES))
 
#define CHUNK_ALIGN_MASK   (MALLOC_ALIGNMENT - SIZE_T_ONE)
 
#define chunk_minus_offset(p, s)   ((mchunkptr)(((char*)(p)) - (s)))
 
#define CHUNK_OVERHEAD   (SIZE_T_SIZE)
 
#define chunk_plus_offset(p, s)   ((mchunkptr)(((char*)(p)) + (s)))
 
#define chunksize(p)   ((p)->head & ~(INUSE_BITS))
 
#define cinuse(p)   ((p)->head & CINUSE_BIT)
 
#define CINUSE_BIT   (SIZE_T_TWO)
 
#define clear_cinuse(p)   ((p)->head &= ~CINUSE_BIT)
 
#define clear_pinuse(p)   ((p)->head &= ~PINUSE_BIT)
 
#define clear_smallmap(M, i)   ((M)->smallmap &= ~idx2bit(i))
 
#define clear_treemap(M, i)   ((M)->treemap &= ~idx2bit(i))
 
#define CMFAIL   ((char*)(MFAIL)) /* defined for convenience */
 
#define compute_bit2idx(X, I)
 
#define compute_tree_index(S, I)
 
#define CORRUPTION_ERROR_ACTION(m)   ABORT
 
#define DIRECT_MMAP(s)   CALL_MMAP(s)
 
#define disable_contiguous(M)   ((M)->mflags |= USE_NONCONTIGUOUS_BIT)
 
#define disable_lock(M)   ((M)->mflags &= ~USE_LOCK_BIT)
 
#define disable_mmap(M)   ((M)->mflags &= ~USE_MMAP_BIT)
 
#define enable_lock(M)   ((M)->mflags |= USE_LOCK_BIT)
 
#define enable_mmap(M)   ((M)->mflags |= USE_MMAP_BIT)
 
#define EXTERN_BIT   (8U)
 
#define FENCEPOST_HEAD   (INUSE_BITS|SIZE_T_SIZE)
 
#define fm   gm
 
#define FOUR_SIZE_T_SIZES   (SIZE_T_SIZE<<2)
 
#define get_foot(p, s)   (((mchunkptr)((char*)(p) + (s)))->prev_foot)
 
#define gm   (&_gm_)
 
#define granularity_align(S)   (((S) + (mparams.granularity)) & ~(mparams.granularity - SIZE_T_ONE))
 
#define HALF_MAX_SIZE_T   (MAX_SIZE_T / 2U)
 
#define idx2bit(i)   ((binmap_t)(1) << (i))
 
#define INITIAL_LOCK(l)
 
#define insert_chunk(M, P, S)
 
#define insert_large_chunk(M, X, S)
 
#define insert_small_chunk(M, P, S)
 
#define internal_free(m, mem)   dlfree(mem)
 
#define internal_malloc(m, b)   dlmalloc(b)
 
#define INUSE_BITS   (PINUSE_BIT|CINUSE_BIT)
 
#define is_aligned(A)   (((size_t)((A)) & (CHUNK_ALIGN_MASK)) == 0)
 
#define is_extern_segment(S)   ((S)->sflags & EXTERN_BIT)
 
#define is_global(M)   ((M) == &_gm_)
 
#define is_granularity_aligned(S)   (((size_t)(S) & (mparams.granularity - SIZE_T_ONE)) == 0)
 
#define is_initialized(M)   ((M)->top != 0)
 
#define is_mmapped(p)   (!((p)->head & PINUSE_BIT) && ((p)->prev_foot & IS_MMAPPED_BIT))
 
#define IS_MMAPPED_BIT   (SIZE_T_ONE)
 
#define is_mmapped_segment(S)   ((S)->sflags & IS_MMAPPED_BIT)
 
#define is_page_aligned(S)   (((size_t)(S) & (mparams.page_size - SIZE_T_ONE)) == 0)
 
#define is_small(s)   (((s) >> SMALLBIN_SHIFT) < NSMALLBINS)
 
#define least_bit(x)   ((x) & -(x))
 
#define left_bits(x)   ((x<<1) | -(x<<1))
 
#define leftmost_child(t)   ((t)->child[0] != 0? (t)->child[0] : (t)->child[1])
 
#define leftshift_for_tree_index(i)
 
#define malloc_getpagesize   ((size_t)4096U)
 
#define mark_inuse_foot(M, p, s)
 
#define mark_smallmap(M, i)   ((M)->smallmap |= idx2bit(i))
 
#define mark_treemap(M, i)   ((M)->treemap |= idx2bit(i))
 
#define MAX_REQUEST   ((-MIN_CHUNK_SIZE) << 2)
 
#define MAX_SMALL_REQUEST   (MAX_SMALL_SIZE - CHUNK_ALIGN_MASK - CHUNK_OVERHEAD)
 
#define MAX_SMALL_SIZE   (MIN_LARGE_SIZE - SIZE_T_ONE)
 
#define MCHUNK_SIZE   (sizeof(mchunk))
 
#define mem2chunk(mem)   ((mchunkptr)((char*)(mem) - TWO_SIZE_T_SIZES))
 
#define MFAIL   ((void*)(MAX_SIZE_T))
 
#define MIN_CHUNK_SIZE   ((MCHUNK_SIZE + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK)
 
#define MIN_LARGE_SIZE   (SIZE_T_ONE << TREEBIN_SHIFT)
 
#define MIN_REQUEST   (MIN_CHUNK_SIZE - CHUNK_OVERHEAD - SIZE_T_ONE)
 
#define MIN_SMALL_INDEX   (small_index(MIN_CHUNK_SIZE))
 
#define minsize_for_tree_index(i)
 
#define MMAP_CHUNK_OVERHEAD   (TWO_SIZE_T_SIZES)
 
#define MMAP_FLAGS   (MAP_PRIVATE|MAP_ANONYMOUS)
 
#define MMAP_FOOT_PAD   (FOUR_SIZE_T_SIZES)
 
#define MMAP_PROT   (PROT_READ|PROT_WRITE)
 
#define next_chunk(p)   ((mchunkptr)( ((char*)(p)) + ((p)->head & ~INUSE_BITS)))
 
#define next_pinuse(p)   ((next_chunk(p)->head) & PINUSE_BIT)
 
#define NSMALLBINS   (32U)
 
#define NTREEBINS   (32U)
 
#define ok_address(M, a)   ((char*)(a) >= (M)->least_addr)
 
#define ok_cinuse(p)   cinuse(p)
 
#define ok_magic(M)   (1)
 
#define ok_next(p, n)   ((char*)(p) < (char*)(n))
 
#define ok_pinuse(p)   pinuse(p)
 
#define overhead_for(p)   (is_mmapped(p)? MMAP_CHUNK_OVERHEAD : CHUNK_OVERHEAD)
 
#define pad_request(req)   (((req) + CHUNK_OVERHEAD + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK)
 
#define page_align(S)   (((S) + (mparams.page_size)) & ~(mparams.page_size - SIZE_T_ONE))
 
#define pinuse(p)   ((p)->head & PINUSE_BIT)
 
#define PINUSE_BIT   (SIZE_T_ONE)
 
#define POSTACTION(M)
 
#define PREACTION(M)   (0)
 
#define prev_chunk(p)   ((mchunkptr)( ((char*)(p)) - ((p)->prev_foot) ))
 
#define RELEASE_MAGIC_INIT_LOCK()
 
#define RELEASE_MORECORE_LOCK()
 
#define replace_dv(M, P, S)
 
#define request2size(req)   (((req) < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(req))
 
#define RTCHECK(e)   __builtin_expect(e, 1)
 
#define same_or_left_bits(x)   ((x) | -(x))
 
#define segment_holds(S, A)   ((char*)(A) >= S->base && (char*)(A) < S->base + S->size)
 
#define set_foot(p, s)   (((mchunkptr)((char*)(p) + (s)))->prev_foot = (s))
 
#define set_free_with_pinuse(p, s, n)   (clear_pinuse(n), set_size_and_pinuse_of_free_chunk(p, s))
 
#define set_inuse(M, p, s)
 
#define set_inuse_and_pinuse(M, p, s)
 
#define set_lock(M, L)
 
#define set_size_and_pinuse_of_free_chunk(p, s)   ((p)->head = (s|PINUSE_BIT), set_foot(p, s))
 
#define set_size_and_pinuse_of_inuse_chunk(M, p, s)   ((p)->head = (s|PINUSE_BIT|CINUSE_BIT))
 
#define should_trim(M, s)   ((s) > (M)->trim_check)
 
#define SIX_SIZE_T_SIZES   (FOUR_SIZE_T_SIZES+TWO_SIZE_T_SIZES)
 
#define SIZE_T_BITSIZE   (sizeof(size_t) << 3)
 
#define SIZE_T_ONE   ((size_t)1)
 
#define SIZE_T_SIZE   (sizeof(size_t))
 
#define SIZE_T_TWO   ((size_t)2)
 
#define SIZE_T_ZERO   ((size_t)0)
 
#define small_index(s)   ((s) >> SMALLBIN_SHIFT)
 
#define small_index2size(i)   ((i) << SMALLBIN_SHIFT)
 
#define smallbin_at(M, i)   ((sbinptr)((char*)&((M)->smallbins[(i)<<1])))
 
#define SMALLBIN_SHIFT   (3U)
 
#define SMALLBIN_WIDTH   (SIZE_T_ONE << SMALLBIN_SHIFT)
 
#define smallmap_is_marked(M, i)   ((M)->smallmap & idx2bit(i))
 
#define TOP_FOOT_SIZE   (align_offset(chunk2mem(0))+pad_request(sizeof(struct malloc_segment))+MIN_CHUNK_SIZE)
 
#define treebin_at(M, i)   (&((M)->treebins[i]))
 
#define TREEBIN_SHIFT   (8U)
 
#define treemap_is_marked(M, i)   ((M)->treemap & idx2bit(i))
 
#define TWO_SIZE_T_SIZES   (SIZE_T_SIZE<<1)
 
#define unlink_chunk(M, P, S)
 
#define unlink_first_small_chunk(M, B, P, I)
 
#define unlink_large_chunk(M, X)
 
#define unlink_small_chunk(M, P, S)
 
#define USAGE_ERROR_ACTION(m, p)   ABORT
 
#define use_lock(M)   ((M)->mflags & USE_LOCK_BIT)
 
#define USE_LOCK_BIT   (0U)
 
#define use_mmap(M)   ((M)->mflags & USE_MMAP_BIT)
 
#define USE_MMAP_BIT   (SIZE_T_ONE)
 
#define use_noncontiguous(M)   ((M)->mflags & USE_NONCONTIGUOUS_BIT)
 
#define USE_NONCONTIGUOUS_BIT   (4U)
 

Typedefs

typedef unsigned int bindex_t
 
typedef unsigned int binmap_t
 
typedef unsigned int flag_t
 
typedef struct malloc_chunk mchunk
 
typedef struct malloc_chunkmchunkptr
 
typedef struct malloc_segment msegment
 
typedef struct malloc_segmentmsegmentptr
 
typedef struct malloc_statemstate
 
typedef struct malloc_chunksbinptr
 
typedef struct malloc_tree_chunktbinptr
 
typedef struct malloc_tree_chunk tchunk
 
typedef struct malloc_tree_chunktchunkptr
 

Functions

static void add_segment (mstate m, char *tbase, size_t tsize, flag_t mmapped)
 
static int change_mparam (int param_number, int value)
 
void * dlcalloc (size_t n_elements, size_t elem_size)
 
void dlfree (void *mem)
 
void ** dlindependent_calloc (size_t n_elements, size_t elem_size, void *chunks[])
 
void ** dlindependent_comalloc (size_t n_elements, size_t sizes[], void *chunks[])
 
struct mallinfo dlmallinfo (void)
 
void * dlmalloc (size_t bytes)
 
size_t dlmalloc_footprint (void)
 
size_t dlmalloc_max_footprint (void)
 
void dlmalloc_stats ()
 
int dlmalloc_trim (size_t pad)
 
size_t dlmalloc_usable_size (void *mem)
 
int dlmallopt (int param_number, int value)
 
void * dlmemalign (size_t alignment, size_t bytes)
 
void * dlpvalloc (size_t bytes)
 
void * dlrealloc (void *oldmem, size_t bytes)
 
void * dlvalloc (size_t bytes)
 
static int has_segment_link (mstate m, msegmentptr ss)
 
static void ** ialloc (mstate m, size_t n_elements, size_t *sizes, int opts, void *chunks[])
 
static void init_bins (mstate m)
 
static int init_mparams (void)
 
static void init_top (mstate m, mchunkptr p, size_t psize)
 
static struct mallinfo internal_mallinfo (mstate m)
 
static void internal_malloc_stats (mstate m)
 
static void * internal_memalign (mstate m, size_t alignment, size_t bytes)
 
static void * internal_realloc (mstate m, void *oldmem, size_t bytes)
 
static void * mmap_alloc (mstate m, size_t nb)
 
static mchunkptr mmap_resize (mstate m, mchunkptr oldp, size_t nb)
 
static void * prepend_alloc (mstate m, char *newbase, char *oldbase, size_t nb)
 
static size_t release_unused_segments (mstate m)
 
static msegmentptr segment_holding (mstate m, char *addr)
 
static void * sys_alloc (mstate m, size_t nb)
 
static int sys_trim (mstate m, size_t pad)
 
static void * tmalloc_large (mstate m, size_t nb)
 
static void * tmalloc_small (mstate m, size_t nb)
 

Variables

static struct malloc_state _gm_
 
static struct malloc_params mparams
 

#define ACQUIRE_MAGIC_INIT_LOCK ( )

Referenced by init_mparams().

#define ACQUIRE_MORECORE_LOCK ( )

Referenced by sys_alloc(), and sys_trim().

#define align_as_chunk (   A)    (mchunkptr)((A) + align_offset(chunk2mem(A)))
#define align_offset (   A)
Value:
((((size_t)(A) & CHUNK_ALIGN_MASK) == 0)? 0 :\
#define A
Definition: op_fix_asin.c:48
#define CHUNK_ALIGN_MASK
Definition: dlmalloc.c:133
#define MALLOC_ALIGNMENT
Definition: dlmalloc.h:73

Referenced by add_segment(), init_top(), and mmap_alloc().

#define bit_for_tree_index (   i)    (i == NTREEBINS-1)? (SIZE_T_BITSIZE-1) : (((i) >> 1) + TREEBIN_SHIFT - 2)
#define CALL_MMAP (   s)    mmap(0, (s), MMAP_PROT, MMAP_FLAGS, -1, 0)

Referenced by sys_alloc().

#define CALL_MORECORE (   S)    MORECORE(S)

Referenced by sys_alloc(), and sys_trim().

#define CALL_MREMAP (   addr,
  osz,
  nsz,
  mv 
)    MFAIL

Referenced by mmap_resize(), and sys_trim().

#define CALL_MUNMAP (   a,
  s 
)    munmap((a), (s))
#define calloc_must_clear (   p)    (!is_mmapped(p))

Referenced by dlcalloc().

#define check_free_chunk (   M,
 
)

Referenced by dlfree(), and prepend_alloc().

#define check_inuse_chunk (   M,
 
)
#define check_malloc_state (   M)
#define check_malloced_chunk (   M,
  P,
  N 
)

Referenced by dlmalloc(), prepend_alloc(), and sys_alloc().

#define check_mmapped_chunk (   M,
 
)

Referenced by mmap_alloc(), and mmap_resize().

#define check_top_chunk (   M,
 
)
#define CHUNK_ALIGN_MASK   (MALLOC_ALIGNMENT - SIZE_T_ONE)
#define chunk_minus_offset (   p,
  s 
)    ((mchunkptr)(((char*)(p)) - (s)))

Referenced by dlfree().

#define CHUNK_OVERHEAD   (SIZE_T_SIZE)

Referenced by ialloc(), and internal_memalign().

#define CINUSE_BIT   (SIZE_T_TWO)
#define clear_cinuse (   p)    ((p)->head &= ~CINUSE_BIT)
#define clear_pinuse (   p)    ((p)->head &= ~PINUSE_BIT)
#define clear_smallmap (   M,
  i 
)    ((M)->smallmap &= ~idx2bit(i))
#define clear_treemap (   M,
  i 
)    ((M)->treemap &= ~idx2bit(i))
#define CMFAIL   ((char*)(MFAIL)) /* defined for convenience */
#define compute_bit2idx (   X,
 
)
Value:
{\
unsigned int Y = X - 1;\
unsigned int K = Y >> (16-4) & 16;\
unsigned int N = K; Y >>= K;\
N += K = Y >> (8-3) & 8; Y >>= K;\
N += K = Y >> (4-2) & 4; Y >>= K;\
N += K = Y >> (2-1) & 2; Y >>= K;\
N += K = Y >> (1-0) & 1; Y >>= K;\
I = (bindex_t)(N + Y);\
}
#define N
Number of point to process.
Definition: resampling_example.c:67
unsigned int bindex_t
Definition: dlmalloc.c:483

Referenced by dlmalloc(), tmalloc_large(), and tmalloc_small().

#define compute_tree_index (   S,
 
)
Value:
{\
size_t X = S >> TREEBIN_SHIFT;\
if (X == 0)\
I = 0;\
else if (X > 0xFFFF)\
I = NTREEBINS-1;\
unsigned int Y = (unsigned int)X;\
unsigned int N = ((Y - 0x100) >> 16) & 8;\
unsigned int K = (((Y <<= N) - 0x1000) >> 16) & 4;\
N += K;\
N += K = (((Y <<= K) - 0x4000) >> 16) & 2;\
K = 14 - N + ((Y <<= K) >> 15);\
I = (K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1));\
}\
}
#define NTREEBINS
Definition: dlmalloc.c:844
if(Is_usb_id_transition()&&Is_usb_id_interrupt_enabled())
Definition: applications/uc3-audio-player/usb_task.c:395
#define N
Number of point to process.
Definition: resampling_example.c:67
else
Definition: lwip-1.4.0/src/core/memp.c:417
#define TREEBIN_SHIFT
Definition: dlmalloc.c:847

Referenced by tmalloc_large().

#define CORRUPTION_ERROR_ACTION (   m)    ABORT

Referenced by tmalloc_large(), and tmalloc_small().

#define DIRECT_MMAP (   s)    CALL_MMAP(s)

Referenced by mmap_alloc().

#define disable_contiguous (   M)    ((M)->mflags |= USE_NONCONTIGUOUS_BIT)

Referenced by sys_alloc().

#define disable_lock (   M)    ((M)->mflags &= ~USE_LOCK_BIT)
#define disable_mmap (   M)    ((M)->mflags &= ~USE_MMAP_BIT)

Referenced by ialloc().

#define enable_lock (   M)    ((M)->mflags |= USE_LOCK_BIT)
#define enable_mmap (   M)    ((M)->mflags |= USE_MMAP_BIT)

Referenced by ialloc().

#define EXTERN_BIT   (8U)
#define fm   gm

Referenced by dlfree().

#define FOUR_SIZE_T_SIZES   (SIZE_T_SIZE<<2)

Referenced by add_segment().

#define get_foot (   p,
  s 
)    (((mchunkptr)((char*)(p) + (s)))->prev_foot)
#define granularity_align (   S)    (((S) + (mparams.granularity)) & ~(mparams.granularity - SIZE_T_ONE))

Referenced by mmap_alloc(), mmap_resize(), and sys_alloc().

#define HALF_MAX_SIZE_T   (MAX_SIZE_T / 2U)

Referenced by sys_alloc(), and sys_trim().

#define idx2bit (   i)    ((binmap_t)(1) << (i))

Referenced by dlmalloc(), and tmalloc_large().

#define INITIAL_LOCK (   l)

Referenced by init_mparams().

#define insert_chunk (   M,
  P,
 
)
Value:
else { tchunkptr TP = (tchunkptr)(P); insert_large_chunk(M, TP, S); }
Definition: dlmalloc.c:678
#define insert_large_chunk(M, X, S)
Definition: dlmalloc.c:1843
int M
Definition: jdmainct.c:205
#define insert_small_chunk(M, P, S)
Definition: dlmalloc.c:1772
struct malloc_tree_chunk * tchunkptr
Definition: dlmalloc.c:691
else
Definition: lwip-1.4.0/src/core/memp.c:417
#define is_small(s)
Definition: dlmalloc.c:1097

Referenced by add_segment(), dlfree(), prepend_alloc(), and tmalloc_large().

#define insert_large_chunk (   M,
  X,
 
)

Referenced by release_unused_segments().

#define insert_small_chunk (   M,
  P,
 
)
Value:
{\
else if (RTCHECK(ok_address(M, B->fd)))\
F = B->fd;\
}\
B->fd = P;\
F->bk = P;\
P->fd = F;\
P->bk = B;\
}
#define RTCHECK(e)
Definition: dlmalloc.c:1265
#define smallmap_is_marked(M, i)
Definition: dlmalloc.c:1164
#define assert(x)
Definition: dlmalloc.c:36
int M
Definition: jdmainct.c:205
struct malloc_chunk * mchunkptr
Definition: dlmalloc.c:481
if(Is_usb_id_transition()&&Is_usb_id_interrupt_enabled())
Definition: applications/uc3-audio-player/usb_task.c:395
#define small_index(s)
Definition: dlmalloc.c:1098
unsigned int bindex_t
Definition: dlmalloc.c:483
#define mark_smallmap(M, i)
Definition: dlmalloc.c:1162
#define B
Definition: op_fix_asin.c:49
else
Definition: lwip-1.4.0/src/core/memp.c:417
#define CORRUPTION_ERROR_ACTION(m)
Definition: dlmalloc.c:1053
#define F
Definition: op_fix_asin.c:53
#define MIN_CHUNK_SIZE
Definition: dlmalloc.c:503
#define smallbin_at(M, i)
Definition: dlmalloc.c:1103
#define ok_address(M, a)
Definition: dlmalloc.c:1239
#define internal_free (   m,
  mem 
)    dlfree(mem)
#define internal_malloc (   m,
  b 
)    dlmalloc(b)
#define INUSE_BITS   (PINUSE_BIT|CINUSE_BIT)

Referenced by dlfree().

#define is_aligned (   A)    (((size_t)((A)) & (CHUNK_ALIGN_MASK)) == 0)

Referenced by add_segment(), and mmap_alloc().

#define is_extern_segment (   S)    ((S)->sflags & EXTERN_BIT)
#define is_global (   M)    ((M) == &_gm_)

Referenced by sys_alloc().

#define is_granularity_aligned (   S)    (((size_t)(S) & (mparams.granularity - SIZE_T_ONE)) == 0)
#define is_initialized (   M)    ((M)->top != 0)
#define is_mmapped (   p)    (!((p)->head & PINUSE_BIT) && ((p)->prev_foot & IS_MMAPPED_BIT))
#define IS_MMAPPED_BIT   (SIZE_T_ONE)
#define is_mmapped_segment (   S)    ((S)->sflags & IS_MMAPPED_BIT)
#define is_page_aligned (   S)    (((size_t)(S) & (mparams.page_size - SIZE_T_ONE)) == 0)

Referenced by sys_alloc().

#define is_small (   s)    (((s) >> SMALLBIN_SHIFT) < NSMALLBINS)

Referenced by mmap_resize().

#define least_bit (   x)    ((x) & -(x))
#define left_bits (   x)    ((x<<1) | -(x<<1))

Referenced by dlmalloc(), and tmalloc_large().

#define leftmost_child (   t)    ((t)->child[0] != 0? (t)->child[0] : (t)->child[1])

Referenced by tmalloc_large(), and tmalloc_small().

#define leftshift_for_tree_index (   i)
Value:
((i == NTREEBINS-1)? 0 : \
((SIZE_T_BITSIZE-SIZE_T_ONE) - (((i) >> 1) + TREEBIN_SHIFT - 2)))
int i
Definition: jcmarker.c:150
#define NTREEBINS
Definition: dlmalloc.c:844
#define SIZE_T_BITSIZE
Definition: dlmalloc.c:120
#define SIZE_T_ONE
Definition: dlmalloc.c:125
#define TREEBIN_SHIFT
Definition: dlmalloc.c:847

Referenced by tmalloc_large().

#define malloc_getpagesize   ((size_t)4096U)

Referenced by init_mparams().

#define mark_inuse_foot (   M,
  p,
  s 
)

Referenced by mmap_alloc(), and mmap_resize().

#define mark_smallmap (   M,
  i 
)    ((M)->smallmap |= idx2bit(i))
#define mark_treemap (   M,
  i 
)    ((M)->treemap |= idx2bit(i))
#define MAX_REQUEST   ((-MIN_CHUNK_SIZE) << 2)
#define MAX_SMALL_REQUEST   (MAX_SMALL_SIZE - CHUNK_ALIGN_MASK - CHUNK_OVERHEAD)

Referenced by dlmalloc().

#define MAX_SMALL_SIZE   (MIN_LARGE_SIZE - SIZE_T_ONE)
#define MCHUNK_SIZE   (sizeof(mchunk))

Referenced by init_mparams().

#define MFAIL   ((void*)(MAX_SIZE_T))

Referenced by sys_trim().

#define MIN_LARGE_SIZE   (SIZE_T_ONE << TREEBIN_SHIFT)
#define MIN_REQUEST   (MIN_CHUNK_SIZE - CHUNK_OVERHEAD - SIZE_T_ONE)

Referenced by dlmalloc().

#define MIN_SMALL_INDEX   (small_index(MIN_CHUNK_SIZE))
#define minsize_for_tree_index (   i)
Value:
((SIZE_T_ONE << (((i) >> 1) + TREEBIN_SHIFT)) | \
(((size_t)((i) & SIZE_T_ONE)) << (((i) >> 1) + TREEBIN_SHIFT - 1)))
int i
Definition: jcmarker.c:150
#define SIZE_T_ONE
Definition: dlmalloc.c:125
#define TREEBIN_SHIFT
Definition: dlmalloc.c:847
#define MMAP_CHUNK_OVERHEAD   (TWO_SIZE_T_SIZES)
#define MMAP_FLAGS   (MAP_PRIVATE|MAP_ANONYMOUS)
#define MMAP_FOOT_PAD   (FOUR_SIZE_T_SIZES)

Referenced by dlfree(), mmap_alloc(), and mmap_resize().

#define MMAP_PROT   (PROT_READ|PROT_WRITE)
#define next_chunk (   p)    ((mchunkptr)( ((char*)(p)) + ((p)->head & ~INUSE_BITS)))
#define next_pinuse (   p)    ((next_chunk(p)->head) & PINUSE_BIT)
#define NSMALLBINS   (32U)

Referenced by init_bins().

#define NTREEBINS   (32U)
#define ok_address (   M,
  a 
)    ((char*)(a) >= (M)->least_addr)
#define ok_cinuse (   p)    cinuse(p)

Referenced by dlfree(), and internal_realloc().

#define ok_magic (   M)    (1)

Referenced by dlfree(), and dlrealloc().

#define ok_next (   p,
  n 
)    ((char*)(p) < (char*)(n))
#define ok_pinuse (   p)    pinuse(p)

Referenced by dlfree(), and internal_realloc().

#define overhead_for (   p)    (is_mmapped(p)? MMAP_CHUNK_OVERHEAD : CHUNK_OVERHEAD)
#define pad_request (   req)    (((req) + CHUNK_OVERHEAD + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK)

Referenced by add_segment(), and dlmalloc().

#define page_align (   S)    (((S) + (mparams.page_size)) & ~(mparams.page_size - SIZE_T_ONE))

Referenced by sys_alloc().

#define pinuse (   p)    ((p)->head & PINUSE_BIT)

Referenced by dlfree(), and prepend_alloc().

#define PINUSE_BIT   (SIZE_T_ONE)
#define prev_chunk (   p)    ((mchunkptr)( ((char*)(p)) - ((p)->prev_foot) ))
#define RELEASE_MAGIC_INIT_LOCK ( )

Referenced by init_mparams().

#define RELEASE_MORECORE_LOCK ( )

Referenced by sys_alloc(), and sys_trim().

#define replace_dv (   M,
  P,
 
)
Value:
{\
size_t DVS = M->dvsize;\
if (DVS != 0) {\
mchunkptr DV = M->dv;\
}\
M->dvsize = S;\
M->dv = P;\
}
#define assert(x)
Definition: dlmalloc.c:36
int M
Definition: jdmainct.c:205
#define insert_small_chunk(M, P, S)
Definition: dlmalloc.c:1772
struct malloc_chunk * mchunkptr
Definition: dlmalloc.c:481
if(Is_usb_id_transition()&&Is_usb_id_interrupt_enabled())
Definition: applications/uc3-audio-player/usb_task.c:395
#define is_small(s)
Definition: dlmalloc.c:1097

Referenced by dlmalloc(), and tmalloc_small().

#define request2size (   req)    (((req) < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(req))
#define RTCHECK (   e)    __builtin_expect(e, 1)
#define same_or_left_bits (   x)    ((x) | -(x))
#define segment_holds (   S,
  A 
)    ((char*)(A) >= S->base && (char*)(A) < S->base + S->size)
#define set_foot (   p,
  s 
)    (((mchunkptr)((char*)(p) + (s)))->prev_foot = (s))
#define set_free_with_pinuse (   p,
  s,
  n 
)    (clear_pinuse(n), set_size_and_pinuse_of_free_chunk(p, s))

Referenced by add_segment(), dlfree(), and prepend_alloc().

#define set_inuse (   M,
  p,
  s 
)
Value:
((p)->head = (((p)->head & PINUSE_BIT)|s|CINUSE_BIT),\
((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT)
A_ALIGNED dsp16_t s[N]
Definition: resampling_example.c:72
Definition: dlmalloc.c:473
#define PINUSE_BIT
Definition: dlmalloc.c:535
#define CINUSE_BIT
Definition: dlmalloc.c:536

Referenced by internal_memalign(), and internal_realloc().

#define set_inuse_and_pinuse (   M,
  p,
  s 
)
Value:
((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\
((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT)
A_ALIGNED dsp16_t s[N]
Definition: resampling_example.c:72
struct malloc_chunk * mchunkptr
Definition: dlmalloc.c:481
#define PINUSE_BIT
Definition: dlmalloc.c:535
#define CINUSE_BIT
Definition: dlmalloc.c:536

Referenced by dlmalloc(), tmalloc_large(), and tmalloc_small().

#define set_lock (   M,
 
)
Value:
((M)->mflags = (L)?\
((M)->mflags | USE_LOCK_BIT) :\
((M)->mflags & ~USE_LOCK_BIT))
#define USE_LOCK_BIT
Definition: dlmalloc.c:315
int M
Definition: jdmainct.c:205
#define set_size_and_pinuse_of_free_chunk (   p,
  s 
)    ((p)->head = (s|PINUSE_BIT), set_foot(p, s))
#define set_size_and_pinuse_of_inuse_chunk (   M,
  p,
  s 
)    ((p)->head = (s|PINUSE_BIT|CINUSE_BIT))
#define should_trim (   M,
  s 
)    ((s) > (M)->trim_check)

Referenced by dlfree().

#define SIX_SIZE_T_SIZES   (FOUR_SIZE_T_SIZES+TWO_SIZE_T_SIZES)

Referenced by mmap_alloc(), and mmap_resize().

#define SIZE_T_BITSIZE   (sizeof(size_t) << 3)

Referenced by tmalloc_large().

#define SIZE_T_ONE   ((size_t)1)
#define SIZE_T_SIZE   (sizeof(size_t))
#define SIZE_T_TWO   ((size_t)2)
#define SIZE_T_ZERO   ((size_t)0)
#define small_index (   s)    ((s) >> SMALLBIN_SHIFT)

Referenced by dlmalloc().

#define small_index2size (   i)    ((i) << SMALLBIN_SHIFT)

Referenced by dlmalloc().

#define smallbin_at (   M,
  i 
)    ((sbinptr)((char*)&((M)->smallbins[(i)<<1])))

Referenced by dlmalloc(), and init_bins().

#define SMALLBIN_SHIFT   (3U)
#define SMALLBIN_WIDTH   (SIZE_T_ONE << SMALLBIN_SHIFT)
#define smallmap_is_marked (   M,
  i 
)    ((M)->smallmap & idx2bit(i))
#define treebin_at (   M,
  i 
)    (&((M)->treebins[i]))

Referenced by tmalloc_large(), and tmalloc_small().

#define TREEBIN_SHIFT   (8U)
#define treemap_is_marked (   M,
  i 
)    ((M)->treemap & idx2bit(i))
#define TWO_SIZE_T_SIZES   (SIZE_T_SIZE<<1)
#define unlink_chunk (   M,
  P,
 
)
Value:
Definition: dlmalloc.c:678
#define unlink_small_chunk(M, P, S)
Definition: dlmalloc.c:1791
#define unlink_large_chunk(M, X)
Definition: dlmalloc.c:1911
int M
Definition: jdmainct.c:205
struct malloc_tree_chunk * tchunkptr
Definition: dlmalloc.c:691
else
Definition: lwip-1.4.0/src/core/memp.c:417
#define is_small(s)
Definition: dlmalloc.c:1097

Referenced by dlfree(), and prepend_alloc().

#define unlink_first_small_chunk (   M,
  B,
  P,
 
)
Value:
{\
mchunkptr F = P->fd;\
assert(P != B);\
assert(P != F);\
if (B == F)\
B->fd = F;\
F->bk = B;\
}\
}\
}
#define RTCHECK(e)
Definition: dlmalloc.c:1265
#define assert(x)
Definition: dlmalloc.c:36
#define small_index2size(i)
Definition: dlmalloc.c:1099
#define clear_smallmap(M, i)
Definition: dlmalloc.c:1163
int M
Definition: jdmainct.c:205
struct malloc_chunk * mchunkptr
Definition: dlmalloc.c:481
if(Is_usb_id_transition()&&Is_usb_id_interrupt_enabled())
Definition: applications/uc3-audio-player/usb_task.c:395
#define B
Definition: op_fix_asin.c:49
else
Definition: lwip-1.4.0/src/core/memp.c:417
#define CORRUPTION_ERROR_ACTION(m)
Definition: dlmalloc.c:1053
#define F
Definition: op_fix_asin.c:53
#define ok_address(M, a)
Definition: dlmalloc.c:1239
#define chunksize(p)
Definition: dlmalloc.c:545

Referenced by dlmalloc().

#define unlink_large_chunk (   M,
 
)
#define unlink_small_chunk (   M,
  P,
 
)
Value:
{\
mchunkptr F = P->fd;\
mchunkptr B = P->bk;\
assert(P != B);\
assert(P != F);\
if (F == B)\
else if (RTCHECK((F == smallbin_at(M,I) || ok_address(M, F)) &&\
(B == smallbin_at(M,I) || ok_address(M, B)))) {\
F->bk = B;\
B->fd = F;\
}\
}\
}
#define RTCHECK(e)
Definition: dlmalloc.c:1265
#define assert(x)
Definition: dlmalloc.c:36
#define small_index2size(i)
Definition: dlmalloc.c:1099
#define clear_smallmap(M, i)
Definition: dlmalloc.c:1163
int M
Definition: jdmainct.c:205
struct malloc_chunk * mchunkptr
Definition: dlmalloc.c:481
if(Is_usb_id_transition()&&Is_usb_id_interrupt_enabled())
Definition: applications/uc3-audio-player/usb_task.c:395
#define small_index(s)
Definition: dlmalloc.c:1098
unsigned int bindex_t
Definition: dlmalloc.c:483
#define B
Definition: op_fix_asin.c:49
else
Definition: lwip-1.4.0/src/core/memp.c:417
#define CORRUPTION_ERROR_ACTION(m)
Definition: dlmalloc.c:1053
#define F
Definition: op_fix_asin.c:53
#define smallbin_at(M, i)
Definition: dlmalloc.c:1103
#define ok_address(M, a)
Definition: dlmalloc.c:1239
#define chunksize(p)
Definition: dlmalloc.c:545
#define USAGE_ERROR_ACTION (   m,
 
)    ABORT

Referenced by dlfree(), dlrealloc(), and internal_realloc().

#define use_lock (   M)    ((M)->mflags & USE_LOCK_BIT)
#define USE_LOCK_BIT   (0U)

Referenced by init_mparams().

#define use_mmap (   M)    ((M)->mflags & USE_MMAP_BIT)

Referenced by ialloc(), and sys_alloc().

#define USE_MMAP_BIT   (SIZE_T_ONE)

Referenced by init_mparams().

#define use_noncontiguous (   M)    ((M)->mflags & USE_NONCONTIGUOUS_BIT)

Referenced by sys_alloc().

#define USE_NONCONTIGUOUS_BIT   (4U)

Referenced by init_mparams().

typedef unsigned int bindex_t
typedef unsigned int binmap_t
typedef unsigned int flag_t
typedef struct malloc_chunk mchunk
typedef struct malloc_chunk* mchunkptr
typedef struct malloc_segment msegment
typedef struct malloc_segment* msegmentptr
typedef struct malloc_state* mstate
typedef struct malloc_chunk* sbinptr
typedef struct malloc_tree_chunk* tbinptr
typedef struct malloc_tree_chunk tchunk
typedef struct malloc_tree_chunk* tchunkptr

void* dlcalloc ( size_t  n_elements,
size_t  elem_size 
)
void** dlindependent_calloc ( size_t  n_elements,
size_t  elem_size,
void *  chunks[] 
)

References gm, and ialloc().

void** dlindependent_comalloc ( size_t  n_elements,
size_t  sizes[],
void *  chunks[] 
)

References gm, and ialloc().

struct mallinfo dlmallinfo ( void  )

References gm, and internal_mallinfo().

size_t dlmalloc_footprint ( void  )

References gm.

size_t dlmalloc_max_footprint ( void  )

References gm.

void dlmalloc_stats ( void  )

References gm, and internal_malloc_stats().

int dlmalloc_trim ( size_t  pad)

References gm, POSTACTION, PREACTION, and sys_trim().

size_t dlmalloc_usable_size ( void *  mem)

References chunksize, cinuse, mem2chunk, and overhead_for.

int dlmallopt ( int  param_number,
int  value 
)

References change_mparam().

void* dlmemalign ( size_t  alignment,
size_t  bytes 
)

References gm, and internal_memalign().

void* dlpvalloc ( size_t  bytes)
void* dlrealloc ( void *  oldmem,
size_t  bytes 
)
void* dlvalloc ( size_t  bytes)
static int has_segment_link ( mstate  m,
msegmentptr  ss 
)
static
static void** ialloc ( mstate  m,
size_t  n_elements,
size_t *  sizes,
int  opts,
void *  chunks[] 
)
static
static void init_bins ( mstate  m)
static
static msegmentptr segment_holding ( mstate  m,
char *  addr 
)
static

struct malloc_state _gm_
static