mirror of
https://github.com/reactos/reactos.git
synced 2025-01-06 06:20:13 +00:00
- CELL_HEADER -> HCELL.
svn path=/trunk/; revision=23576
This commit is contained in:
parent
b2ff1d22b8
commit
b25952bbc1
4 changed files with 71 additions and 51 deletions
|
@ -21,7 +21,7 @@ HvpAddBin(
|
||||||
ULONG BitmapSize;
|
ULONG BitmapSize;
|
||||||
ULONG BlockCount;
|
ULONG BlockCount;
|
||||||
ULONG OldBlockListSize;
|
ULONG OldBlockListSize;
|
||||||
PCELL_HEADER Block;
|
PHCELL Block;
|
||||||
|
|
||||||
BinSize = ROUND_UP(Size + sizeof(HBIN), HV_BLOCK_SIZE);
|
BinSize = ROUND_UP(Size + sizeof(HBIN), HV_BLOCK_SIZE);
|
||||||
BlockCount = BinSize / HV_BLOCK_SIZE;
|
BlockCount = BinSize / HV_BLOCK_SIZE;
|
||||||
|
@ -64,8 +64,8 @@ HvpAddBin(
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Initialize a free block in this heap. */
|
/* Initialize a free block in this heap. */
|
||||||
Block = (PCELL_HEADER)(Bin + 1);
|
Block = (PHCELL)(Bin + 1);
|
||||||
Block->CellSize = BinSize - sizeof(HBIN);
|
Block->Size = BinSize - sizeof(HBIN);
|
||||||
|
|
||||||
if (Storage == HvStable)
|
if (Storage == HvStable)
|
||||||
{
|
{
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
#define NDEBUG
|
#define NDEBUG
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
static PCELL_HEADER __inline CMAPI
|
static PHCELL __inline CMAPI
|
||||||
HvpGetCellHeader(
|
HvpGetCellHeader(
|
||||||
PHHIVE RegistryHive,
|
PHHIVE RegistryHive,
|
||||||
HCELL_INDEX CellIndex)
|
HCELL_INDEX CellIndex)
|
||||||
|
@ -52,7 +52,7 @@ HvpGetCellFullSize(
|
||||||
PHHIVE RegistryHive,
|
PHHIVE RegistryHive,
|
||||||
PVOID Cell)
|
PVOID Cell)
|
||||||
{
|
{
|
||||||
return ((PCELL_HEADER)Cell - 1)->CellSize;
|
return ((PHCELL)Cell - 1)->Size;
|
||||||
}
|
}
|
||||||
|
|
||||||
LONG CMAPI
|
LONG CMAPI
|
||||||
|
@ -60,13 +60,13 @@ HvGetCellSize(
|
||||||
PHHIVE RegistryHive,
|
PHHIVE RegistryHive,
|
||||||
PVOID Cell)
|
PVOID Cell)
|
||||||
{
|
{
|
||||||
PCELL_HEADER CellHeader;
|
PHCELL CellHeader;
|
||||||
|
|
||||||
CellHeader = (PCELL_HEADER)Cell - 1;
|
CellHeader = (PHCELL)Cell - 1;
|
||||||
if (CellHeader->CellSize < 0)
|
if (CellHeader->Size < 0)
|
||||||
return CellHeader->CellSize + sizeof(CELL_HEADER);
|
return CellHeader->Size + sizeof(HCELL);
|
||||||
else
|
else
|
||||||
return CellHeader->CellSize - sizeof(CELL_HEADER);
|
return CellHeader->Size - sizeof(HCELL);
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID CMAPI
|
VOID CMAPI
|
||||||
|
@ -132,7 +132,7 @@ HvpComputeFreeListIndex(
|
||||||
static NTSTATUS CMAPI
|
static NTSTATUS CMAPI
|
||||||
HvpAddFree(
|
HvpAddFree(
|
||||||
PHHIVE RegistryHive,
|
PHHIVE RegistryHive,
|
||||||
PCELL_HEADER FreeBlock,
|
PHCELL FreeBlock,
|
||||||
HCELL_INDEX FreeIndex)
|
HCELL_INDEX FreeIndex)
|
||||||
{
|
{
|
||||||
PHCELL_INDEX FreeBlockData;
|
PHCELL_INDEX FreeBlockData;
|
||||||
|
@ -143,7 +143,7 @@ HvpAddFree(
|
||||||
ASSERT(FreeBlock != NULL);
|
ASSERT(FreeBlock != NULL);
|
||||||
|
|
||||||
Storage = (FreeIndex & HCELL_TYPE_MASK) >> HCELL_TYPE_SHIFT;
|
Storage = (FreeIndex & HCELL_TYPE_MASK) >> HCELL_TYPE_SHIFT;
|
||||||
Index = HvpComputeFreeListIndex(FreeBlock->CellSize);
|
Index = HvpComputeFreeListIndex(FreeBlock->Size);
|
||||||
|
|
||||||
FreeBlockData = (PHCELL_INDEX)(FreeBlock + 1);
|
FreeBlockData = (PHCELL_INDEX)(FreeBlock + 1);
|
||||||
*FreeBlockData = RegistryHive->Storage[Storage].FreeDisplay[Index];
|
*FreeBlockData = RegistryHive->Storage[Storage].FreeDisplay[Index];
|
||||||
|
@ -157,7 +157,7 @@ HvpAddFree(
|
||||||
static VOID CMAPI
|
static VOID CMAPI
|
||||||
HvpRemoveFree(
|
HvpRemoveFree(
|
||||||
PHHIVE RegistryHive,
|
PHHIVE RegistryHive,
|
||||||
PCELL_HEADER CellBlock,
|
PHCELL CellBlock,
|
||||||
HCELL_INDEX CellIndex)
|
HCELL_INDEX CellIndex)
|
||||||
{
|
{
|
||||||
PHCELL_INDEX FreeCellData;
|
PHCELL_INDEX FreeCellData;
|
||||||
|
@ -168,7 +168,7 @@ HvpRemoveFree(
|
||||||
ASSERT(RegistryHive->ReadOnly == FALSE);
|
ASSERT(RegistryHive->ReadOnly == FALSE);
|
||||||
|
|
||||||
Storage = (CellIndex & HCELL_TYPE_MASK) >> HCELL_TYPE_SHIFT;
|
Storage = (CellIndex & HCELL_TYPE_MASK) >> HCELL_TYPE_SHIFT;
|
||||||
Index = HvpComputeFreeListIndex(CellBlock->CellSize);
|
Index = HvpComputeFreeListIndex(CellBlock->Size);
|
||||||
|
|
||||||
pFreeCellOffset = &RegistryHive->Storage[Storage].FreeDisplay[Index];
|
pFreeCellOffset = &RegistryHive->Storage[Storage].FreeDisplay[Index];
|
||||||
while (*pFreeCellOffset != HCELL_NULL)
|
while (*pFreeCellOffset != HCELL_NULL)
|
||||||
|
@ -220,7 +220,7 @@ HvpCreateHiveFreeCellList(
|
||||||
PHHIVE Hive)
|
PHHIVE Hive)
|
||||||
{
|
{
|
||||||
HCELL_INDEX BlockOffset;
|
HCELL_INDEX BlockOffset;
|
||||||
PCELL_HEADER FreeBlock;
|
PHCELL FreeBlock;
|
||||||
ULONG BlockIndex;
|
ULONG BlockIndex;
|
||||||
ULONG FreeOffset;
|
ULONG FreeOffset;
|
||||||
PHBIN Bin;
|
PHBIN Bin;
|
||||||
|
@ -244,18 +244,18 @@ HvpCreateHiveFreeCellList(
|
||||||
FreeOffset = sizeof(HBIN);
|
FreeOffset = sizeof(HBIN);
|
||||||
while (FreeOffset < Bin->Size)
|
while (FreeOffset < Bin->Size)
|
||||||
{
|
{
|
||||||
FreeBlock = (PCELL_HEADER)((ULONG_PTR)Bin + FreeOffset);
|
FreeBlock = (PHCELL)((ULONG_PTR)Bin + FreeOffset);
|
||||||
if (FreeBlock->CellSize > 0)
|
if (FreeBlock->Size > 0)
|
||||||
{
|
{
|
||||||
Status = HvpAddFree(Hive, FreeBlock, Bin->FileOffset + FreeOffset);
|
Status = HvpAddFree(Hive, FreeBlock, Bin->FileOffset + FreeOffset);
|
||||||
if (!NT_SUCCESS(Status))
|
if (!NT_SUCCESS(Status))
|
||||||
return Status;
|
return Status;
|
||||||
|
|
||||||
FreeOffset += FreeBlock->CellSize;
|
FreeOffset += FreeBlock->Size;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FreeOffset -= FreeBlock->CellSize;
|
FreeOffset -= FreeBlock->Size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,15 +272,15 @@ HvAllocateCell(
|
||||||
ULONG Size,
|
ULONG Size,
|
||||||
HV_STORAGE_TYPE Storage)
|
HV_STORAGE_TYPE Storage)
|
||||||
{
|
{
|
||||||
PCELL_HEADER FreeCell;
|
PHCELL FreeCell;
|
||||||
HCELL_INDEX FreeCellOffset;
|
HCELL_INDEX FreeCellOffset;
|
||||||
PCELL_HEADER NewCell;
|
PHCELL NewCell;
|
||||||
PHBIN Bin;
|
PHBIN Bin;
|
||||||
|
|
||||||
ASSERT(RegistryHive->ReadOnly == FALSE);
|
ASSERT(RegistryHive->ReadOnly == FALSE);
|
||||||
|
|
||||||
/* Round to 16 bytes multiple. */
|
/* Round to 16 bytes multiple. */
|
||||||
Size = ROUND_UP(Size + sizeof(CELL_HEADER), 16);
|
Size = ROUND_UP(Size + sizeof(HCELL), 16);
|
||||||
|
|
||||||
/* First search in free blocks. */
|
/* First search in free blocks. */
|
||||||
FreeCellOffset = HvpFindFree(RegistryHive, Size, Storage);
|
FreeCellOffset = HvpFindFree(RegistryHive, Size, Storage);
|
||||||
|
@ -299,11 +299,11 @@ HvAllocateCell(
|
||||||
|
|
||||||
/* Split the block in two parts */
|
/* Split the block in two parts */
|
||||||
/* FIXME: There is some minimal cell size that we must respect. */
|
/* FIXME: There is some minimal cell size that we must respect. */
|
||||||
if (FreeCell->CellSize > Size + sizeof(HCELL_INDEX))
|
if (FreeCell->Size > Size + sizeof(HCELL_INDEX))
|
||||||
{
|
{
|
||||||
NewCell = (PCELL_HEADER)((ULONG_PTR)FreeCell + Size);
|
NewCell = (PHCELL)((ULONG_PTR)FreeCell + Size);
|
||||||
NewCell->CellSize = FreeCell->CellSize - Size;
|
NewCell->Size = FreeCell->Size - Size;
|
||||||
FreeCell->CellSize = Size;
|
FreeCell->Size = Size;
|
||||||
HvpAddFree(RegistryHive, NewCell, FreeCellOffset + Size);
|
HvpAddFree(RegistryHive, NewCell, FreeCellOffset + Size);
|
||||||
if (Storage == HvStable)
|
if (Storage == HvStable)
|
||||||
HvMarkCellDirty(RegistryHive, FreeCellOffset + Size);
|
HvMarkCellDirty(RegistryHive, FreeCellOffset + Size);
|
||||||
|
@ -311,8 +311,8 @@ HvAllocateCell(
|
||||||
|
|
||||||
if (Storage == HvStable)
|
if (Storage == HvStable)
|
||||||
HvMarkCellDirty(RegistryHive, FreeCellOffset);
|
HvMarkCellDirty(RegistryHive, FreeCellOffset);
|
||||||
FreeCell->CellSize = -FreeCell->CellSize;
|
FreeCell->Size = -FreeCell->Size;
|
||||||
RtlZeroMemory(FreeCell + 1, Size - sizeof(CELL_HEADER));
|
RtlZeroMemory(FreeCell + 1, Size - sizeof(HCELL));
|
||||||
|
|
||||||
return FreeCellOffset;
|
return FreeCellOffset;
|
||||||
}
|
}
|
||||||
|
@ -366,8 +366,8 @@ HvFreeCell(
|
||||||
PHHIVE RegistryHive,
|
PHHIVE RegistryHive,
|
||||||
HCELL_INDEX CellIndex)
|
HCELL_INDEX CellIndex)
|
||||||
{
|
{
|
||||||
PCELL_HEADER Free;
|
PHCELL Free;
|
||||||
PCELL_HEADER Neighbor;
|
PHCELL Neighbor;
|
||||||
PHBIN Bin;
|
PHBIN Bin;
|
||||||
ULONG CellType;
|
ULONG CellType;
|
||||||
ULONG CellBlock;
|
ULONG CellBlock;
|
||||||
|
@ -376,9 +376,9 @@ HvFreeCell(
|
||||||
|
|
||||||
Free = HvpGetCellHeader(RegistryHive, CellIndex);
|
Free = HvpGetCellHeader(RegistryHive, CellIndex);
|
||||||
|
|
||||||
ASSERT(Free->CellSize < 0);
|
ASSERT(Free->Size < 0);
|
||||||
|
|
||||||
Free->CellSize = -Free->CellSize;
|
Free->Size = -Free->Size;
|
||||||
|
|
||||||
CellType = (CellIndex & HCELL_TYPE_MASK) >> HCELL_TYPE_SHIFT;
|
CellType = (CellIndex & HCELL_TYPE_MASK) >> HCELL_TYPE_SHIFT;
|
||||||
CellBlock = (CellIndex & HCELL_BLOCK_MASK) >> HCELL_BLOCK_SHIFT;
|
CellBlock = (CellIndex & HCELL_BLOCK_MASK) >> HCELL_BLOCK_SHIFT;
|
||||||
|
@ -386,38 +386,38 @@ HvFreeCell(
|
||||||
/* FIXME: Merge free blocks */
|
/* FIXME: Merge free blocks */
|
||||||
Bin = (PHBIN)RegistryHive->Storage[CellType].BlockList[CellBlock].Bin;
|
Bin = (PHBIN)RegistryHive->Storage[CellType].BlockList[CellBlock].Bin;
|
||||||
|
|
||||||
if ((CellIndex & ~HCELL_TYPE_MASK) + Free->CellSize <
|
if ((CellIndex & ~HCELL_TYPE_MASK) + Free->Size <
|
||||||
Bin->FileOffset + Bin->Size)
|
Bin->FileOffset + Bin->Size)
|
||||||
{
|
{
|
||||||
Neighbor = (PCELL_HEADER)((ULONG_PTR)Free + Free->CellSize);
|
Neighbor = (PHCELL)((ULONG_PTR)Free + Free->Size);
|
||||||
if (Neighbor->CellSize > 0)
|
if (Neighbor->Size > 0)
|
||||||
{
|
{
|
||||||
HvpRemoveFree(RegistryHive, Neighbor,
|
HvpRemoveFree(RegistryHive, Neighbor,
|
||||||
((HCELL_INDEX)Neighbor - (HCELL_INDEX)Bin +
|
((HCELL_INDEX)Neighbor - (HCELL_INDEX)Bin +
|
||||||
Bin->FileOffset) | (CellIndex & HCELL_TYPE_MASK));
|
Bin->FileOffset) | (CellIndex & HCELL_TYPE_MASK));
|
||||||
Free->CellSize += Neighbor->CellSize;
|
Free->Size += Neighbor->Size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Neighbor = (PCELL_HEADER)(Bin + 1);
|
Neighbor = (PHCELL)(Bin + 1);
|
||||||
while (Neighbor < Free)
|
while (Neighbor < Free)
|
||||||
{
|
{
|
||||||
if (Neighbor->CellSize > 0)
|
if (Neighbor->Size > 0)
|
||||||
{
|
{
|
||||||
if ((ULONG_PTR)Neighbor + Neighbor->CellSize == (ULONG_PTR)Free)
|
if ((ULONG_PTR)Neighbor + Neighbor->Size == (ULONG_PTR)Free)
|
||||||
{
|
{
|
||||||
Neighbor->CellSize += Free->CellSize;
|
Neighbor->Size += Free->Size;
|
||||||
if (CellType == HvStable)
|
if (CellType == HvStable)
|
||||||
HvMarkCellDirty(RegistryHive,
|
HvMarkCellDirty(RegistryHive,
|
||||||
(HCELL_INDEX)Neighbor - (HCELL_INDEX)Bin +
|
(HCELL_INDEX)Neighbor - (HCELL_INDEX)Bin +
|
||||||
Bin->FileOffset);
|
Bin->FileOffset);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Neighbor = (PCELL_HEADER)((ULONG_PTR)Neighbor + Neighbor->CellSize);
|
Neighbor = (PHCELL)((ULONG_PTR)Neighbor + Neighbor->Size);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Neighbor = (PCELL_HEADER)((ULONG_PTR)Neighbor - Neighbor->CellSize);
|
Neighbor = (PHCELL)((ULONG_PTR)Neighbor - Neighbor->Size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -119,16 +119,36 @@ typedef struct _HBIN
|
||||||
ULONG MemAlloc;
|
ULONG MemAlloc;
|
||||||
} HBIN, *PHBIN;
|
} HBIN, *PHBIN;
|
||||||
|
|
||||||
typedef struct _CELL_HEADER
|
typedef struct _HCELL
|
||||||
{
|
{
|
||||||
/* <0 if used, >0 if free */
|
/* <0 if used, >0 if free */
|
||||||
LONG CellSize;
|
LONG Size;
|
||||||
} CELL_HEADER, *PCELL_HEADER;
|
union
|
||||||
|
{
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
ULONG Last;
|
||||||
|
union
|
||||||
|
{
|
||||||
|
ULONG UserData;
|
||||||
|
HCELL_INDEX Next;
|
||||||
|
} u;
|
||||||
|
} OldCell;
|
||||||
|
struct
|
||||||
|
{
|
||||||
|
union
|
||||||
|
{
|
||||||
|
ULONG UserData;
|
||||||
|
HCELL_INDEX Next;
|
||||||
|
} u;
|
||||||
|
} NewCell;
|
||||||
|
} u;
|
||||||
|
} HCELL, *PHCELL;
|
||||||
|
|
||||||
#include <poppack.h>
|
#include <poppack.h>
|
||||||
|
|
||||||
#define IsFreeCell(Cell)(Cell->CellSize >= 0)
|
#define IsFreeCell(Cell)(Cell->Size >= 0)
|
||||||
#define IsUsedCell(Cell)(Cell->CellSize < 0)
|
#define IsUsedCell(Cell)(Cell->Size < 0)
|
||||||
|
|
||||||
typedef enum _HV_STORAGE_TYPE
|
typedef enum _HV_STORAGE_TYPE
|
||||||
{
|
{
|
||||||
|
|
|
@ -1522,11 +1522,11 @@ CmiAddValueToKey(IN PEREGISTRY_HIVE RegistryHive,
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
DPRINT("KeyCell->ValueList.Count %lu, ValueListCell->CellSize %lu (%lu %lx)\n",
|
DPRINT("KeyCell->ValueList.Count %lu, ValueListCell->Size %lu (%lu %lx)\n",
|
||||||
KeyCell->ValueList.Count,
|
KeyCell->ValueList.Count,
|
||||||
(ULONG)ABS_VALUE(ValueListCell->CellSize),
|
(ULONG)ABS_VALUE(ValueListCell->Size),
|
||||||
((ULONG)ABS_VALUE(ValueListCell->CellSize) - sizeof(CELL_HEADER)) / sizeof(HCELL_INDEX),
|
((ULONG)ABS_VALUE(ValueListCell->Size) - sizeof(HCELL)) / sizeof(HCELL_INDEX),
|
||||||
((ULONG)ABS_VALUE(ValueListCell->CellSize) - sizeof(CELL_HEADER)) / sizeof(HCELL_INDEX));
|
((ULONG)ABS_VALUE(ValueListCell->Size) - sizeof(HCELL)) / sizeof(HCELL_INDEX));
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Status = CmiAllocateValueCell(RegistryHive,
|
Status = CmiAllocateValueCell(RegistryHive,
|
||||||
|
|
Loading…
Reference in a new issue