+RtlDelete()
authorshort <>
Thu, 12 Dec 2002 04:01:12 +0000 (04:01 +0000)
committershort <>
Thu, 12 Dec 2002 04:01:12 +0000 (04:01 +0000)
src/libcaptive/rtl/Makefile.am
src/libcaptive/rtl/splaylinks.c [new file with mode: 0644]

index ae50e29..c96a8a9 100644 (file)
@@ -24,5 +24,6 @@ librtl_la_SOURCES= \
                error.c \
                file.c \
                generictable.c \
+               splaylinks.c \
                unicode.c \
                unicode_reactos.c
diff --git a/src/libcaptive/rtl/splaylinks.c b/src/libcaptive/rtl/splaylinks.c
new file mode 100644 (file)
index 0000000..38ccf9a
--- /dev/null
@@ -0,0 +1,53 @@
+/* $Id$
+ * Implementation of RTL_SPLAY_LINKS functions of libcaptive
+ * Copyright (C) 2002 Jan Kratochvil <project-captive@jankratochvil.net>
+ * 
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; exactly version 2 of June 1991 is required
+ * 
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ * 
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+
+#include "config.h"
+
+#include "reactos/ddk/rtltypes.h"      /* self */
+#include <glib/gmessages.h>
+
+
+PRTL_SPLAY_LINKS RtlDelete(PRTL_SPLAY_LINKS Links)
+{
+RTL_SPLAY_LINKS *root,**selfp;
+
+       g_return_val_if_fail(Links!=NULL,NULL);
+
+       for (root=Links;root->Parent!=root;) {
+               g_assert(root->Parent!=NULL);
+               root=root->Parent;
+               }
+       if (root==Links)
+               selfp=&root;
+       else if (Links->Parent->LeftChild==Links)
+               selfp=&Links->Parent->LeftChild;
+       else if (Links->Parent->RightChild==Links)
+               selfp=&Links->Parent->RightChild;
+       else g_assert_not_reached();    /* should not happen if the structures are valid */
+
+            if (!Links->LeftChild)
+               *selfp=Links->RightChild;
+       else if (!Links->RightChild)
+               *selfp=Links->LeftChild;
+       else g_assert_not_reached();    /* FIXME: NOT IMPLEMENTED YET */
+
+       /* FIXME: rebalance: NOT IMPLEMENTED YET */
+
+       return root;
+}