r3024 - in trunk/varnish-cache: include lib/libvarnish
phk at projects.linpro.no
phk at projects.linpro.no
Fri Jul 25 16:53:08 CEST 2008
Author: phk
Date: 2008-07-25 16:53:08 +0200 (Fri, 25 Jul 2008)
New Revision: 3024
Modified:
trunk/varnish-cache/include/vsb.h
trunk/varnish-cache/lib/libvarnish/vsb.c
Log:
Give VSB's the mini-obj/magic treatment and enable asserts in general.
Modified: trunk/varnish-cache/include/vsb.h
===================================================================
--- trunk/varnish-cache/include/vsb.h 2008-07-25 14:52:08 UTC (rev 3023)
+++ trunk/varnish-cache/include/vsb.h 2008-07-25 14:53:08 UTC (rev 3024)
@@ -36,6 +36,7 @@
* Structure definition
*/
struct vsb {
+ unsigned s_magic;
char *s_buf; /* storage buffer */
void *s_unused; /* binary compatibility. */
int s_size; /* size of storage buffer */
Modified: trunk/varnish-cache/lib/libvarnish/vsb.c
===================================================================
--- trunk/varnish-cache/lib/libvarnish/vsb.c 2008-07-25 14:52:08 UTC (rev 3023)
+++ trunk/varnish-cache/lib/libvarnish/vsb.c 2008-07-25 14:53:08 UTC (rev 3024)
@@ -38,13 +38,16 @@
#include <string.h>
#include <strings.h>
+#include "libvarnish.h"
#include "vsb.h"
+#include "miniobj.h"
-#define KASSERT(e, m)
+#define KASSERT(e, m) assert(e)
#define SBMALLOC(size) malloc(size)
#define SBFREE(buf) free(buf)
#define min(x,y) (x < y ? x : y)
+#define VSB_MAGIC 0x4a82dd8a
/*
* Predicates
*/
@@ -77,6 +80,8 @@
(void)s;
KASSERT(s != NULL,
("%s called with a NULL vsb pointer", fun));
+ KASSERT(s->s_magic == VSB_MAGIC,
+ ("%s called wih an unintialized vsb pointer", fun));
KASSERT(s->s_buf != NULL,
("%s called with uninitialized or corrupt vsb", fun));
KASSERT(s->s_len < s->s_size,
@@ -163,10 +168,12 @@
return (NULL);
bzero(s, sizeof *s);
s->s_flags = flags;
+ s->s_magic = VSB_MAGIC;
VSB_SETFLAG(s, VSB_DYNSTRUCT);
} else {
bzero(s, sizeof *s);
s->s_flags = flags;
+ s->s_magic = VSB_MAGIC;
}
s->s_size = length;
if (buf) {
More information about the varnish-commit
mailing list