chiark / gitweb /
[PATCH] add volume_id support to the udev.spec file
[elogind.git] / libsysfs / dlist.c
index a94ab1f854be6d9f784dc5b4657fd8fde0935324..b440d65bed0f0f1fb7b8be5fa69999c6ba8a0692 100644 (file)
@@ -74,14 +74,14 @@ inline void *_dlist_mark_move(Dlist *list,int direction)
 {
   if(direction)
     {
-      if( list->marker->next!=NULL)
+      if( list->marker && list->marker->next!=NULL)
        list->marker=list->marker->next;
       else
        return(NULL);
     }
   else
     {
-      if( list->marker->prev!=NULL)
+      if( list->marker && list->marker->prev!=NULL)
        list->marker=list->marker->prev;
       else
        return(NULL);
@@ -260,6 +260,16 @@ void dlist_unshift(Dlist *list,void *data)
   dlist_insert(list,data,0);
 }
 
+void dlist_unshift_sorted(Dlist *list, void *data, 
+                       int (*sorter)(void *new, void *old))
+{
+       if (list->count == 0)
+               dlist_unshift(list, data);
+       else {
+               list->marker=list->head->next;
+               dlist_insert_sorted(list, data, sorter);
+       }
+}
 
 /* 
  * Remove end node from list.