diff options
author | Thomas Haller <thaller@redhat.com> | 2021-05-25 14:05:53 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2021-06-04 21:31:50 +0200 |
commit | 17a3d19478367536b066417fb61b94526b493684 (patch) | |
tree | e639891e5912b12db063c7c61f334af098fd7dc4 | |
parent | 2e5c4abc8cd130534500eb60d47dee9ea6bc10b8 (diff) | |
download | NetworkManager-17a3d19478367536b066417fb61b94526b493684.tar.gz |
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.
(cherry picked from commit 8da91cd85f0e21d1c8c9d89d20a9e5ab5d7b03ac)
-rw-r--r-- | shared/nm-glib-aux/nm-macros-internal.h | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/shared/nm-glib-aux/nm-macros-internal.h b/shared/nm-glib-aux/nm-macros-internal.h index 3f45cfaea2..cbda66ac2c 100644 --- a/shared/nm-glib-aux/nm-macros-internal.h +++ b/shared/nm-glib-aux/nm-macros-internal.h @@ -1112,6 +1112,18 @@ nm_clear_g_variant(GVariant **variant) } 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) { GCancellable *v; |