malloc
[generic]

Malloc originally written by Doug Lea and ported to HelenOS. More...

Files

file  malloc.c

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 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 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)

Typedefs

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

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_

Detailed Description


Define Documentation

#define LACKS_FCNTL_H
 

Non-default helenos customizations

Definition at line 453 of file malloc.c.

#define LACKS_SYS_MMAN_H
 

Definition at line 454 of file malloc.c.

#define LACKS_SYS_PARAM_H
 

Definition at line 455 of file malloc.c.

#define HAVE_MMAP   0
 

Definition at line 481 of file malloc.c.

Referenced by sys_trim().

#define HAVE_MMAP   0
 

Definition at line 481 of file malloc.c.

#define LACKS_ERRNO_H
 

Definition at line 458 of file malloc.c.

#define MALLOC_FAILURE_ACTION
 

Definition at line 461 of file malloc.c.

Referenced by internal_memalign(), and internal_realloc().

#define MAX_SIZE_T   (~(size_t)0)
 

Definition at line 464 of file malloc.c.

Referenced by dlcalloc(), dlmalloc(), init_mparams(), and sys_trim().

#define ONLY_MSPACES   0
 

Definition at line 466 of file malloc.c.

#define MSPACES   0
 

Definition at line 467 of file malloc.c.

#define MALLOC_ALIGNMENT   ((size_t)8U)
 

Definition at line 472 of file malloc.c.

Referenced by init_mparams(), and internal_memalign().

#define FOOTERS   0
 

Definition at line 475 of file malloc.c.

#define ABORT   abort()
 

Definition at line 476 of file malloc.c.

Referenced by init_mparams().

#define ABORT_ON_ASSERT_FAILURE   1
 

Definition at line 477 of file malloc.c.

#define PROCEED_ON_ERROR   0
 

Definition at line 478 of file malloc.c.

#define USE_LOCKS   1
 

Definition at line 479 of file malloc.c.

#define INSECURE   0
 

Definition at line 480 of file malloc.c.

#define MMAP_CLEARS   1
 

Definition at line 483 of file malloc.c.

#define HAVE_MORECORE   1
 

Definition at line 485 of file malloc.c.

Referenced by sys_trim().

#define MORECORE_CONTIGUOUS   1
 

Definition at line 486 of file malloc.c.

Referenced by sys_alloc().

#define MORECORE   sbrk
 

Definition at line 487 of file malloc.c.

#define DEFAULT_GRANULARITY   (0)
 

Definition at line 488 of file malloc.c.

Referenced by init_mparams().

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

Definition at line 492 of file malloc.c.

Referenced by init_mparams().

#define DEFAULT_MMAP_THRESHOLD   MAX_SIZE_T
 

Definition at line 501 of file malloc.c.

Referenced by init_mparams().

#define USE_BUILTIN_FFS   0
 

Definition at line 505 of file malloc.c.

#define USE_DEV_RANDOM   0
 

Definition at line 508 of file malloc.c.

#define NO_MALLINFO   0
 

Definition at line 511 of file malloc.c.

#define MALLINFO_FIELD_TYPE   size_t
 

Definition at line 514 of file malloc.c.

#define M_TRIM_THRESHOLD   (-1)
 

Definition at line 524 of file malloc.c.

#define M_GRANULARITY   (-2)
 

Definition at line 525 of file malloc.c.

#define M_MMAP_THRESHOLD   (-3)
 

Definition at line 526 of file malloc.c.

#define assert  ) 
 

Definition at line 559 of file malloc.c.

#define malloc_getpagesize   ((size_t)4096U)
 

Definition at line 620 of file malloc.c.

Referenced by init_mparams().

#define SIZE_T_SIZE   (sizeof(size_t))
 

Definition at line 634 of file malloc.c.

Referenced by add_segment(), dlmalloc(), ialloc(), mmap_alloc(), and mmap_resize().

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

Definition at line 635 of file malloc.c.

Referenced by tmalloc_large().

#define SIZE_T_ZERO   ((size_t)0)
 

Definition at line 639 of file malloc.c.

#define SIZE_T_ONE   ((size_t)1)
 

Definition at line 640 of file malloc.c.

Referenced by init_mparams(), internal_mallinfo(), and sys_alloc().

#define SIZE_T_TWO   ((size_t)2)
 

Definition at line 641 of file malloc.c.

#define TWO_SIZE_T_SIZES   (SIZE_T_SIZE<<1)
 

Definition at line 642 of file malloc.c.

#define FOUR_SIZE_T_SIZES   (SIZE_T_SIZE<<2)
 

Definition at line 643 of file malloc.c.

Referenced by add_segment().

#define SIX_SIZE_T_SIZES   (FOUR_SIZE_T_SIZES+TWO_SIZE_T_SIZES)
 

Definition at line 644 of file malloc.c.

Referenced by mmap_alloc(), and mmap_resize().

#define HALF_MAX_SIZE_T   (MAX_SIZE_T / 2U)
 

Definition at line 645 of file malloc.c.

Referenced by sys_alloc(), and sys_trim().

#define CHUNK_ALIGN_MASK   (MALLOC_ALIGNMENT - SIZE_T_ONE)
 

Definition at line 648 of file malloc.c.

Referenced by add_segment(), mmap_alloc(), and mmap_resize().

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

Definition at line 651 of file malloc.c.

Referenced by add_segment(), and mmap_alloc().

#define align_offset  ) 
 

Value:

Definition at line 654 of file malloc.c.

Referenced by add_segment(), init_top(), and mmap_alloc().

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

Definition at line 668 of file malloc.c.

Referenced by sys_trim().

#define CMFAIL   ((char*)(MFAIL))
 

Definition at line 669 of file malloc.c.

Referenced by mmap_alloc(), mmap_resize(), sys_alloc(), and sys_trim().

#define IS_MMAPPED_BIT   (SIZE_T_ZERO)
 

Definition at line 672 of file malloc.c.

Referenced by dlfree(), mmap_alloc(), and mmap_resize().

#define USE_MMAP_BIT   (SIZE_T_ZERO)
 

Definition at line 673 of file malloc.c.

Referenced by init_mparams().

#define CALL_MMAP  )     MFAIL
 

Definition at line 674 of file malloc.c.

#define CALL_MUNMAP a,
 )     (-1)
 

Definition at line 675 of file malloc.c.

Referenced by dlfree(), release_unused_segments(), and sys_trim().

#define DIRECT_MMAP  )     MFAIL
 

Definition at line 676 of file malloc.c.

Referenced by mmap_alloc().

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

Definition at line 747 of file malloc.c.

Referenced by mmap_resize(), and sys_trim().

#define CALL_MORECORE  )     MORECORE(S)
 

Definition at line 751 of file malloc.c.

Referenced by sys_alloc(), and sys_trim().

#define USE_NONCONTIGUOUS_BIT   (4U)
 

Definition at line 757 of file malloc.c.

Referenced by init_mparams().

#define EXTERN_BIT   (8U)
 

Definition at line 760 of file malloc.c.

#define MLOCK_T   atomic_t
 

Definition at line 783 of file malloc.c.

#define INITIAL_LOCK  )     futex_initialize(l, 1)
 

Definition at line 784 of file malloc.c.

Referenced by init_mparams().

#define ACQUIRE_LOCK  )     ({futex_down(l);0;})
 

Definition at line 788 of file malloc.c.

#define RELEASE_LOCK  )     futex_up(l)
 

Definition at line 789 of file malloc.c.

#define USE_LOCK_BIT   (2U)
 

Definition at line 798 of file malloc.c.

Referenced by init_mparams().

 
#define ACQUIRE_MORECORE_LOCK  )     ACQUIRE_LOCK(&morecore_mutex);
 

Definition at line 805 of file malloc.c.

Referenced by sys_alloc(), and sys_trim().

 
#define RELEASE_MORECORE_LOCK  )     RELEASE_LOCK(&morecore_mutex);
 

Definition at line 806 of file malloc.c.

Referenced by sys_alloc(), and sys_trim().

 
#define ACQUIRE_MAGIC_INIT_LOCK  )     ACQUIRE_LOCK(&magic_init_mutex);
 

Definition at line 813 of file malloc.c.

Referenced by init_mparams().

 
#define RELEASE_MAGIC_INIT_LOCK  )     RELEASE_LOCK(&magic_init_mutex);
 

Definition at line 814 of file malloc.c.

Referenced by init_mparams().

#define MCHUNK_SIZE   (sizeof(mchunk))
 

Definition at line 974 of file malloc.c.

Referenced by init_mparams().

#define CHUNK_OVERHEAD   (SIZE_T_SIZE)
 

Definition at line 979 of file malloc.c.

Referenced by ialloc(), and internal_memalign().

#define MMAP_CHUNK_OVERHEAD   (TWO_SIZE_T_SIZES)
 

Definition at line 983 of file malloc.c.

#define MMAP_FOOT_PAD   (FOUR_SIZE_T_SIZES)
 

Definition at line 985 of file malloc.c.

Referenced by dlfree(), mmap_alloc(), and mmap_resize().

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

Definition at line 988 of file malloc.c.

Referenced by add_segment(), dlmalloc(), init_mparams(), internal_memalign(), internal_realloc(), prepend_alloc(), and tmalloc_small().

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

Definition at line 992 of file malloc.c.

Referenced by add_segment(), dlmalloc(), ialloc(), init_top(), internal_memalign(), internal_realloc(), mmap_alloc(), prepend_alloc(), and tmalloc_small().

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

Definition at line 993 of file malloc.c.

Referenced by dlcalloc(), dlfree(), dlmalloc_usable_size(), dlrealloc(), ialloc(), internal_memalign(), and internal_realloc().

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

Definition at line 995 of file malloc.c.

Referenced by internal_mallinfo(), internal_malloc_stats(), prepend_alloc(), and release_unused_segments().

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

Definition at line 998 of file malloc.c.

Referenced by dlmalloc(), internal_memalign(), internal_realloc(), and sys_trim().

#define MIN_REQUEST   (MIN_CHUNK_SIZE - CHUNK_OVERHEAD - SIZE_T_ONE)
 

Definition at line 999 of file malloc.c.

Referenced by dlmalloc().

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

Definition at line 1002 of file malloc.c.

Referenced by add_segment(), and dlmalloc().

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

Definition at line 1006 of file malloc.c.

Referenced by ialloc(), internal_memalign(), and internal_realloc().

#define PINUSE_BIT   (SIZE_T_ONE)
 

Definition at line 1020 of file malloc.c.

Referenced by dlfree(), dlmalloc(), init_top(), internal_realloc(), and prepend_alloc().

#define CINUSE_BIT   (SIZE_T_TWO)
 

Definition at line 1021 of file malloc.c.

Referenced by internal_memalign(), mmap_alloc(), and mmap_resize().

#define INUSE_BITS   (PINUSE_BIT|CINUSE_BIT)
 

Definition at line 1022 of file malloc.c.

Referenced by dlfree().

#define FENCEPOST_HEAD   (INUSE_BITS|SIZE_T_SIZE)
 

Definition at line 1025 of file malloc.c.

Referenced by add_segment(), internal_mallinfo(), internal_malloc_stats(), mmap_alloc(), and mmap_resize().

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

Definition at line 1028 of file malloc.c.

Referenced by dlfree(), dlmalloc_usable_size(), internal_mallinfo(), internal_malloc_stats(), prepend_alloc(), and release_unused_segments().

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

Definition at line 1029 of file malloc.c.

Referenced by dlfree(), and prepend_alloc().

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

Definition at line 1030 of file malloc.c.

Referenced by dlfree(), dlmalloc(), dlmalloc_usable_size(), ialloc(), internal_mallinfo(), internal_malloc_stats(), internal_memalign(), internal_realloc(), mmap_resize(), prepend_alloc(), release_unused_segments(), tmalloc_large(), and tmalloc_small().

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

Definition at line 1032 of file malloc.c.

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

Definition at line 1033 of file malloc.c.

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

Definition at line 1036 of file malloc.c.

Referenced by add_segment(), dlfree(), dlmalloc(), ialloc(), init_top(), internal_memalign(), internal_realloc(), mmap_alloc(), mmap_resize(), prepend_alloc(), and tmalloc_small().

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

Definition at line 1037 of file malloc.c.

Referenced by dlfree().

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

Definition at line 1040 of file malloc.c.

Referenced by internal_mallinfo(), and internal_malloc_stats().

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

Definition at line 1041 of file malloc.c.

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

Definition at line 1044 of file malloc.c.

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

Definition at line 1047 of file malloc.c.

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

Definition at line 1048 of file malloc.c.

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

Definition at line 1051 of file malloc.c.

Referenced by dlfree(), dlmalloc(), prepend_alloc(), and tmalloc_small().

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

Definition at line 1055 of file malloc.c.

Referenced by dlfree(), and prepend_alloc().

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

Definition at line 1058 of file malloc.c.

Referenced by ialloc(), internal_memalign(), and internal_realloc().

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

Definition at line 1062 of file malloc.c.

Referenced by dlmalloc_usable_size(), and internal_realloc().

#define calloc_must_clear  )     (!is_mmapped(p))
 

Definition at line 1067 of file malloc.c.

Referenced by dlcalloc().

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

Definition at line 1180 of file malloc.c.

Referenced by tmalloc_small().

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

Definition at line 1246 of file malloc.c.

Referenced by release_unused_segments(), and sys_trim().

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

Definition at line 1247 of file malloc.c.

Referenced by release_unused_segments(), and sys_trim().

#define NSMALLBINS   (32U)
 

Definition at line 1328 of file malloc.c.

#define NTREEBINS   (32U)
 

Definition at line 1329 of file malloc.c.

#define SMALLBIN_SHIFT   (3U)
 

Definition at line 1330 of file malloc.c.

#define SMALLBIN_WIDTH   (SIZE_T_ONE << SMALLBIN_SHIFT)
 

Definition at line 1331 of file malloc.c.

#define TREEBIN_SHIFT   (8U)
 

Definition at line 1332 of file malloc.c.

#define MIN_LARGE_SIZE   (SIZE_T_ONE << TREEBIN_SHIFT)
 

Definition at line 1333 of file malloc.c.

#define MAX_SMALL_SIZE   (MIN_LARGE_SIZE - SIZE_T_ONE)
 

Definition at line 1334 of file malloc.c.

#define MAX_SMALL_REQUEST   (MAX_SMALL_SIZE - CHUNK_ALIGN_MASK - CHUNK_OVERHEAD)
 

Definition at line 1335 of file malloc.c.

Referenced by dlmalloc().

#define gm   (&_gm_)
 

Definition at line 1381 of file malloc.c.

Referenced by dlindependent_calloc(), dlindependent_comalloc(), dlmallinfo(), dlmalloc(), dlmalloc_footprint(), dlmalloc_max_footprint(), dlmalloc_stats(), dlmalloc_trim(), dlmemalign(), dlrealloc(), and init_mparams().

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

Definition at line 1382 of file malloc.c.

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

Definition at line 1383 of file malloc.c.

Referenced by internal_mallinfo(), internal_malloc_stats(), and sys_trim().

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

Definition at line 1389 of file malloc.c.

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

Definition at line 1390 of file malloc.c.

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

Definition at line 1391 of file malloc.c.

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

Definition at line 1393 of file malloc.c.

Referenced by ialloc(), and sys_alloc().

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

Definition at line 1394 of file malloc.c.

Referenced by ialloc().

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

Definition at line 1395 of file malloc.c.

Referenced by ialloc().

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

Definition at line 1397 of file malloc.c.

Referenced by sys_alloc().

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

Definition at line 1398 of file malloc.c.

Referenced by sys_alloc().

#define set_lock M,
 ) 
 

Value:

((M)->mflags = (L)?\
  ((M)->mflags | USE_LOCK_BIT) :\
  ((M)->mflags & ~USE_LOCK_BIT))

Definition at line 1400 of file malloc.c.

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

Definition at line 1406 of file malloc.c.

Referenced by sys_alloc().

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

Definition at line 1410 of file malloc.c.

Referenced by mmap_alloc(), mmap_resize(), and sys_alloc().

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

Definition at line 1413 of file malloc.c.

Referenced by sys_alloc().

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

Definition at line 1415 of file malloc.c.

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

Definition at line 1419 of file malloc.c.

Referenced by internal_mallinfo(), internal_malloc_stats(), and release_unused_segments().

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

Definition at line 1445 of file malloc.c.

Referenced by dlfree().

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

Definition at line 1455 of file malloc.c.

Referenced by add_segment(), init_top(), internal_mallinfo(), internal_malloc_stats(), release_unused_segments(), sys_alloc(), and sys_trim().

 
#define GLOBALLY_INITIALIZE  )     (mparams.page_size == 0 && init_mparams())
 

Definition at line 1470 of file malloc.c.

#define PREACTION  )     ((GLOBALLY_INITIALIZE() || use_lock(M))? ACQUIRE_LOCK(&(M)->mutex) : 0)
 

Definition at line 1472 of file malloc.c.

Referenced by dlfree(), dlmalloc(), dlmalloc_trim(), ialloc(), internal_mallinfo(), internal_malloc_stats(), internal_memalign(), and internal_realloc().

#define POSTACTION  )     { if (use_lock(M)) RELEASE_LOCK(&(M)->mutex); }
 

Definition at line 1473 of file malloc.c.

Referenced by dlfree(), dlmalloc(), dlmalloc_trim(), internal_mallinfo(), internal_malloc_stats(), internal_memalign(), and internal_realloc().

#define CORRUPTION_ERROR_ACTION  )     ABORT
 

Definition at line 1508 of file malloc.c.

Referenced by tmalloc_small().

#define USAGE_ERROR_ACTION m,
 )     ABORT
 

Definition at line 1512 of file malloc.c.

Referenced by dlfree(), dlrealloc(), and internal_realloc().

#define check_free_chunk M,
 ) 
 

Definition at line 1521 of file malloc.c.

Referenced by dlfree(), and prepend_alloc().

#define check_inuse_chunk M,
 ) 
 

Definition at line 1522 of file malloc.c.

Referenced by dlfree(), internal_memalign(), and internal_realloc().

#define check_malloced_chunk M,
P,
 ) 
 

Definition at line 1523 of file malloc.c.

Referenced by dlmalloc(), and prepend_alloc().

#define check_mmapped_chunk M,
 ) 
 

Definition at line 1524 of file malloc.c.

Referenced by mmap_alloc(), and mmap_resize().

#define check_malloc_state  ) 
 

Definition at line 1525 of file malloc.c.

Referenced by internal_mallinfo(), and internal_malloc_stats().

#define check_top_chunk M,
 ) 
 

Definition at line 1526 of file malloc.c.

Referenced by dlmalloc(), prepend_alloc(), and sys_trim().

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

Definition at line 1552 of file malloc.c.

Referenced by mmap_resize().

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

Definition at line 1553 of file malloc.c.

Referenced by dlmalloc().

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

Definition at line 1554 of file malloc.c.

Referenced by dlmalloc().

#define MIN_SMALL_INDEX   (small_index(MIN_CHUNK_SIZE))
 

Definition at line 1555 of file malloc.c.

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

Definition at line 1558 of file malloc.c.

Referenced by dlmalloc(), and init_bins().

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

Definition at line 1559 of file malloc.c.

Referenced by tmalloc_large(), and tmalloc_small().

#define compute_tree_index S,
 ) 
 

Value:

{\
  size_t X = S >> TREEBIN_SHIFT;\
  if (X == 0)\
    I = 0;\
  else if (X > 0xFFFF)\
    I = NTREEBINS-1;\
  else {\
    unsigned int Y = (unsigned int)X;\
    unsigned int N = ((Y - 0x100) >> 16) & 8;\
    unsigned int K = (((Y <<= N) - 0x1000) >> 16) & 4;\
    N += K;\
    N += K = (((Y <<= K) - 0x4000) >> 16) & 2;\
    K = 14 - N + ((Y <<= K) >> 15);\
    I = (K << 1) + ((S >> (K + (TREEBIN_SHIFT-1)) & 1));\
  }\
}

Definition at line 1577 of file malloc.c.

Referenced by tmalloc_large().

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

Definition at line 1597 of file malloc.c.

#define leftshift_for_tree_index  ) 
 

Value:

((i == NTREEBINS-1)? 0 : \
    ((SIZE_T_BITSIZE-SIZE_T_ONE) - (((i) >> 1) + TREEBIN_SHIFT - 2)))

Definition at line 1601 of file malloc.c.

Referenced by tmalloc_large().

#define minsize_for_tree_index  ) 
 

Value:

((SIZE_T_ONE << (((i) >> 1) + TREEBIN_SHIFT)) |  \
   (((size_t)((i) & SIZE_T_ONE)) << (((i) >> 1) + TREEBIN_SHIFT - 1)))

Definition at line 1606 of file malloc.c.

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

Definition at line 1614 of file malloc.c.

Referenced by dlmalloc().

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

Definition at line 1617 of file malloc.c.

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

Definition at line 1618 of file malloc.c.

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

Definition at line 1619 of file malloc.c.

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

Definition at line 1621 of file malloc.c.

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

Definition at line 1622 of file malloc.c.

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

Definition at line 1623 of file malloc.c.

#define compute_bit2idx X,
 ) 
 

Value:

{\
  unsigned int Y = X - 1;\
  unsigned int K = Y >> (16-4) & 16;\
  unsigned int N = K;        Y >>= K;\
  N += K = Y >> (8-3) &  8;  Y >>= K;\
  N += K = Y >> (4-2) &  4;  Y >>= K;\
  N += K = Y >> (2-1) &  2;  Y >>= K;\
  N += K = Y >> (1-0) &  1;  Y >>= K;\
  I = (bindex_t)(N + Y);\
}

Definition at line 1640 of file malloc.c.

Referenced by dlmalloc(), and tmalloc_small().

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

Definition at line 1655 of file malloc.c.

Referenced by dlmalloc(), and tmalloc_small().

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

Definition at line 1658 of file malloc.c.

Referenced by dlmalloc().

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

Definition at line 1661 of file malloc.c.

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

Definition at line 1694 of file malloc.c.

Referenced by dlfree(), internal_realloc(), and tmalloc_small().

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

Definition at line 1696 of file malloc.c.

Referenced by dlfree(), internal_realloc(), and tmalloc_small().

#define ok_cinuse  )     cinuse(p)
 

Definition at line 1698 of file malloc.c.

Referenced by dlfree(), and internal_realloc().

#define ok_pinuse  )     pinuse(p)
 

Definition at line 1700 of file malloc.c.

Referenced by dlfree(), and internal_realloc().

#define ok_magic  )     (1)
 

Definition at line 1713 of file malloc.c.

Referenced by dlfree(), and dlrealloc().

#define RTCHECK  )     (e)
 

Definition at line 1722 of file malloc.c.

Referenced by dlfree(), internal_realloc(), and tmalloc_small().

#define mark_inuse_foot M,
p,
 ) 
 

Definition at line 1732 of file malloc.c.

Referenced by mmap_alloc(), and mmap_resize().

#define set_inuse M,
p,
 ) 
 

Value:

((p)->head = (((p)->head & PINUSE_BIT)|s|CINUSE_BIT),\
  ((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT)

Definition at line 1735 of file malloc.c.

Referenced by internal_memalign(), and internal_realloc().

#define set_inuse_and_pinuse M,
p,
 ) 
 

Value:

((p)->head = (s|PINUSE_BIT|CINUSE_BIT),\
  ((mchunkptr)(((char*)(p)) + (s)))->head |= PINUSE_BIT)

Definition at line 1740 of file malloc.c.

Referenced by dlmalloc(), and tmalloc_small().

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

Definition at line 1745 of file malloc.c.

Referenced by add_segment(), dlmalloc(), ialloc(), prepend_alloc(), and tmalloc_small().

#define insert_small_chunk M,
P,
 ) 
 

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;\
}

Definition at line 2227 of file malloc.c.

#define unlink_small_chunk M,
P,
 ) 
 

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 2246 of file malloc.c.

#define unlink_first_small_chunk M,
B,
P,
 ) 
 

Value:

{\
  mchunkptr F = P->fd;\
  assert(P != B);\
  assert(P != F);\
  assert(chunksize(P) == small_index2size(I));\
  if (B == F)\
    clear_smallmap(M, I);\
  else if (RTCHECK(ok_address(M, F))) {\
    B->fd = F;\
    F->bk = B;\
  }\
  else {\
    CORRUPTION_ERROR_ACTION(M);\
  }\
}

Definition at line 2266 of file malloc.c.

Referenced by dlmalloc().

#define replace_dv M,
P,
 ) 
 

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 2284 of file malloc.c.

Referenced by dlmalloc(), and tmalloc_small().

#define insert_large_chunk M,
X,
 ) 
 

Definition at line 2298 of file malloc.c.

Referenced by release_unused_segments().

#define unlink_large_chunk M,
 ) 
 

Definition at line 2366 of file malloc.c.

Referenced by release_unused_segments(), and tmalloc_small().

#define insert_chunk M,
P,
 ) 
 

Value:

if (is_small(S)) insert_small_chunk(M, P, S)\
  else { tchunkptr TP = (tchunkptr)(P); insert_large_chunk(M, TP, S); }

Definition at line 2439 of file malloc.c.

Referenced by dlfree(), and prepend_alloc().

#define unlink_chunk M,
P,
 ) 
 

Value:

if (is_small(S)) unlink_small_chunk(M, P, S)\
  else { tchunkptr TP = (tchunkptr)(P); unlink_large_chunk(M, TP); }

Definition at line 2443 of file malloc.c.

Referenced by dlfree(), and prepend_alloc().

#define internal_malloc m,
 )     dlmalloc(b)
 

Definition at line 2460 of file malloc.c.

Referenced by ialloc(), internal_memalign(), and internal_realloc().

#define internal_free m,
mem   )     dlfree(mem)
 

Definition at line 2461 of file malloc.c.

Referenced by internal_memalign(), and internal_realloc().


Typedef Documentation

typedef struct malloc_chunk mchunk
 

Definition at line 965 of file malloc.c.

typedef struct malloc_chunk* mchunkptr
 

Definition at line 966 of file malloc.c.

typedef struct malloc_chunk* sbinptr
 

Definition at line 967 of file malloc.c.

typedef unsigned int bindex_t
 

Definition at line 968 of file malloc.c.

typedef unsigned int binmap_t
 

Definition at line 969 of file malloc.c.

typedef unsigned int flag_t
 

Definition at line 970 of file malloc.c.

typedef struct malloc_tree_chunk tchunk
 

Definition at line 1175 of file malloc.c.

typedef struct malloc_tree_chunk* tchunkptr
 

Definition at line 1176 of file malloc.c.

typedef struct malloc_tree_chunk* tbinptr
 

Definition at line 1177 of file malloc.c.

typedef struct malloc_segment msegment
 

Definition at line 1249 of file malloc.c.

typedef struct malloc_segment* msegmentptr
 

Definition at line 1250 of file malloc.c.

typedef struct malloc_state* mstate
 

Definition at line 1358 of file malloc.c.


Function Documentation

static msegmentptr segment_holding mstate  m,
char *  addr
[static]
 

Definition at line 1423 of file malloc.c.

References malloc_segment::base, malloc_segment::next, malloc_state::seg, and malloc_segment::size.

Referenced by add_segment(), sys_alloc(), and sys_trim().

static int has_segment_link mstate  m,
msegmentptr  ss
[static]
 

Definition at line 1434 of file malloc.c.

References malloc_segment::base, malloc_segment::next, malloc_state::seg, and malloc_segment::size.

Referenced by sys_trim().

static int init_mparams void   )  [static]
 

Definition at line 1777 of file malloc.c.

References ABORT, ACQUIRE_MAGIC_INIT_LOCK, DEFAULT_GRANULARITY, malloc_params::default_mflags, DEFAULT_MMAP_THRESHOLD, DEFAULT_TRIM_THRESHOLD, gm, malloc_params::granularity, INITIAL_LOCK, malloc_params::magic, MALLOC_ALIGNMENT, malloc_getpagesize, MAX_SIZE_T, MCHUNK_SIZE, MIN_CHUNK_SIZE, malloc_params::mmap_threshold, mparams, open(), malloc_params::page_size, read(), RELEASE_MAGIC_INIT_LOCK, SIZE_T_ONE, malloc_params::trim_threshold, USE_LOCK_BIT, USE_MMAP_BIT, and USE_NONCONTIGUOUS_BIT.

Referenced by change_mparam(), dlpvalloc(), dlvalloc(), and sys_alloc().

Here is the call graph for this function:

static int change_mparam int  param_number,
int  value
[static]
 

Definition at line 1853 of file malloc.c.

References malloc_params::granularity, init_mparams(), M_GRANULARITY, M_MMAP_THRESHOLD, M_TRIM_THRESHOLD, malloc_params::mmap_threshold, mparams, malloc_params::page_size, and malloc_params::trim_threshold.

Referenced by dlmallopt().

Here is the call graph for this function:

static struct mallinfo internal_mallinfo mstate  m  )  [static]
 

Definition at line 2146 of file malloc.c.

References align_as_chunk, mallinfo::arena, malloc_segment::base, check_malloc_state, chunksize, cinuse, FENCEPOST_HEAD, mallinfo::fordblks, mallinfo::hblkhd, malloc_chunk::head, is_initialized, mallinfo::keepcost, malloc_segment::next, next_chunk, mallinfo::ordblks, POSTACTION, PREACTION, segment_holds, SIZE_T_ONE, TOP_FOOT_SIZE, mallinfo::uordblks, and mallinfo::usmblks.

Referenced by dlmallinfo().

static void internal_malloc_stats mstate  m  )  [static]
 

Definition at line 2185 of file malloc.c.

References align_as_chunk, malloc_segment::base, check_malloc_state, chunksize, cinuse, FENCEPOST_HEAD, malloc_state::footprint, fprintf, malloc_chunk::head, is_initialized, malloc_state::max_footprint, malloc_segment::next, next_chunk, POSTACTION, PREACTION, malloc_state::seg, segment_holds, malloc_state::top, TOP_FOOT_SIZE, and malloc_state::topsize.

Referenced by dlmalloc_stats().

static void* mmap_alloc mstate  m,
size_t  nb
[static]
 

Definition at line 2478 of file malloc.c.

References align_offset, assert, check_mmapped_chunk, chunk2mem, CHUNK_ALIGN_MASK, chunk_plus_offset, CINUSE_BIT, CMFAIL, DIRECT_MMAP, FENCEPOST_HEAD, malloc_state::footprint, granularity_align, is_aligned, IS_MMAPPED_BIT, malloc_state::least_addr, mark_inuse_foot, malloc_state::max_footprint, MMAP_FOOT_PAD, malloc_chunk::prev_foot, SIX_SIZE_T_SIZES, and SIZE_T_SIZE.

Referenced by sys_alloc().

static mchunkptr mmap_resize mstate  m,
mchunkptr  oldp,
size_t  nb
[static]
 

Definition at line 2505 of file malloc.c.

References CALL_MREMAP, check_mmapped_chunk, CHUNK_ALIGN_MASK, chunk_plus_offset, chunksize, CINUSE_BIT, CMFAIL, FENCEPOST_HEAD, malloc_state::footprint, malloc_params::granularity, granularity_align, malloc_chunk::head, IS_MMAPPED_BIT, is_small, malloc_state::least_addr, mark_inuse_foot, malloc_state::max_footprint, MMAP_FOOT_PAD, mparams, malloc_chunk::prev_foot, SIX_SIZE_T_SIZES, and SIZE_T_SIZE.

Referenced by internal_realloc().

static void init_top mstate  m,
mchunkptr  p,
size_t  psize
[static]
 

Definition at line 2542 of file malloc.c.

References align_offset, chunk2mem, chunk_plus_offset, malloc_chunk::head, mparams, PINUSE_BIT, malloc_state::top, TOP_FOOT_SIZE, malloc_state::topsize, malloc_state::trim_check, and malloc_params::trim_threshold.

Referenced by add_segment(), and sys_trim().

static void init_bins mstate  m  )  [static]
 

Definition at line 2557 of file malloc.c.

References smallbin_at.

static void* prepend_alloc mstate  m,
char *  newbase,
char *  oldbase,
size_t  nb
[static]
 

Definition at line 2586 of file malloc.c.

References align_as_chunk, assert, check_free_chunk, check_malloced_chunk, check_top_chunk, chunk2mem, chunk_plus_offset, chunksize, cinuse, malloc_state::dv, malloc_state::dvsize, malloc_chunk::head, insert_chunk, MIN_CHUNK_SIZE, pinuse, PINUSE_BIT, set_free_with_pinuse, set_size_and_pinuse_of_free_chunk, set_size_and_pinuse_of_inuse_chunk, malloc_state::top, malloc_state::topsize, and unlink_chunk.

static void add_segment mstate  m,
char *  tbase,
size_t  tsize,
flag_t  mmapped
[static]
 

Definition at line 2629 of file malloc.c.

References align_offset, assert, malloc_segment::base, chunk2mem, CHUNK_ALIGN_MASK, chunk_plus_offset, FENCEPOST_HEAD, FOUR_SIZE_T_SIZES, malloc_chunk::head, init_top(), is_aligned, MIN_CHUNK_SIZE, malloc_segment::next, pad_request, malloc_state::seg, segment_holding(), set_size_and_pinuse_of_inuse_chunk, malloc_segment::sflags, malloc_segment::size, SIZE_T_SIZE, malloc_state::top, and TOP_FOOT_SIZE.

Here is the call graph for this function:

static void* sys_alloc mstate  m,
size_t  nb
[static]
 

Definition at line 2684 of file malloc.c.

References ACQUIRE_MORECORE_LOCK, CALL_MORECORE, CMFAIL, disable_contiguous, granularity_align, HALF_MAX_SIZE_T, init_mparams(), is_page_aligned, mmap_alloc(), malloc_params::mmap_threshold, MORECORE_CONTIGUOUS, mparams, page_align, RELEASE_MORECORE_LOCK, segment_holding(), SIZE_T_ONE, malloc_state::top, TOP_FOOT_SIZE, malloc_state::topsize, use_mmap, and use_noncontiguous.

Referenced by dlmalloc().

Here is the call graph for this function:

static size_t release_unused_segments mstate  m  )  [static]
 

Definition at line 2876 of file malloc.c.

References align_as_chunk, assert, malloc_segment::base, CALL_MUNMAP, chunksize, cinuse, malloc_state::dv, malloc_state::dvsize, malloc_state::footprint, insert_large_chunk, is_extern_segment, is_mmapped_segment, malloc_segment::next, malloc_state::seg, segment_holds, malloc_segment::size, TOP_FOOT_SIZE, and unlink_large_chunk.

Referenced by sys_trim().

static int sys_trim mstate  m,
size_t  pad
[static]
 

Definition at line 2916 of file malloc.c.

References ACQUIRE_MORECORE_LOCK, CALL_MORECORE, CALL_MREMAP, CALL_MUNMAP, check_top_chunk, CMFAIL, malloc_state::footprint, malloc_params::granularity, HALF_MAX_SIZE_T, has_segment_link(), HAVE_MMAP, HAVE_MORECORE, init_top(), is_extern_segment, is_initialized, is_mmapped_segment, MAX_REQUEST, MAX_SIZE_T, MFAIL, mparams, RELEASE_MORECORE_LOCK, release_unused_segments(), segment_holding(), malloc_segment::size, malloc_state::top, TOP_FOOT_SIZE, malloc_state::topsize, and malloc_state::trim_check.

Referenced by dlfree(), and dlmalloc_trim().

Here is the call graph for this function:

static void* tmalloc_large mstate  m,
size_t  nb
[static]
 

Definition at line 2981 of file malloc.c.

References malloc_tree_chunk::child, chunksize, compute_tree_index, leftshift_for_tree_index, SIZE_T_BITSIZE, and treebin_at.

Referenced by dlmalloc().

static void* tmalloc_small mstate  m,
size_t  nb
[static]
 

Definition at line 3054 of file malloc.c.

References assert, chunk2mem, chunk_plus_offset, chunksize, compute_bit2idx, CORRUPTION_ERROR_ACTION, least_bit, leftmost_child, MIN_CHUNK_SIZE, ok_address, ok_next, replace_dv, RTCHECK, set_inuse_and_pinuse, set_size_and_pinuse_of_free_chunk, set_size_and_pinuse_of_inuse_chunk, treebin_at, malloc_state::treemap, and unlink_large_chunk.

Referenced by dlmalloc().

static void* internal_realloc mstate  m,
void *  oldmem,
size_t  bytes
[static]
 

Definition at line 3094 of file malloc.c.

References check_inuse_chunk, chunk2mem, chunk_plus_offset, chunksize, malloc_chunk::head, internal_free, internal_malloc, is_mmapped, MALLOC_FAILURE_ACTION, MAX_REQUEST, mem2chunk, memcpy(), MIN_CHUNK_SIZE, mmap_resize(), ok_address, ok_cinuse, ok_next, ok_pinuse, overhead_for, PINUSE_BIT, POSTACTION, PREACTION, request2size, RTCHECK, set_inuse, malloc_state::top, malloc_state::topsize, and USAGE_ERROR_ACTION.

Referenced by dlrealloc().

Here is the call graph for this function:

static void* internal_memalign mstate  m,
size_t  alignment,
size_t  bytes
[static]
 

Definition at line 3165 of file malloc.c.

References assert, check_inuse_chunk, chunk2mem, CHUNK_OVERHEAD, chunk_plus_offset, chunksize, CINUSE_BIT, malloc_chunk::head, internal_free, internal_malloc, is_mmapped, MALLOC_ALIGNMENT, MALLOC_FAILURE_ACTION, MAX_REQUEST, mem2chunk, MIN_CHUNK_SIZE, POSTACTION, PREACTION, malloc_chunk::prev_foot, request2size, and set_inuse.

Referenced by dlmemalign().

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

Definition at line 3252 of file malloc.c.

References assert, chunk2mem, CHUNK_OVERHEAD, chunk_plus_offset, chunksize, disable_mmap, enable_mmap, internal_malloc, is_mmapped, mem2chunk, memset(), PREACTION, request2size, set_size_and_pinuse_of_inuse_chunk, SIZE_T_SIZE, and use_mmap.

Referenced by dlindependent_calloc(), and dlindependent_comalloc().

Here is the call graph for this function:

void* dlmalloc size_t  bytes  ) 
 

Definition at line 3383 of file malloc.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, sys_alloc(), tmalloc_large(), tmalloc_small(), and unlink_first_small_chunk.

Here is the call graph for this function:

void dlfree void *  mem  ) 
 

Definition at line 3515 of file malloc.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, sys_trim(), unlink_chunk, and USAGE_ERROR_ACTION.

Here is the call graph for this function:

void* dlcalloc size_t  n_elements,
size_t  elem_size
 

Definition at line 3615 of file malloc.c.

References calloc_must_clear, dlmalloc, MAX_SIZE_T, mem2chunk, and memset().

Here is the call graph for this function:

void* dlrealloc void *  oldmem,
size_t  bytes
 

Definition at line 3630 of file malloc.c.

References dlfree, dlmalloc, gm, internal_realloc(), mem2chunk, ok_magic, and USAGE_ERROR_ACTION.

Here is the call graph for this function:

void* dlmemalign size_t  alignment,
size_t  bytes
 

Definition at line 3653 of file malloc.c.

References gm, and internal_memalign().

Here is the call graph for this function:

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

Definition at line 3657 of file malloc.c.

References gm, and ialloc().

Here is the call graph for this function:

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

Definition at line 3663 of file malloc.c.

References gm, and ialloc().

Here is the call graph for this function:

void* dlvalloc size_t  bytes  ) 
 

Definition at line 3668 of file malloc.c.

References dlmemalign, init_mparams(), mparams, and malloc_params::page_size.

Here is the call graph for this function:

void* dlpvalloc size_t  bytes  ) 
 

Definition at line 3675 of file malloc.c.

References dlmemalign, init_mparams(), mparams, and malloc_params::page_size.

Here is the call graph for this function:

int dlmalloc_trim size_t  pad  ) 
 

Definition at line 3682 of file malloc.c.

References gm, POSTACTION, PREACTION, and sys_trim().

Here is the call graph for this function:

size_t dlmalloc_footprint void   ) 
 

Definition at line 3691 of file malloc.c.

References gm.

size_t dlmalloc_max_footprint void   ) 
 

Definition at line 3695 of file malloc.c.

References gm.

struct mallinfo dlmallinfo void   ) 
 

Definition at line 3700 of file malloc.c.

References gm, and internal_mallinfo().

Here is the call graph for this function:

void dlmalloc_stats void   ) 
 

Definition at line 3705 of file malloc.c.

References gm, and internal_malloc_stats().

Here is the call graph for this function:

size_t dlmalloc_usable_size void *  mem  ) 
 

Definition at line 3709 of file malloc.c.

References chunksize, cinuse, mem2chunk, and overhead_for.

int dlmallopt int  param_number,
int  value
 

Definition at line 3718 of file malloc.c.

References change_mparam().

Here is the call graph for this function:


Variable Documentation

MLOCK_T morecore_mutex = FUTEX_INITIALIZER [static]
 

Definition at line 792 of file malloc.c.

MLOCK_T magic_init_mutex = FUTEX_INITIALIZER [static]
 

Definition at line 795 of file malloc.c.

struct malloc_params mparams [static]
 

Definition at line 1377 of file malloc.c.

Referenced by change_mparam(), dlpvalloc(), dlvalloc(), init_mparams(), init_top(), mmap_resize(), sys_alloc(), and sys_trim().

struct malloc_state _gm_ [static]
 

Definition at line 1380 of file malloc.c.


Generated on Sun Jun 18 18:04:56 2006 for HelenOS Userspace (ia64) by  doxygen 1.4.6