Updated PCI IDs to latest snapshot.
[tangerine.git] / workbench / libs / gadtools / freemenus.c
blob47ff454badca27295e2220f8ed855c6ade6123f1
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc: Free memory allocated by CreateMenusA()
6 Lang: english
7 */
8 #include <proto/exec.h>
9 #include "gadtools_intern.h"
11 /*********************************************************************
13 NAME */
14 #include <proto/gadtools.h>
15 #include <intuition/intuition.h>
17 AROS_LH1(VOID, FreeMenus,
19 /* SYNOPSIS */
20 AROS_LHA(struct Menu *, menu, A0),
22 /* LOCATION */
23 struct Library *, GadToolsBase, 9, GadTools)
25 /* FUNCTION
26 Frees the menus allocated by CreateMenusA().
28 INPUTS
29 menu - pointer to the menu (or first MenuItem) to be freed, may be NULL.
31 RESULT
33 NOTES
35 EXAMPLE
37 BUGS
39 SEE ALSO
40 CreateMenusA()
42 INTERNALS
44 HISTORY
46 ***************************************************************************/
47 #if NEWMENUCODE
49 AROS_LIBFUNC_INIT
51 DEBUG_FREEMENUS(bug("FreeMenus: menu %p\n", menu));
53 * ULONG BarLabelTable[BarLabelCount]
54 * ULONG BarLabelCount
55 * ULONG Menu==0|Item!=0
56 * Menu:
58 if (menu)
60 ULONG *p = (ULONG *)menu - 1;
61 ULONG BarLabels;
62 int i;
64 DEBUG_FREEMENUS(bug("FreeMenus: p 0x%lx\n", *p));
65 DEBUG_FREEMENUS(bug("FreeMenus: NextMenu 0x%lx\n", menu->NextMenu));
66 DEBUG_FREEMENUS(bug("FreeMenus: Left %ld Top %ld Width %ld Height %ld\n", menu->LeftEdge,menu->TopEdge,menu->Width,menu->Height));
67 DEBUG_FREEMENUS(bug("FreeMenus: Flags 0x%lx\n", menu->Flags));
68 DEBUG_FREEMENUS(bug("FreeMenus: MenuName <%s> FirstItem 0x%lx\n", menu->MenuName,menu->FirstItem));
70 p = p - 1;
72 * p points now on BarLabelCount
74 BarLabels = *p;
75 DEBUG_FREEMENUS(bug("FreeMenus: BarLabels %ld\n", BarLabels));
76 for (i=0;i<BarLabels;i++)
78 // get the next Image pointer address
79 p = (IPTR) p - sizeof(APTR);
80 if (*(APTR*)p)
82 DEBUG_FREEMENUS(bug("FreeMenus: Free Image 0x%lx\n", *(APTR*)p));
83 DisposeObject(*(APTR*)p);
86 DEBUG_FREEMENUS(bug("FreeMenus: Free MenuMem 0x%lx\n", p));
87 FreeVec(p);
89 DEBUG_FREEMENUS(bug("FreeMenus: done\n"));
91 AROS_LIBFUNC_EXIT
92 } /* FreeMenus */
93 #else
95 AROS_LIBFUNC_INIT
97 DEBUG_FREEMENUS(bug("FreeMenus: menu %p\n", menu));
99 DumpMenu(menu);
100 if (menu)
102 ULONG *p = (ULONG *)menu - 1;
104 DEBUG_FREEMENUS(bug("FreeMenus: NextMenu 0x%lx\n", menu->NextMenu));
105 DEBUG_FREEMENUS(bug("FreeMenus: Left %ld Top %ld Width %ld Height %ld\n", menu->LeftEdge,menu->TopEdge,menu->Width,menu->Height));
106 DEBUG_FREEMENUS(bug("FreeMenus: Flags 0x%lx\n", menu->Flags));
107 DEBUG_FREEMENUS(bug("FreeMenus: MenuName <%s> FirstItem 0x%lx\n", menu->MenuName,menu->FirstItem));
109 * Check if we are freeing a Menu or a MenuItem list.
111 if (*p)
113 DEBUG_FREEMENUS(bug("FreeMenus: menuitem list\n"));
114 freeitems((struct MenuItem *)menu, (struct GadToolsBase_intern *)GadToolsBase);
116 else
118 DEBUG_FREEMENUS(bug("FreeMenus: menu list\n"));
119 while (NULL != menu)
121 struct Menu * _menu;
123 _menu = menu->NextMenu;
124 DEBUG_FREEMENUS(bug("FreeMenus: menu 0x%lx nextmenu 0x%lx\n",menu,_menu));
127 ** Free all items and subitems of this menu title
129 DEBUG_FREEMENUS(bug("FreeMenus: freeitems\n"));
130 freeitems(menu->FirstItem, (struct GadToolsBase_intern *)GadToolsBase);
132 DEBUG_FREEMENUS(bug("FreeMenus: menu 0x%lx size %ld\n",p,sizeof(ULONG) + sizeof(struct Menu) + sizeof(APTR)));
133 FreeMem(p, sizeof(ULONG) + sizeof(struct Menu) + sizeof(APTR));
135 menu = _menu;
136 p = (ULONG *)menu - 1;
140 DEBUG_FREEMENUS(bug("FreeMenus: done\n"));
142 AROS_LIBFUNC_EXIT
144 } /* FreeMenus */
145 #endif