mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-07-18 00:58:31 +00:00
Change made through this commit: - Include copy of flog as a seperate tree. - Modify the makefile to add and compile flog code. Signed-off-by: prakritigoyal19 <prakritigoyal19@gmail.com>
37 lines
842 B
C
37 lines
842 B
C
#ifndef __UTIL_H__
|
|
#define __UTIL_H__
|
|
|
|
#include <string.h>
|
|
#include <errno.h>
|
|
|
|
#include "log.h"
|
|
#include "types.h"
|
|
|
|
#define __xalloc(op, size, ...) \
|
|
({ \
|
|
void *___p = op(__VA_ARGS__); \
|
|
___p; \
|
|
})
|
|
|
|
#define xstrdup(str) __xalloc(strdup, strlen(str) + 1, str)
|
|
#define xmalloc(size) __xalloc(malloc, size, size)
|
|
#define xzalloc(size) __xalloc(calloc, size, 1, size)
|
|
#define xrealloc(p, size) __xalloc(realloc, size, p, size)
|
|
|
|
#define xfree(p) do { if (p) free(p); } while (0)
|
|
|
|
#define xrealloc_safe(pptr, size) \
|
|
({ \
|
|
int __ret = -ENOMEM; \
|
|
void *new = xrealloc(*pptr, size); \
|
|
if (new) { \
|
|
*pptr = new; \
|
|
__ret = 0; \
|
|
} \
|
|
__ret; \
|
|
})
|
|
|
|
#define memzero_p(p) memset(p, 0, sizeof(*p))
|
|
#define memzero(p, size) memset(p, 0, size)
|
|
|
|
#endif /* __UTIL_H__ */
|