1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
//! Process-wide global allocator registration.
//!
//! When the `mimalloc` feature is enabled on a non-WASM target, registers
//! `mimalloc::MiMalloc` as the `#[global_allocator]`. This routes all
//! `Box`/`Vec`/`String` allocations through mimalloc.
//!
//! On WASM (`target_arch = "wasm32"`) the system allocator is always used,
//! since mimalloc relies on TLS and `mmap` primitives that wasm32 lacks.
//!
//! > **Note for library consumers:** the `mimalloc` feature registers MiMalloc
//! > as the binary's `#[global_allocator]`. If the downstream binary already
//! > declares a `#[global_allocator]`, enabling this feature will cause a
//! > link-time conflict. Opt in only if your binary does not set its own
//! > global allocator.
static GLOBAL: MiMalloc = MiMalloc;
/// Returns the name of the active process-wide allocator.
///
/// Useful for diagnostics, logging, and benchmark reporting.
///
/// # Examples
///
/// ```
/// let name = pjson_rs::global_allocator_name();
/// assert!(name == "mimalloc" || name == "system");
/// ```