What is the best way to reallocate memory for char array?

kay nginx-forum at nginx.us
Mon Nov 17 14:09:34 UTC 2014

For example I've allocated memory for char *str:

str = ngx_pnalloc(r->pool, len1);

Then I've added some data to "str":

ngx_sprintf(str, "abc");

How should I reallocate this memory? Should I use:

str = ngx_pnalloc(r->pool, len2);

? And I would like to keep the str's "abc" data as well.

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,254851,254851#msg-254851

More information about the nginx mailing list