1) OK

2) No. During a IupDestroy, one of the other handles in the array could be
destroyed, so the check must remain.

Best,
Scuri


Em sáb., 11 de jul. de 2020 às 00:31, Ranier Vilela <ranier_...@hotmail.com>
escreveu:

> De: Antonio Scuri <antonio.sc...@gmail.com>
> Enviado: sexta-feira, 29 de maio de 2020 13:12
> Para: IUP discussion list.
> Assunto: Re: [Iup-users] IUP iupDlgListDestroyAll refactored
>
> >  Because IupDestroy will also remove the dialog from that list and
> list->next will be invalid.
> Like this, it worked without problems.
>
> void iupDlgListDestroyAll(void)
> {
>   int i, count = 0;
>   Ihandle** ih_array = (Ihandle**)malloc(idlg_count * sizeof(Ihandle*));
>   Idiallst *list;
>   for (list = idlglist; list; list = list->next)
>   {
>     if (iupObjectCheck(list->ih))
>     {
>       ih_array[count] = list->ih;
>       ++count;
>     }
>   }
>
>   for (i = 0; i < count; ++i)
>   {
>       IupDestroy(ih_array[i]);   /* this will also destroy the list */
>   }
>
>   free(ih_array);
> }
>
> Advantagens:
> 1. Avoid assign variable count with i value;
> 2. Avoid call iupObjectCheck for every ih_array[i], since they have all
> been verified.
>
> regards,
> Ranier Vilela
>
> _______________________________________________
> Iup-users mailing list
> Iup-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/iup-users
>
_______________________________________________
Iup-users mailing list
Iup-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/iup-users

Reply via email to