[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [osip-dev] Howto free resources correctly

From: Aymeric Moizard
Subject: Re: [osip-dev] Howto free resources correctly
Date: Fri, 26 Sep 2014 11:59:56 +0200


I'm replying with my phone so I can't be precise on answers.

Best is to look at sample code inside exosip which correctly use osip.

I'm almost sure (but can't check code) that those are correct:
osip_message_set_max_forwards(*msg, "70");
  osip_message_set_user_agent(*msg, "my_application 1.0");

The parameter may be are "const char*"? And duplicated by the stack using osip_strdup (or other way).

For "events": you are right for both point you mentioned, they are allocated and then will be handled asynchronously, so they are released by the stack itself from the moment you provide them to the stack, (after osip_transaction_add_event, I guess) (See exosip/source code)

If it's still obscure, please ask again and I'll reply on Monday when I'll be back ;)


Le 25 sept. 2014 21:57, "Roger Schreiter" <address@hidden> a écrit :
> Hello,
> I'm just doing first steps with libosip2.
> libosip2 seems to prefer malloc and free instead of using
> constant mem space provided by the application.
> Can someone please check my below assumptions and tell, whether
> I understand right:
> - When using osip_message_set_xyz, all data, which are passed by
>   pointer, have to be in allocated memory (osip_malloc, osip_strdup,
>   ...), never in heap or global variable or part of other allocated
>   block.
> - osip_message_free tries to osip_free every data, which was set by
>   osip_message_set_xyz
> - I saw in sample code:
>   osip_message_set_max_forwards(*msg, "70");
>   osip_message_set_user_agent(*msg, "my_application 1.0");
>   This might leed to problems?
> - When a message is transformed to an event with
>   osip_new_outgoing_sipmessage(msg)
>   I need not care anymore to free the msg, because it will be
>   freed automatically, when the event is freed later.
> - When an event was fed to a transaction with:
>   osip_transaction_add_event
>   I need not care anymore to free the event.
>   It will be freed, by the transaction, after the application did
>   consume the event.
>   Or maybe, when the transaction is killed.
>   Anyway: As soon, as the event is part of the transaction, I do not
>   need explicitely free the event anymore.
> Regards,
> Roger.
> _______________________________________________
> osip-dev mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/osip-dev

reply via email to

[Prev in Thread] Current Thread [Next in Thread]