This structure represents the header details of an Arena. The main thread’s arena is a global variable and not part of the heap segment. Arena headers (malloc_state structures) for other threads are themselves stored in the heap segment. Non main arenas can have multiple heaps (‘heap’ here refers to the internal structure used instead of the heap segment) associated with them.
structmalloc_state{/* Serialize access. */__libc_lock_define(,mutex);/* Flags (formerly in max_fast). */intflags;/* Fastbins */mfastbinptrfastbinsY[NFASTBINS];/* Base of the topmost chunk -- not otherwise kept in a bin */mchunkptrtop;/* The remainder from the most recent split of a small request */mchunkptrlast_remainder;/* Normal bins packed as described above */mchunkptrbins[NBINS*2-2];/* Bitmap of bins */unsignedintbinmap[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_Tattached_threads;/* Memory allocated from the system in this arena. */INTERNAL_SIZE_Tsystem_mem;INTERNAL_SIZE_Tmax_system_mem;};typedefstructmalloc_state*mstate;