mirror of
https://github.com/MidnightCommander/mc
synced 2025-01-26 05:02:03 +03:00
* util.h: Added the function free_after for easier handling of dynamically allocated strings.
This commit is contained in:
parent
c6e3dde5a5
commit
d3a5b40c19
@ -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.
|
||||
|
11
src/util.h
11
src/util.h
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user