2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
5 Desc: Free memory allocated by CreateMenusA()
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
, FreeMenus
,
20 AROS_LHA(struct Menu
*, menu
, A0
),
23 struct Library
*, GadToolsBase
, 9, GadTools
)
26 Frees the menus allocated by CreateMenusA().
29 menu - pointer to the menu (or first MenuItem) to be freed, may be NULL.
46 ***************************************************************************/
51 DEBUG_FREEMENUS(bug("FreeMenus: menu %p\n", menu
));
53 * ULONG BarLabelTable[BarLabelCount]
55 * ULONG Menu==0|Item!=0
60 ULONG
*p
= (ULONG
*)menu
- 1;
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
));
72 * p points now on BarLabelCount
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
= (ULONG
*)((IPTR
) p
- sizeof(APTR
));
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
));
89 DEBUG_FREEMENUS(bug("FreeMenus: done\n"));
97 DEBUG_FREEMENUS(bug("FreeMenus: menu %p\n", 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.
113 DEBUG_FREEMENUS(bug("FreeMenus: menuitem list\n"));
114 freeitems((struct MenuItem
*)menu
, (struct GadToolsBase_intern
*)GadToolsBase
);
118 DEBUG_FREEMENUS(bug("FreeMenus: menu list\n"));
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
));
136 p
= (ULONG
*)menu
- 1;
140 DEBUG_FREEMENUS(bug("FreeMenus: done\n"));