MCPcopy Create free account
hub / github.com/Gecode/gecode / alloc

Method alloc

gecode/kernel/memory/manager.hpp:199–220  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

197 }
198
199 forceinline HeapChunk*
200 SharedMemory::alloc(size_t s, size_t l) {
201 // To protect from exceptions from heap.ralloc()
202 Support::Lock guard(m());
203 while ((heap.hc != nullptr) && (heap.hc->size < l)) {
204 heap.n_hc--;
205 HeapChunk* hc = heap.hc;
206 heap.hc = static_cast<HeapChunk*>(hc->next);
207 Gecode::heap.rfree(hc);
208 }
209 HeapChunk* hc;
210 if (heap.hc == nullptr) {
211 assert(heap.n_hc == 0);
212 hc = static_cast<HeapChunk*>(Gecode::heap.ralloc(s));
213 hc->size = s;
214 } else {
215 heap.n_hc--;
216 hc = heap.hc;
217 heap.hc = static_cast<HeapChunk*>(hc->next);
218 }
219 return hc;
220 }
221 forceinline void
222 SharedMemory::free(HeapChunk* hc) {
223 Support::Lock guard(m());

Callers 1

alloc_fillMethod · 0.45

Calls 4

mFunction · 0.85
alignFunction · 0.85
rfreeMethod · 0.45
rallocMethod · 0.45

Tested by

no test coverage detected