From 9d475e959b3b314d904a984898a29bbd63df4ca8 Mon Sep 17 00:00:00 2001
From: David Maciejak <david.maciejak@gmail.com>
Date: Mon, 31 Mar 2014 22:45:52 +0800
Subject: [PATCH 1/3] Added cleaned function in wings

---
 WINGs/WINGs/WINGs.h  |  3 ++-
 WINGs/notification.c | 12 ++++++++++++
 WINGs/wapplication.c | 11 +++++++++++
 3 files changed, 25 insertions(+), 1 deletion(-)

diff --git a/WINGs/WINGs/WINGs.h b/WINGs/WINGs/WINGs.h
index aa95844..6597504 100644
--- a/WINGs/WINGs/WINGs.h
+++ b/WINGs/WINGs/WINGs.h
@@ -642,9 +642,10 @@ WMRect wmkrect(int x, int y, unsigned int width, unsigned int height);
 /* ---[ WINGs/wapplication.c ]-------------------------------------------- */
 
 
-
 void WMInitializeApplication(const char *applicationName, int *argc, char **argv);
 
+void WMReleaseApplication();
+
 void WMSetResourcePath(const char *path);
 
 /* don't free the returned string */
diff --git a/WINGs/notification.c b/WINGs/notification.c
index ada942f..ebb05ec 100644
--- a/WINGs/notification.c
+++ b/WINGs/notification.c
@@ -94,6 +94,18 @@ void W_InitNotificationCenter(void)
 	notificationCenter->observerTable = WMCreateHashTable(WMIntHashCallbacks);
 }
 
+void WMReleaseNotificationCenter()
+{
+	if (notificationCenter->nameTable)
+		WMFreeHashTable(notificationCenter->nameTable);
+	if (notificationCenter->objectTable)
+		WMFreeHashTable(notificationCenter->objectTable);
+	if (notificationCenter->observerTable)
+		WMFreeHashTable(notificationCenter->observerTable);
+	if (notificationCenter)
+		wfree(notificationCenter);
+}
+
 void
 WMAddNotificationObserver(WMNotificationObserverAction * observerAction,
 			  void *observer, const char *name, void *object)
diff --git a/WINGs/wapplication.c b/WINGs/wapplication.c
index a0aec2e..84ede06 100644
--- a/WINGs/wapplication.c
+++ b/WINGs/wapplication.c
@@ -48,6 +48,17 @@ void WMInitializeApplication(const char *applicationName, int *argc, char **argv
 	W_InitNotificationCenter();
 }
 
+void WMReleaseApplication() {
+	int i =0;
+	if (WMApplication.applicationName)
+		wfree(WMApplication.applicationName);
+	for (i = 0; i < WMApplication.argc; i++)
+		wfree(WMApplication.argv[i]);
+	if (WMApplication.argv)
+		wfree(WMApplication.argv);
+	WMReleaseNotificationCenter();
+}
+
 void WMSetResourcePath(const char *path)
 {
 	if (WMApplication.resourcePath)
-- 
1.8.3.2

