chiark
/
gitweb
/
~ianmdlvl
/
elogind.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
[PATCH] Revert previous dev_d.c change, it's not what is causing HAL problems.
[elogind.git]
/
libsysfs
/
dlist.c
diff --git
a/libsysfs/dlist.c
b/libsysfs/dlist.c
index 6dfcf726baed68e8aa595416a321718e6e3da43c..b440d65bed0f0f1fb7b8be5fa69999c6ba8a0692 100644
(file)
--- a/
libsysfs/dlist.c
+++ b/
libsysfs/dlist.c
@@
-27,6
+27,7
@@
* delete function. Otherwise dlist will just use free.
*/
* delete function. Otherwise dlist will just use free.
*/
+#include <stdlib.h>
#include "dlist.h"
/*
#include "dlist.h"
/*
@@
-73,14
+74,14
@@
inline void *_dlist_mark_move(Dlist *list,int direction)
{
if(direction)
{
{
if(direction)
{
- if( list->marker->next!=NULL)
+ if( list->marker
&& list->marker
->next!=NULL)
list->marker=list->marker->next;
else
return(NULL);
}
else
{
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);
list->marker=list->marker->prev;
else
return(NULL);
@@
-259,6
+260,16
@@
void dlist_unshift(Dlist *list,void *data)
dlist_insert(list,data,0);
}
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.
/*
* Remove end node from list.