Commit 99636168 authored by Geoff Simmons's avatar Geoff Simmons

use WS_Assert_Allocated() from Varnish

parent 3e49b60e
...@@ -91,13 +91,6 @@ errmsg(VRT_CTX, const char *fmt, ...) ...@@ -91,13 +91,6 @@ errmsg(VRT_CTX, const char *fmt, ...)
va_end(args); va_end(args);
} }
static inline void
WS_Allocated(struct ws * const restrict ws, const void * const restrict ptr,
const size_t len)
{
assert((char *)ptr >= ws->s && ((char *)ptr + len) <= ws->f);
}
static inline int static inline int
get_pcre2_errmsg(struct ws * const restrict ws, int errcode, get_pcre2_errmsg(struct ws * const restrict ws, int errcode,
char * restrict * const restrict buf) char * restrict * const restrict buf)
...@@ -148,7 +141,7 @@ ws_free(void *ptr, void *ws) ...@@ -148,7 +141,7 @@ ws_free(void *ptr, void *ws)
{ {
VSL(SLT_Debug, 0, "free ptr = %p, ws = %p", ptr, ws); VSL(SLT_Debug, 0, "free ptr = %p, ws = %p", ptr, ws);
WS_Assert(ws); WS_Assert(ws);
WS_Allocated(ws, ptr, 0); WS_Assert_Allocated(ws, ptr, 0);
} }
static void static void
...@@ -423,7 +416,7 @@ vmod_regex_match(VRT_CTX, struct vmod_pcre2_regex *regex, ...@@ -423,7 +416,7 @@ vmod_regex_match(VRT_CTX, struct vmod_pcre2_regex *regex,
* pcre2_general_context is declared as an incomplete * pcre2_general_context is declared as an incomplete
* type, so we can't check if it's full size is allocated. * type, so we can't check if it's full size is allocated.
*/ */
WS_Allocated(ctx->ws, gctx_task->priv, 0); WS_Assert_Allocated(ctx->ws, gctx_task->priv, 0);
gctx = gctx_task->priv; gctx = gctx_task->priv;
} }
...@@ -496,7 +489,7 @@ vmod_regex_match(VRT_CTX, struct vmod_pcre2_regex *regex, ...@@ -496,7 +489,7 @@ vmod_regex_match(VRT_CTX, struct vmod_pcre2_regex *regex,
* As with the general context above, pcre2_match_data is * As with the general context above, pcre2_match_data is
* an incomplete type. * an incomplete type.
*/ */
WS_Allocated(ctx->ws, match_task->priv, 0); WS_Assert_Allocated(ctx->ws, match_task->priv, 0);
mdata = match_task->priv; mdata = match_task->priv;
} }
......
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