CVS update: /ccvs/src/

[email protected] 9 May 2005 18:22:19 -0000
Newsgroups gmane.comp.version-control.cvs.cvs
Message-ID <[email protected]>
User: dprice  
Date: 05/05/09 11:22:19

Modified:
 /ccvs/src/
  ChangeLog, hash.c, hash.h

Log:
 * hash.c (removenode, mergelists): New function.
 (delnode): Use removenode.
 * hash.h (mergelists): New proto.

File Changes:

Directory: /ccvs/src/
=====================

File [changed]: ChangeLog
Url: https://ccvs.cvshome.org/source/browse/ccvs/src/ChangeLog?r1=1.3187&r2=1.3188
Delta lines:  +6 -0
-------------------
--- ChangeLog	5 May 2005 01:29:37 -0000	1.3187
+++ ChangeLog	9 May 2005 18:22:11 -0000	1.3188
@@ -1,3 +1,9 @@
+2005-05-09  Derek Price  <[email protected]>
+
+	* hash.c (removenode, mergelists): New function.
+	(delnode): Use removenode.
+	* hash.h (mergelists): New proto.
+
 2005-05-04  Derek Price  <[email protected]>
 
 	* error.c (error): Avoid recursion and syslog the problem.

File [changed]: hash.c
Url: https://ccvs.cvshome.org/source/browse/ccvs/src/hash.c?r1=1.47&r2=1.48
Delta lines:  +42 -14
---------------------
--- hash.c	17 Mar 2005 17:15:19 -0000	1.47
+++ hash.c	9 May 2005 18:22:12 -0000	1.48
@@ -139,6 +139,45 @@
 
 
 /*
+ * remove a node from it's list (maybe hash list too)
+ */
+void
+removenode (Node *p)
+{
+    if (!p) return;
+
+    /* take it out of the list */
+    p->next->prev = p->prev;
+    p->prev->next = p->next;
+
+    /* if it was hashed, remove it from there too */
+    if (p->hashnext)
+    {
+	p->hashnext->hashprev = p->hashprev;
+	p->hashprev->hashnext = p->hashnext;
+    }
+}
+
+
+
+void
+mergelists (List *dest, List **src)
+{
+    Node *head, *p, *n;
+
+    head = (*src)->list;
+    for (p = head->next; p != head; p = n)
+    {
+	n = p->next;
+	removenode (p);
+	addnode (dest, p);
+    }
+    dellist (src);
+}
+
+
+
+/*
  * get a new list node
  */
 Node *
@@ -173,20 +212,9 @@
 void
 delnode (Node *p)
 {
-    if (p == NULL)
-	return;
-
-    /* take it out of the list */
-    p->next->prev = p->prev;
-    p->prev->next = p->next;
-
-    /* if it was hashed, remove it from there too */
-    if (p->hashnext != NULL)
-    {
-	p->hashnext->hashprev = p->hashprev;
-	p->hashprev->hashnext = p->hashnext;
-    }
-
+    if (!p) return;
+    /* remove it */
+    removenode (p);
     /* free up the storage */
     freenode (p);
 }

File [changed]: hash.h
Url: https://ccvs.cvshome.org/source/browse/ccvs/src/hash.h?r1=1.20&r2=1.21
Delta lines:  +13 -11
---------------------
--- hash.h	1 Feb 2005 22:20:06 -0000	1.20
+++ hash.h	9 May 2005 18:22:16 -0000	1.21
@@ -49,16 +49,18 @@
 typedef struct list List;
 
 List *getlist (void);
-Node *findnode (List * list, const char *key);
-Node *findnode_fn (List * list, const char *key);
+Node *findnode (List *list, const char *key);
+Node *findnode_fn (List *list, const char *key);
 Node *getnode (void);
-int insert_before (List * list, Node * marker, Node * p);
-int addnode (List * list, Node * p);
-int addnode_at_front (List * list, Node * p);
-int walklist (List * list, int (*)(Node *n, void *closure), void *closure);
+int insert_before (List *list, Node *marker, Node *p);
+int addnode (List *list, Node *p);
+int addnode_at_front (List *list, Node *p);
+int walklist (List *list, int (*)(Node *n, void *closure), void *closure);
 int list_isempty (List *list);
-void dellist (List ** listp);
-void delnode (Node * p);
-void freenode (Node * p);
-void sortlist (List * list, int (*)(const Node *, const Node *));
-int fsortcmp (const Node * p, const Node * q);
+void removenode (Node *p);
+void mergelists (List *dest, List **src);
+void dellist (List **listp);
+void delnode (Node *p);
+void freenode (Node *p);
+void sortlist (List *list, int (*)(const Node *, const Node *));
+int fsortcmp (const Node *p, const Node *q);