mirror of
https://github.com/reactos/reactos.git
synced 2025-05-25 12:14:32 +00:00
- Implement simple case of RtlInsertUnicodePrefix where a new node entry needs to be created.
svn path=/trunk/; revision=19040
This commit is contained in:
parent
be502089da
commit
03ff526652
2 changed files with 50 additions and 7 deletions
|
@ -36,6 +36,13 @@
|
||||||
#define RtlParent(Links) \
|
#define RtlParent(Links) \
|
||||||
(PRTL_SPLAY_LINKS)(Links)->Parent
|
(PRTL_SPLAY_LINKS)(Links)->Parent
|
||||||
|
|
||||||
|
#define RtlInitializeSplayLinks(Links) \
|
||||||
|
PRTL_SPLAY_LINKS _SplayLinks; \
|
||||||
|
_SplayLinks = (PRTL_SPLAY_LINKS)(Links); \
|
||||||
|
_SplayLinks->Parent = _SplayLinks; \
|
||||||
|
_SplayLinks->LeftChild = NULL; \
|
||||||
|
_SplayLinks->RightChild = NULL;
|
||||||
|
|
||||||
/* PROTOTYPES ****************************************************************/
|
/* PROTOTYPES ****************************************************************/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
|
@ -25,7 +25,7 @@ typedef USHORT NODE_TYPE_CODE;
|
||||||
|
|
||||||
/* FUNCTIONS ***************************************************************/
|
/* FUNCTIONS ***************************************************************/
|
||||||
|
|
||||||
/*STATIC*/
|
STATIC
|
||||||
ULONG
|
ULONG
|
||||||
NTAPI
|
NTAPI
|
||||||
ComputeUnicodeNameLength(IN PUNICODE_STRING UnicodeName)
|
ComputeUnicodeNameLength(IN PUNICODE_STRING UnicodeName)
|
||||||
|
@ -82,15 +82,52 @@ RtlInsertUnicodePrefix(PUNICODE_PREFIX_TABLE PrefixTable,
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* implementation notes:
|
* implementation notes:
|
||||||
* - get name length (number of names)
|
* - get name length (number of names) DONE
|
||||||
* - init splay links
|
* - init splay links DONE
|
||||||
* - find a matching tree
|
* - find a matching tree DONE
|
||||||
* - if !found, insert a new NTC_ROOT entry and return TRUE;
|
* - if !found, insert a new NTC_ROOT entry and return TRUE; DONE
|
||||||
* - if found, loop tree and compare strings:
|
* - if found, loop tree and compare strings:
|
||||||
* if equal, handle casematch/nomatch
|
* if equal, handle casematch/nomatch
|
||||||
* if greater or lesser equal, then add left/right childs accordingly
|
* if greater or lesser equal, then add left/right childs accordingly
|
||||||
* - splay the tree
|
* - splay the tree
|
||||||
*/
|
*/
|
||||||
|
PUNICODE_PREFIX_TABLE_ENTRY CurrentEntry, PreviousEntry;
|
||||||
|
ULONG NameCount;
|
||||||
|
|
||||||
|
/* Find out how many names there are */
|
||||||
|
NameCount = ComputeUnicodeNameLength(Prefix);
|
||||||
|
|
||||||
|
/* Set up the initial entry data */
|
||||||
|
PrefixTableEntry->NameLength = NameCount;
|
||||||
|
PrefixTableEntry->Prefix = Prefix;
|
||||||
|
RtlInitializeSplayLinks(&PrefixTableEntry->Links);
|
||||||
|
|
||||||
|
/* Find the right spot where to insert this entry */
|
||||||
|
PreviousEntry = (PUNICODE_PREFIX_TABLE_ENTRY)PrefixTable;
|
||||||
|
CurrentEntry = PreviousEntry->NextPrefixTree;
|
||||||
|
while (CurrentEntry->NameLength > NameCount)
|
||||||
|
{
|
||||||
|
/* Not a match, move to the next entry */
|
||||||
|
PreviousEntry = CurrentEntry;
|
||||||
|
CurrentEntry = CurrentEntry->NextPrefixTree;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check if we did find a tree by now */
|
||||||
|
if (CurrentEntry->NameLength != NameCount)
|
||||||
|
{
|
||||||
|
/* We didn't, so insert a new entry in the list */
|
||||||
|
PreviousEntry->NextPrefixTree = PrefixTableEntry;
|
||||||
|
PrefixTableEntry->NextPrefixTree = CurrentEntry;
|
||||||
|
|
||||||
|
/* This is now a root entry with case match */
|
||||||
|
PrefixTableEntry->NodeTypeCode = PFX_NTC_ROOT;
|
||||||
|
PrefixTableEntry->CaseMatch = PrefixTableEntry;
|
||||||
|
|
||||||
|
/* Quick return */
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* FIXME */
|
||||||
UNIMPLEMENTED;
|
UNIMPLEMENTED;
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -104,8 +141,7 @@ RtlNextUnicodePrefix(PUNICODE_PREFIX_TABLE PrefixTable,
|
||||||
BOOLEAN Restart)
|
BOOLEAN Restart)
|
||||||
{
|
{
|
||||||
PRTL_SPLAY_LINKS SplayLinks;
|
PRTL_SPLAY_LINKS SplayLinks;
|
||||||
PUNICODE_PREFIX_TABLE_ENTRY Entry;
|
PUNICODE_PREFIX_TABLE_ENTRY Entry, CaseMatchEntry;
|
||||||
PUNICODE_PREFIX_TABLE_ENTRY CaseMatchEntry;
|
|
||||||
|
|
||||||
/* We might need this entry 2/3rd of the time, so cache it now */
|
/* We might need this entry 2/3rd of the time, so cache it now */
|
||||||
CaseMatchEntry = PrefixTable->LastNextEntry->CaseMatch;
|
CaseMatchEntry = PrefixTable->LastNextEntry->CaseMatch;
|
||||||
|
|
Loading…
Reference in a new issue