VOID
NTAPI
+INIT_FUNCTION
CmpInitCmPrivateAlloc(VOID)
{
/* Make sure we didn't already do this */
VOID
NTAPI
+INIT_FUNCTION
CmpInitCmPrivateDelayAlloc(VOID)
{
/* Initialize the delay allocation list and lock */
if (!Kcb->PrivateAlloc)
{
/* Free it from the pool */
- ExFreePool(Kcb);
+ CmpFree(Kcb, 0);
return;
}
KeAcquireGuardedMutex(&CmpAllocBucketLock);
/* Sanity check on lock ownership */
- ASSERT((GET_HASH_ENTRY(CmpCacheTable, Kcb->ConvKey).Owner ==
- KeGetCurrentThread()) ||
- (CmpTestRegistryLockExclusive() == TRUE));
+ CMP_ASSERT_HASH_ENTRY_LOCK(Kcb->ConvKey);
/* Add us to the free list */
InsertTailList(&CmpFreeKCBListHead, &Kcb->FreeListEntry);
/* Get the allocation page */
- AllocPage = (PCM_ALLOC_PAGE)((ULONG_PTR)Kcb & 0xFFFFF000);
+ AllocPage = CmpGetAllocPageFromKcb(Kcb);
/* Sanity check */
ASSERT(AllocPage->FreeCount != CM_KCBS_PER_PAGE);
}
/* Free the page */
- ExFreePool(AllocPage);
+ CmpFree(AllocPage, 0);
}
/* Release the lock */
FreeListEntry);
/* Get the allocation page */
- AllocPage = (PCM_ALLOC_PAGE)((ULONG_PTR)CurrentKcb & 0xFFFFF000);
+ AllocPage = CmpGetAllocPageFromKcb(CurrentKcb);
/* Decrease the free count */
ASSERT(AllocPage->FreeCount != 0);
}
/* Allocate an allocation page */
- AllocPage = ExAllocatePoolWithTag(PagedPool, PAGE_SIZE, TAG_CM);
+ AllocPage = CmpAllocate(PAGE_SIZE, TRUE, TAG_CM);
if (AllocPage)
{
/* Set default entries */
/* Set it up */
CurrentKcb->PrivateAlloc = TRUE;
CurrentKcb->DelayCloseEntry = NULL;
- InsertHeadList(&CmpFreeKCBListHead,
+ InsertTailList(&CmpFreeKCBListHead,
&CurrentKcb->FreeListEntry);
}
}
/* Allocate a KCB only */
- CurrentKcb = ExAllocatePoolWithTag(PagedPool,
- sizeof(CM_KEY_CONTROL_BLOCK),
- TAG_CM);
+ CurrentKcb = CmpAllocate(sizeof(CM_KEY_CONTROL_BLOCK), TRUE, TAG_CM);
if (CurrentKcb)
{
/* Set it up */
Entry->ListEntry.Flink = Entry->ListEntry.Blink = NULL;
/* Grab the alloc page */
- AllocPage = (PCM_ALLOC_PAGE)((ULONG_PTR)Entry & 0xFFFFF000);
+ AllocPage = CmpGetAllocPageFromDelayAlloc(Entry);
/* Decrease free entries */
ASSERT(AllocPage->FreeCount != 0);
}
/* Allocate an allocation page */
- AllocPage = ExAllocatePoolWithTag(PagedPool, PAGE_SIZE, TAG_CM);
+ AllocPage = CmpAllocate(PAGE_SIZE, TRUE, TAG_CM);
if (AllocPage)
{
/* Set default entries */
InsertTailList(&CmpFreeDelayItemsListHead, &AllocEntry->ListEntry);
/* Get the alloc page */
- AllocPage = (PCM_ALLOC_PAGE)((ULONG_PTR)Entry & 0xFFFFF000);
+ AllocPage = CmpGetAllocPageFromDelayAlloc(Entry);
ASSERT(AllocPage->FreeCount != CM_DELAYS_PER_PAGE);
/* Increase the number of free items */
}
/* Now free the page */
- ExFreePool(AllocPage);
+ CmpFree(AllocPage, 0);
}
/* Release the lock */