X-Git-Url: https://git.ozlabs.org/?p=ccan;a=blobdiff_plain;f=ccan%2Fstrmap%2Fstrmap.h;h=8fabc359acc64e2d4a4603e7097cfe93b3b2be17;hp=e85b8c8f898f599d9d292f8367d1dcf3d7468fdd;hb=516c47790828cfb892fecdbe03a6928c345d29b2;hpb=ed1b25bbd01f79b5b333fd28b53455d2c91b831f diff --git a/ccan/strmap/strmap.h b/ccan/strmap/strmap.h index e85b8c8f..8fabc359 100644 --- a/ccan/strmap/strmap.h +++ b/ccan/strmap/strmap.h @@ -77,7 +77,7 @@ static inline bool strmap_empty_(const struct strmap *map) * @map: the typed strmap to search. * @member: the string to search for. * - * Returns the value, or NULL if it isn't in the map. + * Returns the value, or NULL if it isn't in the map (and sets errno = ENOENT). * * Example: * int *val = strmap_get(&map, "hello"); @@ -118,7 +118,9 @@ bool strmap_add_(struct strmap *map, const char *member, const void *value); * @member: the string to remove from the map. * @valuep: the value (if non-NULL) * - * This returns the string which was passed to strmap_map(), or NULL. + * This returns the string which was passed to strmap_map(), or NULL if + * it was not in the map (and sets errno = ENOENT). + * * This means that if you allocated a string (eg. using strdup()), you * can free it here. Similarly, the value is returned in @valuep if * @valuep is not NULL. @@ -154,7 +156,7 @@ void strmap_clear_(struct strmap *map); * @handle's prototype should be: * bool @handle(const char *member, type value, typeof(arg) arg) * - * If @handle returns true, the iteration will stop. + * If @handle returns false, the iteration will stop. * You should not alter the map within the @handle function! * * Example: @@ -165,9 +167,9 @@ void strmap_clear_(struct strmap *map); * { * // Only dump out num nodes. * if (*(num--) == 0) - * return true; + * return false; * printf("%s=>%i\n", member, *value); - * return false; + * return true; * } * * static void dump_map(const struct strmap_intp *map) @@ -187,8 +189,8 @@ void strmap_clear_(struct strmap *map); __typeof__(arg)), (handle)), \ (arg)) void strmap_iterate_(const struct strmap *map, - bool (*handle)(const char *, void *, void *), void *data); - + bool (*handle)(const char *, void *, void *), + const void *data); /** * strmap_prefix - return a submap matching a prefix