Skip to content

Commit 3e8a4de

Browse files
committed
libudev-list: use hashmap_dump_sorted()
1 parent 76a8f5a commit 3e8a4de

File tree

1 file changed

+1
-14
lines changed

1 file changed

+1
-14
lines changed

src/libudev/libudev-list.c

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#include "hashmap.h"
55
#include "libudev-list-internal.h"
66
#include "list.h"
7-
#include "sort-util.h"
87

98
/**
109
* SECTION:libudev-list
@@ -136,10 +135,6 @@ struct udev_list *udev_list_free(struct udev_list *list) {
136135
return mfree(list);
137136
}
138137

139-
static int udev_list_entry_compare_func(struct udev_list_entry * const *a, struct udev_list_entry * const *b) {
140-
return strcmp((*a)->name, (*b)->name);
141-
}
142-
143138
struct udev_list_entry *udev_list_get_entry(struct udev_list *list) {
144139
if (!list)
145140
return NULL;
@@ -156,18 +151,10 @@ struct udev_list_entry *udev_list_get_entry(struct udev_list *list) {
156151
LIST_PREPEND(entries, list->entries, hashmap_first(list->unique_entries));
157152
else {
158153
_cleanup_free_ struct udev_list_entry **buf = NULL;
159-
struct udev_list_entry *entry, **p;
160154

161-
buf = new(struct udev_list_entry *, n);
162-
if (!buf)
155+
if (hashmap_dump_sorted(list->unique_entries, (void***) &buf, /* ret_n = */ NULL) < 0)
163156
return NULL;
164157

165-
p = buf;
166-
HASHMAP_FOREACH(entry, list->unique_entries)
167-
*p++ = entry;
168-
169-
typesafe_qsort(buf, n, udev_list_entry_compare_func);
170-
171158
for (size_t j = n; j > 0; j--)
172159
LIST_PREPEND(entries, list->entries, buf[j-1]);
173160
}

0 commit comments

Comments
 (0)