Code

utils strings: Add stringv_append_if_missing().
[sysdb.git] / src / include / utils / strings.h
index 61298ee7cc9d0e96d72bd02a4bb9a259aa07bc5f..46666318ce45b4571cba160cd74325650e4cc551 100644 (file)
@@ -37,7 +37,8 @@ extern "C" {
 /*
  * stringv_copy:
  * Copy a string vector from 'src' to 'dst'. If non-NULL, 'dst' will be
- * reallocated to fit the required size.
+ * reallocated to fit the required size and old entries will be freed before
+ * overriding them.
  *
  * Returns:
  *  - 0 on success
@@ -47,6 +48,19 @@ int
 stringv_copy(char ***dst, size_t *dst_len,
                const char * const *src, size_t src_len);
 
+/*
+ * stringv_append:
+ * Append a string to a string vector.
+ *
+ * Returns:
+ *  - 0 on success
+ *  - a negative value else
+ */
+int
+stringv_append(char ***s, size_t *s_len, const char *elem);
+int
+stringv_append_if_missing(char ***s, size_t *s_len, const char *elem);
+
 /*
  * stringv_free:
  * Free the memory used by 's' and all of it's elements.