common/string-helpers.c: add strdup_printf()

This commit is contained in:
Johan Malm 2023-06-25 09:00:41 +01:00 committed by Johan Malm
parent 41de529fff
commit f4f35a9dff
4 changed files with 47 additions and 23 deletions

View file

@ -16,4 +16,15 @@ char *string_strip(char *s);
*/
void string_truncate_at_pattern(char *buf, const char *pattern);
/**
* strdup_printf - allocate and write to buffer in printf format
* @fmt: printf-style format.
*
* Similar to the standard C sprintf() function but safer as it calculates the
* maximum space required and allocates memory to hold the output.
* The user must free the returned string.
* Returns NULL on error.
*/
char *strdup_printf(const char *fmt, ...);
#endif /* LABWC_STRING_HELPERS_H */