Author: fireball Date: Sat Dec 15 02:17:43 2007 New Revision: 31221
URL: http://svn.reactos.org/svn/reactos?rev=31221&view=rev Log: Filip Navara <xnavara at volny dot cz> - 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.
Modified: trunk/reactos/lib/cmlib/hivecell.c
Modified: trunk/reactos/lib/cmlib/hivecell.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/cmlib/hivecell.c?rev=31... ============================================================================== --- trunk/reactos/lib/cmlib/hivecell.c (original) +++ trunk/reactos/lib/cmlib/hivecell.c Sat Dec 15 02:17:43 2007 @@ -103,7 +103,6 @@ HCELL_INDEX CellIndex, BOOLEAN HoldingLock) { - LONG CellSize; ULONG CellBlock; ULONG CellLastBlock;
@@ -117,10 +116,6 @@
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); @@ -229,7 +224,7 @@ pFreeCellOffset = FreeCellData; }
- //ASSERT(FALSE); + ASSERT(FALSE); }
static HCELL_INDEX CMAPI @@ -349,8 +344,13 @@ 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;