X-Git-Url: http://git.ozlabs.org/?a=blobdiff_plain;f=ccan%2Fhtable%2F_info;h=ea11beb44003520ff137b27afc8fdae85551cae9;hb=e16aa40bed387c9575bc9c5d1b19ecca0e9cbda7;hp=7e06c3867a3f977797720e54368f25cb3084d6c6;hpb=291237b4fed863be74051274ac5ad9920cb33cc3;p=ccan diff --git a/ccan/htable/_info b/ccan/htable/_info index 7e06c386..ea11beb4 100644 --- a/ccan/htable/_info +++ b/ccan/htable/_info @@ -36,11 +36,12 @@ * // Wrapper for rehash function pointer. * static size_t rehash(const void *e, void *unused) * { + * (void)unused; * return hash_string(((struct name_to_digit *)e)->name); * } * * // Comparison function. - * static bool streq(const void *e, void *string) + * static bool nameeq(const void *e, void *string) * { * return strcmp(((struct name_to_digit *)e)->name, string) == 0; * } @@ -48,13 +49,13 @@ * // We let them add their own aliases, eg. --alias=v=5 * static void add_alias(struct htable *ht, const char *alias) * { - * char *eq; + * char *eq, *name; * struct name_to_digit *n; * * n = malloc(sizeof(*n)); - * n->name = strdup(alias); + * n->name = name = strdup(alias); * - * eq = strchr(n->name, '='); + * eq = strchr(name, '='); * if (!eq || ((n->val = atoi(eq+1)) == 0 && !strcmp(eq+1, "0"))) * errx(1, "Usage: --alias=="); * *eq = '\0'; @@ -64,7 +65,7 @@ * int main(int argc, char *argv[]) * { * struct htable ht; - * unsigned int i; + * int i; * unsigned long val; * * if (argc < 2) @@ -73,7 +74,7 @@ * * // Create and populate hash table. * htable_init(&ht, rehash, NULL); - * for (i = 0; i < sizeof(map)/sizeof(map[0]); i++) + * for (i = 0; i < (int)(sizeof(map)/sizeof(map[0])); i++) * htable_add(&ht, hash_string(map[i].name), &map[i]); * * // Add any aliases to the hash table. @@ -88,7 +89,7 @@ * for (val = 0; i < argc; i++) { * struct name_to_digit *n; * n = htable_get(&ht, hash_string(argv[i]), - * streq, argv[i]); + * nameeq, argv[i]); * if (!n) * errx(1, "Invalid digit name %s", argv[i]); * // Append it to the value we are building up. @@ -109,6 +110,7 @@ int main(int argc, char *argv[]) if (strcmp(argv[1], "depends") == 0) { printf("ccan/compiler\n"); + printf("ccan/str\n"); return 0; }