ayttm-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Ayttm-commits] CVS: ayttm/src llist.c,1.3,1.4


From: Colin Leroy <address@hidden>
Subject: [Ayttm-commits] CVS: ayttm/src llist.c,1.3,1.4
Date: Fri, 24 Jan 2003 08:58:24 -0500

Update of /cvsroot/ayttm/ayttm/src
In directory subversions:/tmp/cvs-serv16662/src

Modified Files:
        llist.c 
Log Message:
fix segfaults


Index: llist.c
===================================================================
RCS file: /cvsroot/ayttm/ayttm/src/llist.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- llist.c     24 Jan 2003 13:34:41 -0000      1.3
+++ llist.c     24 Jan 2003 13:58:22 -0000      1.4
@@ -56,7 +56,8 @@
        n->next = list;
        n->prev = NULL;
        n->data = data;
-       list->prev = n;
+       if (list)
+               list->prev = n;
 
        return n;
 }
@@ -172,14 +173,20 @@
 LList *l_list_insert_sorted(LList * list, void *data, LListCompFunc comp)
 {
        LList *l, *n = malloc(sizeof(LList));
+       if (!list)
+               return l_list_append(list, data);
+
        n->data = data;
        for (l = list; l && comp(l->data, (const void *)data) <= 0; l = l->next)
                ;
 
-
-       n->prev = l->prev;
+       if (l)
+               n->prev = l->prev;
+       else
+               n->prev = NULL;
        n->next = l;
-       l->prev = n;
+       if (l)
+               l->prev = n;
 
        if(n->prev) {
                n->prev->next = n;





reply via email to

[Prev in Thread] Current Thread [Next in Thread]