cgroups: partially switch to cleanup macros

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
This commit is contained in:
Christian Brauner 2019-02-07 09:15:09 +01:00
parent 42bd57bdbd
commit d97919abf2
No known key found for this signature in database
GPG Key ID: 8EB056D53EECB12D
2 changed files with 152 additions and 251 deletions

File diff suppressed because it is too large Load Diff

View File

@ -20,13 +20,31 @@
#ifndef __LXC_MEMORY_UTILS_H
#define __LXC_MEMORY_UTILS_H
#include <dirent.h>
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
static inline void __auto_free__(void *p)
{
free(*(void **)p);
}
static inline void __auto_fclose__(FILE **f)
{
if (*f)
fclose(*f);
}
static inline void __auto_closedir__(DIR **d)
{
if (*d)
closedir(*d);
}
#define __do_free __attribute__((__cleanup__(__auto_free__)))
#define __do_fclose __attribute__((__cleanup__(__auto_fclose__)))
#define __do_closedir __attribute__((__cleanup__(__auto_closedir__)))
#endif /* __LXC_MEMORY_UTILS_H */