[systemd-devel] [RFC 20/25] udevadm-hwdb: don't use glibc-specific qsort_r
Tom Gundersen
teg at jklm.no
Thu Sep 18 08:55:48 PDT 2014
It does not make sense for us to work around this. Please add it to
your libc instead.
On Thu, Sep 18, 2014 at 3:24 PM, Emil Renner Berthing <systemd at esmil.dk> wrote:
> ---
> src/udev/udevadm-hwdb.c | 16 ++++++++++------
> 1 file changed, 10 insertions(+), 6 deletions(-)
>
> diff --git a/src/udev/udevadm-hwdb.c b/src/udev/udevadm-hwdb.c
> index 65cbf61..3f31662 100644
> --- a/src/udev/udevadm-hwdb.c
> +++ b/src/udev/udevadm-hwdb.c
> @@ -123,13 +123,13 @@ 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 struct trie *trie_node_add_value_trie;
> +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;
>
> - return strcmp(trie->strings->buf + val1->key_off,
> - trie->strings->buf + val2->key_off);
> + return strcmp(trie_node_add_value_trie->strings->buf + val1->key_off,
> + trie_node_add_value_trie->strings->buf + val2->key_off);
> }
>
> static int trie_node_add_value(struct trie *trie, struct trie_node *node,
> @@ -150,7 +150,9 @@ 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);
> + trie_node_add_value_trie = trie;
> + val = bsearch(&search, node->values, node->values_count, sizeof(struct trie_value_entry), trie_values_cmp);
> + trie_node_add_value_trie = NULL;
> if (val) {
> /* replace existing earlier key with new value */
> val->value_off = v;
> @@ -167,7 +169,9 @@ 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_node_add_value_trie = trie;
> + qsort(node->values, node->values_count, sizeof(struct trie_value_entry), trie_values_cmp);
> + trie_node_add_value_trie = NULL;
> return 0;
> }
>
> --
> 2.1.0
>
> _______________________________________________
> systemd-devel mailing list
> systemd-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/systemd-devel
More information about the systemd-devel
mailing list