MCPcopy Create free account
hub / github.com/FirebirdSQL/firebird / newExtent

Method newExtent

src/common/classes/alloc.cpp:2200–2233  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2198
2199template <class Extent>
2200void MemPool::newExtent(size_t& size, Extent** linkedList)
2201{
2202 // No large enough block found. We need to extend the pool
2203 void* memory = NULL;
2204 const unsigned TOTAL_OVERHEAD = DoubleLinkedList::MEM_OVERHEAD + GUARD_BYTES + VALGRIND_REDZONE;
2205 const unsigned FROM_LIMIT = mediumLimits[10]; // 4224 // 10
2206 const unsigned TO_LIMIT = mediumLimits[15]; // 7552 // 15
2207
2208 size_t ext_size = size + MEM_ALIGN(sizeof(Extent));
2209 const bool allocByParent = parent && (ext_size <= TO_LIMIT);
2210
2211 if (allocByParent)
2212 {
2213 size_t from = FROM_LIMIT;
2214 if (ext_size + TOTAL_OVERHEAD > from)
2215 from = ext_size + TOTAL_OVERHEAD;
2216 ext_size = TO_LIMIT;
2217 if (ext_size < from)
2218 ext_size = from;
2219
2220 fb_assert(ext_size < DEFAULT_ALLOCATION);
2221 memory = parent->getExtent(from, ext_size);
2222 }
2223 else
2224 {
2225 fb_assert(ext_size <= DEFAULT_ALLOCATION);
2226 ext_size = DEFAULT_ALLOCATION;
2227 memory = allocRaw(ext_size);
2228 fb_assert(ext_size == DEFAULT_ALLOCATION); // Make sure extent size is as expected
2229 }
2230
2231 Extent* extent = new(memory) Extent(linkedList, ext_size);
2232 size = extent->spaceRemaining;
2233}
2234
2235MemoryPool* MemoryPool::createPool(MemoryPool* parentPool, MemoryStats& stats)
2236{

Callers 1

newBlockMethod · 0.80

Calls 2

MEM_ALIGNFunction · 0.85
getExtentMethod · 0.80

Tested by

no test coverage detected