Include dependency graph for malloc.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 |
Defines | |
#define | LACKS_FCNTL_H |
#define | LACKS_SYS_MMAN_H |
#define | LACKS_SYS_PARAM_H |
#define | HAVE_MMAP 0 |
#define | LACKS_ERRNO_H |
#define | MALLOC_FAILURE_ACTION |
#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 1 |
#define | INSECURE 0 |
#define | HAVE_MMAP 0 |
#define | MMAP_CLEARS 1 |
#define | HAVE_MORECORE 1 |
#define | MORECORE_CONTIGUOUS 1 |
#define | MORECORE sbrk |
#define | DEFAULT_GRANULARITY (0) |
#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 | 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)) |
#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) MORECORE(S) |
#define | USE_NONCONTIGUOUS_BIT (4U) |
#define | EXTERN_BIT (8U) |
#define | MLOCK_T atomic_t |
#define | INITIAL_LOCK(l) futex_initialize(l, 1) |
#define | ACQUIRE_LOCK(l) ({futex_down(l);0;}) |
#define | RELEASE_LOCK(l) futex_up(l) |
#define | USE_LOCK_BIT (2U) |
#define | ACQUIRE_MORECORE_LOCK() ACQUIRE_LOCK(&morecore_mutex); |
#define | RELEASE_MORECORE_LOCK() RELEASE_LOCK(&morecore_mutex); |
#define | ACQUIRE_MAGIC_INIT_LOCK() ACQUIRE_LOCK(&magic_init_mutex); |
#define | RELEASE_MAGIC_INIT_LOCK() RELEASE_LOCK(&magic_init_mutex); |
#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) (!is_mmapped(p)) |
#define | leftmost_child(t) ((t)->child[0] != 0? (t)->child[0] : (t)->child[1]) |
#define | is_mmapped_segment(S) ((S)->sflags & IS_MMAPPED_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 | 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 | GLOBALLY_INITIALIZE() (mparams.page_size == 0 && init_mparams()) |
#define | PREACTION(M) ((GLOBALLY_INITIALIZE() || use_lock(M))? ACQUIRE_LOCK(&(M)->mutex) : 0) |
#define | POSTACTION(M) { if (use_lock(M)) RELEASE_LOCK(&(M)->mutex); } |
#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) (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 malloc_chunk | mchunk |
typedef malloc_chunk * | mchunkptr |
typedef malloc_chunk * | sbinptr |
typedef unsigned int | bindex_t |
typedef unsigned int | binmap_t |
typedef unsigned int | flag_t |
typedef malloc_tree_chunk | tchunk |
typedef malloc_tree_chunk * | tchunkptr |
typedef malloc_tree_chunk * | tbinptr |
typedef malloc_segment | msegment |
typedef malloc_segment * | msegmentptr |
typedef malloc_state * | mstate |
Functions | |
static msegmentptr | segment_holding (mstate m, char *addr) |
static int | has_segment_link (mstate m, msegmentptr ss) |
static int | init_mparams (void) |
static int | change_mparam (int param_number, int value) |
static struct mallinfo | 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) |
static void | init_top (mstate m, mchunkptr p, size_t psize) |
static void | init_bins (mstate m) |
static void * | prepend_alloc (mstate m, char *newbase, char *oldbase, size_t nb) |
static void | add_segment (mstate m, char *tbase, size_t tsize, flag_t mmapped) |
static void * | sys_alloc (mstate m, size_t nb) |
static size_t | release_unused_segments (mstate m) |
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) |
static void * | internal_realloc (mstate m, void *oldmem, size_t bytes) |
static 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[]) |
void * | dlmalloc (size_t bytes) |
void | dlfree (void *mem) |
void * | dlcalloc (size_t n_elements, size_t elem_size) |
void * | dlrealloc (void *oldmem, size_t bytes) |
void * | dlmemalign (size_t alignment, 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[]) |
void * | dlvalloc (size_t bytes) |
void * | dlpvalloc (size_t bytes) |
int | dlmalloc_trim (size_t pad) |
size_t | dlmalloc_footprint (void) |
size_t | dlmalloc_max_footprint (void) |
mallinfo | dlmallinfo (void) |
void | dlmalloc_stats () |
size_t | dlmalloc_usable_size (void *mem) |
int | dlmallopt (int param_number, int value) |
Variables | |
static MLOCK_T | morecore_mutex = FUTEX_INITIALIZER |
static MLOCK_T | magic_init_mutex = FUTEX_INITIALIZER |
static struct malloc_params | mparams |
static struct malloc_state | _gm_ |
Definition in file malloc.c.
|
Referenced by dlfree(). |