De: Pete Lomax via Iup-users <iup-users@lists.sourceforge.net>
Enviado: segunda-feira, 18 de maio de 2020 02:34
Para: IUP discussion list.
Cc: Pete Lomax
Assunto: Re: [Iup-users] Repeat of IM's "process/im_analyze.cpp allow 
free(NULL); " patch...

On Sunday, 17 May 2020, 23:05:05 BST, Ranier Vilela <ranier_...@hotmail.com> 
wrote:

The big question is how to catch the double free that may exist.

Because this not to protect against double free.
if (ptr) {
  free(ptr);
}

>One tactic I have just recently started adopting, entirely independent of this 
>and in fact in a completely different l>anguage is:
>ptr = ffree(ptr)
>where ffree() always returns null.
FFree comes in the case of defensive programming and depending on what is 
inside it, it remains a waste.
Probably ffree is written something like this:
void * ffree (void * ptr) {
    if (ptr) {
       free (ptr)
    }
    return NULL;
}

I am using only free, without any ifs, and using tools to detect memory 
problems, such as DrMemory on Windows.
If a double free occurs, it will certainly be detected either by me or by the 
user.

regards,
Ranier Vilela

_______________________________________________
Iup-users mailing list
Iup-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/iup-users

Reply via email to