summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/udev/udevadm-hwdb.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/udev/udevadm-hwdb.c b/src/udev/udevadm-hwdb.c
index 65ea866f4d..1026a7a66d 100644
--- a/src/udev/udevadm-hwdb.c
+++ b/src/udev/udevadm-hwdb.c
@@ -123,14 +123,20 @@ static void trie_node_cleanup(struct trie_node *node) {
free(node);
}
-static int trie_values_cmp(const void *v1, const void *v2, void *arg) {
+
+static __thread void* trie_values_cmp_param;
+static int trie_values_cmp(const void *v1, const void *v2) {
const struct trie_value_entry *val1 = v1;
const struct trie_value_entry *val2 = v2;
- struct trie *trie = arg;
+ struct trie *trie = trie_values_cmp_param;
return strcmp(trie->strings->buf + val1->key_off,
trie->strings->buf + val2->key_off);
}
+static int trie_values_cmp_r(const void *v1, const void *v2, void* arg) {
+ trie_values_cmp_param = arg;
+ return trie_values_cmp(v1, v2);
+}
static int trie_node_add_value(struct trie *trie, struct trie_node *node,
const char *key, const char *value) {
@@ -150,7 +156,7 @@ static int trie_node_add_value(struct trie *trie, struct trie_node *node,
.value_off = v,
};
- val = xbsearch_r(&search, node->values, node->values_count, sizeof(struct trie_value_entry), trie_values_cmp, trie);
+ val = xbsearch_r(&search, node->values, node->values_count, sizeof(struct trie_value_entry), trie_values_cmp_r, trie);
if (val) {
/* replace existing earlier key with new value */
val->value_off = v;
@@ -167,7 +173,8 @@ static int trie_node_add_value(struct trie *trie, struct trie_node *node,
node->values[node->values_count].key_off = k;
node->values[node->values_count].value_off = v;
node->values_count++;
- qsort_r(node->values, node->values_count, sizeof(struct trie_value_entry), trie_values_cmp, trie);
+ trie_values_cmp_param = trie;
+ qsort(node->values, node->values_count, sizeof(struct trie_value_entry), trie_values_cmp);
return 0;
}