its not perfect but better to have Octstr * being set to NULL then to
be left.
Generally a free function for any type of object should be defined as
passing a double pointer
like
MyOctstr * x;
x = NewAllocMyOctstr()
do_something(x);
FreeAllocMyOctstr(&x);
whereas
FreeAllocMyOctstr(**x)
{
gw_free(*x)
*x = NULL;
};
This is what I call defensive programming. Never the less, its too
late to introduce that into gwlib with its many different object
types except by some places where you can use a macro instead to put
the variable to NULL after freeing that object type. It wont work for
nested calls but it does work for objects of that type.
On 22.01.2007, at 19:46, Stipe Tolj wrote:
Andreas Fink wrote:
depends on WHERE you do this macro
I often use it on ocstr_destroy by using O_DESTROY instead doing
just setting my octstr * to NULL after the call.
yep, as far as the octstr_create() is in the same stack scope.
If you pass the Octstr* pointer to several subsequent subcalls, and
down the lane you do gw_free(), then there is no use for it.
Complexity is the callstack IMO.
Stipe
-------------------------------------------------------------------
Kölner Landstrasse 419
40589 Düsseldorf, NRW, Germany
tolj.org system architecture Kannel Software Foundation (KSF)
http://www.tolj.org/ http://www.kannel.org/
mailto:st_{at}_tolj.org mailto:stolj_{at}_kannel.org
-------------------------------------------------------------------
Andreas Fink
Fink Consulting GmbH
Global Networks Schweiz AG
BebbiCell AG
---------------------------------------------------------------
Tel: +41-61-6666330 Fax: +41-61-6666331 Mobile: +41-79-2457333
Address: Clarastrasse 3, 4058 Basel, Switzerland
E-Mail: [EMAIL PROTECTED]
www.finkconsulting.com www.global-networks.ch www.bebbicell.ch
---------------------------------------------------------------
ICQ: 8239353 MSN: [EMAIL PROTECTED] AIM: smsrelay Skype: andreasfink
Yahoo: finkconsulting SMS: +41792457333