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