fwupd/plugins/uefi/efi/fwup-cleanups.h
2019-02-09 08:42:30 -06:00

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;
}