glib-aux: add nm_str_truncate() helper

This commit is contained in:
Thomas Haller 2022-09-20 14:59:07 +02:00
parent d1fd6eb53b
commit cc36baa5c7
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -495,6 +495,17 @@ nm_strdup_not_empty(const char *str)
return !nm_str_is_empty(str) ? g_strdup(str) : NULL;
}
static inline char *
nm_str_truncate(char *str)
{
/* This is trivial, and is only useful in a macro, to
* ensure that we access the macro argument only once. */
nm_assert(str);
str[0] = '\0';
return str;
}
static inline char *
nm_str_realloc(char *str)
{