Ruby: ext/fiddle/libffi-3.2.1/src/dlmalloc.c File Reference

Ruby 3.0.5p211 (2022-11-24 revision ba5cf0f7c52d4d35cc6a173c89eda98ceffa2dcf)

Data Structures | Macros | Typedefs | Functions
dlmalloc.c File Reference
`#include <sys/types.h>`
`#include <stdio.h>`
`#include <errno.h>`
`#include <stdlib.h>`
`#include <string.h>`
`#include <sys/param.h>`

Go to the source code of this file.

## Data Structures
struct | mallinfo
struct | malloc_chunk
struct | malloc_tree_chunk
struct | malloc_segment
struct | malloc_state
struct | malloc_params

## Macros
#define | MAX_SIZE_T (~(size_t)0)
#define | ONLY_MSPACES 0
#define | MSPACES 0
#define | MALLOC_ALIGNMENT ((size_t)8U)
#define | FOOTERS 0
#define | ABORT abort()
#define | ABORT_ON_ASSERT_FAILURE 1
#define | PROCEED_ON_ERROR 0
#define | USE_LOCKS 0
#define | INSECURE 0
#define | HAVE_MMAP 1
#define | MMAP_CLEARS 1
#define | HAVE_MREMAP 0
#define | MALLOC_FAILURE_ACTION errno = ENOMEM;
#define | HAVE_MORECORE 1
#define | MORECORE_CONTIGUOUS 0
#define | DEFAULT_GRANULARITY ((size_t)64U * (size_t)1024U)
#define | DEFAULT_TRIM_THRESHOLD ((size_t)2U * (size_t)1024U * (size_t)1024U)
#define | DEFAULT_MMAP_THRESHOLD MAX_SIZE_T
#define | USE_BUILTIN_FFS 0
#define | USE_DEV_RANDOM 0
#define | NO_MALLINFO 0
#define | MALLINFO_FIELD_TYPE size_t
#define | M_TRIM_THRESHOLD (-1)
#define | M_GRANULARITY (-2)
#define | M_MMAP_THRESHOLD (-3)
#define | _STRUCT_MALLINFO
#define | dlcalloc calloc
#define | dlfree free
#define | dlmalloc malloc
#define | dlmemalign memalign
#define | dlrealloc realloc
#define | dlvalloc valloc
#define | dlpvalloc pvalloc
#define | dlmallinfo mallinfo
#define | dlmallopt mallopt
#define | dlmalloc_trim malloc_trim
#define | dlmalloc_stats malloc_stats
#define | dlmalloc_usable_size malloc_usable_size
#define | dlmalloc_footprint malloc_footprint
#define | dlmalloc_max_footprint malloc_max_footprint
#define | dlindependent_calloc independent_calloc
#define | dlindependent_comalloc independent_comalloc
#define | assert(x)
#define | malloc_getpagesize ((size_t)4096U)
#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 | 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 | IS_MMAPPED_BIT (SIZE_T_ZERO)
#define | USE_MMAP_BIT (SIZE_T_ZERO)
#define | CALL_MMAP(s) MFAIL
#define | CALL_MUNMAP(a, s) (-1)
#define | DIRECT_MMAP(s) MFAIL
#define | CALL_MREMAP(addr, osz, nsz, mv) MFAIL
#define | CALL_MORECORE(S) MFAIL
#define | USE_NONCONTIGUOUS_BIT (4U)
#define | EXTERN_BIT (8U)
#define | USE_LOCK_BIT (0U)
#define | INITIAL_LOCK(l)
#define | ACQUIRE_MORECORE_LOCK()
#define | RELEASE_MORECORE_LOCK()
#define | ACQUIRE_MAGIC_INIT_LOCK()
#define | RELEASE_MAGIC_INIT_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 | INUSE_BITS (PINUSE_BIT|CINUSE_BIT)
#define | FENCEPOST_HEAD (INUSE_BITS|SIZE_T_SIZE)
#define | cinuse(p) ((p)->head & CINUSE_BIT)
#define | pinuse(p) ((p)->head & PINUSE_BIT)
#define | chunksize(p) ((p)->head & ~(INUSE_BITS))
#define | clear_pinuse(p) ((p)->head &= ~PINUSE_BIT)
#define | clear_cinuse(p) ((p)->head &= ~CINUSE_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 & ~INUSE_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 | is_mmapped(p) (!((p)->head & PINUSE_BIT) && ((p)->prev_foot & IS_MMAPPED_BIT))
#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 | get_segment_flags(S) ((S)->sflags)
#define | set_segment_flags(S, v) ((S)->sflags = (v))
#define | check_segment_merge(S, b, s) (1)
#define | is_mmapped_segment(S) (get_segment_flags(S) & IS_MMAPPED_BIT)
#define | is_extern_segment(S) (get_segment_flags(S) & 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 | 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) ((M)->mflags &= ~USE_LOCK_BIT)
#define | use_mmap(M) ((M)->mflags & USE_MMAP_BIT)
#define | enable_mmap(M) ((M)->mflags |= USE_MMAP_BIT)
#define | disable_mmap(M) ((M)->mflags &= ~USE_MMAP_BIT)
#define | use_noncontiguous(M) ((M)->mflags & USE_NONCONTIGUOUS_BIT)
#define | disable_contiguous(M) ((M)->mflags |= USE_NONCONTIGUOUS_BIT)
#define | set_lock(M, L)
#define | page_align(S) (((S) + (mparams.page_size)) & ~(mparams.page_size - SIZE_T_ONE))
#define | granularity_align(S) (((S) + (mparams.granularity)) & ~(mparams.granularity - SIZE_T_ONE))
#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) ABORT
#define | USAGE_ERROR_ACTION(m, p) 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) ((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 | compute_bit2idx(X, I)
#define | least_bit(x) ((x) & -(x))
#define | left_bits(x) ((x<<1) | -(x<<1))
#define | same_or_left_bits(x) ((x) | -(x))
#define | ok_address(M, a) ((char*)(a) >= (M)->least_addr)
#define | ok_next(p, n) ((char*)(p) < (char*)(n))
#define | ok_cinuse(p) cinuse(p)
#define | ok_pinuse(p) pinuse(p)
#define | ok_magic(M) (1)
#define | RTCHECK(e) __builtin_expect(e, 1)
#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_chunk * | mchunkptr
typedef struct malloc_chunk * | sbinptr
typedef size_t | bindex_t
typedef unsigned int | binmap_t
typedef unsigned int | flag_t
typedef struct malloc_tree_chunk | tchunk
typedef struct malloc_tree_chunk * | tchunkptr
typedef struct malloc_tree_chunk * | tbinptr
typedef struct malloc_segment | msegment
typedef struct malloc_segment * | msegmentptr
typedef struct malloc_state * | mstate

## Functions
void * | dlmalloc (size_t)
void | dlfree (void *)
void * | dlcalloc (size_t, size_t)
void * | dlrealloc (void *, size_t)
void * | dlmemalign (size_t, size_t)
void * | dlvalloc (size_t)
int | dlmallopt (int, int)
void ** | dlindependent_calloc (size_t, size_t, void **)
void ** | dlindependent_comalloc (size_t, size_t *, void **)
void * | dlpvalloc (size_t)
int | dlmalloc_trim (size_t)
size_t | dlmalloc_usable_size (void *)
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[])

## Macro Definition Documentation

## ◆ _STRUCT_MALLINFO

#define _STRUCT_MALLINFO

Definition at line 626 of file dlmalloc.c.

## ◆ ABORT

#define ABORT abort()

Definition at line 502 of file dlmalloc.c.

## ◆ ABORT_ON_ASSERT_FAILURE

#define ABORT_ON_ASSERT_FAILURE 1

Definition at line 505 of file dlmalloc.c.

## ◆ ACQUIRE_MAGIC_INIT_LOCK

#define ACQUIRE_MAGIC_INIT_LOCK | ( |  | ) |

Definition at line 1512 of file dlmalloc.c.

## ◆ ACQUIRE_MORECORE_LOCK

#define ACQUIRE_MORECORE_LOCK | ( |  | ) |

Definition at line 1504 of file dlmalloc.c.

## ◆ align_as_chunk

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

Definition at line 1691 of file dlmalloc.c.

## ◆ align_offset

#define align_offset | ( |  | A | ) |

Value:
((((size_t)(A) & CHUNK_ALIGN_MASK) == 0)? 0 :\
((MALLOC_ALIGNMENT - ((size_t)(A) & CHUNK_ALIGN_MASK)) & CHUNK_ALIGN_MASK))
MALLOC_ALIGNMENT
#define MALLOC_ALIGNMENT
Definition: dlmalloc.c:496
CHUNK_ALIGN_MASK
#define CHUNK_ALIGN_MASK
Definition: dlmalloc.c:1268
A
Definition: nested_struct10.c:12

Definition at line 1274 of file dlmalloc.c.

## ◆ assert

#define assert | ( |  | x | ) |

Definition at line 1176 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 2329 of file dlmalloc.c.

## ◆ CALL_MMAP

#define CALL_MMAP | ( |  | s | ) | MFAIL

Definition at line 1294 of file dlmalloc.c.

## ◆ CALL_MORECORE

#define CALL_MORECORE | ( |  | S | ) | MFAIL

Definition at line 1409 of file dlmalloc.c.

## ◆ CALL_MREMAP

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

Definition at line 1403 of file dlmalloc.c.

## ◆ CALL_MUNMAP

#define CALL_MUNMAP | ( |  | a,
|  |  | s
| ) |  | (-1)

Definition at line 1295 of file dlmalloc.c.

## ◆ calloc_must_clear

#define calloc_must_clear | ( |  | p | ) | (1)

Definition at line 1765 of file dlmalloc.c.

## ◆ check_free_chunk

#define check_free_chunk | ( |  | M,
|  |  | P
| ) |  |

Definition at line 2253 of file dlmalloc.c.

## ◆ check_inuse_chunk

#define check_inuse_chunk | ( |  | M,
|  |  | P
| ) |  |

Definition at line 2254 of file dlmalloc.c.

## ◆ check_malloc_state

#define check_malloc_state | ( |  | M | ) |

Definition at line 2257 of file dlmalloc.c.

## ◆ check_malloced_chunk

#define check_malloced_chunk | ( |  | M,
|  |  | P,
|  |  | N
| ) |  |

Definition at line 2255 of file dlmalloc.c.

## ◆ check_mmapped_chunk

#define check_mmapped_chunk | ( |  | M,
|  |  | P
| ) |  |

Definition at line 2256 of file dlmalloc.c.

## ◆ check_segment_merge

#define check_segment_merge | ( |  | S,
|  |  | b,
|  |  | s
| ) |  | (1)

Definition at line 1972 of file dlmalloc.c.

## ◆ check_top_chunk

#define check_top_chunk | ( |  | M,
|  |  | P
| ) |  |

Definition at line 2258 of file dlmalloc.c.

## ◆ chunk2mem

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

Definition at line 1688 of file dlmalloc.c.

## ◆ CHUNK_ALIGN_MASK

#define CHUNK_ALIGN_MASK (MALLOC_ALIGNMENT - SIZE_T_ONE)

Definition at line 1268 of file dlmalloc.c.

## ◆ chunk_minus_offset

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

Definition at line 1733 of file dlmalloc.c.

## ◆ CHUNK_OVERHEAD

#define CHUNK_OVERHEAD (SIZE_T_SIZE)

Definition at line 1675 of file dlmalloc.c.

## ◆ chunk_plus_offset

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

Definition at line 1732 of file dlmalloc.c.

## ◆ chunksize

#define chunksize | ( |  | p | ) | ((p)->head & ~(INUSE_BITS))

Definition at line 1726 of file dlmalloc.c.

## ◆ cinuse

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

Definition at line 1724 of file dlmalloc.c.

## ◆ CINUSE_BIT

#define CINUSE_BIT (SIZE_T_TWO)

Definition at line 1717 of file dlmalloc.c.

## ◆ clear_cinuse

#define clear_cinuse | ( |  | p | ) | ((p)->head &= ~CINUSE_BIT)

Definition at line 1729 of file dlmalloc.c.

## ◆ clear_pinuse

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

Definition at line 1728 of file dlmalloc.c.

## ◆ clear_smallmap

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

Definition at line 2350 of file dlmalloc.c.

## ◆ clear_treemap

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

Definition at line 2354 of file dlmalloc.c.

## ◆ CMFAIL

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

Definition at line 1289 of file dlmalloc.c.

## ◆ compute_bit2idx

#define compute_bit2idx | ( |  | X,
|  |  | I
| ) |  |

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);\
}
N
#define N
Definition: crc32.c:57
bindex_t
size_t bindex_t
Definition: dlmalloc.c:1664
I
#define I(x, y, z)

Definition at line 2372 of file dlmalloc.c.

## ◆ compute_tree_index

#define compute_tree_index | ( |  | S,
|  |  | I
| ) |  |

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));\
}\
}
NTREEBINS
#define NTREEBINS
Definition: dlmalloc.c:2061
TREEBIN_SHIFT
#define TREEBIN_SHIFT
Definition: dlmalloc.c:2064
S
#define S(s)
int
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque

Definition at line 2309 of file dlmalloc.c.

## ◆ CORRUPTION_ERROR_ACTION

#define CORRUPTION_ERROR_ACTION | ( |  | m | ) | ABORT

Definition at line 2240 of file dlmalloc.c.

## ◆ DEFAULT_GRANULARITY

#define DEFAULT_GRANULARITY ((size_t)64U * (size_t)1024U)

Definition at line 553 of file dlmalloc.c.

## ◆ DEFAULT_MMAP_THRESHOLD

#define DEFAULT_MMAP_THRESHOLD MAX_SIZE_T

Definition at line 567 of file dlmalloc.c.

## ◆ DEFAULT_TRIM_THRESHOLD

#define DEFAULT_TRIM_THRESHOLD ((size_t)2U * (size_t)1024U * (size_t)1024U)

Definition at line 558 of file dlmalloc.c.

## ◆ DIRECT_MMAP

#define DIRECT_MMAP | ( |  | s | ) | MFAIL

Definition at line 1296 of file dlmalloc.c.

## ◆ disable_contiguous

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

Definition at line 2130 of file dlmalloc.c.

## ◆ disable_lock

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

Definition at line 2123 of file dlmalloc.c.

## ◆ disable_mmap

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

Definition at line 2127 of file dlmalloc.c.

## ◆ dlcalloc

#define dlcalloc calloc

Definition at line 653 of file dlmalloc.c.

## ◆ dlfree

#define dlfree free

Definition at line 654 of file dlmalloc.c.

## ◆ dlindependent_calloc

#define dlindependent_calloc independent_calloc

Definition at line 667 of file dlmalloc.c.

## ◆ dlindependent_comalloc

#define dlindependent_comalloc independent_comalloc

Definition at line 668 of file dlmalloc.c.

## ◆ dlmallinfo

struct mallinfo dlmallinfo | ( |  | void | ) | mallinfo

Definition at line 660 of file dlmalloc.c.

## ◆ dlmalloc

#define dlmalloc malloc

Definition at line 655 of file dlmalloc.c.

## ◆ dlmalloc_footprint

size_t dlmalloc_footprint | ( |  | void | ) | malloc_footprint

Definition at line 665 of file dlmalloc.c.

## ◆ dlmalloc_max_footprint

size_t dlmalloc_max_footprint | ( |  | void | ) | malloc_max_footprint

Definition at line 666 of file dlmalloc.c.

## ◆ dlmalloc_stats

void dlmalloc_stats | ( |  | void | ) | malloc_stats

Definition at line 663 of file dlmalloc.c.

## ◆ dlmalloc_trim

#define dlmalloc_trim malloc_trim

Definition at line 662 of file dlmalloc.c.

## ◆ dlmalloc_usable_size

#define dlmalloc_usable_size malloc_usable_size

Definition at line 664 of file dlmalloc.c.

## ◆ dlmallopt

#define dlmallopt mallopt

Definition at line 661 of file dlmalloc.c.

## ◆ dlmemalign

#define dlmemalign memalign

Definition at line 656 of file dlmalloc.c.

## ◆ dlpvalloc

#define dlpvalloc pvalloc

Definition at line 659 of file dlmalloc.c.

## ◆ dlrealloc

#define dlrealloc realloc

Definition at line 657 of file dlmalloc.c.

## ◆ dlvalloc

#define dlvalloc valloc

Definition at line 658 of file dlmalloc.c.

## ◆ enable_lock

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

Definition at line 2122 of file dlmalloc.c.

## ◆ enable_mmap

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

Definition at line 2126 of file dlmalloc.c.

## ◆ EXTERN_BIT

#define EXTERN_BIT (8U)

Definition at line 1416 of file dlmalloc.c.

## ◆ FENCEPOST_HEAD

#define FENCEPOST_HEAD (INUSE_BITS|SIZE_T_SIZE)

Definition at line 1721 of file dlmalloc.c.

## ◆ fm

#define fm gm

## ◆ FOOTERS

#define FOOTERS 0

Definition at line 499 of file dlmalloc.c.

## ◆ FOUR_SIZE_T_SIZES

#define FOUR_SIZE_T_SIZES (SIZE_T_SIZE<<2)

Definition at line 1263 of file dlmalloc.c.

## ◆ get_foot

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

Definition at line 1743 of file dlmalloc.c.

## ◆ get_segment_flags

#define get_segment_flags | ( |  | S | ) | ((S)->sflags)

Definition at line 1970 of file dlmalloc.c.

## ◆ gm

#define gm (&_gm_)

Definition at line 2113 of file dlmalloc.c.

## ◆ granularity_align

#define granularity_align | ( |  | S | ) | (((S) + (mparams.granularity)) & ~(mparams.granularity - SIZE_T_ONE))

Definition at line 2142 of file dlmalloc.c.

## ◆ HALF_MAX_SIZE_T

#define HALF_MAX_SIZE_T (MAX_SIZE_T / 2U)

Definition at line 1265 of file dlmalloc.c.

## ◆ HAVE_MMAP

#define HAVE_MMAP 1

Definition at line 517 of file dlmalloc.c.

## ◆ HAVE_MORECORE

#define HAVE_MORECORE 1

Definition at line 536 of file dlmalloc.c.

## ◆ HAVE_MREMAP

#define HAVE_MREMAP 0

Definition at line 526 of file dlmalloc.c.

## ◆ idx2bit

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

Definition at line 2346 of file dlmalloc.c.

## ◆ INITIAL_LOCK

#define INITIAL_LOCK | ( |  | l | ) |

Definition at line 1497 of file dlmalloc.c.

## ◆ INSECURE

#define INSECURE 0

Definition at line 514 of file dlmalloc.c.

## ◆ insert_chunk

#define insert_chunk | ( |  | M,
|  |  | P,
|  |  | S
| ) |  |

Value:
if (is_small(S)) insert_small_chunk(M, P, S)\
else { tchunkptr TP = (tchunkptr)(P); insert_large_chunk(M, TP, S); }
is_small
#define is_small(s)
Definition: dlmalloc.c:2284
insert_large_chunk
#define insert_large_chunk(M, X, S)
Definition: dlmalloc.c:3035
insert_small_chunk
#define insert_small_chunk(M, P, S)
Definition: dlmalloc.c:2964
tchunkptr
struct malloc_tree_chunk * tchunkptr
Definition: dlmalloc.c:1872
P
#define P
Definition: dtoa.c:350
M
#define M
Definition: mt19937.c:53
malloc_tree_chunk
Definition: dlmalloc.c:1859

Definition at line 3176 of file dlmalloc.c.

## ◆ insert_large_chunk

#define insert_large_chunk | ( |  | M,
|  |  | X,
|  |  | S
| ) |  |

Definition at line 3035 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;\
}
ok_address
#define ok_address(M, a)
Definition: dlmalloc.c:2426
small_index
#define small_index(s)
Definition: dlmalloc.c:2285
smallmap_is_marked
#define smallmap_is_marked(M, i)
Definition: dlmalloc.c:2351
smallbin_at
#define smallbin_at(M, i)
Definition: dlmalloc.c:2290
MIN_CHUNK_SIZE
#define MIN_CHUNK_SIZE
Definition: dlmalloc.c:1684
RTCHECK
#define RTCHECK(e)
Definition: dlmalloc.c:2452
F
#define F(x, y, z)
B
Definition: nested_struct10.c:17
malloc_chunk
Definition: dlmalloc.c:1654
B
#define B
Definition: util.c:268

Definition at line 2964 of file dlmalloc.c.

## ◆ internal_free

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

Definition at line 3198 of file dlmalloc.c.

## ◆ internal_malloc

#define internal_malloc | ( |  | m,
|  |  | b
| ) |  | dlmalloc(b)

Definition at line 3197 of file dlmalloc.c.

## ◆ INUSE_BITS

#define INUSE_BITS (PINUSE_BIT|CINUSE_BIT)

Definition at line 1718 of file dlmalloc.c.

## ◆ is_aligned

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

Definition at line 1271 of file dlmalloc.c.

## ◆ is_extern_segment

#define is_extern_segment | ( |  | S | ) | (get_segment_flags(S) & EXTERN_BIT)

Definition at line 1979 of file dlmalloc.c.

## ◆ is_global

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

Definition at line 2114 of file dlmalloc.c.

## ◆ is_granularity_aligned

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

Definition at line 2147 of file dlmalloc.c.

## ◆ is_initialized

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

Definition at line 2115 of file dlmalloc.c.

## ◆ is_mmapped

#define is_mmapped | ( |  | p | ) | (!((p)->head & PINUSE_BIT) && ((p)->prev_foot & IS_MMAPPED_BIT))

Definition at line 1754 of file dlmalloc.c.

## ◆ IS_MMAPPED_BIT

#define IS_MMAPPED_BIT (SIZE_T_ZERO)

Definition at line 1292 of file dlmalloc.c.

## ◆ is_mmapped_segment

#define is_mmapped_segment | ( |  | S | ) | (get_segment_flags(S) & IS_MMAPPED_BIT)

Definition at line 1978 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 2145 of file dlmalloc.c.

## ◆ is_small

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

Definition at line 2284 of file dlmalloc.c.

## ◆ least_bit

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

Definition at line 2387 of file dlmalloc.c.

## ◆ left_bits

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

Definition at line 2390 of file dlmalloc.c.

## ◆ leftmost_child

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

Definition at line 1876 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)))
SIZE_T_ONE
#define SIZE_T_ONE
Definition: dlmalloc.c:1260
SIZE_T_BITSIZE
#define SIZE_T_BITSIZE
Definition: dlmalloc.c:1255

Definition at line 2333 of file dlmalloc.c.

## ◆ M_GRANULARITY

#define M_GRANULARITY (-2)

Definition at line 591 of file dlmalloc.c.

## ◆ M_MMAP_THRESHOLD

#define M_MMAP_THRESHOLD (-3)

Definition at line 592 of file dlmalloc.c.

## ◆ M_TRIM_THRESHOLD

#define M_TRIM_THRESHOLD (-1)

Definition at line 590 of file dlmalloc.c.

## ◆ MALLINFO_FIELD_TYPE

#define MALLINFO_FIELD_TYPE size_t

Definition at line 580 of file dlmalloc.c.

## ◆ MALLOC_ALIGNMENT

#define MALLOC_ALIGNMENT ((size_t)8U)

Definition at line 496 of file dlmalloc.c.

## ◆ MALLOC_FAILURE_ACTION

#define MALLOC_FAILURE_ACTION errno = ENOMEM;

Definition at line 530 of file dlmalloc.c.

## ◆ malloc_getpagesize

#define malloc_getpagesize ((size_t)4096U)

Definition at line 1240 of file dlmalloc.c.

## ◆ mark_inuse_foot

#define mark_inuse_foot | ( |  | M,
|  |  | p,
|  |  | s
| ) |  |

Definition at line 2464 of file dlmalloc.c.

## ◆ mark_smallmap

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

Definition at line 2349 of file dlmalloc.c.

## ◆ mark_treemap

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

Definition at line 2353 of file dlmalloc.c.

## ◆ MAX_REQUEST

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

Definition at line 1694 of file dlmalloc.c.

## ◆ MAX_SIZE_T

#define MAX_SIZE_T (~(size_t)0)

Definition at line 483 of file dlmalloc.c.

## ◆ MAX_SMALL_REQUEST

#define MAX_SMALL_REQUEST (MAX_SMALL_SIZE - CHUNK_ALIGN_MASK - CHUNK_OVERHEAD)

Definition at line 2067 of file dlmalloc.c.

## ◆ MAX_SMALL_SIZE

#define MAX_SMALL_SIZE (MIN_LARGE_SIZE - SIZE_T_ONE)

Definition at line 2066 of file dlmalloc.c.

## ◆ MCHUNK_SIZE

#define MCHUNK_SIZE (sizeof(mchunk))

Definition at line 1670 of file dlmalloc.c.

## ◆ mem2chunk

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

Definition at line 1689 of file dlmalloc.c.

## ◆ MFAIL

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

Definition at line 1288 of file dlmalloc.c.

## ◆ MIN_CHUNK_SIZE

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

Definition at line 1684 of file dlmalloc.c.

## ◆ MIN_LARGE_SIZE

#define MIN_LARGE_SIZE (SIZE_T_ONE << TREEBIN_SHIFT)

Definition at line 2065 of file dlmalloc.c.

## ◆ MIN_REQUEST

#define MIN_REQUEST (MIN_CHUNK_SIZE - CHUNK_OVERHEAD - SIZE_T_ONE)

Definition at line 1695 of file dlmalloc.c.

## ◆ MIN_SMALL_INDEX

#define MIN_SMALL_INDEX (small_index(MIN_CHUNK_SIZE))

Definition at line 2287 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)))

Definition at line 2338 of file dlmalloc.c.

## ◆ MMAP_CHUNK_OVERHEAD

#define MMAP_CHUNK_OVERHEAD (TWO_SIZE_T_SIZES)

Definition at line 1679 of file dlmalloc.c.

## ◆ MMAP_CLEARS

#define MMAP_CLEARS 1

Definition at line 520 of file dlmalloc.c.

## ◆ MMAP_FOOT_PAD

#define MMAP_FOOT_PAD (FOUR_SIZE_T_SIZES)

Definition at line 1681 of file dlmalloc.c.

## ◆ MORECORE_CONTIGUOUS

#define MORECORE_CONTIGUOUS 0

Definition at line 540 of file dlmalloc.c.

## ◆ MSPACES

#define MSPACES 0

Definition at line 492 of file dlmalloc.c.

## ◆ next_chunk

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

Definition at line 1736 of file dlmalloc.c.

## ◆ next_pinuse

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

Definition at line 1740 of file dlmalloc.c.

## ◆ NO_MALLINFO

#define NO_MALLINFO 0

Definition at line 577 of file dlmalloc.c.

## ◆ NSMALLBINS

#define NSMALLBINS (32U)

Definition at line 2060 of file dlmalloc.c.

## ◆ NTREEBINS

#define NTREEBINS (32U)

Definition at line 2061 of file dlmalloc.c.

## ◆ ok_address

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

Definition at line 2426 of file dlmalloc.c.

## ◆ ok_cinuse

#define ok_cinuse | ( |  | p | ) | cinuse(p)

Definition at line 2430 of file dlmalloc.c.

## ◆ ok_magic

#define ok_magic | ( |  | M | ) | (1)

Definition at line 2445 of file dlmalloc.c.

## ◆ ok_next

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

Definition at line 2428 of file dlmalloc.c.

## ◆ ok_pinuse

#define ok_pinuse | ( |  | p | ) | pinuse(p)

Definition at line 2432 of file dlmalloc.c.

## ◆ ONLY_MSPACES

#define ONLY_MSPACES 0

Definition at line 486 of file dlmalloc.c.

## ◆ overhead_for

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

Definition at line 1758 of file dlmalloc.c.

## ◆ pad_request

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

Definition at line 1698 of file dlmalloc.c.

## ◆ page_align

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

Definition at line 2138 of file dlmalloc.c.

## ◆ pinuse

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

Definition at line 1725 of file dlmalloc.c.

## ◆ PINUSE_BIT

#define PINUSE_BIT (SIZE_T_ONE)

Definition at line 1716 of file dlmalloc.c.

## ◆ POSTACTION

#define POSTACTION | ( |  | M | ) |

Definition at line 2213 of file dlmalloc.c.

## ◆ PREACTION

#define PREACTION | ( |  | M | ) | (0)

Definition at line 2209 of file dlmalloc.c.

## ◆ prev_chunk

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

Definition at line 1737 of file dlmalloc.c.

## ◆ PROCEED_ON_ERROR

#define PROCEED_ON_ERROR 0

Definition at line 508 of file dlmalloc.c.

## ◆ RELEASE_MAGIC_INIT_LOCK

#define RELEASE_MAGIC_INIT_LOCK | ( |  | ) |

Definition at line 1513 of file dlmalloc.c.

## ◆ RELEASE_MORECORE_LOCK

#define RELEASE_MORECORE_LOCK | ( |  | ) |

Definition at line 1505 of file dlmalloc.c.

## ◆ replace_dv

#define replace_dv | ( |  | M,
|  |  | P,
|  |  | S
| ) |  |

Value:
{\
size_t DVS = M->dvsize;\
if (DVS != 0) {\
mchunkptr DV = M->dv;\
assert(is_small(DVS));\
insert_small_chunk(M, DV, DVS);\
}\
M->dvsize = S;\
M->dv = P;\
}

Definition at line 3021 of file dlmalloc.c.

## ◆ request2size

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

Definition at line 1702 of file dlmalloc.c.

## ◆ RTCHECK

#define RTCHECK | ( |  | e | ) | __builtin_expect(e, 1)

Definition at line 2452 of file dlmalloc.c.

## ◆ same_or_left_bits

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

Definition at line 2393 of file dlmalloc.c.

## ◆ segment_holds

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

Definition at line 2151 of file dlmalloc.c.

## ◆ set_foot

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

Definition at line 1744 of file dlmalloc.c.

## ◆ set_free_with_pinuse

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

Definition at line 1751 of file dlmalloc.c.

## ◆ set_inuse

#define set_inuse | ( |  | M,
|  |  | p,
|  |  | s
| ) |  |

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

Definition at line 2467 of file dlmalloc.c.

## ◆ set_inuse_and_pinuse

#define set_inuse_and_pinuse | ( |  | M,
|  |  | p,
|  |  | s
| ) |  |

Value:
((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\
((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT)
mchunkptr
struct malloc_chunk * mchunkptr
Definition: dlmalloc.c:1662

Definition at line 2472 of file dlmalloc.c.

## ◆ set_lock

#define set_lock | ( |  | M,
|  |  | L
| ) |  |

Value:
((M)->mflags = (L)?\
((M)->mflags | USE_LOCK_BIT) :\
((M)->mflags & ~USE_LOCK_BIT))
L
#define L(x)
Definition: asm.h:125
USE_LOCK_BIT
#define USE_LOCK_BIT
Definition: dlmalloc.c:1496

Definition at line 2132 of file dlmalloc.c.

## ◆ set_segment_flags

#define set_segment_flags | ( |  | S,
|  |  | v
| ) |  | ((S)->sflags = (v))

Definition at line 1971 of file dlmalloc.c.

## ◆ set_size_and_pinuse_of_free_chunk

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

Definition at line 1747 of file dlmalloc.c.

## ◆ set_size_and_pinuse_of_inuse_chunk

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

Definition at line 2477 of file dlmalloc.c.

## ◆ should_trim

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

Definition at line 2177 of file dlmalloc.c.

## ◆ SIX_SIZE_T_SIZES

#define SIX_SIZE_T_SIZES (FOUR_SIZE_T_SIZES+TWO_SIZE_T_SIZES)

Definition at line 1264 of file dlmalloc.c.

## ◆ SIZE_T_BITSIZE

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

Definition at line 1255 of file dlmalloc.c.

## ◆ SIZE_T_ONE

#define SIZE_T_ONE ((size_t)1)

Definition at line 1260 of file dlmalloc.c.

## ◆ SIZE_T_SIZE

#define SIZE_T_SIZE (sizeof(size_t))

Definition at line 1254 of file dlmalloc.c.

## ◆ SIZE_T_TWO

#define SIZE_T_TWO ((size_t)2)

Definition at line 1261 of file dlmalloc.c.

## ◆ SIZE_T_ZERO

#define SIZE_T_ZERO ((size_t)0)

Definition at line 1259 of file dlmalloc.c.

## ◆ small_index

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

Definition at line 2285 of file dlmalloc.c.

## ◆ small_index2size

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

Definition at line 2286 of file dlmalloc.c.

## ◆ smallbin_at

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

Definition at line 2290 of file dlmalloc.c.

## ◆ SMALLBIN_SHIFT

#define SMALLBIN_SHIFT (3U)

Definition at line 2062 of file dlmalloc.c.

## ◆ SMALLBIN_WIDTH

#define SMALLBIN_WIDTH (SIZE_T_ONE << SMALLBIN_SHIFT)

Definition at line 2063 of file dlmalloc.c.

## ◆ smallmap_is_marked

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

Definition at line 2351 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 2187 of file dlmalloc.c.

## ◆ treebin_at

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

Definition at line 2291 of file dlmalloc.c.

## ◆ TREEBIN_SHIFT

#define TREEBIN_SHIFT (8U)

Definition at line 2064 of file dlmalloc.c.

## ◆ treemap_is_marked

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

Definition at line 2355 of file dlmalloc.c.

## ◆ TWO_SIZE_T_SIZES

#define TWO_SIZE_T_SIZES (SIZE_T_SIZE<<1)

Definition at line 1262 of file dlmalloc.c.

## ◆ unlink_chunk

#define unlink_chunk | ( |  | M,
|  |  | P,
|  |  | S
| ) |  |

Value:
if (is_small(S)) unlink_small_chunk(M, P, S)\
else { tchunkptr TP = (tchunkptr)(P); unlink_large_chunk(M, TP); }
unlink_large_chunk
#define unlink_large_chunk(M, X)
Definition: dlmalloc.c:3103
unlink_small_chunk
#define unlink_small_chunk(M, P, S)
Definition: dlmalloc.c:2983

Definition at line 3180 of file dlmalloc.c.

## ◆ unlink_first_small_chunk

#define unlink_first_small_chunk | ( |  | M,
|  |  | B,
|  |  | P,
|  |  | I
| ) |  |

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))) {\
B->fd = F;\
F->bk = B;\
}\
else {\
CORRUPTION_ERROR_ACTION(M);\
}\
}
chunksize
#define chunksize(p)
Definition: dlmalloc.c:1726
small_index2size
#define small_index2size(i)
Definition: dlmalloc.c:2286

Definition at line 3003 of file dlmalloc.c.

## ◆ unlink_large_chunk

#define unlink_large_chunk | ( |  | M,
|  |  | X
| ) |  |

Definition at line 3103 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 (F == B)\
clear_smallmap(M, I);\
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;\
}\
else {\
CORRUPTION_ERROR_ACTION(M);\
}\
}

Definition at line 2983 of file dlmalloc.c.

## ◆ USAGE_ERROR_ACTION

#define USAGE_ERROR_ACTION | ( |  | m,
|  |  | p
| ) |  | ABORT

Definition at line 2244 of file dlmalloc.c.

## ◆ USE_BUILTIN_FFS

#define USE_BUILTIN_FFS 0

Definition at line 571 of file dlmalloc.c.

## ◆ USE_DEV_RANDOM

#define USE_DEV_RANDOM 0

Definition at line 574 of file dlmalloc.c.

## ◆ use_lock

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

Definition at line 2121 of file dlmalloc.c.

## ◆ USE_LOCK_BIT

#define USE_LOCK_BIT (0U)

Definition at line 1496 of file dlmalloc.c.

## ◆ USE_LOCKS

#define USE_LOCKS 0

Definition at line 511 of file dlmalloc.c.

## ◆ use_mmap

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

Definition at line 2125 of file dlmalloc.c.

## ◆ USE_MMAP_BIT

#define USE_MMAP_BIT (SIZE_T_ZERO)

Definition at line 1293 of file dlmalloc.c.

## ◆ use_noncontiguous

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

Definition at line 2129 of file dlmalloc.c.

## ◆ USE_NONCONTIGUOUS_BIT

#define USE_NONCONTIGUOUS_BIT (4U)

Definition at line 1413 of file dlmalloc.c.

## Typedef Documentation

## ◆ bindex_t

typedef size_t bindex_t

Definition at line 1664 of file dlmalloc.c.

## ◆ binmap_t

typedef unsigned int binmap_t

Definition at line 1665 of file dlmalloc.c.

## ◆ flag_t

typedef unsigned int flag_t

Definition at line 1666 of file dlmalloc.c.

## ◆ mchunk

typedef struct malloc_chunk mchunk

Definition at line 1661 of file dlmalloc.c.

## ◆ mchunkptr

typedef struct malloc_chunk* mchunkptr

Definition at line 1662 of file dlmalloc.c.

## ◆ msegment

typedef struct malloc_segment msegment

Definition at line 1981 of file dlmalloc.c.

## ◆ msegmentptr

typedef struct malloc_segment* msegmentptr

Definition at line 1982 of file dlmalloc.c.

## ◆ mstate

typedef struct malloc_state* mstate

Definition at line 2090 of file dlmalloc.c.

## ◆ sbinptr

typedef struct malloc_chunk* sbinptr

Definition at line 1663 of file dlmalloc.c.

## ◆ tbinptr

typedef struct malloc_tree_chunk* tbinptr

Definition at line 1873 of file dlmalloc.c.

## ◆ tchunk

typedef struct malloc_tree_chunk tchunk

Definition at line 1871 of file dlmalloc.c.

## ◆ tchunkptr

typedef struct malloc_tree_chunk* tchunkptr

Definition at line 1872 of file dlmalloc.c.

## Function Documentation

## ◆ dlcalloc()

void * dlcalloc | ( | size_t | n_elements,
|  | size_t | elem_size
| ) |  |

Definition at line 4355 of file dlmalloc.c.

References calloc_must_clear, dlmalloc, MAX_SIZE_T, and mem2chunk.

## ◆ dlfree()

void dlfree | ( | void * | mem | ) |

Definition at line 4255 of file dlmalloc.c.

References CALL_MUNMAP, check_free_chunk, check_inuse_chunk, chunk_minus_offset, chunk_plus_offset, chunksize, cinuse, fm, malloc_chunk::head, insert_chunk, INUSE_BITS, IS_MMAPPED_BIT, mem2chunk, MMAP_FOOT_PAD, ok_address, ok_cinuse, ok_magic, ok_next, ok_pinuse, pinuse, PINUSE_BIT, POSTACTION, PREACTION, malloc_chunk::prev_foot, RTCHECK, set_free_with_pinuse, set_size_and_pinuse_of_free_chunk, should_trim, unlink_chunk, and USAGE_ERROR_ACTION.

## ◆ dlindependent_calloc() [1/2]

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

Definition at line 4397 of file dlmalloc.c.

References gm.

## ◆ dlindependent_calloc() [2/2]

void ** dlindependent_calloc | ( | size_t | ,
|  | size_t | ,
|  | void ** |
| ) |  |

## ◆ dlindependent_comalloc() [1/2]

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

Definition at line 4403 of file dlmalloc.c.

References gm.

## ◆ dlindependent_comalloc() [2/2]

void ** dlindependent_comalloc | ( | size_t | ,
|  | size_t * | ,
|  | void ** |
| ) |  |

## ◆ dlmalloc()

void * dlmalloc | ( | size_t | bytes | ) |

Definition at line 4123 of file dlmalloc.c.

References assert, check_malloced_chunk, check_top_chunk, chunk2mem, chunk_plus_offset, chunksize, compute_bit2idx, malloc_chunk::fd, gm, malloc_chunk::head, idx2bit, least_bit, left_bits, MAX_REQUEST, MAX_SIZE_T, MAX_SMALL_REQUEST, MIN_CHUNK_SIZE, MIN_REQUEST, pad_request, PINUSE_BIT, POSTACTION, PREACTION, replace_dv, set_inuse_and_pinuse, set_size_and_pinuse_of_free_chunk, set_size_and_pinuse_of_inuse_chunk, SIZE_T_SIZE, small_index, small_index2size, smallbin_at, and unlink_first_small_chunk.

## ◆ dlmalloc_trim()

int dlmalloc_trim | ( | size_t | pad | ) |

Definition at line 4422 of file dlmalloc.c.

References gm, POSTACTION, and PREACTION.

## ◆ dlmalloc_usable_size()

size_t dlmalloc_usable_size | ( | void * | mem | ) |

Definition at line 4449 of file dlmalloc.c.

References chunksize, cinuse, mem2chunk, and overhead_for.

## ◆ dlmallopt()

int dlmallopt | ( | int | param_number,
|  | int | value
| ) |  |

Definition at line 4458 of file dlmalloc.c.

## ◆ dlmemalign()

void * dlmemalign | ( | size_t | alignment,
|  | size_t | bytes
| ) |  |

Definition at line 4393 of file dlmalloc.c.

References gm.

## ◆ dlpvalloc()

void * dlpvalloc | ( | size_t | bytes | ) |

Definition at line 4415 of file dlmalloc.c.

References dlmemalign, malloc_params::page_size, and SIZE_T_ONE.

## ◆ dlrealloc()

void * dlrealloc | ( | void * | oldmem,
|  | size_t | bytes
| ) |  |

Definition at line 4370 of file dlmalloc.c.

References dlfree, dlmalloc, gm, mem2chunk, ok_magic, and USAGE_ERROR_ACTION.

## ◆ dlvalloc()

void * dlvalloc | ( | size_t | bytes | ) |

Definition at line 4408 of file dlmalloc.c.

References dlmemalign, and malloc_params::page_size.