MCPcopy Create free account
hub / github.com/bblanchon/ArduinoJson / allocSlot

Method allocSlot

src/ArduinoJson/Memory/MemoryPoolList.hpp:82–101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

80 }
81
82 Slot<T> allocSlot(Allocator* allocator) {
83 // try to allocate from free list
84 if (freeList_ != NULL_SLOT) {
85 return allocFromFreeList();
86 }
87
88 // try to allocate from last pool (other pools are full)
89 if (count_) {
90 auto slot = allocFromLastPool();
91 if (slot)
92 return slot;
93 }
94
95 // create a new pool and try again
96 auto pool = addPool(allocator);
97 if (!pool)
98 return {};
99
100 return allocFromLastPool();
101 }
102
103 void freeSlot(Slot<T> slot) {
104 reinterpret_cast<FreeSlot*>(slot.ptr())->next = freeList_;

Callers 1

allocFromLastPoolMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected