]> git.proxmox.com Git - mirror_lxc.git/commitdiff
lxc: add cleanup helpers
authorChristian Brauner <christian.brauner@ubuntu.com>
Wed, 9 Dec 2020 09:06:06 +0000 (10:06 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Tue, 15 Dec 2020 11:03:58 +0000 (12:03 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/lxc.h

index 9e31366eb5f17536e09117e01ec332f17e6c113c..f688b25c264a6b399486c03966ac1705d4328760 100644 (file)
@@ -13,6 +13,7 @@ extern "C" {
 #include <sys/types.h>
 
 #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.