add casts to zune macros to silence some warnings
[tangerine.git] / workbench / libs / gadtools / freemenus.c
blob9912f7b066bcf4ece9e999cc29df3c01388552f0
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 if (*--p)
80 DEBUG_FREEMENUS(bug("FreeMenus: Free Image 0x%lx\n", *p));
81 DisposeObject((APTR) *p);
84 DEBUG_FREEMENUS(bug("FreeMenus: Free MenuMem 0x%lx\n", p));
85 FreeVec(p);
87 DEBUG_FREEMENUS(bug("FreeMenus: done\n"));
89 AROS_LIBFUNC_EXIT
90 } /* FreeMenus */
91 #else
93 AROS_LIBFUNC_INIT
95 DEBUG_FREEMENUS(bug("FreeMenus: menu %p\n", menu));
97 DumpMenu(menu);
98 if (menu)
100 ULONG *p = (ULONG *)menu - 1;
102 DEBUG_FREEMENUS(bug("FreeMenus: NextMenu 0x%lx\n", menu->NextMenu));
103 DEBUG_FREEMENUS(bug("FreeMenus: Left %ld Top %ld Width %ld Height %ld\n", menu->LeftEdge,menu->TopEdge,menu->Width,menu->Height));
104 DEBUG_FREEMENUS(bug("FreeMenus: Flags 0x%lx\n", menu->Flags));
105 DEBUG_FREEMENUS(bug("FreeMenus: MenuName <%s> FirstItem 0x%lx\n", menu->MenuName,menu->FirstItem));
107 * Check if we are freeing a Menu or a MenuItem list.
109 if (*p)
111 DEBUG_FREEMENUS(bug("FreeMenus: menuitem list\n"));
112 freeitems((struct MenuItem *)menu, (struct GadToolsBase_intern *)GadToolsBase);
114 else
116 DEBUG_FREEMENUS(bug("FreeMenus: menu list\n"));
117 while (NULL != menu)
119 struct Menu * _menu;
121 _menu = menu->NextMenu;
122 DEBUG_FREEMENUS(bug("FreeMenus: menu 0x%lx nextmenu 0x%lx\n",menu,_menu));
125 ** Free all items and subitems of this menu title
127 DEBUG_FREEMENUS(bug("FreeMenus: freeitems\n"));
128 freeitems(menu->FirstItem, (struct GadToolsBase_intern *)GadToolsBase);
130 DEBUG_FREEMENUS(bug("FreeMenus: menu 0x%lx size %ld\n",p,sizeof(ULONG) + sizeof(struct Menu) + sizeof(APTR)));
131 FreeMem(p, sizeof(ULONG) + sizeof(struct Menu) + sizeof(APTR));
133 menu = _menu;
134 p = (ULONG *)menu - 1;
138 DEBUG_FREEMENUS(bug("FreeMenus: done\n"));
140 AROS_LIBFUNC_EXIT
142 } /* FreeMenus */
143 #endif