From 60ae9d76bad0efd18edd8e5217148e171128f224 Mon Sep 17 00:00:00 2001 From: phk Date: Wed, 24 Oct 2007 10:24:08 +0000 Subject: [PATCH] Add a WS_Dup() function git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@2166 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/bin/varnishd/cache.h | 1 + varnish-cache/bin/varnishd/cache_ws.c | 13 +++++++++++++ 2 files changed, 14 insertions(+) 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) { -- 2.39.5