blob: 32d8b4b07b33b3b6ef132baea0e0c933783b5c9a (
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
40
41
42
43
44
45
46
|
#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);
}
static inline void string_freep(char **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)
#define _cleanup_string_ _cleanup_(string_freep)
#ifdef __cplusplus
}
#endif
#endif /* __UTILS_H */
|