From 49aaa7546f6ac71196c787cff628efefc8fc5788 Mon Sep 17 00:00:00 2001 From: Christian Brauner Date: Wed, 9 Dec 2020 10:06:06 +0100 Subject: [PATCH] lxc: add cleanup helpers Signed-off-by: Christian Brauner --- src/lxc/lxc.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/lxc/lxc.h b/src/lxc/lxc.h index 9e31366eb..f688b25c2 100644 --- a/src/lxc/lxc.h +++ b/src/lxc/lxc.h @@ -13,6 +13,7 @@ extern "C" { #include #include "compiler.h" +#include "memory_utils.h" #include "state.h" struct lxc_msg; @@ -94,6 +95,13 @@ extern int lxc_container_get(struct lxc_container *c); * If it is the last reference, free the lxccontainer and return 1. */ extern int lxc_container_put(struct lxc_container *c); +static inline void put_lxc_container(struct lxc_container *c) +{ + if (c) + lxc_container_put(c); +} +define_cleanup_function(struct lxc_container *, put_lxc_container); +#define __put_lxc_container call_cleaner(put_lxc_container) /* * Get a list of valid wait states. -- 2.47.2