mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-02-05 08:50:27 +01:00
shared: add nm_auto_free_secret macro
This commit is contained in:
parent
a7c97d58db
commit
97f8d21674
1 changed files with 24 additions and 0 deletions
|
|
@ -69,6 +69,30 @@ static inline int nm_close (int fd);
|
|||
#define nm_auto_free nm_auto(_nm_auto_free_impl)
|
||||
GS_DEFINE_CLEANUP_FUNCTION(void*, _nm_auto_free_impl, free)
|
||||
|
||||
static inline void
|
||||
nm_free_secret (char *secret)
|
||||
{
|
||||
if (secret) {
|
||||
memset (secret, 0, strlen (secret));
|
||||
g_free (secret);
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
_nm_auto_free_secret_impl (char **v)
|
||||
{
|
||||
nm_free_secret (*v);
|
||||
}
|
||||
|
||||
/**
|
||||
* nm_auto_free_secret:
|
||||
*
|
||||
* Call g_free() on a variable location when it goes out of scope.
|
||||
* Also, previously, calls memset(loc, 0, strlen(loc)) to clear out
|
||||
* the secret.
|
||||
*/
|
||||
#define nm_auto_free_secret nm_auto(_nm_auto_free_secret_impl)
|
||||
|
||||
static inline void
|
||||
_nm_auto_unset_gvalue_impl (GValue *v)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue