From f47c8172e1fc0148d46d33b847c52d41f3e92d42 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Fri, 8 May 2015 20:31:19 -0400 Subject: [PATCH] Implemented uninitMenus() on Mac OS X. --- darwin/init.m | 2 +- darwin/menu.m | 24 ++++++++++++++++++++++++ darwin/uipriv_darwin.h | 1 + 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/darwin/init.m b/darwin/init.m index f6a5ac42..d810a05d 100644 --- a/darwin/init.m +++ b/darwin/init.m @@ -65,7 +65,7 @@ const char *uiInit(uiInitOptions *o) void uiUninit(void) { - // TODO free menus + uninitMenus(); // TODO free application delegate uninitAlloc(); } diff --git a/darwin/menu.m b/darwin/menu.m index 3dbfa999..f6047db9 100644 --- a/darwin/menu.m +++ b/darwin/menu.m @@ -347,3 +347,27 @@ void finalizeMenus(void) { menusFinalized = YES; } + +void uninitMenus(void) +{ + if (menus == NULL) + return; + [menus enumerateObjectsUsingBlock:^(id obj, NSUInteger index, BOOL *stop) { + NSValue *v; + struct menu *m; + + v = (NSValue *) obj; + m = (struct menu *) [v pointerValue]; + [m->items enumerateObjectsUsingBlock:^(id obj, NSUInteger index, BOOL *stop) { + NSValue *v; + struct menuItem *mi; + + v = (NSValue *) obj; + mi = (struct menuItem *) [v pointerValue]; + uiFree(mi); + }]; + [m->items release]; + uiFree(m); + }]; + [menus release]; +} diff --git a/darwin/uipriv_darwin.h b/darwin/uipriv_darwin.h index 9e621328..7a0f5f12 100644 --- a/darwin/uipriv_darwin.h +++ b/darwin/uipriv_darwin.h @@ -30,6 +30,7 @@ - (NSMenu *)makeMenubar; @end extern void finalizeMenus(void); +extern void uninitMenus(void); // init.m @interface appDelegate : NSObject