From 8299862fdd6b853a889da837e6f6fbced350ef25 Mon Sep 17 00:00:00 2001 From: phk Date: Wed, 19 Jul 2006 12:36:42 +0000 Subject: [PATCH] Add miniobj.h for debugging git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@499 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/include/miniobj.h | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 varnish-cache/include/miniobj.h diff --git a/varnish-cache/include/miniobj.h b/varnish-cache/include/miniobj.h new file mode 100644 index 00000000..a1f72814 --- /dev/null +++ b/varnish-cache/include/miniobj.h @@ -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); + -- 2.39.5