[CMAKE]
[reactos.git] / ntoskrnl / config / cmalloc.c
index 37da97e..6502883 100644 (file)
@@ -25,6 +25,7 @@ LIST_ENTRY CmpFreeDelayItemsListHead;
 
 VOID
 NTAPI
+INIT_FUNCTION
 CmpInitCmPrivateAlloc(VOID)
 {
     /* Make sure we didn't already do this */
@@ -39,6 +40,7 @@ CmpInitCmPrivateAlloc(VOID)
 
 VOID
 NTAPI
+INIT_FUNCTION
 CmpInitCmPrivateDelayAlloc(VOID)
 {
     /* Initialize the delay allocation list and lock */
@@ -70,14 +72,13 @@ CmpFreeKeyControlBlock(IN PCM_KEY_CONTROL_BLOCK Kcb)
     KeAcquireGuardedMutex(&CmpAllocBucketLock);
     
     /* Sanity check on lock ownership */
-    //ASSERT((CmpIsKcbLockedExclusive(Kcb) == TRUE) ||
-    //       (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);
@@ -134,7 +135,7 @@ SearchKcbList:
                                            FreeListEntry);
             
             /* Get the allocation page */
-            AllocPage = (PCM_ALLOC_PAGE)((ULONG_PTR)CurrentKcb & 0xFFFFF000);
+            AllocPage = CmpGetAllocPageFromKcb(CurrentKcb);
             
             /* Decrease the free count */
             ASSERT(AllocPage->FreeCount != 0);
@@ -168,7 +169,7 @@ SearchKcbList:
                 /* Set it up */
                 CurrentKcb->PrivateAlloc = TRUE;
                 CurrentKcb->DelayCloseEntry = NULL;
-                InsertHeadList(&CmpFreeKCBListHead,
+                InsertTailList(&CmpFreeKCBListHead,
                                &CurrentKcb->FreeListEntry);
             }
             
@@ -178,9 +179,7 @@ SearchKcbList:
     }
 
     /* Allocate a KCB only */
-    CurrentKcb = CmpAllocate(sizeof(CM_KEY_CONTROL_BLOCK),
-                             TRUE,
-                             TAG_CM);
+    CurrentKcb = CmpAllocate(sizeof(CM_KEY_CONTROL_BLOCK), TRUE, TAG_CM);
     if (CurrentKcb)
     {
         /* Set it up */
@@ -219,7 +218,7 @@ SearchList:
         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);
@@ -278,7 +277,7 @@ CmpFreeDelayItem(PVOID Entry)
     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 */