aheinecke@60: #ifndef STRHELP_H aheinecke@60: #define STRHELP_H aheinecke@59: /* @file Helper functions for c strings and memory management aheinecke@59: * aheinecke@59: * strhelp contains terminating memory allocation functions and aheinecke@59: * some conveniance functions to work with c strings or arrays aheinecke@59: * of c strings. aheinecke@59: */ aheinecke@59: void *xmalloc( size_t n ); aheinecke@59: void *xrealloc( void *a, size_t n ); aheinecke@59: void *xcalloc( size_t n, size_t m ); aheinecke@60: char *xstrndup( const char *string, const size_t len ); aheinecke@59: aheinecke@59: /** aheinecke@59: * strv_length: aheinecke@59: * @str_array: a %NULL-terminated array of strings aheinecke@59: * aheinecke@59: * Returns the length of the given %NULL-terminated aheinecke@59: * string array @str_array. aheinecke@59: * aheinecke@59: * Return value: length of @str_array. aheinecke@59: * aheinecke@59: */ aheinecke@59: unsigned int strv_length (char **str_array); aheinecke@59: aheinecke@59: /* @brief append a string to a NULL terminated array of strings. aheinecke@59: * aheinecke@59: * @param[inout] array pointer to the NULL terminated list of string pointers. aheinecke@59: * @param[in] string pointer to the string to append to the list. aheinecke@60: * @param[in] len length of the string to append to the list aheinecke@59: * */ aheinecke@60: void array_append_str(char ***pArray, const char *string, const size_t len); aheinecke@59: aheinecke@59: /* @brief append a string to another string. aheinecke@59: * aheinecke@59: * @param[inout] pDst pointer to the string to be extended. aheinecke@59: * @param[in] appendage pointer to the string to append. aheinecke@60: * @param[in] len length of the string to append. aheinecke@59: * */ aheinecke@60: void str_append_str(char **pDst, const char *appendage, const size_t len); aheinecke@59: aheinecke@59: void strfreev (char **str_array); aheinecke@60: #endif