1
0
mirror of git://projects.qi-hardware.com/wernermisc.git synced 2024-11-22 11:50:16 +02:00

qpkg: converted ID comparison from "struct id *" to "void *"

- id.h (struct tree, comp_id, make_tree), id.c (comp_id, make_tree):
  comparison function now takes "void *" (pointing to a "struct id")
  arguments instead of "struct id *", for compatibility with jrb
- id.c (comp_id, do_comp_id): added wrapper to convert "void *" back to
  "struct id *"
This commit is contained in:
Werner Almesberger 2010-11-19 21:48:48 -03:00
parent af27092667
commit a9f12d5666
2 changed files with 10 additions and 5 deletions

View File

@ -7,7 +7,7 @@
static struct id *free_id = NULL; static struct id *free_id = NULL;
int comp_id(const struct id *a, const struct id *b) static int do_comp_id(const struct id *a, const struct id *b)
{ {
int len = a->len < b->len ? a->len : b->len; int len = a->len < b->len ? a->len : b->len;
int cmp; int cmp;
@ -19,7 +19,12 @@ int comp_id(const struct id *a, const struct id *b)
} }
struct tree *make_tree(int (*comp)(const struct id *a, const struct id *b)) int comp_id(const void *a, const void *b)
{
return do_comp_id(a, b);
}
struct tree *make_tree(int (*comp)(const void *a, const void *b))
{ {
struct tree *tree; struct tree *tree;

View File

@ -9,7 +9,7 @@
struct id; struct id;
struct tree { struct tree {
int (*comp)(const struct id *a, const struct id *b); int (*comp)(const void *a, const void *b);
struct jrb *root; struct jrb *root;
}; };
@ -21,9 +21,9 @@ struct id {
}; };
int comp_id(const struct id *a, const struct id *b); int comp_id(const void *a, const void *b);
struct tree *make_tree(int (*comp)(const struct id *a, const struct id *b)); struct tree *make_tree(int (*comp)(const void *a, const void *b));
struct id *make_id(struct tree *tree, const char *s, size_t len); struct id *make_id(struct tree *tree, const char *s, size_t len);
const struct id *find_id(const struct tree *tree, const char *s, size_t len); const struct id *find_id(const struct tree *tree, const char *s, size_t len);
const struct id *first_id(const struct tree *tree); const struct id *first_id(const struct tree *tree);