mirror of
https://github.com/reactos/reactos.git
synced 2024-12-27 01:24:38 +00:00
Support non-paged version of binary tree, splay tree and hash table.
svn path=/trunk/; revision=2771
This commit is contained in:
parent
716ec9c7cf
commit
59562362a8
7 changed files with 316 additions and 74 deletions
|
@ -824,7 +824,8 @@ ExHookException (
|
|||
|
||||
BOOLEAN STDCALL
|
||||
ExInitializeBinaryTree(IN PBINARY_TREE Tree,
|
||||
IN PKEY_COMPARATOR Compare);
|
||||
IN PKEY_COMPARATOR Compare,
|
||||
IN BOOLEAN UseNonPagedPool);
|
||||
|
||||
VOID STDCALL
|
||||
ExDeleteBinaryTree(IN PBINARY_TREE Tree);
|
||||
|
@ -847,7 +848,8 @@ ExRemoveBinaryTree(IN PBINARY_TREE Tree,
|
|||
BOOLEAN STDCALL
|
||||
ExInitializeSplayTree(IN PSPLAY_TREE Tree,
|
||||
IN PKEY_COMPARATOR Compare,
|
||||
IN BOOLEAN Weighted);
|
||||
IN BOOLEAN Weighted,
|
||||
IN BOOLEAN UseNonPagedPool);
|
||||
|
||||
VOID STDCALL
|
||||
ExDeleteSplayTree(IN PSPLAY_TREE Tree);
|
||||
|
@ -874,7 +876,8 @@ ExWeightOfSplayTree(IN PSPLAY_TREE Tree,
|
|||
BOOLEAN STDCALL
|
||||
ExInitializeHashTable(IN PHASH_TABLE HashTable,
|
||||
IN ULONG HashTableSize,
|
||||
IN PKEY_COMPARATOR Compare OPTIONAL);
|
||||
IN PKEY_COMPARATOR Compare OPTIONAL,
|
||||
IN BOOLEAN UseNonPagedPool);
|
||||
|
||||
VOID STDCALL
|
||||
ExDeleteHashTable(IN PHASH_TABLE HashTable);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $Id: extypes.h,v 1.7 2002/03/22 20:58:23 chorns Exp $ */
|
||||
/* $Id: extypes.h,v 1.8 2002/03/23 13:53:21 chorns Exp $ */
|
||||
|
||||
#ifndef __INCLUDE_DDK_EXTYPES_H
|
||||
#define __INCLUDE_DDK_EXTYPES_H
|
||||
|
@ -169,8 +169,15 @@ typedef struct _BINARY_TREE
|
|||
{
|
||||
struct _BINARY_TREE_NODE * RootNode;
|
||||
PKEY_COMPARATOR Compare;
|
||||
PAGED_LOOKASIDE_LIST LookasideList;
|
||||
FAST_MUTEX Lock;
|
||||
BOOLEAN UseNonPagedPool;
|
||||
union {
|
||||
NPAGED_LOOKASIDE_LIST NonPaged;
|
||||
PAGED_LOOKASIDE_LIST Paged;
|
||||
} List;
|
||||
union {
|
||||
KSPIN_LOCK NonPaged;
|
||||
FAST_MUTEX Paged;
|
||||
} Lock;
|
||||
} BINARY_TREE, *PBINARY_TREE;
|
||||
|
||||
|
||||
|
@ -181,20 +188,33 @@ typedef struct _SPLAY_TREE
|
|||
struct _SPLAY_TREE_NODE * RootNode;
|
||||
PKEY_COMPARATOR Compare;
|
||||
BOOLEAN Weighted;
|
||||
PAGED_LOOKASIDE_LIST LookasideList;
|
||||
FAST_MUTEX Lock;
|
||||
BOOLEAN UseNonPagedPool;
|
||||
union {
|
||||
NPAGED_LOOKASIDE_LIST NonPaged;
|
||||
PAGED_LOOKASIDE_LIST Paged;
|
||||
} List;
|
||||
union {
|
||||
KSPIN_LOCK NonPaged;
|
||||
FAST_MUTEX Paged;
|
||||
} Lock;
|
||||
PVOID Reserved[4];
|
||||
} SPLAY_TREE, *PSPLAY_TREE;
|
||||
|
||||
|
||||
typedef struct _HASH_TABLE
|
||||
{
|
||||
// Lock for this structure
|
||||
FAST_MUTEX Lock;
|
||||
|
||||
// Size of hash table in number of bits
|
||||
ULONG HashTableSize;
|
||||
|
||||
// Use non-paged pool memory?
|
||||
BOOLEAN UseNonPagedPool;
|
||||
|
||||
// Lock for this structure
|
||||
union {
|
||||
KSPIN_LOCK NonPaged;
|
||||
FAST_MUTEX Paged;
|
||||
} Lock;
|
||||
|
||||
// Pointer to array of hash buckets with splay trees
|
||||
PSPLAY_TREE HashTrees;
|
||||
} HASH_TABLE, *PHASH_TABLE;
|
||||
|
|
|
@ -56,6 +56,42 @@ typedef struct _BINARY_TREE_NODE
|
|||
#define ExpBinaryTreeNodeMore(Equality)((Equality) > 0)
|
||||
|
||||
|
||||
/*
|
||||
* Lock the binary tree
|
||||
*/
|
||||
inline VOID
|
||||
ExpLockBinaryTree(PBINARY_TREE Tree,
|
||||
PKIRQL OldIrql)
|
||||
{
|
||||
if (Tree->UseNonPagedPool)
|
||||
{
|
||||
KeAcquireSpinLock(&Tree->Lock.NonPaged, OldIrql);
|
||||
}
|
||||
else
|
||||
{
|
||||
ExAcquireFastMutex(&Tree->Lock.Paged);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Unlock the binary tree
|
||||
*/
|
||||
inline VOID
|
||||
ExpUnlockBinaryTree(PBINARY_TREE Tree,
|
||||
PKIRQL OldIrql)
|
||||
{
|
||||
if (Tree->UseNonPagedPool)
|
||||
{
|
||||
KeReleaseSpinLock(&Tree->Lock.NonPaged, *OldIrql);
|
||||
}
|
||||
else
|
||||
{
|
||||
ExReleaseFastMutex(&Tree->Lock.Paged);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Allocate resources for a new node and initialize it.
|
||||
*/
|
||||
|
@ -66,7 +102,14 @@ ExpCreateBinaryTreeNode(PBINARY_TREE Tree,
|
|||
{
|
||||
PBINARY_TREE_NODE Node;
|
||||
|
||||
Node = (PBINARY_TREE_NODE) ExAllocateFromPagedLookasideList(&Tree->LookasideList);
|
||||
if (Tree->UseNonPagedPool)
|
||||
{
|
||||
Node = (PBINARY_TREE_NODE) ExAllocateFromNPagedLookasideList(&Tree->List.NonPaged);
|
||||
}
|
||||
else
|
||||
{
|
||||
Node = (PBINARY_TREE_NODE) ExAllocateFromPagedLookasideList(&Tree->List.Paged);
|
||||
}
|
||||
|
||||
if (Node)
|
||||
{
|
||||
|
@ -87,7 +130,14 @@ inline VOID
|
|||
ExpDestroyBinaryTreeNode(PBINARY_TREE Tree,
|
||||
PBINARY_TREE_NODE Node)
|
||||
{
|
||||
ExFreeToPagedLookasideList(&Tree->LookasideList, Node);
|
||||
if (Tree->UseNonPagedPool)
|
||||
{
|
||||
ExFreeToNPagedLookasideList(&Tree->List.NonPaged, Node);
|
||||
}
|
||||
else
|
||||
{
|
||||
ExFreeToPagedLookasideList(&Tree->List.Paged, Node);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -273,29 +323,55 @@ ExpBinaryTreeDefaultCompare(PVOID Key1,
|
|||
*/
|
||||
BOOLEAN STDCALL
|
||||
ExInitializeBinaryTree(IN PBINARY_TREE Tree,
|
||||
IN PKEY_COMPARATOR Compare)
|
||||
IN PKEY_COMPARATOR Compare,
|
||||
IN BOOLEAN UseNonPagedPool)
|
||||
{
|
||||
RtlZeroMemory(Tree, sizeof(BINARY_TREE));
|
||||
|
||||
Tree->Compare = (Compare == NULL)
|
||||
? ExpBinaryTreeDefaultCompare : Compare;
|
||||
|
||||
ExInitializePagedLookasideList(
|
||||
&Tree->LookasideList, /* Lookaside list */
|
||||
NULL, /* Allocate routine */
|
||||
NULL, /* Free routine */
|
||||
0, /* Flags */
|
||||
sizeof(BINARY_TREE_NODE), /* Size of each entry */
|
||||
TAG('E','X','B','T'), /* Tag */
|
||||
0); /* Depth */
|
||||
Tree->UseNonPagedPool = UseNonPagedPool;
|
||||
|
||||
ExInitializeFastMutex(&Tree->Lock);
|
||||
if (UseNonPagedPool)
|
||||
{
|
||||
ExInitializeNPagedLookasideList(
|
||||
&Tree->List.NonPaged, /* Lookaside list */
|
||||
NULL, /* Allocate routine */
|
||||
NULL, /* Free routine */
|
||||
0, /* Flags */
|
||||
sizeof(BINARY_TREE_NODE), /* Size of each entry */
|
||||
TAG('E','X','B','T'), /* Tag */
|
||||
0); /* Depth */
|
||||
|
||||
KeInitializeSpinLock(&Tree->Lock.NonPaged);
|
||||
}
|
||||
else
|
||||
{
|
||||
ExInitializePagedLookasideList(
|
||||
&Tree->List.Paged, /* Lookaside list */
|
||||
NULL, /* Allocate routine */
|
||||
NULL, /* Free routine */
|
||||
0, /* Flags */
|
||||
sizeof(BINARY_TREE_NODE), /* Size of each entry */
|
||||
TAG('E','X','B','T'), /* Tag */
|
||||
0); /* Depth */
|
||||
|
||||
ExInitializeFastMutex(&Tree->Lock.Paged);
|
||||
}
|
||||
|
||||
ExpBinaryTreeRootNode(Tree) = ExpCreateBinaryTreeNode(Tree, NULL, NULL);
|
||||
|
||||
if (ExpBinaryTreeRootNode(Tree) == NULL)
|
||||
{
|
||||
ExDeletePagedLookasideList(&Tree->LookasideList);
|
||||
if (UseNonPagedPool)
|
||||
{
|
||||
ExDeleteNPagedLookasideList(&Tree->List.NonPaged);
|
||||
}
|
||||
else
|
||||
{
|
||||
ExDeletePagedLookasideList(&Tree->List.Paged);
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
|
@ -314,7 +390,14 @@ ExDeleteBinaryTree(IN PBINARY_TREE Tree)
|
|||
/* Remove all nodes */
|
||||
ExpDeleteBinaryTree(Tree, ExpBinaryTreeRootNode(Tree));
|
||||
|
||||
ExDeletePagedLookasideList(&Tree->LookasideList);
|
||||
if (Tree->UseNonPagedPool)
|
||||
{
|
||||
ExDeleteNPagedLookasideList(&Tree->List.NonPaged);
|
||||
}
|
||||
else
|
||||
{
|
||||
ExDeletePagedLookasideList(&Tree->List.Paged);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -327,10 +410,11 @@ ExInsertBinaryTree(IN PBINARY_TREE Tree,
|
|||
IN PVOID Value)
|
||||
{
|
||||
PBINARY_TREE_NODE Node;
|
||||
KIRQL OldIrql;
|
||||
|
||||
/* FIXME: Use SEH for error reporting */
|
||||
|
||||
ExAcquireFastMutex(&Tree->Lock);
|
||||
ExpLockBinaryTree(Tree, &OldIrql);
|
||||
Node = ExpBinaryTreeRootNode(Tree);
|
||||
do
|
||||
{
|
||||
|
@ -348,7 +432,7 @@ ExInsertBinaryTree(IN PBINARY_TREE Tree,
|
|||
ExpExpandExternalBinaryTreeNode(Tree, Node);
|
||||
ExpBinaryTreeNodeKey(Node) = Key;
|
||||
ExpBinaryTreeNodeValue(Node) = Value;
|
||||
ExReleaseFastMutex(&Tree->Lock);
|
||||
ExpUnlockBinaryTree(Tree, &OldIrql);
|
||||
}
|
||||
|
||||
|
||||
|
@ -361,19 +445,20 @@ ExSearchBinaryTree(IN PBINARY_TREE Tree,
|
|||
OUT PVOID * Value)
|
||||
{
|
||||
PBINARY_TREE_NODE Node;
|
||||
KIRQL OldIrql;
|
||||
|
||||
ExAcquireFastMutex(&Tree->Lock);
|
||||
ExpLockBinaryTree(Tree, &OldIrql);
|
||||
Node = ExpSearchBinaryTree(Tree, Key, ExpBinaryTreeRootNode(Tree));
|
||||
|
||||
if (ExpIsInternalBinaryTreeNode(Node))
|
||||
{
|
||||
*Value = ExpBinaryTreeNodeValue(Node);
|
||||
ExReleaseFastMutex(&Tree->Lock);
|
||||
ExpUnlockBinaryTree(Tree, &OldIrql);
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
ExReleaseFastMutex(&Tree->Lock);
|
||||
ExpUnlockBinaryTree(Tree, &OldIrql);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -388,13 +473,15 @@ ExRemoveBinaryTree(IN PBINARY_TREE Tree,
|
|||
IN PVOID * Value)
|
||||
{
|
||||
PBINARY_TREE_NODE Node;
|
||||
KIRQL OldIrql;
|
||||
|
||||
ExpLockBinaryTree(Tree, &OldIrql);
|
||||
|
||||
ExAcquireFastMutex(&Tree->Lock);
|
||||
Node = ExpSearchBinaryTree(Tree, Key, ExpBinaryTreeRootNode(Tree));
|
||||
|
||||
if (ExpIsExternalBinaryTreeNode(Node))
|
||||
{
|
||||
ExReleaseFastMutex(&Tree->Lock);
|
||||
ExpUnlockBinaryTree(Tree, &OldIrql);
|
||||
return FALSE;
|
||||
}
|
||||
else
|
||||
|
@ -422,7 +509,7 @@ ExRemoveBinaryTree(IN PBINARY_TREE Tree,
|
|||
}
|
||||
|
||||
ExpRemoveAboveExternalBinaryTreeNode(Tree, Node);
|
||||
ExReleaseFastMutex(&Tree->Lock);
|
||||
ExpUnlockBinaryTree(Tree, &OldIrql);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -98,6 +98,42 @@ ExpHash(PUCHAR Key,
|
|||
}
|
||||
|
||||
|
||||
/*
|
||||
* Lock the hash table
|
||||
*/
|
||||
inline VOID
|
||||
ExpLockHashTable(PHASH_TABLE HashTable,
|
||||
PKIRQL OldIrql)
|
||||
{
|
||||
if (HashTable->UseNonPagedPool)
|
||||
{
|
||||
KeAcquireSpinLock(&HashTable->Lock.NonPaged, OldIrql);
|
||||
}
|
||||
else
|
||||
{
|
||||
ExAcquireFastMutex(&HashTable->Lock.Paged);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Unlock the hash table
|
||||
*/
|
||||
inline VOID
|
||||
ExpUnlockHashTable(PHASH_TABLE HashTable,
|
||||
PKIRQL OldIrql)
|
||||
{
|
||||
if (HashTable->UseNonPagedPool)
|
||||
{
|
||||
KeReleaseSpinLock(&HashTable->Lock.NonPaged, *OldIrql);
|
||||
}
|
||||
else
|
||||
{
|
||||
ExReleaseFastMutex(&HashTable->Lock.Paged);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Insert a value in a hash table.
|
||||
*/
|
||||
|
@ -155,7 +191,8 @@ ExpRemoveHashTable(IN PHASH_TABLE HashTable,
|
|||
BOOLEAN STDCALL
|
||||
ExInitializeHashTable(IN PHASH_TABLE HashTable,
|
||||
IN ULONG HashTableSize,
|
||||
IN PKEY_COMPARATOR Compare OPTIONAL)
|
||||
IN PKEY_COMPARATOR Compare OPTIONAL,
|
||||
IN BOOLEAN UseNonPagedPool)
|
||||
{
|
||||
BOOLEAN Status;
|
||||
LONG Index;
|
||||
|
@ -164,9 +201,18 @@ ExInitializeHashTable(IN PHASH_TABLE HashTable,
|
|||
|
||||
HashTable->HashTableSize = HashTableSize;
|
||||
|
||||
ExInitializeFastMutex(&HashTable->Lock);
|
||||
HashTable->UseNonPagedPool = UseNonPagedPool;
|
||||
|
||||
HashTable->HashTrees = ExAllocatePool(PagedPool, ExpHashTableSize(HashTableSize) * sizeof(SPLAY_TREE));
|
||||
if (UseNonPagedPool)
|
||||
{
|
||||
KeInitializeSpinLock(&HashTable->Lock.NonPaged);
|
||||
HashTable->HashTrees = ExAllocatePool(NonPagedPool, ExpHashTableSize(HashTableSize) * sizeof(SPLAY_TREE));
|
||||
}
|
||||
else
|
||||
{
|
||||
ExInitializeFastMutex(&HashTable->Lock.Paged);
|
||||
HashTable->HashTrees = ExAllocatePool(PagedPool, ExpHashTableSize(HashTableSize) * sizeof(SPLAY_TREE));
|
||||
}
|
||||
|
||||
if (HashTable->HashTrees == NULL)
|
||||
{
|
||||
|
@ -175,7 +221,7 @@ ExInitializeHashTable(IN PHASH_TABLE HashTable,
|
|||
|
||||
for (Index = 0; Index < ExpHashTableSize(HashTableSize); Index++)
|
||||
{
|
||||
Status = ExInitializeSplayTree(&HashTable->HashTrees[Index], Compare, FALSE);
|
||||
Status = ExInitializeSplayTree(&HashTable->HashTrees[Index], Compare, FALSE, UseNonPagedPool);
|
||||
|
||||
if (!Status)
|
||||
{
|
||||
|
@ -222,11 +268,13 @@ ExInsertHashTable(IN PHASH_TABLE HashTable,
|
|||
IN ULONG KeyLength,
|
||||
IN PVOID Value)
|
||||
{
|
||||
KIRQL OldIrql;
|
||||
|
||||
/* FIXME: Use SEH for error reporting */
|
||||
|
||||
ExAcquireFastMutex(&HashTable->Lock);
|
||||
ExpLockHashTable(HashTable, &OldIrql);
|
||||
ExpInsertHashTable(HashTable, Key, KeyLength, Value);
|
||||
ExReleaseFastMutex(&HashTable->Lock);
|
||||
ExpUnlockHashTable(HashTable, &OldIrql);
|
||||
}
|
||||
|
||||
|
||||
|
@ -240,10 +288,11 @@ ExSearchHashTable(IN PHASH_TABLE HashTable,
|
|||
OUT PVOID * Value)
|
||||
{
|
||||
BOOLEAN Status;
|
||||
KIRQL OldIrql;
|
||||
|
||||
ExAcquireFastMutex(&HashTable->Lock);
|
||||
ExpLockHashTable(HashTable, &OldIrql);
|
||||
Status = ExpSearchHashTable(HashTable, Key, KeyLength, Value);
|
||||
ExReleaseFastMutex(&HashTable->Lock);
|
||||
ExpUnlockHashTable(HashTable, &OldIrql);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
@ -259,10 +308,11 @@ ExRemoveHashTable(IN PHASH_TABLE HashTable,
|
|||
IN PVOID * Value)
|
||||
{
|
||||
BOOLEAN Status;
|
||||
KIRQL OldIrql;
|
||||
|
||||
ExAcquireFastMutex(&HashTable->Lock);
|
||||
ExpLockHashTable(HashTable, &OldIrql);
|
||||
Status = ExpRemoveHashTable(HashTable, Key, KeyLength, Value);
|
||||
ExReleaseFastMutex(&HashTable->Lock);
|
||||
ExpUnlockHashTable(HashTable, &OldIrql);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
|
|
@ -101,6 +101,42 @@ typedef PSPLAY_TREE_NODE (*PSPLAY_TREE_REMOVE)(PSPLAY_TREE Tree,
|
|||
#define KEY_NOTUSED (PVOID)-1
|
||||
|
||||
|
||||
/*
|
||||
* Lock the splay tree
|
||||
*/
|
||||
inline VOID
|
||||
ExpLockSplayTree(PSPLAY_TREE Tree,
|
||||
PKIRQL OldIrql)
|
||||
{
|
||||
if (Tree->UseNonPagedPool)
|
||||
{
|
||||
KeAcquireSpinLock(&Tree->Lock.NonPaged, OldIrql);
|
||||
}
|
||||
else
|
||||
{
|
||||
ExAcquireFastMutex(&Tree->Lock.Paged);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Unlock the splay tree
|
||||
*/
|
||||
inline VOID
|
||||
ExpUnlockSplayTree(PSPLAY_TREE Tree,
|
||||
PKIRQL OldIrql)
|
||||
{
|
||||
if (Tree->UseNonPagedPool)
|
||||
{
|
||||
KeReleaseSpinLock(&Tree->Lock.NonPaged, *OldIrql);
|
||||
}
|
||||
else
|
||||
{
|
||||
ExReleaseFastMutex(&Tree->Lock.Paged);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Allocate resources for a new node and initialize it.
|
||||
*/
|
||||
|
@ -110,7 +146,14 @@ ExpCreateSplayTreeNode(PSPLAY_TREE Tree,
|
|||
{
|
||||
PSPLAY_TREE_NODE Node;
|
||||
|
||||
Node = (PSPLAY_TREE_NODE) ExAllocateFromPagedLookasideList(&Tree->LookasideList);
|
||||
if (Tree->UseNonPagedPool)
|
||||
{
|
||||
Node = (PSPLAY_TREE_NODE) ExAllocateFromNPagedLookasideList(&Tree->List.NonPaged);
|
||||
}
|
||||
else
|
||||
{
|
||||
Node = (PSPLAY_TREE_NODE) ExAllocateFromPagedLookasideList(&Tree->List.Paged);
|
||||
}
|
||||
|
||||
if (Node)
|
||||
{
|
||||
|
@ -129,7 +172,14 @@ inline VOID
|
|||
ExpDestroySplayTreeNode(PSPLAY_TREE Tree,
|
||||
PSPLAY_TREE_NODE Node)
|
||||
{
|
||||
ExFreeToPagedLookasideList(&Tree->LookasideList, Node);
|
||||
if (Tree->UseNonPagedPool)
|
||||
{
|
||||
ExFreeToNPagedLookasideList(&Tree->List.NonPaged, Node);
|
||||
}
|
||||
else
|
||||
{
|
||||
ExFreeToPagedLookasideList(&Tree->List.Paged, Node);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -913,7 +963,8 @@ ExpSplayTreeDefaultCompare(IN PVOID Key1,
|
|||
BOOLEAN STDCALL
|
||||
ExInitializeSplayTree(IN PSPLAY_TREE Tree,
|
||||
IN PKEY_COMPARATOR Compare,
|
||||
IN BOOLEAN Weighted)
|
||||
IN BOOLEAN Weighted,
|
||||
IN BOOLEAN UseNonPagedPool)
|
||||
{
|
||||
RtlZeroMemory(Tree, sizeof(SPLAY_TREE));
|
||||
|
||||
|
@ -937,16 +988,34 @@ ExInitializeSplayTree(IN PSPLAY_TREE Tree,
|
|||
Tree->Reserved[REMOVE_INDEX] = (PVOID) ExpRemoveSplayTreeNoWeight;
|
||||
}
|
||||
|
||||
ExInitializePagedLookasideList(
|
||||
&Tree->LookasideList, /* Lookaside list */
|
||||
NULL, /* Allocate routine */
|
||||
NULL, /* Free routine */
|
||||
0, /* Flags */
|
||||
sizeof(SPLAY_TREE_NODE), /* Size of each entry */
|
||||
TAG('E','X','S','T'), /* Tag */
|
||||
0); /* Depth */
|
||||
Tree->UseNonPagedPool = UseNonPagedPool;
|
||||
|
||||
ExInitializeFastMutex(&Tree->Lock);
|
||||
if (UseNonPagedPool)
|
||||
{
|
||||
ExInitializeNPagedLookasideList(
|
||||
&Tree->List.NonPaged, /* Lookaside list */
|
||||
NULL, /* Allocate routine */
|
||||
NULL, /* Free routine */
|
||||
0, /* Flags */
|
||||
sizeof(SPLAY_TREE_NODE), /* Size of each entry */
|
||||
TAG('E','X','S','T'), /* Tag */
|
||||
0); /* Depth */
|
||||
|
||||
KeInitializeSpinLock(&Tree->Lock.NonPaged);
|
||||
}
|
||||
else
|
||||
{
|
||||
ExInitializePagedLookasideList(
|
||||
&Tree->List.Paged, /* Lookaside list */
|
||||
NULL, /* Allocate routine */
|
||||
NULL, /* Free routine */
|
||||
0, /* Flags */
|
||||
sizeof(SPLAY_TREE_NODE), /* Size of each entry */
|
||||
TAG('E','X','S','T'), /* Tag */
|
||||
0); /* Depth */
|
||||
|
||||
ExInitializeFastMutex(&Tree->Lock.Paged);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -973,7 +1042,14 @@ ExDeleteSplayTree(IN PSPLAY_TREE Tree)
|
|||
}
|
||||
}
|
||||
|
||||
ExDeletePagedLookasideList(&Tree->LookasideList);
|
||||
if (Tree->UseNonPagedPool)
|
||||
{
|
||||
ExDeleteNPagedLookasideList(&Tree->List.NonPaged);
|
||||
}
|
||||
else
|
||||
{
|
||||
ExDeletePagedLookasideList(&Tree->List.Paged);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -987,15 +1063,16 @@ ExInsertSplayTree(IN PSPLAY_TREE Tree,
|
|||
{
|
||||
PSPLAY_TREE_NODE Node;
|
||||
PSPLAY_TREE_NODE NewNode;
|
||||
KIRQL OldIrql;
|
||||
|
||||
/* FIXME: Use SEH for error reporting */
|
||||
|
||||
NewNode = ExpCreateSplayTreeNode(Tree, Value);
|
||||
|
||||
ExAcquireFastMutex(&Tree->Lock);
|
||||
ExpLockSplayTree(Tree, &OldIrql);
|
||||
Node = ExpInsertSplayTree(Tree, Key, ExpSplayTreeRootNode(Tree), NewNode);
|
||||
ExpSplayTreeRootNode(Tree) = Node;
|
||||
ExReleaseFastMutex(&Tree->Lock);
|
||||
ExpUnlockSplayTree(Tree, &OldIrql);
|
||||
}
|
||||
|
||||
|
||||
|
@ -1009,20 +1086,21 @@ ExSearchSplayTree(IN PSPLAY_TREE Tree,
|
|||
{
|
||||
PSPLAY_TREE_NODE Node;
|
||||
BOOLEAN Status;
|
||||
KIRQL OldIrql;
|
||||
|
||||
ExAcquireFastMutex(&Tree->Lock);
|
||||
ExpLockSplayTree(Tree, &OldIrql);
|
||||
Status = ExpSearchSplayTree(Tree, Key, ExpSplayTreeRootNode(Tree), &Node);
|
||||
|
||||
if (Status)
|
||||
{
|
||||
ExpSplayTreeRootNode(Tree) = Node;
|
||||
*Value = ExpSplayTreeNodeValue(Node);
|
||||
ExReleaseFastMutex(&Tree->Lock);
|
||||
ExpUnlockSplayTree(Tree, &OldIrql);
|
||||
return TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
ExReleaseFastMutex(&Tree->Lock);
|
||||
ExpUnlockSplayTree(Tree, &OldIrql);
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
@ -1038,11 +1116,12 @@ ExRemoveSplayTree(IN PSPLAY_TREE Tree,
|
|||
{
|
||||
PSPLAY_TREE_NODE RemovedNode;
|
||||
PSPLAY_TREE_NODE Node;
|
||||
KIRQL OldIrql;
|
||||
|
||||
ExAcquireFastMutex(&Tree->Lock);
|
||||
ExpLockSplayTree(Tree, &OldIrql);
|
||||
Node = ExpRemoveSplayTree(Tree, Key, ExpSplayTreeRootNode(Tree), &RemovedNode);
|
||||
ExpSplayTreeRootNode(Tree) = Node;
|
||||
ExReleaseFastMutex(&Tree->Lock);
|
||||
ExpUnlockSplayTree(Tree, &OldIrql);
|
||||
|
||||
if (RemovedNode != NULL)
|
||||
{
|
||||
|
@ -1065,16 +1144,19 @@ BOOLEAN STDCALL
|
|||
ExWeightOfSplayTree(IN PSPLAY_TREE Tree,
|
||||
OUT PULONG Weight)
|
||||
{
|
||||
ExAcquireFastMutex(&Tree->Lock);
|
||||
KIRQL OldIrql;
|
||||
|
||||
ExpLockSplayTree(Tree, &OldIrql);
|
||||
|
||||
if (!Tree->Weighted)
|
||||
{
|
||||
ExReleaseFastMutex(&Tree->Lock);
|
||||
ExpUnlockSplayTree(Tree, &OldIrql);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
*Weight = ExpSplayTreeNodeWeight(ExpSplayTreeRootNode(Tree));
|
||||
ExReleaseFastMutex(&Tree->Lock);
|
||||
ExpUnlockSplayTree(Tree, &OldIrql);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
; $Id: ntoskrnl.def,v 1.130 2002/03/22 20:58:23 chorns Exp $
|
||||
; $Id: ntoskrnl.def,v 1.131 2002/03/23 13:53:22 chorns Exp $
|
||||
;
|
||||
; reactos/ntoskrnl/ntoskrnl.def
|
||||
;
|
||||
|
@ -93,18 +93,18 @@ ExSystemTimeToLocalTime@8
|
|||
ExTryToAcquireResourceExclusiveLite@4
|
||||
ExUnregisterCallback@4
|
||||
ExWindowStationObjectType DATA
|
||||
ExInitializeBinaryTree@8
|
||||
ExInitializeBinaryTree@12
|
||||
ExDeleteBinaryTree@4
|
||||
ExInsertBinaryTree@12
|
||||
ExSearchBinaryTree@12
|
||||
ExRemoveBinaryTree@12
|
||||
ExInitializeSplayTree@12
|
||||
ExInitializeSplayTree@16
|
||||
ExDeleteSplayTree@4
|
||||
ExInsertSplayTree@12
|
||||
ExSearchSplayTree@12
|
||||
ExRemoveSplayTree@12
|
||||
ExWeightOfSplayTree@8
|
||||
ExInitializeHashTable@12
|
||||
ExInitializeHashTable@16
|
||||
ExDeleteHashTable@4
|
||||
ExInsertHashTable@16
|
||||
ExSearchHashTable@16
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
; $Id: ntoskrnl.edf,v 1.116 2002/03/22 20:58:23 chorns Exp $
|
||||
; $Id: ntoskrnl.edf,v 1.117 2002/03/23 13:53:22 chorns Exp $
|
||||
;
|
||||
; reactos/ntoskrnl/ntoskrnl.def
|
||||
;
|
||||
|
@ -93,18 +93,18 @@ ExSystemTimeToLocalTime=ExSystemTimeToLocalTime@8
|
|||
ExTryToAcquireResourceExclusiveLite=ExTryToAcquireResourceExclusiveLite@4
|
||||
ExUnregisterCallback=ExUnregisterCallback@4
|
||||
ExWindowStationObjectType DATA
|
||||
ExInitializeBinaryTree=ExInitializeBinaryTree@8
|
||||
ExInitializeBinaryTree=ExInitializeBinaryTree@12
|
||||
ExDeleteBinaryTree=ExDeleteBinaryTree@4
|
||||
ExInsertBinaryTree=ExInsertBinaryTree@12
|
||||
ExSearchBinaryTree=ExSearchBinaryTree@12
|
||||
ExRemoveBinaryTree=ExRemoveBinaryTree@12
|
||||
ExInitializeSplayTree=ExInitializeSplayTree@12
|
||||
ExInitializeSplayTree=ExInitializeSplayTree@16
|
||||
ExDeleteSplayTree=ExDeleteSplayTree@4
|
||||
ExInsertSplayTree=ExInsertSplayTree@12
|
||||
ExSearchSplayTree=ExSearchSplayTree@12
|
||||
ExRemoveSplayTree=ExRemoveSplayTree@12
|
||||
ExWeightOfSplayTree=ExWeightOfSplayTree@8
|
||||
ExInitializeHashTable=ExInitializeHashTable@12
|
||||
ExInitializeHashTable=ExInitializeHashTable@16
|
||||
ExDeleteHashTable=ExDeleteHashTable@4
|
||||
ExInsertHashTable=ExInsertHashTable@16
|
||||
ExSearchHashTable=ExSearchHashTable@16
|
||||
|
|
Loading…
Reference in a new issue