From: phk Date: Wed, 24 Oct 2007 10:24:08 +0000 (+0000) Subject: Add a WS_Dup() function X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=60ae9d76bad0efd18edd8e5217148e171128f224;p=varnish Add a WS_Dup() function git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@2166 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/cache.h b/varnish-cache/bin/varnishd/cache.h index 68ce9af9..6707c585 100644 --- a/varnish-cache/bin/varnishd/cache.h +++ b/varnish-cache/bin/varnishd/cache.h @@ -585,6 +585,7 @@ void WS_ReleaseP(struct ws *ws, char *ptr); void WS_Assert(const struct ws *ws); void WS_Reset(struct ws *ws); char *WS_Alloc(struct ws *ws, unsigned bytes); +char *WS_Dup(struct ws *ws, const char *); /* rfc2616.c */ int RFC2616_cache_policy(const struct sess *sp, const struct http *hp); diff --git a/varnish-cache/bin/varnishd/cache_ws.c b/varnish-cache/bin/varnishd/cache_ws.c index 2629126b..a43e0751 100644 --- a/varnish-cache/bin/varnishd/cache_ws.c +++ b/varnish-cache/bin/varnishd/cache_ws.c @@ -96,6 +96,19 @@ WS_Alloc(struct ws *ws, unsigned bytes) return (r); } +char * +WS_Dup(struct ws *ws, const char *s) +{ + unsigned l; + char *p; + + l = strlen(s) + 1; + p = WS_Alloc(ws, l); + if (p != NULL) + memcpy(p, s, l); + return (p); +} + unsigned WS_Reserve(struct ws *ws, unsigned bytes) {