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

Method dealloc

thread/stack-allocator.cpp:115–127  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 ||
118 (in_pool_size + slots[idx].slotsize >= trim_threshold))) {
119 // big block or in-pool buffers reaches to threshold
120 __dealloc(ptr, idx >= N_SLOTS ? size : slots[idx].slotsize);
121 return 0;
122 }
123 // Collect into pool
124 in_pool_size += slots[idx].slotsize;
125 slots[idx].put(ptr);
126 return 0;
127 }
128 size_t trim(size_t keep_size) {
129 size_t count = 0;
130 for (int i = 0; in_pool_size > keep_size; i = (i + 1) % N_SLOTS) {

Callers 1

pooled_stack_deallocFunction · 0.45

Calls 2

unlikelyFunction · 0.50
putMethod · 0.45

Tested by

no test coverage detected