2022-06-10 00:45:30 +00:00
|
|
|
|
|
|
|
/* ------------- Global malloc_state and malloc_params ------------------- */
|
|
|
|
|
|
|
|
/*
|
|
|
|
malloc_params holds global properties, including those that can be
|
|
|
|
dynamically set using mallopt. There is a single instance, mparams,
|
|
|
|
initialized in init_mparams. Note that the non-zeroness of "magic"
|
|
|
|
also serves as an initialization flag.
|
|
|
|
*/
|
|
|
|
|
|
|
|
struct malloc_params {
|
|
|
|
size_t magic;
|
|
|
|
size_t page_size;
|
|
|
|
size_t granularity;
|
|
|
|
size_t mmap_threshold;
|
|
|
|
size_t trim_threshold;
|
|
|
|
flag_t default_mflags;
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct malloc_params mparams;
|
|
|
|
|
|
|
|
/* Ensure mparams initialized */
|
2022-11-02 05:36:03 +00:00
|
|
|
#define ensure_initialization() (void)0
|
2022-06-10 00:45:30 +00:00
|
|
|
|
|
|
|
#if !ONLY_MSPACES
|
|
|
|
|
|
|
|
/* The global malloc_state used for all non-"mspace" calls */
|
|
|
|
static struct malloc_state _gm_;
|
|
|
|
#define gm (&_gm_)
|
|
|
|
#define is_global(M) ((M) == &_gm_)
|
|
|
|
|
|
|
|
#endif /* !ONLY_MSPACES */
|
|
|
|
|
|
|
|
#define is_initialized(M) ((M)->top != 0)
|