[MOUNTMGR][NTOSKRNL] ZwWriteFile() calls: Use explicit NULL instead of ambiguous...
[reactos.git] / ntoskrnl / config / cmmapvw.c
1 /*
2 * PROJECT: ReactOS Kernel
3 * LICENSE: GPL - See COPYING in the top level directory
4 * FILE: ntoskrnl/config/cmmapvw.c
5 * PURPOSE: Configuration Manager - Map-Viewed Hive Support
6 * PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
7 */
8
9 /* INCLUDES ******************************************************************/
10
11 #include "ntoskrnl.h"
12 #define NDEBUG
13 #include "debug.h"
14
15 /* GLOBALS *******************************************************************/
16
17 /* FUNCTIONS *****************************************************************/
18
19 VOID
20 NTAPI
21 CmpInitHiveViewList(IN PCMHIVE Hive)
22 {
23 /* Initialize the list heads */
24 InitializeListHead(&Hive->LRUViewListHead);
25 InitializeListHead(&Hive->PinViewListHead);
26
27 /* Reset data */
28 Hive->MappedViews = 0;
29 Hive->PinnedViews = 0;
30 Hive->UseCount = 0;
31 }
32
33 VOID
34 NTAPI
35 CmpDestroyHiveViewList(IN PCMHIVE Hive)
36 {
37 PCM_VIEW_OF_FILE CmView;
38 PLIST_ENTRY EntryList;
39
40 /* Do NOT destroy the views of read-only hives */
41 ASSERT(Hive->Hive.ReadOnly == FALSE);
42
43 /* Free all the views inside the Pinned View List */
44 while (!IsListEmpty(&Hive->PinViewListHead))
45 {
46 EntryList = RemoveHeadList(&Hive->PinViewListHead);
47
48 CmView = CONTAINING_RECORD(EntryList, CM_VIEW_OF_FILE, PinViewList);
49
50 /* FIXME: Unmap the view if it is mapped */
51
52 ExFreePool(CmView);
53
54 Hive->PinnedViews--;
55 }
56
57 /* The Pinned View List should be empty */
58 ASSERT(IsListEmpty(&Hive->PinViewListHead) == TRUE);
59 ASSERT(Hive->PinnedViews == 0);
60
61 /* Now, free all the views inside the LRU View List */
62 while (!IsListEmpty(&Hive->LRUViewListHead))
63 {
64 EntryList = RemoveHeadList(&Hive->LRUViewListHead);
65
66 CmView = CONTAINING_RECORD(EntryList, CM_VIEW_OF_FILE, LRUViewList);
67
68 /* FIXME: Unmap the view if it is mapped */
69
70 ExFreePool(CmView);
71
72 Hive->MappedViews--;
73 }
74
75 /* The LRU View List should be empty */
76 ASSERT(IsListEmpty(&Hive->LRUViewListHead) == TRUE);
77 ASSERT(Hive->MappedViews == 0);
78 }
79
80 /* EOF */