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

Method fl_refill

gecode/kernel/memory/manager.hpp:446–478  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

444
445 template<size_t sz>
446 void
447 MemoryManager::fl_refill(SharedMemory& sm) {
448 // Try to acquire memory from slack
449 if (slack != nullptr) {
450 MemoryChunk* m = slack;
451 slack = nullptr;
452 do {
453 char* block = ptr_cast<char*>(m);
454 size_t s = m->size;
455 assert(s >= sz);
456 m = m->next;
457 fl[sz2i(sz)] = ptr_cast<FreeList*>(block);
458 while (s >= 2*sz) {
459 ptr_cast<FreeList*>(block)->next(ptr_cast<FreeList*>(block+sz));
460 block += sz;
461 s -= sz;
462 }
463 ptr_cast<FreeList*>(block)->next(nullptr);
464 } while (m != nullptr);
465 } else {
466 char* block = static_cast<char*>(alloc(sm,MemoryConfig::fl_refill*sz));
467 fl[sz2i(sz)] = ptr_cast<FreeList*>(block);
468 int i = MemoryConfig::fl_refill-2;
469 do {
470 ptr_cast<FreeList*>(block+static_cast<unsigned int>(i)*sz)
471 ->next(ptr_cast<FreeList*>(block+
472 (static_cast<unsigned int>(i)+1)*sz));
473 } while (--i >= 0);
474 ptr_cast<FreeList*>(block+
475 (MemoryConfig::fl_refill-1)*sz)->next
476 (ptr_cast<FreeList*>(nullptr));
477 }
478 }
479
480}}
481

Callers

nothing calls this directly

Calls 1

nextMethod · 0.45

Tested by

no test coverage detected