From: Christian Brauner Date: Wed, 9 Dec 2020 09:06:06 +0000 (+0100) Subject: lxc: add cleanup helpers X-Git-Tag: lxc-5.0.0~330^2~24 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=49aaa7546f6ac71196c787cff628efefc8fc5788;p=thirdparty%2Flxc.git lxc: add cleanup helpers Signed-off-by: Christian Brauner --- 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.