From 541c17ddaa1cb0d6447886da2ab3b402ea0db1b2 Mon Sep 17 00:00:00 2001 From: Aleksey Bragin Date: Fri, 14 Dec 2007 23:17:43 +0000 Subject: [PATCH] Filip Navara - Remove unused code from HvGetCellSize(). - Fix situation, when a new cell is allocated with a too small size, resulting in an empty free cell (a cell has to be able to store at least one HCELL_INDEX), then the free list code overrides the next cell after the empty one. - Reenable commented out assert in HvpRemoveFree(), since now it works as expected. svn path=/trunk/; revision=31221 --- reactos/lib/cmlib/hivecell.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/reactos/lib/cmlib/hivecell.c b/reactos/lib/cmlib/hivecell.c index 8f268d43660..314dde9f589 100644 --- a/reactos/lib/cmlib/hivecell.c +++ b/reactos/lib/cmlib/hivecell.c @@ -103,7 +103,6 @@ HvMarkCellDirty( HCELL_INDEX CellIndex, BOOLEAN HoldingLock) { - LONG CellSize; ULONG CellBlock; ULONG CellLastBlock; @@ -118,10 +117,6 @@ HvMarkCellDirty( CellBlock = (CellIndex & HCELL_BLOCK_MASK) >> HCELL_BLOCK_SHIFT; CellLastBlock = ((CellIndex + HV_BLOCK_SIZE - 1) & HCELL_BLOCK_MASK) >> HCELL_BLOCK_SHIFT; - CellSize = HvpGetCellFullSize(RegistryHive, HvGetCell(RegistryHive, CellIndex)); - if (CellSize < 0) - CellSize = -CellSize; - RtlSetBits(&RegistryHive->DirtyVector, CellBlock, CellLastBlock - CellBlock); return TRUE; @@ -229,7 +224,7 @@ HvpRemoveFree( pFreeCellOffset = FreeCellData; } - //ASSERT(FALSE); + ASSERT(FALSE); } static HCELL_INDEX CMAPI @@ -349,8 +344,13 @@ HvAllocateCell( FreeCell = HvpGetCellHeader(RegistryHive, FreeCellOffset); /* Split the block in two parts */ - /* FIXME: There is some minimal cell size that we must respect. */ - if ((ULONG)FreeCell->Size > Size + sizeof(HCELL_INDEX)) + + /* The free block that is created has to be at least + sizeof(HCELL) + sizeof(HCELL_INDEX) big, so that free + cell list code can work. Moreover we round cell sizes + to 16 bytes, so creating a smaller block would result in + a cell that would never be allocated. */ + if ((ULONG)FreeCell->Size > Size + 16) { NewCell = (PHCELL)((ULONG_PTR)FreeCell + Size); NewCell->Size = FreeCell->Size - Size;