libgpac
Documentation of the core library of GPAC
|
#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 <sys/param.h>
Data Structures | |
struct | mallinfo |
struct | sbinptr |
struct | tbinptr |
struct | msegmentptr |
struct | mstate |
struct | malloc_params |
Macros | |
#define | USE_LOCK 1 |
#define | DLMALLOC_VERSION 20804 |
#define | SPIN_LOCKS_AVAILABLE 0 |
#define | MAX_SIZE_T (~(size_t)0) |
#define | ONLY_MSPACES 0 /* define to a value */ |
#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 | USE_SPIN_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_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_SEGMENT_TRAVERSAL 0 |
#define | M_TRIM_THRESHOLD (-1) |
#define | M_GRANULARITY (-2) |
#define | M_MMAP_THRESHOLD (-3) |
#define | STRUCT_MALLINFO_DECLARED 1 |
#define | NOINLINE |
#define | FORCEINLINE |
#define | USE_DL_PREFIX |
#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 | USE_LOCK_BIT (0U) |
#define | INITIAL_LOCK(l) |
#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 | 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 | 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) (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 | 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 unsigned int | bindex_t |
typedef unsigned int | binmap_t |
typedef unsigned int | flag_t |
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) |
size_t | dlmalloc_footprint (void) |
size_t | dlmalloc_max_footprint (void) |
struct mallinfo | dlmallinfo (void) |
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) |
void | dlmalloc_stats (void) |
size_t | dlmalloc_usable_size (void *) |
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 ** | dlindependent_calloc (size_t n_elements, size_t elem_size, void *chunks[]) |
void ** | dlindependent_comalloc (size_t n_elements, size_t sizes[], void *chunks[]) |
Variables | |
static int | dev_zero_fd = -1 |
static struct malloc_params | mparams |
static struct malloc_state | _gm_ |
struct mallinfo |
Data Fields | ||
---|---|---|
MALLINFO_FIELD_TYPE | arena | |
MALLINFO_FIELD_TYPE | ordblks | |
MALLINFO_FIELD_TYPE | smblks | |
MALLINFO_FIELD_TYPE | hblks | |
MALLINFO_FIELD_TYPE | hblkhd | |
MALLINFO_FIELD_TYPE | usmblks | |
MALLINFO_FIELD_TYPE | fsmblks | |
MALLINFO_FIELD_TYPE | uordblks | |
MALLINFO_FIELD_TYPE | fordblks | |
MALLINFO_FIELD_TYPE | keepcost |
struct malloc_chunk |
Data Fields | ||
---|---|---|
size_t | prev_foot | |
size_t | head | |
struct malloc_chunk * | fd | |
struct malloc_chunk * | bk |
struct malloc_tree_chunk |
Data Fields | ||
---|---|---|
size_t | prev_foot | |
size_t | head | |
struct malloc_tree_chunk * | fd | |
struct malloc_tree_chunk * | bk | |
struct malloc_tree_chunk * | child[2] | |
struct malloc_tree_chunk * | parent | |
bindex_t | index |
struct malloc_segment |
Data Fields | ||
---|---|---|
char * | base | |
size_t | size | |
struct malloc_segment * | next | |
flag_t | sflags |
struct malloc_state |
Data Fields | ||
---|---|---|
binmap_t | smallmap | |
binmap_t | treemap | |
size_t | dvsize | |
size_t | topsize | |
char * | least_addr | |
mchunkptr | dv | |
mchunkptr | top | |
size_t | trim_check | |
size_t | release_checks | |
size_t | magic | |
mchunkptr | smallbins[(NSMALLBINS+1) *2] | |
tbinptr | treebins[NTREEBINS] | |
size_t | footprint | |
size_t | max_footprint | |
flag_t | mflags | |
msegment | seg | |
void * | extp | |
size_t | exts |
struct malloc_params |
Data Fields | ||
---|---|---|
volatile size_t | magic | |
size_t | page_size | |
size_t | granularity | |
size_t | mmap_threshold | |
size_t | trim_threshold | |
flag_t | default_mflags |
#define USE_LOCK 1 |
#define DLMALLOC_VERSION 20804 |
#define SPIN_LOCKS_AVAILABLE 0 |
#define MAX_SIZE_T (~(size_t)0) |
#define ONLY_MSPACES 0 /* define to a value */ |
#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 USE_SPIN_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_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_SEGMENT_TRAVERSAL 0 |
#define M_TRIM_THRESHOLD (-1) |
#define M_GRANULARITY (-2) |
#define M_MMAP_THRESHOLD (-3) |
#define STRUCT_MALLINFO_DECLARED 1 |
#define NOINLINE |
#define FORCEINLINE |
#define USE_DL_PREFIX |
#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 CALL_MORECORE
#define USE_MMAP_BIT (SIZE_T_ONE) |
Define CALL_MMAP/CALL_MUNMAP/CALL_DIRECT_MMAP
#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 CALL_MREMAP
#define USE_NONCONTIGUOUS_BIT (4U) |
#define EXTERN_BIT (8U) |
#define USE_LOCK_BIT (0U) |
#define INITIAL_LOCK | ( | l | ) |
#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 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 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 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 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 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_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 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 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_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 unlink_large_chunk | ( | M, | |
X | |||
) |
#define internal_malloc | ( | m, | |
b | |||
) | dlmalloc(b) |
#define internal_free | ( | m, | |
mem | |||
) | dlfree(mem) |
#define fm gm |
typedef unsigned int bindex_t |
typedef unsigned int binmap_t |
typedef unsigned int flag_t |
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 * dlvalloc | ( | size_t | bytes | ) |
int dlmallopt | ( | int | param_number, |
int | value | ||
) |
size_t dlmalloc_footprint | ( | void | ) |
size_t dlmalloc_max_footprint | ( | void | ) |
struct mallinfo dlmallinfo | ( | void | ) |
void** dlindependent_calloc | ( | size_t | , |
size_t | , | ||
void ** | |||
) |
void** dlindependent_comalloc | ( | size_t | , |
size_t * | , | ||
void ** | |||
) |
void * dlpvalloc | ( | size_t | bytes | ) |
int dlmalloc_trim | ( | size_t | pad | ) |
void dlmalloc_stats | ( | void | ) |
size_t dlmalloc_usable_size | ( | void * | mem | ) |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
|
static |
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[] | ||
) |
|
static |
|
static |
|
static |