![]() |
GNU PROLOG with UTF8 support
|
#include <sys/types.h>#include <stdio.h>#include <errno.h>#include <time.h>#include <stdlib.h>#include <string.h>#include <sys/mman.h>#include <fcntl.h>#include <unistd.h>#include <sched.h>#include <pthread.h>#include <sys/param.h>
Data Structures | |
| struct | mallinfo |
| struct | malloc_chunk |
| struct | malloc_tree_chunk |
| struct | malloc_segment |
| struct | malloc_state |
| struct | malloc_params |
Macros | |
| #define | DLMALLOC_VERSION 20805 |
| #define | DLMALLOC_EXPORT extern |
| #define | MAX_SIZE_T (~(size_t)0) |
| #define | USE_LOCKS |
| #define | USE_SPIN_LOCKS 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 | INSECURE 0 |
| #define | MALLOC_INSPECT_ALL 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_DEFAULT sbrk |
| #define | MORECORE_CONTIGUOUS 1 |
| #define | DEFAULT_GRANULARITY (0) /* 0 means to compute in init_mparams */ |
| #define | DEFAULT_TRIM_THRESHOLD ((size_t)2U * (size_t)1024U * (size_t)1024U) |
| #define | DEFAULT_MMAP_THRESHOLD ((size_t)256U * (size_t)1024U) |
| #define | MAX_RELEASE_CHECK_RATE 4095 |
| #define | USE_BUILTIN_FFS 0 |
| #define | USE_DEV_RANDOM 0 |
| #define | NO_MALLINFO 0 |
| #define | MALLINFO_FIELD_TYPE size_t |
| #define | NO_MALLOC_STATS 0 |
| #define | NO_SEGMENT_TRAVERSAL 0 |
| #define | M_TRIM_THRESHOLD (-1) |
| #define | M_GRANULARITY (-2) |
| #define | M_MMAP_THRESHOLD (-3) |
| #define | _STRUCT_MALLINFO |
| #define | STRUCT_MALLINFO_DECLARED 1 |
| #define | NOINLINE |
| #define | FORCEINLINE |
| #define | dlcalloc calloc |
| #define | dlfree free |
| #define | dlmalloc malloc |
| #define | dlmemalign memalign |
| #define | dlposix_memalign posix_memalign |
| #define | dlrealloc realloc |
| #define | dlrealloc_in_place realloc_in_place |
| #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 | dlmalloc_footprint_limit malloc_footprint_limit |
| #define | dlmalloc_set_footprint_limit malloc_set_footprint_limit |
| #define | dlmalloc_inspect_all malloc_inspect_all |
| #define | dlindependent_calloc independent_calloc |
| #define | dlindependent_comalloc independent_comalloc |
| #define | dlbulk_free bulk_free |
| #define | assert(x) |
| #define | DEBUG 0 |
| #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 | 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 | MUNMAP_DEFAULT(a, s) munmap((a), (s)) |
| #define | MMAP_PROT (PROT_READ|PROT_WRITE) |
| #define | MMAP_FLAGS (MAP_PRIVATE) |
| #define | MMAP_DEFAULT(s) |
| #define | DIRECT_MMAP_DEFAULT(s) MMAP_DEFAULT(s) |
| #define | CALL_MORECORE(S) MORECORE_DEFAULT(S) |
| #define | USE_MMAP_BIT (SIZE_T_ONE) |
| #define | CALL_MMAP(s) MMAP_DEFAULT(s) |
| #define | CALL_MUNMAP(a, s) MUNMAP_DEFAULT((a), (s)) |
| #define | CALL_DIRECT_MMAP(s) DIRECT_MMAP_DEFAULT(s) |
| #define | CALL_MREMAP(addr, osz, nsz, mv) MFAIL |
| #define | USE_NONCONTIGUOUS_BIT (4U) |
| #define | EXTERN_BIT (8U) |
| #define | MLOCK_T pthread_mutex_t |
| #define | ACQUIRE_LOCK(lk) pthread_mutex_lock(lk) |
| #define | RELEASE_LOCK(lk) pthread_mutex_unlock(lk) |
| #define | TRY_LOCK(lk) (!pthread_mutex_trylock(lk)) |
| #define | INITIAL_LOCK(lk) pthread_init_lock(lk) |
| #define | DESTROY_LOCK(lk) pthread_mutex_destroy(lk) |
| #define | USE_LOCK_BIT (2U) |
| #define | ACQUIRE_MALLOC_GLOBAL_LOCK() ACQUIRE_LOCK(&malloc_global_mutex); |
| #define | RELEASE_MALLOC_GLOBAL_LOCK() RELEASE_LOCK(&malloc_global_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 | 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) (!is_mmapped(p)) |
| #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) ((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 - 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) ((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) (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_chunk * | mchunkptr |
| typedef struct malloc_chunk * | sbinptr |
| 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_chunk * | tchunkptr |
| typedef struct malloc_tree_chunk * | tbinptr |
| typedef struct malloc_segment | msegment |
| typedef struct malloc_segment * | msegmentptr |
| typedef struct malloc_state * | mstate |
Functions | |
| DLMALLOC_EXPORT void * | dlmalloc (size_t) |
| DLMALLOC_EXPORT void | dlfree (void *) |
| DLMALLOC_EXPORT void * | dlcalloc (size_t, size_t) |
| DLMALLOC_EXPORT void * | dlrealloc (void *, size_t) |
| DLMALLOC_EXPORT void * | dlrealloc_in_place (void *, size_t) |
| DLMALLOC_EXPORT void * | dlmemalign (size_t, size_t) |
| DLMALLOC_EXPORT int | dlposix_memalign (void **, size_t, size_t) |
| DLMALLOC_EXPORT void * | dlvalloc (size_t) |
| DLMALLOC_EXPORT int | dlmallopt (int, int) |
| DLMALLOC_EXPORT size_t | dlmalloc_footprint (void) |
| DLMALLOC_EXPORT size_t | dlmalloc_max_footprint (void) |
| DLMALLOC_EXPORT size_t | dlmalloc_footprint_limit () |
| DLMALLOC_EXPORT size_t | dlmalloc_set_footprint_limit (size_t bytes) |
| DLMALLOC_EXPORT struct mallinfo | dlmallinfo (void) |
| DLMALLOC_EXPORT void ** | dlindependent_calloc (size_t, size_t, void **) |
| DLMALLOC_EXPORT void ** | dlindependent_comalloc (size_t, size_t *, void **) |
| DLMALLOC_EXPORT size_t | dlbulk_free (void **, size_t n_elements) |
| DLMALLOC_EXPORT void * | dlpvalloc (size_t) |
| DLMALLOC_EXPORT int | dlmalloc_trim (size_t) |
| DLMALLOC_EXPORT void | dlmalloc_stats (void) |
| size_t | dlmalloc_usable_size (void *) |
| static int | pthread_init_lock (MLOCK_T *lk) |
| 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, int flags) |
| 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 | dispose_chunk (mstate m, mchunkptr p, size_t psize) |
| static void * | tmalloc_large (mstate m, size_t nb) |
| static void * | tmalloc_small (mstate m, size_t nb) |
| static mchunkptr | try_realloc_chunk (mstate m, mchunkptr p, size_t nb, int can_move) |
| 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[]) |
| static size_t | internal_bulk_free (mstate m, void *array[], size_t nelem) |
| 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) |
Variables | |
| static int | dev_zero_fd = -1 |
| static MLOCK_T | malloc_global_mutex = PTHREAD_MUTEX_INITIALIZER |
| static struct malloc_params | mparams |
| static struct malloc_state | _gm_ |
| #define _STRUCT_MALLINFO |
| #define ABORT abort() |
| #define ABORT_ON_ASSERT_FAILURE 1 |
| #define ACQUIRE_LOCK | ( | lk | ) | pthread_mutex_lock(lk) |
| #define ACQUIRE_MALLOC_GLOBAL_LOCK | ( | ) | ACQUIRE_LOCK(&malloc_global_mutex); |
| #define align_as_chunk | ( | A | ) | (mchunkptr)((A) + align_offset(chunk2mem(A))) |
| #define align_offset | ( | A | ) |
| #define assert | ( | x | ) |
| #define bit_for_tree_index | ( | i | ) | (i == NTREEBINS-1)? (SIZE_T_BITSIZE-1) : (((i) >> 1) + TREEBIN_SHIFT - 2) |
| #define CALL_DIRECT_MMAP | ( | s | ) | DIRECT_MMAP_DEFAULT(s) |
| #define CALL_MMAP | ( | s | ) | MMAP_DEFAULT(s) |
| #define CALL_MORECORE | ( | S | ) | MORECORE_DEFAULT(S) |
Define CALL_MORECORE
| #define CALL_MREMAP | ( | addr, | |
| osz, | |||
| nsz, | |||
| mv | |||
| ) | MFAIL |
Define CALL_MREMAP
| #define CALL_MUNMAP | ( | a, | |
| s | |||
| ) | MUNMAP_DEFAULT((a), (s)) |
| #define calloc_must_clear | ( | p | ) | (!is_mmapped(p)) |
| #define check_free_chunk | ( | M, | |
| P | |||
| ) |
| #define check_inuse_chunk | ( | M, | |
| P | |||
| ) |
| #define check_malloc_state | ( | M | ) |
| #define check_malloced_chunk | ( | M, | |
| P, | |||
| N | |||
| ) |
| #define check_mmapped_chunk | ( | M, | |
| P | |||
| ) |
| #define check_top_chunk | ( | M, | |
| P | |||
| ) |
| #define chunk2mem | ( | p | ) | ((void*)((char*)(p) + TWO_SIZE_T_SIZES)) |
| #define CHUNK_ALIGN_MASK (MALLOC_ALIGNMENT - SIZE_T_ONE) |
| #define chunk_minus_offset | ( | p, | |
| s | |||
| ) | ((mchunkptr)(((char*)(p)) - (s))) |
| #define CHUNK_OVERHEAD (SIZE_T_SIZE) |
| #define chunk_plus_offset | ( | p, | |
| s | |||
| ) | ((mchunkptr)(((char*)(p)) + (s))) |
| #define chunksize | ( | p | ) | ((p)->head & ~(FLAG_BITS)) |
| #define cinuse | ( | p | ) | ((p)->head & CINUSE_BIT) |
| #define CINUSE_BIT (SIZE_T_TWO) |
| #define clear_flag4 | ( | p | ) | ((p)->head &= ~FLAG4_BIT) |
| #define clear_pinuse | ( | p | ) | ((p)->head &= ~PINUSE_BIT) |
| #define CMFAIL ((char*)(MFAIL)) /* defined for convenience */ |
| #define compute_bit2idx | ( | X, | |
| I | |||
| ) |
| #define compute_tree_index | ( | S, | |
| I | |||
| ) |
| #define CORRUPTION_ERROR_ACTION | ( | m | ) | ABORT |
| #define DEBUG 0 |
| #define DEFAULT_GRANULARITY (0) /* 0 means to compute in init_mparams */ |
| #define DEFAULT_MMAP_THRESHOLD ((size_t)256U * (size_t)1024U) |
| #define DEFAULT_TRIM_THRESHOLD ((size_t)2U * (size_t)1024U * (size_t)1024U) |
| #define DESTROY_LOCK | ( | lk | ) | pthread_mutex_destroy(lk) |
| #define DIRECT_MMAP_DEFAULT | ( | s | ) | MMAP_DEFAULT(s) |
| #define disable_contiguous | ( | M | ) | ((M)->mflags |= USE_NONCONTIGUOUS_BIT) |
| #define disable_lock | ( | M | ) | ((M)->mflags &= ~USE_LOCK_BIT) |
| #define disable_mmap | ( | M | ) | ((M)->mflags &= ~USE_MMAP_BIT) |
| #define dlbulk_free bulk_free |
| #define dlcalloc calloc |
| #define dlfree free |
| #define dlindependent_calloc independent_calloc |
| #define dlindependent_comalloc independent_comalloc |
| #define dlmallinfo mallinfo |
| #define dlmalloc malloc |
| #define DLMALLOC_EXPORT extern |
| #define dlmalloc_footprint malloc_footprint |
| #define dlmalloc_footprint_limit malloc_footprint_limit |
| #define dlmalloc_inspect_all malloc_inspect_all |
| #define dlmalloc_max_footprint malloc_max_footprint |
| #define dlmalloc_set_footprint_limit malloc_set_footprint_limit |
| void dlmalloc_stats malloc_stats |
| #define dlmalloc_trim malloc_trim |
| #define dlmalloc_usable_size malloc_usable_size |
| #define DLMALLOC_VERSION 20805 |
| #define dlmallopt mallopt |
| #define dlmemalign memalign |
| #define dlposix_memalign posix_memalign |
| #define dlpvalloc pvalloc |
| #define dlrealloc realloc |
| #define dlrealloc_in_place realloc_in_place |
| #define dlvalloc valloc |
| #define enable_lock | ( | M | ) | ((M)->mflags |= USE_LOCK_BIT) |
| #define enable_mmap | ( | M | ) | ((M)->mflags |= USE_MMAP_BIT) |
| #define ensure_initialization | ( | ) | (void)(mparams.magic != 0 || init_mparams()) |
| #define EXTERN_BIT (8U) |
| #define FENCEPOST_HEAD (INUSE_BITS|SIZE_T_SIZE) |
| #define FLAG4_BIT (SIZE_T_FOUR) |
| #define flag4inuse | ( | p | ) | ((p)->head & FLAG4_BIT) |
| #define FLAG_BITS (PINUSE_BIT|CINUSE_BIT|FLAG4_BIT) |
| #define fm gm |
| #define FOOTERS 0 |
| #define FORCEINLINE |
| #define FOUR_SIZE_T_SIZES (SIZE_T_SIZE<<2) |
| #define get_foot | ( | p, | |
| s | |||
| ) | (((mchunkptr)((char*)(p) + (s)))->prev_foot) |
| #define gm (&_gm_) |
| #define granularity_align | ( | S | ) |
| #define HALF_MAX_SIZE_T (MAX_SIZE_T / 2U) |
| #define HAVE_MMAP 1 |
| #define HAVE_MORECORE 1 |
| #define HAVE_MREMAP 0 |
| #define INITIAL_LOCK | ( | lk | ) | pthread_init_lock(lk) |
| #define INSECURE 0 |
| #define insert_chunk | ( | M, | |
| P, | |||
| S | |||
| ) |
| #define insert_large_chunk | ( | M, | |
| X, | |||
| S | |||
| ) |
| #define insert_small_chunk | ( | M, | |
| P, | |||
| S | |||
| ) |
| #define internal_malloc | ( | m, | |
| b | |||
| ) | dlmalloc(b) |
| #define INUSE_BITS (PINUSE_BIT|CINUSE_BIT) |
| #define is_aligned | ( | A | ) | (((size_t)((A)) & (CHUNK_ALIGN_MASK)) == 0) |
| #define is_extern_segment | ( | S | ) | ((S)->sflags & EXTERN_BIT) |
| #define is_global | ( | M | ) | ((M) == &_gm_) |
| #define is_granularity_aligned | ( | S | ) | (((size_t)(S) & (mparams.granularity - SIZE_T_ONE)) == 0) |
| #define is_initialized | ( | M | ) | ((M)->top != 0) |
| #define is_inuse | ( | p | ) | (((p)->head & INUSE_BITS) != PINUSE_BIT) |
| #define is_mmapped | ( | p | ) | (((p)->head & INUSE_BITS) == 0) |
| #define is_mmapped_segment | ( | S | ) | ((S)->sflags & USE_MMAP_BIT) |
| #define is_page_aligned | ( | S | ) | (((size_t)(S) & (mparams.page_size - SIZE_T_ONE)) == 0) |
| #define is_small | ( | s | ) | (((s) >> SMALLBIN_SHIFT) < NSMALLBINS) |
| #define leftshift_for_tree_index | ( | i | ) |
| #define M_GRANULARITY (-2) |
| #define M_MMAP_THRESHOLD (-3) |
| #define M_TRIM_THRESHOLD (-1) |
| #define MALLINFO_FIELD_TYPE size_t |
| #define MALLOC_ALIGNMENT ((size_t)8U) |
| #define MALLOC_FAILURE_ACTION errno = ENOMEM; |
| #define malloc_getpagesize ((size_t)4096U) |
| #define MALLOC_INSPECT_ALL 0 |
| #define mark_inuse_foot | ( | M, | |
| p, | |||
| s | |||
| ) |
| #define MAX_RELEASE_CHECK_RATE 4095 |
| #define MAX_REQUEST ((-MIN_CHUNK_SIZE) << 2) |
| #define MAX_SIZE_T (~(size_t)0) |
| #define MAX_SMALL_REQUEST (MAX_SMALL_SIZE - CHUNK_ALIGN_MASK - CHUNK_OVERHEAD) |
| #define MAX_SMALL_SIZE (MIN_LARGE_SIZE - SIZE_T_ONE) |
| #define MCHUNK_SIZE (sizeof(mchunk)) |
| #define mem2chunk | ( | mem | ) | ((mchunkptr)((char*)(mem) - TWO_SIZE_T_SIZES)) |
| #define MFAIL ((void*)(MAX_SIZE_T)) |
| #define MIN_CHUNK_SIZE ((MCHUNK_SIZE + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK) |
| #define MIN_LARGE_SIZE (SIZE_T_ONE << TREEBIN_SHIFT) |
| #define MIN_REQUEST (MIN_CHUNK_SIZE - CHUNK_OVERHEAD - SIZE_T_ONE) |
| #define MIN_SMALL_INDEX (small_index(MIN_CHUNK_SIZE)) |
| #define minsize_for_tree_index | ( | i | ) |
| #define MLOCK_T pthread_mutex_t |
| #define mmap_align | ( | S | ) | page_align(S) |
| #define MMAP_CHUNK_OVERHEAD (TWO_SIZE_T_SIZES) |
| #define MMAP_CLEARS 1 |
| #define MMAP_DEFAULT | ( | s | ) |
| #define MMAP_FLAGS (MAP_PRIVATE) |
| #define MMAP_FOOT_PAD (FOUR_SIZE_T_SIZES) |
| #define MMAP_PROT (PROT_READ|PROT_WRITE) |
| #define MORECORE_CONTIGUOUS 1 |
| #define MORECORE_DEFAULT sbrk |
| #define MSPACES 0 |
| #define MUNMAP_DEFAULT | ( | a, | |
| s | |||
| ) | munmap((a), (s)) |
| #define next_pinuse | ( | p | ) | ((next_chunk(p)->head) & PINUSE_BIT) |
| #define NO_MALLINFO 0 |
| #define NO_MALLOC_STATS 0 |
| #define NO_SEGMENT_TRAVERSAL 0 |
| #define NOINLINE |
| #define NSMALLBINS (32U) |
| #define NTREEBINS (32U) |
| #define ok_address | ( | M, | |
| a | |||
| ) | ((char*)(a) >= (M)->least_addr) |
| #define ok_inuse | ( | p | ) | is_inuse(p) |
| #define ok_magic | ( | M | ) | (1) |
| #define ok_next | ( | p, | |
| n | |||
| ) | ((char*)(p) < (char*)(n)) |
| #define ok_pinuse | ( | p | ) | pinuse(p) |
| #define ONLY_MSPACES 0 |
| #define overhead_for | ( | p | ) | (is_mmapped(p)? MMAP_CHUNK_OVERHEAD : CHUNK_OVERHEAD) |
| #define pad_request | ( | req | ) | (((req) + CHUNK_OVERHEAD + CHUNK_ALIGN_MASK) & ~CHUNK_ALIGN_MASK) |
| #define page_align | ( | S | ) | (((S) + (mparams.page_size - SIZE_T_ONE)) & ~(mparams.page_size - SIZE_T_ONE)) |
| #define pinuse | ( | p | ) | ((p)->head & PINUSE_BIT) |
| #define PINUSE_BIT (SIZE_T_ONE) |
| #define POSTACTION | ( | M | ) | { if (use_lock(M)) RELEASE_LOCK(&(M)->mutex); } |
| #define PREACTION | ( | M | ) | ((use_lock(M))? ACQUIRE_LOCK(&(M)->mutex) : 0) |
| #define prev_chunk | ( | p | ) | ((mchunkptr)( ((char*)(p)) - ((p)->prev_foot) )) |
| #define PROCEED_ON_ERROR 0 |
| #define RELEASE_LOCK | ( | lk | ) | pthread_mutex_unlock(lk) |
| #define RELEASE_MALLOC_GLOBAL_LOCK | ( | ) | RELEASE_LOCK(&malloc_global_mutex); |
| #define replace_dv | ( | M, | |
| P, | |||
| S | |||
| ) |
| #define request2size | ( | req | ) | (((req) < MIN_REQUEST)? MIN_CHUNK_SIZE : pad_request(req)) |
| #define RTCHECK | ( | e | ) | (e) |
| #define segment_holds | ( | S, | |
| A | |||
| ) | ((char*)(A) >= S->base && (char*)(A) < S->base + S->size) |
| #define set_flag4 | ( | p | ) | ((p)->head |= FLAG4_BIT) |
| #define set_foot | ( | p, | |
| s | |||
| ) | (((mchunkptr)((char*)(p) + (s)))->prev_foot = (s)) |
| #define set_free_with_pinuse | ( | p, | |
| s, | |||
| n | |||
| ) | (clear_pinuse(n), set_size_and_pinuse_of_free_chunk(p, s)) |
| #define set_inuse | ( | M, | |
| p, | |||
| s | |||
| ) |
| #define set_inuse_and_pinuse | ( | M, | |
| p, | |||
| s | |||
| ) |
| #define set_lock | ( | M, | |
| L | |||
| ) |
| #define set_size_and_pinuse_of_free_chunk | ( | p, | |
| s | |||
| ) | ((p)->head = (s|PINUSE_BIT), set_foot(p, s)) |
| #define set_size_and_pinuse_of_inuse_chunk | ( | M, | |
| p, | |||
| s | |||
| ) | ((p)->head = (s|PINUSE_BIT|CINUSE_BIT)) |
| #define should_trim | ( | M, | |
| s | |||
| ) | ((s) > (M)->trim_check) |
| #define SIX_SIZE_T_SIZES (FOUR_SIZE_T_SIZES+TWO_SIZE_T_SIZES) |
| #define SIZE_T_BITSIZE (sizeof(size_t) << 3) |
| #define SIZE_T_FOUR ((size_t)4) |
| #define SIZE_T_ONE ((size_t)1) |
| #define SIZE_T_SIZE (sizeof(size_t)) |
| #define SIZE_T_TWO ((size_t)2) |
| #define SIZE_T_ZERO ((size_t)0) |
| #define small_index | ( | s | ) | (bindex_t)((s) >> SMALLBIN_SHIFT) |
| #define small_index2size | ( | i | ) | ((i) << SMALLBIN_SHIFT) |
| #define SMALLBIN_SHIFT (3U) |
| #define SMALLBIN_WIDTH (SIZE_T_ONE << SMALLBIN_SHIFT) |
| #define STRUCT_MALLINFO_DECLARED 1 |
| #define SYS_ALLOC_PADDING (TOP_FOOT_SIZE + MALLOC_ALIGNMENT) |
| #define TOP_FOOT_SIZE (align_offset(chunk2mem(0))+pad_request(sizeof(struct malloc_segment))+MIN_CHUNK_SIZE) |
| #define TREEBIN_SHIFT (8U) |
| #define TRY_LOCK | ( | lk | ) | (!pthread_mutex_trylock(lk)) |
| #define TWO_SIZE_T_SIZES (SIZE_T_SIZE<<1) |
| #define unlink_chunk | ( | M, | |
| P, | |||
| S | |||
| ) |
| #define unlink_first_small_chunk | ( | M, | |
| B, | |||
| P, | |||
| I | |||
| ) |
| #define unlink_large_chunk | ( | M, | |
| X | |||
| ) |
| #define unlink_small_chunk | ( | M, | |
| P, | |||
| S | |||
| ) |
| #define USAGE_ERROR_ACTION | ( | m, | |
| p | |||
| ) | ABORT |
| #define USE_BUILTIN_FFS 0 |
| #define USE_DEV_RANDOM 0 |
| #define use_lock | ( | M | ) | ((M)->mflags & USE_LOCK_BIT) |
| #define USE_LOCK_BIT (2U) |
| #define USE_LOCKS |
| #define use_mmap | ( | M | ) | ((M)->mflags & USE_MMAP_BIT) |
| #define USE_MMAP_BIT (SIZE_T_ONE) |
Define CALL_MMAP/CALL_MUNMAP/CALL_DIRECT_MMAP
| #define use_noncontiguous | ( | M | ) | ((M)->mflags & USE_NONCONTIGUOUS_BIT) |
| #define USE_NONCONTIGUOUS_BIT (4U) |
| #define USE_SPIN_LOCKS 0 |
| typedef unsigned int bindex_t |
| typedef unsigned int binmap_t |
| typedef unsigned int flag_t |
| typedef struct malloc_chunk mchunk |
| typedef struct malloc_chunk* mchunkptr |
| typedef struct malloc_segment msegment |
| typedef struct malloc_segment* msegmentptr |
| typedef struct malloc_state* mstate |
| typedef struct malloc_chunk* sbinptr |
| typedef struct malloc_tree_chunk* tbinptr |
| typedef struct malloc_tree_chunk tchunk |
| typedef struct malloc_tree_chunk* tchunkptr |


|
static |



| DLMALLOC_EXPORT size_t dlbulk_free | ( | void ** | , |
| size_t | n_elements | ||
| ) |
| size_t dlbulk_free | ( | void * | array[], |
| size_t | nelem | ||
| ) |

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

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

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

| struct mallinfo dlmallinfo | ( | void | ) |

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

| size_t dlmalloc_footprint | ( | void | ) |
| size_t dlmalloc_footprint_limit | ( | void | ) |
| size_t dlmalloc_max_footprint | ( | void | ) |
| size_t dlmalloc_set_footprint_limit | ( | size_t | bytes | ) |
| DLMALLOC_EXPORT void dlmalloc_stats | ( | void | ) |

| int dlmalloc_trim | ( | size_t | pad | ) |

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

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

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

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

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

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

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

|
static |

|
static |

|
static |

|
static |



|
static |

|
static |


|
static |


|
static |

|
static |
|
static |

|
static |

|
static |


|
static |


|
static |

|
static |



|
static |
|
static |
|
static |
|
static |
1.8.11