glib-aux: add nm_clear_g_string() helper

Since g_string_free() takes an additional argument,
it's not direclty usable with nm_clear_pointer(ptr, g_string_free);

As workaround, add nm_clear_g_string() helper.
This commit is contained in:
Thomas Haller 2021-05-25 14:05:53 +02:00
parent c3d3429916
commit 8da91cd85f
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728

View file

@ -1136,6 +1136,18 @@ nm_clear_g_variant(GVariant **variant)
return FALSE;
}
static inline gboolean
nm_clear_g_string(GString **ptr)
{
GString *s;
if (ptr && (s = *ptr)) {
*ptr = NULL;
g_string_free(s, TRUE);
};
return FALSE;
}
static inline gboolean
nm_clear_g_cancellable(GCancellable **cancellable)
{