string duplicate

Mathieu Vachon math.vachon at gmail.com
Fri Oct 21 15:31:31 UTC 2016


I found this on the web :

static ngx_str_t* ngx_http_uploadprogress_strdup(ngx_str_t *src,  ngx_log_t
* log) {
    ngx_str_t *dst;
    dst = ngx_alloc(src->len + sizeof(ngx_str_t), log);
    if (dst == NULL) {
        return NULL;
    }

    dst->len = src->len;
    ngx_memcpy(((char*)dst + sizeof(ngx_str_t)) , src->data, src->len);
    dst->data = ((u_char*)dst + sizeof(ngx_str_t));
    return dst;
}


Was wondering if there was smthg in the api that would achieve the same
thing. Thx for the ngx_pstrdup() suggestion I've look at it , but didnt
want to go all the way with the pool etc .

On Fri, Oct 21, 2016 at 11:26 AM, Valentin V. Bartenev <vbart at nginx.com>
wrote:

> On Friday 21 October 2016 11:17:40 Mathieu Vachon wrote:
> > Hi there,
> >
> > Despite reading the api manual, i cant seem to find a function to
> duplicate
> > a ngx_str_t to another.
> >
> > Did i miss it , or have to roll my own duplicate stuff ?
> >
>
> ngx_pstrdup()?
>
>   wbr, Valentin V. Bartenev
>
> _______________________________________________
> nginx-devel mailing list
> nginx-devel at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx-devel/attachments/20161021/ea0ca878/attachment.html>


More information about the nginx-devel mailing list