mirror of
https://git.proxmox.com/git/fwupd
synced 2025-05-17 20:26:33 +00:00
26 lines
513 B
C
26 lines
513 B
C
/*
|
|
* Copyright (C) 2019 Richard Hughes <richard@hughsie.com>
|
|
*
|
|
* SPDX-License-Identifier: LGPL-2.1+
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#define _DEFINE_CLEANUP_FUNCTION0(Type, name, func) \
|
|
static inline VOID name(VOID *v) \
|
|
{ \
|
|
if (*(Type*)v) \
|
|
func (*(Type*)v); \
|
|
}
|
|
_DEFINE_CLEANUP_FUNCTION0(VOID *, _FreePool_p, FreePool)
|
|
#define _cleanup_free __attribute__ ((cleanup(_FreePool_p)))
|
|
|
|
static inline VOID *
|
|
_steal_pointer(VOID *pp)
|
|
{
|
|
VOID **ptr = (VOID **) pp;
|
|
VOID *ref = *ptr;
|
|
*ptr = NULL;
|
|
return ref;
|
|
}
|