shared: add nm_indirect_g_free() helper

This commit is contained in:
Thomas Haller 2020-05-06 13:30:42 +02:00
parent 070535c6f6
commit 8dd74fe364
No known key found for this signature in database
GPG key ID: 29C2366E4DFC5728
2 changed files with 22 additions and 0 deletions

View file

@ -4817,3 +4817,23 @@ nm_str_buf_append_printf (NMStrBuf *strbuf,
strbuf->_priv_len += (gsize) l;
}
/*****************************************************************************/
/**
* nm_indirect_g_free:
* @arg: a pointer to a pointer that is to be freed.
*
* This does the same as nm_clear_g_free(arg) (g_clear_pointer (arg, g_free)).
* This is for example useful when you have a GArray with pointers and a
* clear function to free them. g_array_set_clear_func()'s destroy notify
* function gets a pointer to the array location, so we have to follow
* the first pointer.
*/
void
nm_indirect_g_free (gpointer arg)
{
gpointer *p = arg;
nm_clear_g_free (p);
}

View file

@ -1864,6 +1864,8 @@ nm_utils_strdup_reset (char **dst, const char *src)
return TRUE;
}
void nm_indirect_g_free (gpointer arg);
/*****************************************************************************/
/* nm_utils_get_next_realloc_size() is used to grow buffers exponentially, when