aheinecke@60: #ifndef STRHELP_H aheinecke@60: #define STRHELP_H wilde@118: wilde@118: /** wilde@118: * @file strhelp.h wilde@118: * @brief Helper functions for c strings and memory management wilde@118: * @details strhelp contains terminating memory allocation functions and wilde@118: * some conveniance functions to work with c strings or arrays of c wilde@118: * strings. aheinecke@59: */ wilde@118: 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: /** wilde@118: * @brief Returns the length of the given %NULL-terminated wilde@118: * string array str_array. wilde@118: * @param[in] str_array a %NULL-terminated array of strings wilde@118: * @returns length of str_array. aheinecke@59: */ aheinecke@59: unsigned int strv_length (char **str_array); aheinecke@59: wilde@118: /** wilde@118: * @brief append a string to a NULL terminated array of strings. aheinecke@59: * wilde@118: * @param[inout] pArray 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 wilde@118: */ wilde@116: void strv_append (char ***pArray, const char *string, const size_t len); aheinecke@59: wilde@118: /** wilde@118: * @brief append a string to another string. aheinecke@59: * aheinecke@59: * @param[inout] pDst pointer to the string to be extended. aheinecke@91: * @param[inout] dst_len length of the dst string. Will be modified. aheinecke@59: * @param[in] appendage pointer to the string to append. aheinecke@60: * @param[in] len length of the string to append. wilde@118: */ wilde@116: void str_append_str (char **pDst, size_t *dst_len, const char *appendage, aheinecke@91: const size_t len); aheinecke@59: wilde@118: /** wilde@118: * @brief Frees the given %NULL-terminated string array. wilde@118: * @param[inout] str_array a %NULL-terminated array of strings wilde@118: */ wilde@116: void strv_free (char **str_array); aheinecke@60: #endif