* util.h: Added the function free_after for easier handling of dynamically allocated strings.

This commit is contained in:
Roland Illig 2004-08-19 11:35:56 +00:00
parent c6e3dde5a5
commit d3a5b40c19
2 changed files with 15 additions and 0 deletions

View File

@ -1,3 +1,7 @@
2004-18-19 Roland Illig <roland.illig@gmx.de>
* util.h: Added the function free_after for easier handling
of dynamically allocated strings.
2004-18-19 Roland Illig <roland.illig@gmx.de>
* util.c: Added the function str_replace, which replaces
all occurences of a character in a string.

View File

@ -172,4 +172,15 @@ void save_file_position (char *filename, long line, long column);
#define ISASCII(c) isascii(c)
#endif
/* this function allows you to write:
* char *s = g_strdup("hello, world");
* s = free_after(g_strconcat(s, s, NULL), s);
*/
static inline char *
free_after (char *result, char *string_to_free)
{
g_free(string_to_free);
return result;
}
#endif /* !__UTIL_H */