2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
8 #include <proto/exec.h>
9 #include "gadtools_intern.h"
11 /*********************************************************************
14 #include <proto/gadtools.h>
15 #include <intuition/intuition.h>
17 AROS_LH1(VOID
, FreeGadgets
,
20 AROS_LHA(struct Gadget
*, glist
, A0
),
23 struct Library
*, GadToolsBase
, 6, GadTools
)
26 Frees all gadtools gadgets in a linked list of gadgets.
29 glist - pointer to the first gadget to be freed, may be NULL.
46 ***************************************************************************/
50 struct Gadget
*lastgad
= NULL
, *nextgad
= NULL
;
52 DEBUG_FREEGADGETS(dprintf("FreeGadgets: glist 0x%lx\n", glist
));
57 for (; glist
; glist
= nextgad
)
59 nextgad
= glist
->NextGadget
;
60 if (glist
->GadgetType
& GTYP_GADTOOLS
)
62 if ((glist
->GadgetType
& GTYP_GTYPEMASK
) == GTYP_CUSTOMGADGET
)
64 DEBUG_FREEGADGETS(dprintf("FreeGadgets: free gadget 0x%lx\n", glist
));
66 /* must check this, because arrowclass uses GA_LabelImage! */
67 if ((glist
->Flags
& GFLG_LABELMASK
) == GFLG_LABELITEXT
)
69 freeitext(GTB(GadToolsBase
), glist
->GadgetText
);
73 } /* if ((glist->GadgetType & GTYP_GTYPEMASK) == GTYP_CUSTOMGADGET) */
76 if ( (((struct GT_ContextGadget
*)glist
)->magic
== CONTEXT_MAGIC
) &&
77 (((struct GT_ContextGadget
*)glist
)->magic2
== CONTEXT_MAGIC2
) )
79 /* This is a GadTools Context Gadget */
81 DEBUG_FREEGADGETS(dprintf("FreeGadgets: free context 0x%lx\n", glist
));
82 FreeMem(glist
, sizeof(struct GT_ContextGadget
));
84 else if ( (((struct GT_GenericGadget
*)glist
)->magic
== GENERIC_MAGIC
) &&
85 (((struct GT_GenericGadget
*)glist
)->magic2
== GENERIC_MAGIC2
) )
87 /* This is a GadTools Generic Kind Gadget */
89 DEBUG_FREEGADGETS(dprintf("FreeGadgets: free generic 0x%lx\n", glist
));
90 freeitext(GTB(GadToolsBase
), ((struct GT_GenericGadget
*)glist
)->itext
);
91 FreeMem(glist
, sizeof(struct GT_GenericGadget
));
95 DEBUG_FREEGADGETS(dprintf("FreeGadgets: bad gadget 0x%lx\n", glist
));
98 } /* if ((glist->GadgetType & GTYP_GTYPEMASK) == GTYP_CUSTOMGADGET) else ... */
100 } /* if (glist->GadgetType & GTYP_GADTOOLS) */
103 DEBUG_FREEGADGETS(dprintf("FreeGadgets: skip non-gadtools 0x%lx\n", glist
));
105 lastgad
->NextGadget
= glist
;
109 } /* for (; glist; glist = nextgad) */
112 lastgad
->NextGadget
= NULL
;
114 DEBUG_FREEGADGETS(dprintf("FreeGadgets: done\n"));