hitch  1.5.2
About: Hitch is a libev-based high performance SSL/TLS proxy that terminates TLS/SSL connections and forwards the unencrypted traffic to some backend.
  Fossies Dox: hitch-1.5.2.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

miniobj.h
Go to the documentation of this file.
1 /*
2  * Written by Poul-Henning Kamp <phk@phk.freebsd.dk>
3  *
4  * This file is in the public domain.
5  *
6  */
7 
8 #define INIT_OBJ(to, type_magic) \
9  do { \
10  (void)memset(to, 0, sizeof *to); \
11  (to)->magic = (type_magic); \
12  } while (0)
13 
14 #define ALLOC_OBJ(to, type_magic) \
15  do { \
16  (to) = calloc(sizeof *(to), 1); \
17  if ((to) != NULL) \
18  (to)->magic = (type_magic); \
19  } while (0)
20 
21 #define FREE_OBJ(to) \
22  do { \
23  (to)->magic = (0); \
24  free(to); \
25  to = NULL; \
26  } while (0)
27 
28 #define VALID_OBJ(ptr, type_magic) \
29  ((ptr) != NULL && (ptr)->magic == (type_magic))
30 
31 #define CHECK_OBJ(ptr, type_magic) \
32  do { \
33  assert((ptr)->magic == type_magic); \
34  } while (0)
35 
36 #define CHECK_OBJ_NOTNULL(ptr, type_magic) \
37  do { \
38  assert((ptr) != NULL); \
39  assert((ptr)->magic == type_magic); \
40  } while (0)
41 
42 #define CHECK_OBJ_ORNULL(ptr, type_magic) \
43  do { \
44  if ((ptr) != NULL) \
45  assert((ptr)->magic == type_magic); \
46  } while (0)
47 
48 #define CAST_OBJ(to, from, type_magic) \
49  do { \
50  (to) = (from); \
51  if ((to) != NULL) \
52  CHECK_OBJ((to), (type_magic)); \
53  } while (0)
54 
55 #define CAST_OBJ_NOTNULL(to, from, type_magic) \
56  do { \
57  (to) = (from); \
58  assert((to) != NULL); \
59  CHECK_OBJ((to), (type_magic)); \
60  } while (0)
61 
62 #define REPLACE(ptr, val) \
63  do { \
64  if ((ptr) != NULL) \
65  free(ptr); \
66  if ((val) != NULL) { \
67  ptr = strdup(val); \
68  AN((ptr)); \
69  } else { \
70  ptr = NULL; \
71  } \
72  } while (0)