What is the best way to reallocate memory for char array?
Maxim Dounin
mdounin at mdounin.ru
Mon Nov 17 14:48:18 UTC 2014
Hello!
On Mon, Nov 17, 2014 at 09:35:18AM -0500, kay wrote:
> Thanks.
>
> Is it necessary to use ngx_pfree(str) at the end of my function?
As long as you allocate memory from a pool, it's not required to
free the memory explicitly via ngx_pfree(). Memory will be
freed automatically on the pool destruction. Moreover, in most
cases ngx_pfree() will not be able to do anything as it can only
free large blocks of memory.
The ngx_pfree() function is only useable in some special cases
when you have to free large blocks of memory before the pool will
be destroyed. For example, nginx uses ngx_pfree() to free
connection's buffer memory for idle keepalive connections, see
ngx_http_set_keepalive().
--
Maxim Dounin
http://nginx.org/
More information about the nginx
mailing list