structmalloc_state{/* Serialize access. */__libc_lock_define(, mutex);//定义了一个0x4字节的lock
/* Flags (formerly in max_fast). */int flags;//0x8
/* Set if the fastbin chunks contain recently inserted free blocks. *//* Note this is a bool but not all targets support atomics on booleans. */int have_fastchunks;//0xc
/* Fastbins */
mfastbinptr fastbinsY[NFASTBINS];//fastbin链的管理头,10个, 0x10
/* Base of the topmost chunk -- not otherwise kept in a bin */
mchunkptr top;//0x60
/* The remainder from the most recent split of a small request */
mchunkptr last_remainder;
/* Normal bins packed as described above */
mchunkptr bins[NBINS *2-2];
/* Bitmap of bins */unsignedint binmap[BINMAPSIZE];
/* Linked list */structmalloc_state*next;
/* Linked list for free arenas. Access to this field is serialized
by free_list_lock in arena.c. */structmalloc_state*next_free;
/* Number of threads attached to this arena. 0 if the arena is on
the free list. Access to this field is serialized by
free_list_lock in arena.c. */
INTERNAL_SIZE_T attached_threads;
/* Memory allocated from the system in this arena. */
INTERNAL_SIZE_T system_mem;
INTERNAL_SIZE_T max_system_mem;}
structmalloc_chunk{
INTERNAL_SIZE_T mchunk_prev_size;/* Size of previous chunk (if free).前面一个空闲块的大小*/
INTERNAL_SIZE_T mchunk_size;/* Size in bytes, including overhead. *///真正的内存从这里开始分配structmalloc_chunk* fd;/* double links -- used only if free. */// 指向前一项chunkstructmalloc_chunk* bk;//指向后一个chunk,当前的chunk需要被free/* Only used for large blocks: pointer to next larger size.> 0x400 */structmalloc_chunk* fd_nextsize;/* double links -- used only if free. */structmalloc_chunk* bk_nextsize;//指向后一个large chunk};