FD.io VPP  v20.09-64-g4f7b92f0a
Vector Packet Processing
dlmalloc.c File Reference
+ Include dependency graph for dlmalloc.c:

Go to the source code of this file.

Data Structures

struct  malloc_chunk
 
struct  malloc_tree_chunk
 
struct  malloc_segment
 
struct  malloc_state
 
struct  malloc_params
 

Macros

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

Typedefs

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

Functions

static CLIB_NOSANITIZE_ADDR msegmentptr segment_holding (mstate m, char *addr)
 
static CLIB_NOSANITIZE_ADDR int has_segment_link (mstate m, msegmentptr ss)
 
static int init_mparams (void)
 
static int change_mparam (int param_number, int value)
 
static CLIB_NOSANITIZE_ADDR struct dlmallinfo internal_mallinfo (mstate m)
 
static void internal_malloc_stats (mstate m)
 
static void * mmap_alloc (mstate m, size_t nb)
 
static mchunkptr mmap_resize (mstate m, mchunkptr oldp, size_t nb, int flags)
 
static CLIB_NOSANITIZE_ADDR void init_top (mstate m, mchunkptr p, size_t psize)
 
static void init_bins (mstate m)
 
static CLIB_NOSANITIZE_ADDR void * prepend_alloc (mstate m, char *newbase, char *oldbase, size_t nb)
 
static CLIB_NOSANITIZE_ADDR void add_segment (mstate m, char *tbase, size_t tsize, flag_t mmapped)
 
static CLIB_NOSANITIZE_ADDR void * sys_alloc (mstate m, size_t nb)
 
static CLIB_NOSANITIZE_ADDR size_t release_unused_segments (mstate m)
 
static CLIB_NOSANITIZE_ADDR int sys_trim (mstate m, size_t pad)
 
static CLIB_NOSANITIZE_ADDR void dispose_chunk (mstate m, mchunkptr p, size_t psize)
 
static CLIB_NOSANITIZE_ADDR void * tmalloc_large (mstate m, size_t nb)
 
static CLIB_NOSANITIZE_ADDR void * tmalloc_small (mstate m, size_t nb)
 
void * dlmalloc (size_t bytes)
 
void dlfree (void *mem)
 
void * dlcalloc (size_t n_elements, size_t elem_size)
 
static mchunkptr try_realloc_chunk (mstate m, mchunkptr p, size_t nb, int can_move)
 
static CLIB_NOSANITIZE_ADDR void * internal_memalign (mstate m, size_t alignment, size_t bytes)
 
static void ** ialloc (mstate m, size_t n_elements, size_t *sizes, int opts, void *chunks[])
 
static size_t internal_bulk_free (mstate m, void *array[], size_t nelem)
 
void * dlrealloc (void *oldmem, size_t bytes)
 
void * dlrealloc_in_place (void *oldmem, size_t bytes)
 
void * dlmemalign (size_t alignment, size_t bytes)
 
int dlposix_memalign (void **pp, size_t alignment, size_t bytes)
 
void * dlvalloc (size_t bytes)
 
void * dlpvalloc (size_t bytes)
 
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[])
 
size_t dlbulk_free (void *array[], size_t nelem)
 
int dlmalloc_trim (size_t pad)
 
size_t dlmalloc_footprint (void)
 
size_t dlmalloc_max_footprint (void)
 
size_t dlmalloc_footprint_limit (void)
 
size_t dlmalloc_set_footprint_limit (size_t bytes)
 
struct dlmallinfo dlmallinfo (void)
 
void dlmalloc_stats ()
 
int dlmallopt (int param_number, int value)
 
size_t dlmalloc_usable_size (void *mem)
 

Variables

static struct malloc_params mparams
 

Macro Definition Documentation

◆ ACQUIRE_MALLOC_GLOBAL_LOCK

#define ACQUIRE_MALLOC_GLOBAL_LOCK ( )

Definition at line 393 of file dlmalloc.c.

◆ align_as_chunk

#define align_as_chunk (   A)    (mchunkptr)((A) + align_offset(chunk2mem(A)))

Definition at line 807 of file dlmalloc.c.

◆ align_offset

#define align_offset (   A)
Value:
((((size_t)(A) & CHUNK_ALIGN_MASK) == 0)? 0 :\
#define CHUNK_ALIGN_MASK
Definition: dlmalloc.c:194
#define A(x)
Definition: main.c:1008
#define MALLOC_ALIGNMENT
Definition: dlmalloc.h:633

Definition at line 200 of file dlmalloc.c.

◆ assert

#define assert (   x)

Definition at line 31 of file dlmalloc.c.

◆ bit_for_tree_index

#define bit_for_tree_index (   i)    (i == NTREEBINS-1)? (SIZE_T_BITSIZE-1) : (((i) >> 1) + TREEBIN_SHIFT - 2)

Definition at line 1491 of file dlmalloc.c.

◆ CALL_DIRECT_MMAP

#define CALL_DIRECT_MMAP (   s)    DIRECT_MMAP(s)

Definition at line 328 of file dlmalloc.c.

◆ CALL_MMAP

#define CALL_MMAP (   s)    MMAP(s)

Definition at line 329 of file dlmalloc.c.

◆ CALL_MORECORE

#define CALL_MORECORE (   S)    MFAIL

Define CALL_MORECORE.

Definition at line 298 of file dlmalloc.c.

◆ CALL_MREMAP

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

Define CALL_MREMAP.

Definition at line 343 of file dlmalloc.c.

◆ CALL_MUNMAP

#define CALL_MUNMAP (   a,
 
)    MUNMAP((a), (s))

Definition at line 330 of file dlmalloc.c.

◆ calloc_must_clear

#define calloc_must_clear (   p)    (1)

Definition at line 885 of file dlmalloc.c.

◆ check_free_chunk

#define check_free_chunk (   M,
  P 
)

Definition at line 1386 of file dlmalloc.c.

◆ check_inuse_chunk

#define check_inuse_chunk (   M,
  P 
)

Definition at line 1387 of file dlmalloc.c.

◆ check_malloc_state

#define check_malloc_state (   M)

Definition at line 1390 of file dlmalloc.c.

◆ check_malloced_chunk

#define check_malloced_chunk (   M,
  P,
  N 
)

Definition at line 1388 of file dlmalloc.c.

◆ check_mmapped_chunk

#define check_mmapped_chunk (   M,
  P 
)

Definition at line 1389 of file dlmalloc.c.

◆ check_top_chunk

#define check_top_chunk (   M,
  P 
)

Definition at line 1391 of file dlmalloc.c.

◆ chunk2mem

#define chunk2mem (   p)    ((void*)((char*)(p) + TWO_SIZE_T_SIZES))

Definition at line 804 of file dlmalloc.c.

◆ CHUNK_ALIGN_MASK

#define CHUNK_ALIGN_MASK   (MALLOC_ALIGNMENT - SIZE_T_ONE)

Definition at line 194 of file dlmalloc.c.

◆ chunk_minus_offset

#define chunk_minus_offset (   p,
 
)    ((mchunkptr)(((char*)(p)) - (s)))

Definition at line 856 of file dlmalloc.c.

◆ CHUNK_OVERHEAD

#define CHUNK_OVERHEAD   (SIZE_T_SIZE)

Definition at line 791 of file dlmalloc.c.

◆ chunk_plus_offset

#define chunk_plus_offset (   p,
 
)    ((mchunkptr)(((char*)(p)) + (s)))

Definition at line 855 of file dlmalloc.c.

◆ chunksize

#define chunksize (   p)    ((p)->head & ~(FLAG_BITS))

Definition at line 848 of file dlmalloc.c.

◆ cinuse

#define cinuse (   p)    ((p)->head & CINUSE_BIT)

Definition at line 842 of file dlmalloc.c.

◆ CINUSE_BIT

#define CINUSE_BIT   (SIZE_T_TWO)

Definition at line 833 of file dlmalloc.c.

◆ clear_flag4

#define clear_flag4 (   p)    ((p)->head &= ~FLAG4_BIT)

Definition at line 852 of file dlmalloc.c.

◆ clear_pinuse

#define clear_pinuse (   p)    ((p)->head &= ~PINUSE_BIT)

Definition at line 850 of file dlmalloc.c.

◆ clear_smallmap

#define clear_smallmap (   M,
  i 
)    ((M)->smallmap &= ~idx2bit(i))

Definition at line 1512 of file dlmalloc.c.

◆ clear_treemap

#define clear_treemap (   M,
  i 
)    ((M)->treemap &= ~idx2bit(i))

Definition at line 1516 of file dlmalloc.c.

◆ CMFAIL

#define CMFAIL   ((char*)(MFAIL)) /* defined for convenience */

Definition at line 215 of file dlmalloc.c.

◆ compute_bit2idx

#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);\
}
unsigned int bindex_t
Definition: dlmalloc.c:780
#define N
Definition: aes_cbc.c:225

Definition at line 1558 of file dlmalloc.c.

◆ compute_tree_index

#define compute_tree_index (   S,
 
)
Value:
{\
size_t X = S >> TREEBIN_SHIFT;\
if (X == 0)\
I = 0;\
else if (X > 0xFFFF)\
I = NTREEBINS-1;\
else {\
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 S(mp)
#define NTREEBINS
Definition: dlmalloc.c:1157
#define N
Definition: aes_cbc.c:225
#define TREEBIN_SHIFT
Definition: dlmalloc.c:1160

Definition at line 1471 of file dlmalloc.c.

◆ CORRUPTION_ERROR_ACTION

#define CORRUPTION_ERROR_ACTION (   m)    DLM_ABORT

Definition at line 1372 of file dlmalloc.c.

◆ DEBUG

#define DEBUG   0

Definition at line 33 of file dlmalloc.c.

◆ DESTROY_LOCK

#define DESTROY_LOCK (   l)    (0)

Definition at line 392 of file dlmalloc.c.

◆ DIRECT_MMAP

#define DIRECT_MMAP (   s)    MFAIL

Definition at line 327 of file dlmalloc.c.

◆ disable_contiguous

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

Definition at line 1247 of file dlmalloc.c.

◆ disable_expand

#define disable_expand (   M)    ((M)->mflags |= USE_NOEXPAND_BIT)

Definition at line 1249 of file dlmalloc.c.

◆ disable_lock

#define disable_lock (   M)

Definition at line 1235 of file dlmalloc.c.

◆ disable_mmap

#define disable_mmap (   M)

Definition at line 1243 of file dlmalloc.c.

◆ disable_trace

#define disable_trace (   M)    ((M)->mflags &= ~USE_TRACE_BIT)

Definition at line 1252 of file dlmalloc.c.

◆ enable_lock

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

Definition at line 1231 of file dlmalloc.c.

◆ enable_mmap

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

Definition at line 1239 of file dlmalloc.c.

◆ enable_trace

#define enable_trace (   M)    ((M)->mflags |= USE_TRACE_BIT)

Definition at line 1251 of file dlmalloc.c.

◆ ensure_initialization

#define ensure_initialization ( )    (void)(mparams.magic != 0 || init_mparams())

Definition at line 1213 of file dlmalloc.c.

◆ EXTERN_BIT

#define EXTERN_BIT   (8U)

Definition at line 356 of file dlmalloc.c.

◆ FENCEPOST_HEAD

#define FENCEPOST_HEAD   (INUSE_BITS|SIZE_T_SIZE)

Definition at line 839 of file dlmalloc.c.

◆ FLAG4_BIT

#define FLAG4_BIT   (SIZE_T_FOUR)

Definition at line 834 of file dlmalloc.c.

◆ flag4inuse

#define flag4inuse (   p)    ((p)->head & FLAG4_BIT)

Definition at line 844 of file dlmalloc.c.

◆ FLAG_BITS

#define FLAG_BITS   (PINUSE_BIT|CINUSE_BIT|FLAG4_BIT)

Definition at line 836 of file dlmalloc.c.

◆ fm

#define fm   gm

◆ FOUR_SIZE_T_SIZES

#define FOUR_SIZE_T_SIZES   (SIZE_T_SIZE<<2)

Definition at line 189 of file dlmalloc.c.

◆ get_foot

#define get_foot (   p,
 
)    (((mchunkptr)((char*)(p) + (s)))->prev_foot)

Definition at line 866 of file dlmalloc.c.

◆ gm

#define gm   (&_gm_)

Definition at line 1219 of file dlmalloc.c.

◆ granularity_align

#define granularity_align (   S)
Value:
static struct malloc_params mparams
Definition: dlmalloc.c:1210
#define S(mp)
#define SIZE_T_ONE
Definition: dlmalloc.c:185
size_t granularity
Definition: dlmalloc.c:1204

Definition at line 1264 of file dlmalloc.c.

◆ HALF_MAX_SIZE_T

#define HALF_MAX_SIZE_T   (MAX_SIZE_T / 2U)

Definition at line 191 of file dlmalloc.c.

◆ idx2bit

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

Definition at line 1508 of file dlmalloc.c.

◆ INITIAL_LOCK

#define INITIAL_LOCK (   l)    (0)

Definition at line 391 of file dlmalloc.c.

◆ insert_chunk

#define insert_chunk (   M,
  P,
  S 
)
Value:
else { tchunkptr TP = (tchunkptr)(P); insert_large_chunk(M, TP, S); }
#define S(mp)
#define insert_large_chunk(M, X, S)
Definition: dlmalloc.c:2248
#define P(fmt,...)
#define insert_small_chunk(M, P, S)
Definition: dlmalloc.c:2170
struct malloc_tree_chunk * tchunkptr
Definition: dlmalloc.c:992
#define is_small(s)
Definition: dlmalloc.c:1417
#define M(T, mp)

Definition at line 2389 of file dlmalloc.c.

◆ insert_large_chunk

#define insert_large_chunk (   M,
  X,
  S 
)
Value:
{\
tbinptr* H;\
bindex_t I;\
compute_tree_index(S, I);\
H = treebin_at(M, I);\
X->index = I;\
X->child[0] = X->child[1] = 0;\
if (!treemap_is_marked(M, I)) {\
mark_treemap(M, I);\
*H = X;\
X->parent = (tchunkptr)H;\
X->fd = X->bk = X;\
}\
else {\
tchunkptr T = *H;\
size_t K = S << leftshift_for_tree_index(I);\
for (;;) {\
if (chunksize(T) != S) {\
tchunkptr* C = &(T->child[(K >> (SIZE_T_BITSIZE-SIZE_T_ONE)) & 1]);\
K <<= 1;\
if (*C != 0)\
T = *C;\
else if (RTCHECK(ok_address(M, C))) {\
*C = X;\
X->parent = T;\
X->fd = X->bk = X;\
break;\
}\
else {\
CORRUPTION_ERROR_ACTION(M);\
break;\
}\
}\
else {\
tchunkptr F = T->fd;\
if (RTCHECK(ok_address(M, T) && ok_address(M, F))) {\
T->fd = F->bk = X;\
X->fd = F;\
X->bk = T;\
X->parent = 0;\
break;\
}\
else {\
CORRUPTION_ERROR_ACTION(M);\
break;\
}\
}\
}\
}\
}
#define RTCHECK(e)
Definition: dlmalloc.c:1634
#define treemap_is_marked(M, i)
Definition: dlmalloc.c:1517
#define S(mp)
#define leftshift_for_tree_index(i)
Definition: dlmalloc.c:1495
#define F(t, n)
Definition: bfd_api.h:32
struct malloc_tree_chunk * tchunkptr
Definition: dlmalloc.c:992
#define SIZE_T_BITSIZE
Definition: dlmalloc.c:180
#define SIZE_T_ONE
Definition: dlmalloc.c:185
#define ok_address(M, a)
Definition: dlmalloc.c:1602
#define treebin_at(M, i)
Definition: dlmalloc.c:1424
#define chunksize(p)
Definition: dlmalloc.c:848
#define M(T, mp)

Definition at line 2248 of file dlmalloc.c.

◆ insert_small_chunk

#define insert_small_chunk (   M,
  P,
  S 
)
Value:
{\
bindex_t I = small_index(S);\
mchunkptr B = smallbin_at(M, I);\
mchunkptr F = B;\
assert(S >= MIN_CHUNK_SIZE);\
if (!smallmap_is_marked(M, I))\
mark_smallmap(M, I);\
else if (RTCHECK(ok_address(M, B->fd)))\
F = B->fd;\
else {\
CORRUPTION_ERROR_ACTION(M);\
}\
B->fd = P;\
F->bk = P;\
P->fd = F;\
P->bk = B;\
}
#define RTCHECK(e)
Definition: dlmalloc.c:1634
#define smallmap_is_marked(M, i)
Definition: dlmalloc.c:1513
#define S(mp)
#define P(fmt,...)
#define F(t, n)
Definition: bfd_api.h:32
#define small_index(s)
Definition: dlmalloc.c:1418
#define MIN_CHUNK_SIZE
Definition: dlmalloc.c:800
#define smallbin_at(M, i)
Definition: dlmalloc.c:1423
#define ok_address(M, a)
Definition: dlmalloc.c:1602
#define M(T, mp)

Definition at line 2170 of file dlmalloc.c.

◆ internal_free

#define internal_free (   m,
  mem 
)    dlfree(mem)

Definition at line 2411 of file dlmalloc.c.

◆ internal_malloc

#define internal_malloc (   m,
 
)    dlmalloc(b)

Definition at line 2410 of file dlmalloc.c.

◆ INUSE_BITS

#define INUSE_BITS   (PINUSE_BIT|CINUSE_BIT)

Definition at line 835 of file dlmalloc.c.

◆ is_aligned

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

Definition at line 197 of file dlmalloc.c.

◆ is_extern_segment

#define is_extern_segment (   S)    ((S)->sflags & EXTERN_BIT)

Definition at line 1063 of file dlmalloc.c.

◆ is_global

#define is_global (   M)    ((M) == &_gm_)

Definition at line 1220 of file dlmalloc.c.

◆ is_granularity_aligned

#define is_granularity_aligned (   S)    (((size_t)(S) & (mparams.granularity - SIZE_T_ONE)) == 0)

Definition at line 1281 of file dlmalloc.c.

◆ is_initialized

#define is_initialized (   M)    ((M)->top != 0)

Definition at line 1224 of file dlmalloc.c.

◆ is_inuse

#define is_inuse (   p)    (((p)->head & INUSE_BITS) != PINUSE_BIT)

Definition at line 845 of file dlmalloc.c.

◆ is_mmapped

#define is_mmapped (   p)    (((p)->head & INUSE_BITS) == 0)

Definition at line 846 of file dlmalloc.c.

◆ is_mmapped_segment

#define is_mmapped_segment (   S)    ((S)->sflags & USE_MMAP_BIT)

Definition at line 1062 of file dlmalloc.c.

◆ is_page_aligned

#define is_page_aligned (   S)    (((size_t)(S) & (mparams.page_size - SIZE_T_ONE)) == 0)

Definition at line 1279 of file dlmalloc.c.

◆ is_small

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

Definition at line 1417 of file dlmalloc.c.

◆ least_bit

#define least_bit (   x)    ((x) & -(x))

Definition at line 1520 of file dlmalloc.c.

◆ left_bits

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

Definition at line 1523 of file dlmalloc.c.

◆ leftmost_child

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

Definition at line 996 of file dlmalloc.c.

◆ leftshift_for_tree_index

#define leftshift_for_tree_index (   i)
Value:
((i == NTREEBINS-1)? 0 : \
((SIZE_T_BITSIZE-SIZE_T_ONE) - (((i) >> 1) + TREEBIN_SHIFT - 2)))
#define NTREEBINS
Definition: dlmalloc.c:1157
sll srl srl sll sra u16x4 i
Definition: vector_sse42.h:317
#define SIZE_T_BITSIZE
Definition: dlmalloc.c:180
#define SIZE_T_ONE
Definition: dlmalloc.c:185
#define TREEBIN_SHIFT
Definition: dlmalloc.c:1160

Definition at line 1495 of file dlmalloc.c.

◆ LOCK_AT_FORK

#define LOCK_AT_FORK   0

Definition at line 107 of file dlmalloc.c.

◆ malloc_getpagesize

#define malloc_getpagesize   sysconf(_SC_PAGE_SIZE)

Definition at line 137 of file dlmalloc.c.

◆ mark_inuse_foot

#define mark_inuse_foot (   M,
  p,
 
)

Definition at line 1644 of file dlmalloc.c.

◆ mark_smallmap

#define mark_smallmap (   M,
  i 
)    ((M)->smallmap |= idx2bit(i))

Definition at line 1511 of file dlmalloc.c.

◆ mark_treemap

#define mark_treemap (   M,
  i 
)    ((M)->treemap |= idx2bit(i))

Definition at line 1515 of file dlmalloc.c.

◆ MAX_REQUEST

#define MAX_REQUEST   ((-MIN_CHUNK_SIZE) << 2)

Definition at line 810 of file dlmalloc.c.

◆ MAX_SMALL_REQUEST

#define MAX_SMALL_REQUEST   (MAX_SMALL_SIZE - CHUNK_ALIGN_MASK - CHUNK_OVERHEAD)

Definition at line 1163 of file dlmalloc.c.

◆ MAX_SMALL_SIZE

#define MAX_SMALL_SIZE   (MIN_LARGE_SIZE - SIZE_T_ONE)

Definition at line 1162 of file dlmalloc.c.

◆ MCHUNK_SIZE

#define MCHUNK_SIZE   (sizeof(mchunk))

Definition at line 786 of file dlmalloc.c.

◆ mem2chunk

#define mem2chunk (   mem)    ((mchunkptr)((char*)(mem) - TWO_SIZE_T_SIZES))

Definition at line 805 of file dlmalloc.c.

◆ MFAIL

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

Definition at line 214 of file dlmalloc.c.

◆ MIN_CHUNK_SIZE

#define MIN_CHUNK_SIZE   ((MCHUNK_SIZE + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK)

Definition at line 800 of file dlmalloc.c.

◆ MIN_LARGE_SIZE

#define MIN_LARGE_SIZE   (SIZE_T_ONE << TREEBIN_SHIFT)

Definition at line 1161 of file dlmalloc.c.

◆ MIN_REQUEST

#define MIN_REQUEST   (MIN_CHUNK_SIZE - CHUNK_OVERHEAD - SIZE_T_ONE)

Definition at line 811 of file dlmalloc.c.

◆ MIN_SMALL_INDEX

#define MIN_SMALL_INDEX   (small_index(MIN_CHUNK_SIZE))

Definition at line 1420 of file dlmalloc.c.

◆ minsize_for_tree_index

#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)))
sll srl srl sll sra u16x4 i
Definition: vector_sse42.h:317
#define SIZE_T_ONE
Definition: dlmalloc.c:185
#define TREEBIN_SHIFT
Definition: dlmalloc.c:1160

Definition at line 1500 of file dlmalloc.c.

◆ MMAP

#define MMAP (   s)    MFAIL

Definition at line 325 of file dlmalloc.c.

◆ mmap_align

#define mmap_align (   S)    page_align(S)

Definition at line 1273 of file dlmalloc.c.

◆ MMAP_CHUNK_OVERHEAD

#define MMAP_CHUNK_OVERHEAD   (TWO_SIZE_T_SIZES)

Definition at line 795 of file dlmalloc.c.

◆ MMAP_FOOT_PAD

#define MMAP_FOOT_PAD   (FOUR_SIZE_T_SIZES)

Definition at line 797 of file dlmalloc.c.

◆ MUNMAP

#define MUNMAP (   a,
 
)    (-1)

Definition at line 326 of file dlmalloc.c.

◆ next_chunk

#define next_chunk (   p)    ((mchunkptr)( ((char*)(p)) + ((p)->head & ~FLAG_BITS)))

Definition at line 859 of file dlmalloc.c.

◆ next_pinuse

#define next_pinuse (   p)    ((next_chunk(p)->head) & PINUSE_BIT)

Definition at line 863 of file dlmalloc.c.

◆ NSMALLBINS

#define NSMALLBINS   (32U)

Definition at line 1156 of file dlmalloc.c.

◆ NTREEBINS

#define NTREEBINS   (32U)

Definition at line 1157 of file dlmalloc.c.

◆ ok_address

#define ok_address (   M,
  a 
)    ((char*)(a) >= (M)->least_addr)

Definition at line 1602 of file dlmalloc.c.

◆ ok_inuse

#define ok_inuse (   p)    is_inuse(p)

Definition at line 1606 of file dlmalloc.c.

◆ ok_magic

#define ok_magic (   M)    (1)

Definition at line 1626 of file dlmalloc.c.

◆ ok_next

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

Definition at line 1604 of file dlmalloc.c.

◆ ok_pinuse

#define ok_pinuse (   p)    pinuse(p)

Definition at line 1608 of file dlmalloc.c.

◆ overhead_for

#define overhead_for (   p)    (is_mmapped(p)? MMAP_CHUNK_OVERHEAD : CHUNK_OVERHEAD)

Definition at line 878 of file dlmalloc.c.

◆ pad_request

#define pad_request (   req)    (((req) + CHUNK_OVERHEAD + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK)

Definition at line 814 of file dlmalloc.c.

◆ page_align

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

Definition at line 1260 of file dlmalloc.c.

◆ pinuse

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

Definition at line 843 of file dlmalloc.c.

◆ PINUSE_BIT

#define PINUSE_BIT   (SIZE_T_ONE)

Definition at line 832 of file dlmalloc.c.

◆ POSTACTION

#define POSTACTION (   M)

Definition at line 1345 of file dlmalloc.c.

◆ PREACTION

#define PREACTION (   M)    (0)

Definition at line 1341 of file dlmalloc.c.

◆ prev_chunk

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

Definition at line 860 of file dlmalloc.c.

◆ RELEASE_MALLOC_GLOBAL_LOCK

#define RELEASE_MALLOC_GLOBAL_LOCK ( )

Definition at line 394 of file dlmalloc.c.

◆ replace_dv

#define replace_dv (   M,
  P,
  S 
)
Value:
{\
size_t DVS = M->dvsize;\
assert(is_small(DVS));\
if (DVS != 0) {\
mchunkptr DV = M->dv;\
insert_small_chunk(M, DV, DVS);\
}\
M->dvsize = S;\
M->dv = P;\
}
#define S(mp)
#define P(fmt,...)
#define is_small(s)
Definition: dlmalloc.c:1417
#define M(T, mp)

Definition at line 2234 of file dlmalloc.c.

◆ request2size

#define request2size (   req)    (((req) < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(req))

Definition at line 818 of file dlmalloc.c.

◆ RTCHECK

#define RTCHECK (   e)    (e)

Definition at line 1634 of file dlmalloc.c.

◆ same_or_left_bits

#define same_or_left_bits (   x)    ((x) | -(x))

Definition at line 1526 of file dlmalloc.c.

◆ segment_holds

#define segment_holds (   S,
  A 
)    ((char*)(A) >= S->base && (char*)(A) < S->base + S->size)

Definition at line 1285 of file dlmalloc.c.

◆ set_flag4

#define set_flag4 (   p)    ((p)->head |= FLAG4_BIT)

Definition at line 851 of file dlmalloc.c.

◆ set_foot

#define set_foot (   p,
 
)    (((mchunkptr)((char*)(p) + (s)))->prev_foot = (s))

Definition at line 867 of file dlmalloc.c.

◆ set_free_with_pinuse

#define set_free_with_pinuse (   p,
  s,
 
)    (clear_pinuse(n), set_size_and_pinuse_of_free_chunk(p, s))

Definition at line 874 of file dlmalloc.c.

◆ set_inuse

#define set_inuse (   M,
  p,
 
)
Value:
((p)->head = (((p)->head & PINUSE_BIT)|s|CINUSE_BIT),\
((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT)
#define PINUSE_BIT
Definition: dlmalloc.c:832
#define CINUSE_BIT
Definition: dlmalloc.c:833

Definition at line 1649 of file dlmalloc.c.

◆ set_inuse_and_pinuse

#define set_inuse_and_pinuse (   M,
  p,
 
)
Value:
((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\
((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT)
struct malloc_chunk * mchunkptr
Definition: dlmalloc.c:778
#define PINUSE_BIT
Definition: dlmalloc.c:832
#define CINUSE_BIT
Definition: dlmalloc.c:833

Definition at line 1654 of file dlmalloc.c.

◆ set_lock

#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:390
#define M(T, mp)

Definition at line 1254 of file dlmalloc.c.

◆ set_size_and_pinuse_of_free_chunk

#define set_size_and_pinuse_of_free_chunk (   p,
 
)    ((p)->head = (s|PINUSE_BIT), set_foot(p, s))

Definition at line 870 of file dlmalloc.c.

◆ set_size_and_pinuse_of_inuse_chunk

#define set_size_and_pinuse_of_inuse_chunk (   M,
  p,
 
)    ((p)->head = (s|PINUSE_BIT|CINUSE_BIT))

Definition at line 1659 of file dlmalloc.c.

◆ should_trim

#define should_trim (   M,
 
)    ((s) > (M)->trim_check)

Definition at line 1313 of file dlmalloc.c.

◆ SIX_SIZE_T_SIZES

#define SIX_SIZE_T_SIZES   (FOUR_SIZE_T_SIZES+TWO_SIZE_T_SIZES)

Definition at line 190 of file dlmalloc.c.

◆ SIZE_T_BITSIZE

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

Definition at line 180 of file dlmalloc.c.

◆ SIZE_T_FOUR

#define SIZE_T_FOUR   ((size_t)4)

Definition at line 187 of file dlmalloc.c.

◆ SIZE_T_ONE

#define SIZE_T_ONE   ((size_t)1)

Definition at line 185 of file dlmalloc.c.

◆ SIZE_T_SIZE

#define SIZE_T_SIZE   (sizeof(size_t))

Definition at line 179 of file dlmalloc.c.

◆ SIZE_T_TWO

#define SIZE_T_TWO   ((size_t)2)

Definition at line 186 of file dlmalloc.c.

◆ SIZE_T_ZERO

#define SIZE_T_ZERO   ((size_t)0)

Definition at line 184 of file dlmalloc.c.

◆ small_index

#define small_index (   s)    (bindex_t)((s) >> SMALLBIN_SHIFT)

Definition at line 1418 of file dlmalloc.c.

◆ small_index2size

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

Definition at line 1419 of file dlmalloc.c.

◆ smallbin_at

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

Definition at line 1423 of file dlmalloc.c.

◆ SMALLBIN_SHIFT

#define SMALLBIN_SHIFT   (3U)

Definition at line 1158 of file dlmalloc.c.

◆ SMALLBIN_WIDTH

#define SMALLBIN_WIDTH   (SIZE_T_ONE << SMALLBIN_SHIFT)

Definition at line 1159 of file dlmalloc.c.

◆ smallmap_is_marked

#define smallmap_is_marked (   M,
  i 
)    ((M)->smallmap & idx2bit(i))

Definition at line 1513 of file dlmalloc.c.

◆ SYS_ALLOC_PADDING

#define SYS_ALLOC_PADDING   (TOP_FOOT_SIZE + MALLOC_ALIGNMENT)

Definition at line 1277 of file dlmalloc.c.

◆ TOP_FOOT_SIZE

#define TOP_FOOT_SIZE   (align_offset(chunk2mem(0))+pad_request(sizeof(struct malloc_segment))+MIN_CHUNK_SIZE)

Definition at line 1323 of file dlmalloc.c.

◆ treebin_at

#define treebin_at (   M,
  i 
)    (&((M)->treebins[i]))

Definition at line 1424 of file dlmalloc.c.

◆ TREEBIN_SHIFT

#define TREEBIN_SHIFT   (8U)

Definition at line 1160 of file dlmalloc.c.

◆ treemap_is_marked

#define treemap_is_marked (   M,
  i 
)    ((M)->treemap & idx2bit(i))

Definition at line 1517 of file dlmalloc.c.

◆ TWO_SIZE_T_SIZES

#define TWO_SIZE_T_SIZES   (SIZE_T_SIZE<<1)

Definition at line 188 of file dlmalloc.c.

◆ unlink_chunk

#define unlink_chunk (   M,
  P,
  S 
)
Value:
else { tchunkptr TP = (tchunkptr)(P); unlink_large_chunk(M, TP); }
#define S(mp)
#define unlink_small_chunk(M, P, S)
Definition: dlmalloc.c:2189
#define unlink_large_chunk(M, X)
Definition: dlmalloc.c:2316
#define P(fmt,...)
struct malloc_tree_chunk * tchunkptr
Definition: dlmalloc.c:992
#define is_small(s)
Definition: dlmalloc.c:1417
#define M(T, mp)

Definition at line 2393 of file dlmalloc.c.

◆ unlink_first_small_chunk

#define unlink_first_small_chunk (   M,
  B,
  P,
 
)
Value:
{\
mchunkptr F = P->fd;\
assert(P != B);\
assert(P != F);\
assert(chunksize(P) == small_index2size(I));\
if (B == F) {\
clear_smallmap(M, I);\
}\
else if (RTCHECK(ok_address(M, F) && F->bk == P)) {\
F->bk = B;\
B->fd = F;\
}\
else {\
CORRUPTION_ERROR_ACTION(M);\
}\
}
#define RTCHECK(e)
Definition: dlmalloc.c:1634
#define small_index2size(i)
Definition: dlmalloc.c:1419
#define P(fmt,...)
#define F(t, n)
Definition: bfd_api.h:32
#define ok_address(M, a)
Definition: dlmalloc.c:1602
#define chunksize(p)
Definition: dlmalloc.c:848
#define M(T, mp)

Definition at line 2215 of file dlmalloc.c.

◆ unlink_large_chunk

#define unlink_large_chunk (   M,
 
)

Definition at line 2316 of file dlmalloc.c.

◆ unlink_small_chunk

#define unlink_small_chunk (   M,
  P,
  S 
)
Value:
{\
mchunkptr F = P->fd;\
mchunkptr B = P->bk;\
bindex_t I = small_index(S);\
assert(P != B);\
assert(P != F);\
assert(chunksize(P) == small_index2size(I));\
if (RTCHECK(F == smallbin_at(M,I) || (ok_address(M, F) && F->bk == P))) { \
if (B == F) {\
clear_smallmap(M, I);\
}\
else if (RTCHECK(B == smallbin_at(M,I) ||\
(ok_address(M, B) && B->fd == P))) {\
F->bk = B;\
B->fd = F;\
}\
else {\
CORRUPTION_ERROR_ACTION(M);\
}\
}\
else {\
CORRUPTION_ERROR_ACTION(M);\
}\
}
#define RTCHECK(e)
Definition: dlmalloc.c:1634
#define S(mp)
#define small_index2size(i)
Definition: dlmalloc.c:1419
#define P(fmt,...)
#define F(t, n)
Definition: bfd_api.h:32
#define small_index(s)
Definition: dlmalloc.c:1418
#define smallbin_at(M, i)
Definition: dlmalloc.c:1423
#define ok_address(M, a)
Definition: dlmalloc.c:1602
#define chunksize(p)
Definition: dlmalloc.c:848
#define M(T, mp)

Definition at line 2189 of file dlmalloc.c.

◆ USAGE_ERROR_ACTION

#define USAGE_ERROR_ACTION (   m,
 
)    DLM_ABORT

Definition at line 1376 of file dlmalloc.c.

◆ use_lock

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

Definition at line 1230 of file dlmalloc.c.

◆ USE_LOCK_BIT

#define USE_LOCK_BIT   (0U)

Definition at line 390 of file dlmalloc.c.

◆ use_mmap

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

Definition at line 1238 of file dlmalloc.c.

◆ USE_MMAP_BIT

#define USE_MMAP_BIT   (SIZE_T_ZERO)

Define CALL_MMAP/CALL_MUNMAP/CALL_DIRECT_MMAP.

Definition at line 323 of file dlmalloc.c.

◆ use_noexpand

#define use_noexpand (   M)    ((M)->mflags & USE_NOEXPAND_BIT)

Definition at line 1248 of file dlmalloc.c.

◆ USE_NOEXPAND_BIT

#define USE_NOEXPAND_BIT   (8U)

Definition at line 350 of file dlmalloc.c.

◆ use_noncontiguous

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

Definition at line 1246 of file dlmalloc.c.

◆ USE_NONCONTIGUOUS_BIT

#define USE_NONCONTIGUOUS_BIT   (4U)

Definition at line 347 of file dlmalloc.c.

◆ use_trace

#define use_trace (   M)    ((M)->mflags & USE_TRACE_BIT)

Definition at line 1250 of file dlmalloc.c.

◆ USE_TRACE_BIT

#define USE_TRACE_BIT   (16U)

Definition at line 353 of file dlmalloc.c.

Typedef Documentation

◆ bindex_t

typedef unsigned int bindex_t

Definition at line 780 of file dlmalloc.c.

◆ binmap_t

typedef unsigned int binmap_t

Definition at line 781 of file dlmalloc.c.

◆ flag_t

typedef unsigned int flag_t

Definition at line 782 of file dlmalloc.c.

◆ mchunk

typedef struct malloc_chunk mchunk

Definition at line 777 of file dlmalloc.c.

◆ mchunkptr

typedef struct malloc_chunk* mchunkptr

Definition at line 778 of file dlmalloc.c.

◆ msegment

typedef struct malloc_segment msegment

Definition at line 1065 of file dlmalloc.c.

◆ msegmentptr

typedef struct malloc_segment* msegmentptr

Definition at line 1066 of file dlmalloc.c.

◆ mstate

typedef struct malloc_state* mstate

Definition at line 1190 of file dlmalloc.c.

◆ sbinptr

typedef struct malloc_chunk* sbinptr

Definition at line 779 of file dlmalloc.c.

◆ tbinptr

typedef struct malloc_tree_chunk* tbinptr

Definition at line 993 of file dlmalloc.c.

◆ tchunk

typedef struct malloc_tree_chunk tchunk

Definition at line 991 of file dlmalloc.c.

◆ tchunkptr

typedef struct malloc_tree_chunk* tchunkptr

Definition at line 992 of file dlmalloc.c.

Function Documentation

◆ add_segment()

static CLIB_NOSANITIZE_ADDR void add_segment ( mstate  m,
char *  tbase,
size_t  tsize,
flag_t  mmapped 
)
static

Definition at line 2585 of file dlmalloc.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ change_mparam()

static int change_mparam ( int  param_number,
int  value 
)
static

Definition at line 1791 of file dlmalloc.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dispose_chunk()

static CLIB_NOSANITIZE_ADDR void dispose_chunk ( mstate  m,
mchunkptr  p,
size_t  psize 
)
static

Definition at line 2973 of file dlmalloc.c.

+ Here is the caller graph for this function:

◆ dlbulk_free()

size_t dlbulk_free ( void *  array[],
size_t  nelem 
)

Definition at line 3929 of file dlmalloc.c.

+ Here is the call graph for this function:

◆ dlcalloc()

void* dlcalloc ( size_t  n_elements,
size_t  elem_size 
)

Definition at line 3403 of file dlmalloc.c.

+ Here is the call graph for this function:

◆ dlfree()

void dlfree ( void *  mem)

Definition at line 3294 of file dlmalloc.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dlindependent_calloc()

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

Definition at line 3918 of file dlmalloc.c.

+ Here is the call graph for this function:

◆ dlindependent_comalloc()

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

Definition at line 3924 of file dlmalloc.c.

+ Here is the call graph for this function:

◆ dlmallinfo()

struct dlmallinfo dlmallinfo ( void  )

Definition at line 3982 of file dlmalloc.c.

+ Here is the call graph for this function:

◆ dlmalloc()

void* dlmalloc ( size_t  bytes)

Definition at line 3156 of file dlmalloc.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dlmalloc_footprint()

size_t dlmalloc_footprint ( void  )

Definition at line 3957 of file dlmalloc.c.

◆ dlmalloc_footprint_limit()

size_t dlmalloc_footprint_limit ( void  )

Definition at line 3965 of file dlmalloc.c.

◆ dlmalloc_max_footprint()

size_t dlmalloc_max_footprint ( void  )

Definition at line 3961 of file dlmalloc.c.

◆ dlmalloc_set_footprint_limit()

size_t dlmalloc_set_footprint_limit ( size_t  bytes)

Definition at line 3970 of file dlmalloc.c.

◆ dlmalloc_stats()

void dlmalloc_stats ( )

Definition at line 3988 of file dlmalloc.c.

+ Here is the call graph for this function:

◆ dlmalloc_trim()

int dlmalloc_trim ( size_t  pad)

Definition at line 3947 of file dlmalloc.c.

+ Here is the call graph for this function:

◆ dlmalloc_usable_size()

size_t dlmalloc_usable_size ( void *  mem)

Definition at line 3997 of file dlmalloc.c.

+ Here is the call graph for this function:

◆ dlmallopt()

int dlmallopt ( int  param_number,
int  value 
)

Definition at line 3993 of file dlmalloc.c.

+ Here is the call graph for this function:

◆ dlmemalign()

void* dlmemalign ( size_t  alignment,
size_t  bytes 
)

Definition at line 3874 of file dlmalloc.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ dlposix_memalign()

int dlposix_memalign ( void **  pp,
size_t  alignment,
size_t  bytes 
)

Definition at line 3881 of file dlmalloc.c.

+ Here is the call graph for this function:

◆ dlpvalloc()

void* dlpvalloc ( size_t  bytes)

Definition at line 3911 of file dlmalloc.c.

+ Here is the call graph for this function:

◆ dlrealloc()

void* dlrealloc ( void *  oldmem,
size_t  bytes 
)

Definition at line 3798 of file dlmalloc.c.

+ Here is the call graph for this function:

◆ dlrealloc_in_place()

void* dlrealloc_in_place ( void *  oldmem,
size_t  bytes 
)

Definition at line 3843 of file dlmalloc.c.

+ Here is the call graph for this function:

◆ dlvalloc()

void* dlvalloc ( size_t  bytes)

Definition at line 3904 of file dlmalloc.c.

+ Here is the call graph for this function:

◆ has_segment_link()

static CLIB_NOSANITIZE_ADDR int has_segment_link ( mstate  m,
msegmentptr  ss 
)
static

Definition at line 1302 of file dlmalloc.c.

+ Here is the caller graph for this function:

◆ ialloc()

static void** ialloc ( mstate  m,
size_t  n_elements,
size_t *  sizes,
int  opts,
void *  chunks[] 
)
static

Definition at line 3584 of file dlmalloc.c.

+ Here is the caller graph for this function:

◆ init_bins()

static void init_bins ( mstate  m)
static

Definition at line 2512 of file dlmalloc.c.

+ Here is the caller graph for this function:

◆ init_mparams()

static int init_mparams ( void  )
static

Definition at line 1697 of file dlmalloc.c.

◆ init_top()

static CLIB_NOSANITIZE_ADDR void init_top ( mstate  m,
mchunkptr  p,
size_t  psize 
)
static

Definition at line 2497 of file dlmalloc.c.

+ Here is the caller graph for this function:

◆ internal_bulk_free()

static size_t internal_bulk_free ( mstate  m,
void *  array[],
size_t  nelem 
)
static

Definition at line 3710 of file dlmalloc.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ internal_mallinfo()

static CLIB_NOSANITIZE_ADDR struct dlmallinfo internal_mallinfo ( mstate  m)
static

Definition at line 2087 of file dlmalloc.c.

+ Here is the caller graph for this function:

◆ internal_malloc_stats()

static void internal_malloc_stats ( mstate  m)
static

Definition at line 2128 of file dlmalloc.c.

+ Here is the caller graph for this function:

◆ internal_memalign()

static CLIB_NOSANITIZE_ADDR void* internal_memalign ( mstate  m,
size_t  alignment,
size_t  bytes 
)
static

Definition at line 3503 of file dlmalloc.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ mmap_alloc()

static void* mmap_alloc ( mstate  m,
size_t  nb 
)
static

Definition at line 2426 of file dlmalloc.c.

+ Here is the caller graph for this function:

◆ mmap_resize()

static mchunkptr mmap_resize ( mstate  m,
mchunkptr  oldp,
size_t  nb,
int  flags 
)
static

Definition at line 2458 of file dlmalloc.c.

+ Here is the caller graph for this function:

◆ prepend_alloc()

static CLIB_NOSANITIZE_ADDR void* prepend_alloc ( mstate  m,
char *  newbase,
char *  oldbase,
size_t  nb 
)
static

Definition at line 2542 of file dlmalloc.c.

+ Here is the caller graph for this function:

◆ release_unused_segments()

static CLIB_NOSANITIZE_ADDR size_t release_unused_segments ( mstate  m)
static

Definition at line 2856 of file dlmalloc.c.

+ Here is the caller graph for this function:

◆ segment_holding()

static CLIB_NOSANITIZE_ADDR msegmentptr segment_holding ( mstate  m,
char *  addr 
)
static

Definition at line 1290 of file dlmalloc.c.

+ Here is the caller graph for this function:

◆ sys_alloc()

static CLIB_NOSANITIZE_ADDR void* sys_alloc ( mstate  m,
size_t  nb 
)
static

Definition at line 2641 of file dlmalloc.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ sys_trim()

static CLIB_NOSANITIZE_ADDR int sys_trim ( mstate  m,
size_t  pad 
)
static

Definition at line 2904 of file dlmalloc.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ tmalloc_large()

static CLIB_NOSANITIZE_ADDR void* tmalloc_large ( mstate  m,
size_t  nb 
)
static

Definition at line 3045 of file dlmalloc.c.

+ Here is the caller graph for this function:

◆ tmalloc_small()

static CLIB_NOSANITIZE_ADDR void* tmalloc_small ( mstate  m,
size_t  nb 
)
static

Definition at line 3117 of file dlmalloc.c.

+ Here is the caller graph for this function:

◆ try_realloc_chunk()

static mchunkptr try_realloc_chunk ( mstate  m,
mchunkptr  p,
size_t  nb,
int  can_move 
)
static

Definition at line 3423 of file dlmalloc.c.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ mparams

struct malloc_params mparams
static

Definition at line 1210 of file dlmalloc.c.