[ros-diffs] [ion] 24543: - Implement RtlLookupElementGenericTableFull. - Implement RtlEnumerateGenericTable.

ion at svn.reactos.org ion at svn.reactos.org
Mon Oct 16 05:47:47 CEST 2006


Author: ion
Date: Mon Oct 16 07:47:47 2006
New Revision: 24543

URL: http://svn.reactos.org/svn/reactos?rev=24543&view=rev
Log:
- Implement RtlLookupElementGenericTableFull.
- Implement RtlEnumerateGenericTable.

Modified:
    trunk/reactos/lib/rtl/generictable.c

Modified: trunk/reactos/lib/rtl/generictable.c
URL: http://svn.reactos.org/svn/reactos/trunk/reactos/lib/rtl/generictable.c?rev=24543&r1=24542&r2=24543&view=diff
==============================================================================
--- trunk/reactos/lib/rtl/generictable.c (original)
+++ trunk/reactos/lib/rtl/generictable.c Mon Oct 16 07:47:47 2006
@@ -258,7 +258,7 @@
 }
 
 /*
- * @unimplemented
+ * @implemented
  */
 PVOID
 NTAPI
@@ -267,8 +267,22 @@
                                  OUT PVOID *NodeOrParent,
                                  OUT TABLE_SEARCH_RESULT *SearchResult)
 {
-    UNIMPLEMENTED;
-    return 0;
+    /* Do the initial lookup */
+    *SearchResult = RtlpFindGenericTableNodeOrParent(Table,
+                                                     Buffer,
+                                                     (PRTL_SPLAY_LINKS *)
+                                                     NodeOrParent);
+
+    /* Check if we found anything */
+    if ((*SearchResult == TableEmptyTree) || (*SearchResult != TableFoundNode))
+    {
+        /* Nothing found */
+        return NULL;
+    }
+
+    /* Otherwise, splay the tree and return this entry */
+    Table->TableRoot = RtlSplay(*NodeOrParent);
+    return &((PTABLE_ENTRY_HEADER)*NodeOrParent)->UserData;
 }
 
 /*
@@ -305,15 +319,41 @@
 }
 
 /*
- * @unimplemented
+ * @implemented
  */
 PVOID
 NTAPI
 RtlEnumerateGenericTable(IN PRTL_GENERIC_TABLE Table,
                          IN BOOLEAN Restart)
 {
-    UNIMPLEMENTED;
-    return 0;
+    PRTL_SPLAY_LINKS FoundNode;
+
+    /* Check if the table is empty */
+    if (RtlIsGenericTableEmpty(Table)) return NULL;
+
+    /* Check if we have to restart */
+    if (Restart)
+    {
+        /* Then find the leftmost element */
+        FoundNode = Table->TableRoot;
+        do
+        {
+            /* Get the left child */
+            FoundNode = RtlLeftChild(FoundNode);
+        } while(RtlLeftChild(FoundNode));
+
+        /* Splay it */
+        Table->TableRoot = RtlSplay(FoundNode);
+    }
+    else
+    {
+        /* Otherwise, try using the real successor */
+        FoundNode = RtlRealSuccessor(Table->TableRoot);
+        if (FoundNode) Table->TableRoot = RtlSplay(FoundNode);
+    }
+
+    /* Check if we found the node and return it */
+    return FoundNode ? &((PTABLE_ENTRY_HEADER)FoundNode)->UserData : NULL;
 }
 
 /*




More information about the Ros-diffs mailing list