[OpenSIPS-Devel] How to allocate and reliable free memory?

Vlad Paiu vladpaiu at opensips.org
Thu Jun 23 14:48:44 CEST 2011


Hello,

This is not correct.

Indeed, the child init functions are run by each process ( almost every 
processes ), after fork.
But the destroy function is called only once, at shutdown. Only the 
attendent process is running the destroy function, after all the other 
children have been shutdown.


Regards,

-- 
Vlad Paiu
OpenSIPS Developer



On 06/23/2011 02:59 PM, Roger Schreiter wrote:
> Hello,
>
> how do I allocate and reliable free some memory I need
> for parsing some SIP body?
>
> Is the following the correct way?
>
> - allocate in the module child init function or later
>    in some function called by the configuration.
>
> - That memory will be thread safe, since it is created
>    once per fork, and per fork there is only one sip_msg
>    handled at once
>
> - My module destroy function is called per fork and thus will
>    be able to free the alloced memory.
>
>
> Please give me some hint!
>
> Roger.
>
>
> P.S.
> In "struct part" (parser/parse_multipart) there is
> a member "void * parsed_data".
> Is it maybe intended (in future) for an automatic
> freeing of allocated memory like the various fields in
> "struct sip_msg"?
>
>
> _______________________________________________
> Devel mailing list
> Devel at lists.opensips.org
> http://lists.opensips.org/cgi-bin/mailman/listinfo/devel
>
>    





More information about the Devel mailing list