diff common/strhelp.h @ 59:3f6378647371

Start work on cinst. Strhelp new helpers to work with C String arrays and to have a terminating malloc / realloc
author Andre Heinecke <aheinecke@intevation.de>
date Tue, 18 Mar 2014 10:04:30 +0000
parents
children 6acb1dae6185
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/strhelp.h	Tue Mar 18 10:04:30 2014 +0000
@@ -0,0 +1,38 @@
+/* @file Helper functions for c strings and memory management
+ *
+ * strhelp contains terminating memory allocation functions and
+ * some conveniance functions to work with c strings or arrays
+ * of c strings.
+ */
+void *xmalloc( size_t n );
+void *xrealloc( void *a, size_t n );
+void *xcalloc( size_t n, size_t m );
+char *xstrdup( const char *string );
+
+/**
+ * strv_length:
+ * @str_array: a %NULL-terminated array of strings
+ *
+ * Returns the length of the given %NULL-terminated
+ * string array @str_array.
+ *
+ * Return value: length of @str_array.
+ *
+ */
+unsigned int strv_length (char **str_array);
+
+/* @brief append a string to a NULL terminated array of strings.
+ *
+ * @param[inout] array pointer to the NULL terminated list of string pointers.
+ * @param[in] string pointer to the string to append to the list.
+ * */
+void array_append_str(char ***pArray, const char *string);
+
+/* @brief append a string to another string.
+ *
+ * @param[inout] pDst pointer to the string to be extended.
+ * @param[in] appendage pointer to the string to append.
+ * */
+void str_append_str(char **pDst, const char *appendage);
+
+void strfreev (char **str_array);

http://wald.intevation.org/projects/trustbridge/