CX Framework
Cross-platform C utility framework
Loading...
Searching...
No Matches
xalloc_private.h
1#pragma once
2
3#include "xalloc.h"
4#include <cx/platform/base.h>
5#include <cx/utils/lazyinit.h>
6
7#ifndef XALLOC_USE_SYSTEM_MALLOC
8#include <mimalloc.h>
9#endif
10
11extern LazyInitState _xaInitState;
12
13static _meta_inline int _xaMaxOOMPhase(unsigned int flags)
14{
15 if (!(flags & XA_Optional_Mask))
16 return XA_Urgent;
17
18 if (flags & XA_Optional_High)
19 return XA_HighEffort;
20 if (flags & XA_Optional_Low)
21 return XA_LowEffort;
22
23 // XA_Optional_None doesn't do any OOM freeing at all
24 return 0;
25}
26
27// go through OOM callbacks to try to free up some memory
28void _xaFreeUpMemory(int phase, size_t allocsz);
29
30// If flags do not include one of the optional flags, this function
31// asserts and does not return.
32_When_(!(flags & XA_Optional_Mask), _Analysis_noreturn_)
33void _xaAllocFailure(size_t allocsz, unsigned int flags);
34
35#ifndef XALLOC_USE_SYSTEM_MALLOC
36void _xaInitOutput(void);
37#endif
Compiler and platform detection macros.
@ XA_Urgent
Definition xalloc.h:140
@ XA_LowEffort
Definition xalloc.h:127
@ XA_HighEffort
Definition xalloc.h:133
Thread-safe lazy initialization.
State tracker for lazy initialization.
Definition lazyinit.h:40
Extended memory allocation system.