From 0ec1e9f4c448bfa929d73c33194d6009f6f86feb Mon Sep 17 00:00:00 2001 From: skidder Date: Tue, 17 Dec 2002 19:42:25 +0000 Subject: [PATCH] Further class library development --- src/common/classes/alloc.cpp | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/common/classes/alloc.cpp b/src/common/classes/alloc.cpp index a6851336f0..21158a32d1 100644 --- a/src/common/classes/alloc.cpp +++ b/src/common/classes/alloc.cpp @@ -156,12 +156,9 @@ MemoryPool* MemoryPool::createPool() { blk->prev = hdr; BlockInfo temp = {blk, blockLength}; 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) pool->spareLeaf = pool->alloc(sizeof(FreeBlocksTree::ItemList)); - pool->verify_pool(); pool->spareNodes.add(pool->alloc(sizeof(FreeBlocksTree::NodeList))); - pool->verify_pool(); return pool; } @@ -302,17 +299,16 @@ void* MemoryPool::alloc(size_t size, SSHORT type) { blk->used = true; blk->type = type; 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 blk->last = true; blk->length = alloc_size - ALIGN(sizeof(MemoryExtent)) - ALIGN(sizeof(MemoryBlock)); } else { // Cut a piece at the beginning of the block - MemoryBlock *blk = (MemoryBlock *)((char*)extent+ALIGN(sizeof(MemoryExtent))); blk->last = false; blk->length = size; // 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->used = false; rest->last = true;