blob: 841579da26b4fb9e0b46867c9648a7f98892780b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#ifndef __UTILS_H
#define __UTILS_H
#include <stdint.h>
#include <stdlib.h>
#ifdef __cplusplus
extern "C" {
#endif
#define MAX_ERROR_MSG_SIZE PATH_MAX
extern void *xmalloc( size_t );
extern void *xrealloc( void *, size_t );
extern char *dupstr( char *s );
static inline void freep(void **p)
{
if (*p)
free(*p);
}
#define DEFINE_TRIVIAL_CLEANUP_FUNC(type, func) \
static inline void func##p(type *p) \
{ \
if (*p) \
*p = func(*p); \
}
#define _cleanup_(_some_) __attribute__((__cleanup__(_some_)))
#define _cleanup_free_ _cleanup_(freep)
#ifdef __cplusplus
}
#endif
#endif /* __UTILS_H */
|