summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2020-01-28 12:28:07 +0100
committerThomas Haller <thaller@redhat.com>2020-02-10 19:11:50 +0100
commit455cec9986b240bb7aa1ae3b17f4aeccb774c7f2 (patch)
tree425a451fc50c1d171296667399ed50992a105f57
parent45a832ac50cda28913dcf3abbe629cb59955d09b (diff)
downloadNetworkManager-455cec9986b240bb7aa1ae3b17f4aeccb774c7f2.tar.gz
shared: add nm_utils_strdup_reset() helper
-rw-r--r--shared/nm-glib-aux/nm-shared-utils.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/shared/nm-glib-aux/nm-shared-utils.h b/shared/nm-glib-aux/nm-shared-utils.h
index ab5ce83cbe..d1257242fa 100644
--- a/shared/nm-glib-aux/nm-shared-utils.h
+++ b/shared/nm-glib-aux/nm-shared-utils.h
@@ -1615,4 +1615,18 @@ guint nm_utils_parse_debug_string (const char *string,
const GDebugKey *keys,
guint nkeys);
+/*****************************************************************************/
+
+static inline gboolean
+nm_utils_strdup_reset (char **dst, const char *src)
+{
+ nm_assert (dst);
+
+ if (nm_streq0 (*dst, src))
+ return FALSE;
+ g_free (*dst);
+ *dst = g_strdup (src);
+ return TRUE;
+}
+
#endif /* __NM_SHARED_UTILS_H__ */