]> git.ozlabs.org Git - ccan/blobdiff - ccan/strmap/strmap.h
strmap: set errno to ENOENT even if we return NULL.
[ccan] / ccan / strmap / strmap.h
index 77197507c742707a5c8ff3e3e41d36ad27d635c5..d6104942f4cea6c7cb218bfd386ced9f96ec3b1a 100644 (file)
@@ -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");
@@ -94,8 +94,8 @@ void *strmap_get_(const struct strmap *map, const char *member);
  * @member: the string to place in the map.
  * @v: the (non-NULL) value.
  *
- * This returns false if we run out of memory, or (more normally) if that
- * string already appears in the map.
+ * This returns false if we run out of memory (errno = ENOMEM), or
+ * (more normally) if that string already appears in the map (EEXIST).
  *
  * Note that the pointer is placed in the map, the string is not copied.  If
  * you want a copy in the map, use strdup().  Similarly for the value.
@@ -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.