shared: add nm_utils_strdup_reset() helper

This commit is contained in:
Thomas Haller 2020-01-28 12:28:07 +01:00
parent 45a832ac50
commit 455cec9986

View file

@ -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__ */