64class GeneralMemoryAllocator {
66 GeneralMemoryAllocator();
67 [[gnu::always_inline]]
void* allocMaxSpeed(uint32_t requiredSize,
void* thingNotToStealFrom =
nullptr) {
68 return alloc(requiredSize,
true,
false, thingNotToStealFrom);
71 [[gnu::always_inline]]
void* allocLowSpeed(uint32_t requiredSize,
void* thingNotToStealFrom =
nullptr) {
72 return alloc(requiredSize,
false,
false, thingNotToStealFrom);
75 [[gnu::always_inline]]
void* allocStealable(uint32_t requiredSize,
void* thingNotToStealFrom =
nullptr) {
76 return alloc(requiredSize,
false,
true, thingNotToStealFrom);
79 void* alloc(uint32_t requiredSize,
bool mayUseOnChipRam,
bool makeStealable,
void* thingNotToStealFrom);
80 void dealloc(
void* address);
81 void* allocExternal(uint32_t requiredSize);
82 void* allocInternal(uint32_t requiredSize);
83 void deallocExternal(
void* address);
84 uint32_t shortenRight(
void* address, uint32_t newSize);
85 uint32_t shortenLeft(
void* address, uint32_t amountToShorten, uint32_t numBytesToMoveRightIfSuccessful = 0);
86 void extend(
void* address, uint32_t minAmountToExtend, uint32_t idealAmountToExtend,
87 uint32_t* getAmountExtendedLeft, uint32_t* getAmountExtendedRight,
void* thingNotToStealFrom =
nullptr);
88 uint32_t extendRightAsMuchAsEasilyPossible(
void* address);
90 uint32_t getAllocatedSize(
void* address);
91 void checkStack(
char const* caller);
92 void testShorten(int32_t i);
93 int32_t getRegion(
void* address);
94 void testMemoryDeallocated(
void* address);
96 void putStealableInQueue(
Stealable& stealable, StealableQueue q);
97 void putStealableInAppropriateQueue(
Stealable& stealable);
104 static GeneralMemoryAllocator& get() {
105 static GeneralMemoryAllocator generalMemoryAllocator;
106 return generalMemoryAllocator;
110 void checkEverythingOk(
char const* errorString);