MCPcopy Create free account
hub / github.com/alibaba/PhotonLibOS / alloc

Method alloc

thread/stack-allocator.cpp:101–114  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

99
100public:
101 void* alloc(size_t size) {
102 auto idx = get_slot(size);
103 if (unlikely(idx >= N_SLOTS)) {
104 // larger than biggest slot
105 return __alloc(size);
106 }
107 auto ptr = slots[idx].get();
108 // got from pool
109 if (ptr) {
110 in_pool_size -= slots[idx].slotsize;
111 return ptr;
112 }
113 return __alloc(slots[idx].slotsize);
114 }
115 int dealloc(void* ptr, size_t size) {
116 auto idx = get_slot(size);
117 if (unlikely(idx >= N_SLOTS ||

Callers 1

pooled_stack_allocFunction · 0.45

Calls 2

unlikelyFunction · 0.50
getMethod · 0.45

Tested by

no test coverage detected