mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-01-29 04:10:31 +01:00
macros: add nm_auto_free macro
Similar to gs_free to cleanup pointers with free(). Note that g_free() and free() cannot be used interchangably.
This commit is contained in:
parent
ad45d232fe
commit
c66ee23f73
2 changed files with 11 additions and 1 deletions
|
|
@ -41,6 +41,8 @@
|
|||
|
||||
/* always include these headers for our internal source files. */
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "nm-glib.h"
|
||||
#include "nm-version.h"
|
||||
#include "gsystem-local-alloc.h"
|
||||
|
|
|
|||
|
|
@ -22,7 +22,15 @@
|
|||
#ifndef __NM_MACROS_INTERNAL_H__
|
||||
#define __NM_MACROS_INTERNAL_H__
|
||||
|
||||
#include "nm-default.h"
|
||||
/********************************************************/
|
||||
|
||||
/**
|
||||
* nm_auto_free:
|
||||
*
|
||||
* Call free() on a variable location when it goes out of scope.
|
||||
*/
|
||||
#define nm_auto_free __attribute__ ((cleanup(_nm_auto_free_impl)))
|
||||
GS_DEFINE_CLEANUP_FUNCTION(void*, _nm_auto_free_impl, free)
|
||||
|
||||
/********************************************************/
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue