[PATCH] ngx_pstrdup() and ngx_copy() problems
maxim at nginx.com
Tue Dec 22 14:51:13 UTC 2015
On 12/22/15 5:47 PM, Maxim Dounin wrote:
> On Tue, Dec 22, 2015 at 05:21:26PM +0300, Sergey Matveychuk wrote:
>> * It looks like strings are supposed to finish with '\0' char to be
>> compatible with C strings. So ngx_pstrdup() must allocate and copy len+1,
>> not just len.
>> * ngx_copy() returns different values for different preprocessor conditions.
>> PS. I have no idea how trac.nginx.org works. I tried to fill a ticket, but
>> it just lost.
> Trac works fine, and I've just replied to you in the ticket.
> Here is a copy of the response:
> No, your assumptions are wrong. Strings in nginx are not expected
> to be null-terminated in general. The ngx_pstrdup() function is
>From Emiller's guide:
Note: an ngx_str_t is a struct with a data element, which is a
string, and a len element, which is the length of that string. Nginx
uses this data structure most places you'd expect a string.
More information about the nginx-devel