Re: another emi2 bugfix
Oded Arbel <[email protected]>
| Newsgroups | gmane.comp.mobile.kannel.devel |
|---|---|
| Organization | m-Wise mobile solutions |
| Message-ID | <[email protected]> |
On Tuesday 06 August 2002 01:21 pm, Harrie Hazewinkel wrote: > --On Tuesday, August 6, 2002 1:14 PM +0300 Oded Arbel <[email protected]> > > wrote: > > On Tuesday 06 August 2002 12:38 pm, Harrie Hazewinkel wrote: > >> The patch below would combine a free(ptr) and a ptr=NULL > >> into a single gw_free(ptr) statement. The extra vaiable is needed > >> in case the variable is returned from a function. > >> This should be wise to include too, I guess. > > > > <snip> > > > >> +#define gw_free(ptr) {void *p=ptr;gw_native_free(p);p=NULL;} > > > > don't you mean : > ># define gw_free(ptr) {void *p=ptr;gw_native_free(p);ptr=NULL;} > > as p is freed from the stack anyway at the end of the macro block. the > > same to the other change. > > NO, since 'ptr' can be directly returned from a function and that > cannot be made NULL. However, I realise now also that this > would not do the trick. It makes the new variable NULL, but not the > pointer I wanted. > > Better drop it for now, and add explicits NULL assignments > each time when needed. Why would you ever want to return a pointer after calling gw_free on it ? after freeing a memory segment, the pointer to it must either be set to NULL or discarded. doing gw_free(pointer); return pointer; make no sense what so ever, unless gw_free also assigns NULL to the pointer. -- Oded Arbel m-Wise mobile solutions [email protected] +972-9-9581711 (116) +972-67-340014 ::.. We've got to pause and ask ourselves: How much clean air do we need? -- Lee Iacocca