celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pnol...@apache.org
Subject [23/38] celix git commit: CELIX-272: Remove memory leaks from framework and dep manager
Date Tue, 17 Nov 2015 11:57:40 GMT
CELIX-272: Remove memory leaks from framework and dep manager


Project: http://git-wip-us.apache.org/repos/asf/celix/repo
Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/7199e5c4
Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/7199e5c4
Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/7199e5c4

Branch: refs/heads/develop
Commit: 7199e5c473b5b024c214fb50779949556799fba7
Parents: 8c02ecf
Author: Pepijn Noltes <pepijnnoltes@gmail.com>
Authored: Mon Nov 16 18:16:16 2015 +0100
Committer: Pepijn Noltes <pepijnnoltes@gmail.com>
Committed: Mon Nov 16 18:16:16 2015 +0100

----------------------------------------------------------------------
 dependency_manager/private/src/dm_service_dependency.c | 3 +++
 framework/private/src/bundle_cache.c                   | 2 +-
 framework/private/src/framework.c                      | 1 +
 framework/private/src/service_registry.c               | 8 ++++++++
 4 files changed, 13 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/7199e5c4/dependency_manager/private/src/dm_service_dependency.c
----------------------------------------------------------------------
diff --git a/dependency_manager/private/src/dm_service_dependency.c b/dependency_manager/private/src/dm_service_dependency.c
index d29a8fe..636fd47 100644
--- a/dependency_manager/private/src/dm_service_dependency.c
+++ b/dependency_manager/private/src/dm_service_dependency.c
@@ -360,6 +360,8 @@ celix_status_t serviceDependency_invokeSet(dm_service_dependency_pt dependency,
 		}
 	}
 
+    arrayList_destroy(serviceReferences);
+
 	if (curServRef) {
 		status = bundleContext_getService(event->context, curServRef, &service);
 	} else {
@@ -646,6 +648,7 @@ celix_status_t serviceDependency_getServiceDependencyInfo(dm_service_dependency_
 		if (refs != NULL) {
 			info->count = arrayList_size(refs);
 		}
+		arrayList_destroy(refs);
 
 		celixThreadMutex_unlock(&dep->lock);
 	} else {

http://git-wip-us.apache.org/repos/asf/celix/blob/7199e5c4/framework/private/src/bundle_cache.c
----------------------------------------------------------------------
diff --git a/framework/private/src/bundle_cache.c b/framework/private/src/bundle_cache.c
index 46a43e4..3c1530a 100644
--- a/framework/private/src/bundle_cache.c
+++ b/framework/private/src/bundle_cache.c
@@ -112,7 +112,7 @@ celix_status_t bundleCache_getArchives(bundle_cache_pt cache, array_list_pt
*arc
                     && (strcmp(dp.d_name, "bundle0") != 0)) {
 
                     bundle_archive_pt archive = NULL;
-                    status = bundleArchive_recreate(strdup(archiveRoot), &archive);
+                    status = bundleArchive_recreate(archiveRoot, &archive);
                     if (status == CELIX_SUCCESS) {
                         arrayList_add(list, archive);
                     }

http://git-wip-us.apache.org/repos/asf/celix/blob/7199e5c4/framework/private/src/framework.c
----------------------------------------------------------------------
diff --git a/framework/private/src/framework.c b/framework/private/src/framework.c
index d603207..25e2442 100644
--- a/framework/private/src/framework.c
+++ b/framework/private/src/framework.c
@@ -2354,6 +2354,7 @@ static void *fw_eventDispatcher(void *fw) {
 
                     fw_invokeBundleListener(framework, listener->listener, event, listener->bundle);
 
+                    free(event->bundleSymbolicName);
                     free(event);
                 } else if (request->type == FRAMEWORK_EVENT_TYPE) {
                     fw_framework_listener_pt listener = (fw_framework_listener_pt) arrayList_get(request->listeners,
i);

http://git-wip-us.apache.org/repos/asf/celix/blob/7199e5c4/framework/private/src/service_registry.c
----------------------------------------------------------------------
diff --git a/framework/private/src/service_registry.c b/framework/private/src/service_registry.c
index 9f90025..db6e305 100644
--- a/framework/private/src/service_registry.c
+++ b/framework/private/src/service_registry.c
@@ -66,6 +66,8 @@ celix_status_t serviceRegistry_create(framework_pt framework, serviceChanged_fun
 		reg->framework = framework;
 		reg->currentServiceId = 1l;
 		reg->serviceReferences = hashMap_create(NULL, NULL, NULL, NULL);
+
+        reg->checkDeletedReferences = true;
         reg->deletedServiceReferences = hashMap_create(NULL, NULL, NULL, NULL);
 
 		arrayList_create(&reg->listenerHooks);
@@ -184,6 +186,11 @@ celix_status_t serviceRegistry_unregisterService(service_registry_pt
registry, b
 	regs = (array_list_pt) hashMap_get(registry->serviceRegistrations, bundle);
 	if (regs != NULL) {
 		arrayList_removeElement(regs, registration);
+        int size = arrayList_size(regs);
+        if (size == 0) {
+            arrayList_destroy(regs);
+            hashMap_remove(registry->serviceRegistrations, bundle);
+        }
 	}
 	celixThreadRwlock_unlock(&registry->lock);
 
@@ -479,6 +486,7 @@ celix_status_t serviceRegistry_clearReferencesFor(service_registry_pt
registry,
 
         }
         hashMapIterator_destroy(iter);
+        hashMap_destroy(refsMap, false, false);
     }
 
     celixThreadRwlock_unlock(&registry->lock);


Mime
View raw message