]> err.no Git - varnish/commitdiff
Add miniobj.h for debugging
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Wed, 19 Jul 2006 12:36:42 +0000 (12:36 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Wed, 19 Jul 2006 12:36:42 +0000 (12:36 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@499 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/include/miniobj.h [new file with mode: 0644]

diff --git a/varnish-cache/include/miniobj.h b/varnish-cache/include/miniobj.h
new file mode 100644 (file)
index 0000000..a1f7281
--- /dev/null
@@ -0,0 +1,33 @@
+/* $Id$ */
+
+#define FREE_OBJ(to)                                                   \
+       do {                                                            \
+               (to)->magic = (0);                                      \
+               free(to);                                               \
+       } while (0)
+
+#define CHECK_OBJ(ptr, type_magic)                                     \
+       do {                                                            \
+               assert((ptr)->magic == type_magic);                     \
+       } while (0)
+
+#define CHECK_OBJ_NOTNULL(ptr, type_magic)                             \
+       do {                                                            \
+               assert((ptr) != NULL);                                  \
+               assert((ptr)->magic == type_magic);                     \
+       } while (0)
+
+#define CAST_OBJ(to, from, type_magic)                                 \
+       do {                                                            \
+               (to) = (from);                                          \
+               if ((to) != NULL)                                       \
+                       CHECK_OBJ((to), (type_magic));                  \
+       } while (0);
+
+#define CAST_OBJ_NOTNULL(to, from, type_magic)                                 \
+       do {                                                            \
+               (to) = (from);                                          \
+               assert((to) != NULL);                                   \
+               CHECK_OBJ((to), (type_magic));                          \
+       } while (0);
+