mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager
synced 2024-09-30 21:35:41 +00:00
shared: add nm_auto_vfree macro
This really is the same as gs_strfreev / g_strfreev(). However, the difference is, that the former has the notion of freeing strv arrays (char **), while this in general frees an array of pointers. Implementation-wise, they are the same.
This commit is contained in:
parent
fe07d6a404
commit
634b2d1ce2
|
@ -161,6 +161,23 @@ _nm_auto_unref_gsource (GSource **ptr)
|
|||
}
|
||||
#define nm_auto_unref_gsource nm_auto(_nm_auto_unref_gsource)
|
||||
|
||||
static inline void
|
||||
_nm_auto_freev (gpointer ptr)
|
||||
{
|
||||
gpointer **p = ptr;
|
||||
gpointer *_ptr;
|
||||
|
||||
if (*p) {
|
||||
for (_ptr = *p; *_ptr; _ptr++)
|
||||
g_free (*_ptr);
|
||||
g_free (*p);
|
||||
}
|
||||
}
|
||||
/* g_free a NULL terminated array of pointers, with also freeing each
|
||||
* pointer with g_free(). It essentially does the same as
|
||||
* gs_strfreev / g_strfreev(), but not restricted to strv arrays. */
|
||||
#define nm_auto_freev nm_auto(_nm_auto_freev)
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/* http://stackoverflow.com/a/11172679 */
|
||||
|
|
Loading…
Reference in a new issue