Commit a53a333e authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Give VSB's the mini-obj/magic treatment and enable asserts in general.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@3024 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 45a41f36
......@@ -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 */
......
......@@ -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 @@ _vsb_assert_integrity(const char *fun, struct vsb *s)
(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 @@ vsb_new(struct vsb *s, char *buf, int length, int flags)
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) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment