aboutsummaryrefslogtreecommitdiffstats
path: root/common.h
blob: 5bb22a1fb443e3a3e34997c4819a537369baade9 (plain) (blame)
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
47
48
/* See LICENSE file for copyright and license details. */
#include "libcontacts.h"

#include <alloca.h>
#include <ctype.h>
#include <dirent.h>
#include <errno.h>
#include <fcntl.h>
#include <limits.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>


#if defined(__GNUC__) || defined(__clang__)
# define ATTRIBUTE_PURE __attribute__((__pure__))
#else
# define ATTRIBUTE_PURE
#endif


#define TIME_MAX ((time_t)((1ULL << (8 * sizeof(time_t) - 1)) - 1ULL))


#define DESTROY_ALL_OBJECTS(LIST, FUNC)\
	do {\
		void *destroy_all_temp__ = (LIST);\
		if (destroy_all_temp__) {\
			for (; *(LIST); (LIST)++) {\
				FUNC(*(LIST));\
				free(*(LIST));\
			}\
			free(destroy_all_temp__);\
		}\
	} while (0)


#define DESTROY_ALL_STRINGS(LIST)\
	do {\
		void *destroy_all_temp__ = (LIST);\
		if (destroy_all_temp__) {\
			for (; *(LIST); (LIST)++)\
				free(*(LIST));\
			free(destroy_all_temp__);\
		}\
	} while (0)