8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-24 03:23:03 +01:00

Further class library development

This commit is contained in:
skidder 2002-12-17 19:42:25 +00:00
parent 044dcc6d25
commit 0ec1e9f4c4

View File

@ -156,12 +156,9 @@ MemoryPool* MemoryPool::createPool() {
blk->prev = hdr; blk->prev = hdr;
BlockInfo temp = {blk, blockLength}; BlockInfo temp = {blk, blockLength};
pool->freeBlocks.add(temp); pool->freeBlocks.add(temp);
pool->verify_pool();
// This code may not work if tree factor is 2 (but if MIN_EXTENT_SIZE is large enough it will) // This code may not work if tree factor is 2 (but if MIN_EXTENT_SIZE is large enough it will)
pool->spareLeaf = pool->alloc(sizeof(FreeBlocksTree::ItemList)); pool->spareLeaf = pool->alloc(sizeof(FreeBlocksTree::ItemList));
pool->verify_pool();
pool->spareNodes.add(pool->alloc(sizeof(FreeBlocksTree::NodeList))); pool->spareNodes.add(pool->alloc(sizeof(FreeBlocksTree::NodeList)));
pool->verify_pool();
return pool; return pool;
} }
@ -302,17 +299,16 @@ void* MemoryPool::alloc(size_t size, SSHORT type) {
blk->used = true; blk->used = true;
blk->type = type; blk->type = type;
blk->prev = NULL; blk->prev = NULL;
if (alloc_size-size < ALIGN(sizeof(MemoryBlock))+ALLOC_ALIGNMENT) { if (alloc_size-size-ALIGN(sizeof(MemoryExtent))-ALIGN(sizeof(MemoryBlock)) < ALIGN(sizeof(MemoryBlock))+ALLOC_ALIGNMENT) {
// Block is small enough to be returned AS IS // Block is small enough to be returned AS IS
blk->last = true; blk->last = true;
blk->length = alloc_size - ALIGN(sizeof(MemoryExtent)) - ALIGN(sizeof(MemoryBlock)); blk->length = alloc_size - ALIGN(sizeof(MemoryExtent)) - ALIGN(sizeof(MemoryBlock));
} else { } else {
// Cut a piece at the beginning of the block // Cut a piece at the beginning of the block
MemoryBlock *blk = (MemoryBlock *)((char*)extent+ALIGN(sizeof(MemoryExtent)));
blk->last = false; blk->last = false;
blk->length = size; blk->length = size;
// Put the rest to the tree of free blocks // Put the rest to the tree of free blocks
MemoryBlock *rest = (MemoryBlock *)((char *)blk + size); MemoryBlock *rest = (MemoryBlock *)((char *)blk + ALIGN(sizeof(MemoryBlock)) + size);
rest->pool = this; rest->pool = this;
rest->used = false; rest->used = false;
rest->last = true; rest->last = true;