celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bpe...@apache.org
Subject celix git commit: CELIX-77: fixed some more memory issues
Date Fri, 15 Jan 2016 10:21:05 GMT
Repository: celix
Updated Branches:
  refs/heads/develop 7d10d6e97 -> 10e5b8969


CELIX-77: fixed some more memory issues


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

Branch: refs/heads/develop
Commit: 10e5b896945ab723aff37d0ea2a26149c00894e5
Parents: 7d10d6e
Author: Bjoern Petri <bpetri@apache.org>
Authored: Fri Jan 15 11:20:38 2016 +0100
Committer: Bjoern Petri <bpetri@apache.org>
Committed: Fri Jan 15 11:20:38 2016 +0100

----------------------------------------------------------------------
 config_admin/config_admin_tst/CMakeLists.txt              |  4 ----
 config_admin/config_admin_tst/config_admin_test.cpp       |  8 ++------
 .../service/private/include/configuration_admin_impl.h    |  1 +
 .../service/private/src/configuration_admin_factory.c     | 10 ++++++----
 .../service/private/src/configuration_admin_impl.c        |  8 ++++++--
 config_admin/service/private/src/configuration_store.c    |  3 +++
 6 files changed, 18 insertions(+), 16 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/celix/blob/10e5b896/config_admin/config_admin_tst/CMakeLists.txt
----------------------------------------------------------------------
diff --git a/config_admin/config_admin_tst/CMakeLists.txt b/config_admin/config_admin_tst/CMakeLists.txt
index ee2e2ec..bc20862 100644
--- a/config_admin/config_admin_tst/CMakeLists.txt
+++ b/config_admin/config_admin_tst/CMakeLists.txt
@@ -40,10 +40,6 @@ get_property(example_test_bundle_file TARGET example_test PROPERTY BUNDLE)
 get_property(example_test2_bundle_file TARGET example_test2 PROPERTY BUNDLE)
 
 configure_file(config.properties.in config.properties @ONLY)
-#configure_file(client.properties.in client.properties @ONLY)
-#configure_file(server.properties.in server.properties @ONLY)
-
-#add_dependencies(test_rsa_dfi remote_service_admin_dfi calculator)
 
 
 #ADD_TARGET_FOR_TEST(config_admin_test)

http://git-wip-us.apache.org/repos/asf/celix/blob/10e5b896/config_admin/config_admin_tst/config_admin_test.cpp
----------------------------------------------------------------------
diff --git a/config_admin/config_admin_tst/config_admin_test.cpp b/config_admin/config_admin_tst/config_admin_test.cpp
index f75cc3a..8539c76 100644
--- a/config_admin/config_admin_tst/config_admin_test.cpp
+++ b/config_admin/config_admin_tst/config_admin_test.cpp
@@ -84,8 +84,9 @@ tst2_service_pt test2Serv = NULL;
         rc = bundleContext_getServiceReference(context, (char *) TST2_SERVICE_NAME, &test2Ref);
         CHECK_EQUAL(CELIX_SUCCESS, rc);
 
-		rc = bundleContext_getService(context, testRef, (void **)&test2Serv);
+		rc = bundleContext_getService(context, test2Ref, (void **)&test2Serv);
 		CHECK_EQUAL(CELIX_SUCCESS, rc);
+
 	}
 
 	void teardownFw(void) {
@@ -94,10 +95,6 @@ tst2_service_pt test2Serv = NULL;
 		rc = bundleContext_ungetService(context, testRef, NULL);
         CHECK_EQUAL(CELIX_SUCCESS, rc);
 
-        // check whether this is necessary
-        rc = bundleContext_ungetService(context, testRef, NULL);
-        CHECK_EQUAL(CELIX_SUCCESS, rc);
-
         rc = bundleContext_ungetServiceReference(context, testRef);
         CHECK_EQUAL(CELIX_SUCCESS, rc);
 
@@ -405,4 +402,3 @@ TEST(managed_service, test_managed_service) {
 TEST(managed_service, test_bundles) {
     testBundles();
 }
-

http://git-wip-us.apache.org/repos/asf/celix/blob/10e5b896/config_admin/service/private/include/configuration_admin_impl.h
----------------------------------------------------------------------
diff --git a/config_admin/service/private/include/configuration_admin_impl.h b/config_admin/service/private/include/configuration_admin_impl.h
index be79602..b90a21d 100644
--- a/config_admin/service/private/include/configuration_admin_impl.h
+++ b/config_admin/service/private/include/configuration_admin_impl.h
@@ -52,6 +52,7 @@ struct configuration_admin{
 /* METHODS: celix.config_admin.private */
 celix_status_t configurationAdmin_create(configuration_admin_factory_pt factory, configuration_store_pt
store, bundle_pt bundle,
 										 configuration_admin_service_pt *service);
+celix_status_t configurationAdmin_destroy(configuration_admin_service_pt *service);
 
 /* METHODS: celix.config_admin.public */
 celix_status_t configurationAdmin_createFactoryConfiguration(configuration_admin_pt configAdmin,
char *factoryPid, configuration_pt *configuration);

http://git-wip-us.apache.org/repos/asf/celix/blob/10e5b896/config_admin/service/private/src/configuration_admin_factory.c
----------------------------------------------------------------------
diff --git a/config_admin/service/private/src/configuration_admin_factory.c b/config_admin/service/private/src/configuration_admin_factory.c
index 1c821ea..f8871d9 100644
--- a/config_admin/service/private/src/configuration_admin_factory.c
+++ b/config_admin/service/private/src/configuration_admin_factory.c
@@ -143,16 +143,18 @@ celix_status_t configurationAdminFactory_getService(void *handle, bundle_pt
bund
 	* END DEBUG CODE */
 
 	(*service) = confAdminService;
+
 	return CELIX_SUCCESS;
 
 }
 
-celix_status_t configurationAdminFactory_ungetService(void *factory, bundle_pt bundle, service_registration_pt
registration, void **service){
-	// do nothing
+celix_status_t configurationAdminFactory_ungetService(void *factory, bundle_pt bundle, service_registration_pt
registration, void **service) {
 
-    free(*service);
+    configuration_admin_service_pt confAdminService = (*service);
 
-	return CELIX_SUCCESS;
+    configurationAdmin_destroy(&confAdminService);
+
+    return CELIX_SUCCESS;
 }
 
 

http://git-wip-us.apache.org/repos/asf/celix/blob/10e5b896/config_admin/service/private/src/configuration_admin_impl.c
----------------------------------------------------------------------
diff --git a/config_admin/service/private/src/configuration_admin_impl.c b/config_admin/service/private/src/configuration_admin_impl.c
index eb8cb06..e88e191 100644
--- a/config_admin/service/private/src/configuration_admin_impl.c
+++ b/config_admin/service/private/src/configuration_admin_impl.c
@@ -49,6 +49,8 @@ celix_status_t configurationAdmin_create(configuration_admin_factory_pt
factory,
 										 configuration_admin_service_pt *service){
 
 	*service = calloc(1, sizeof(**service));
+
+
 	if(!*service){
 		printf("[ ERROR ]: ConfigAdmin - Not initialized(ENOMEM) \n");
 		return CELIX_ENOMEM;
@@ -77,8 +79,10 @@ celix_status_t configurationAdmin_create(configuration_admin_factory_pt
factory,
 }
 
 celix_status_t configurationAdmin_destroy(configuration_admin_service_pt *service) {
-	free(service);
-	return CELIX_SUCCESS;
+    free((*service)->configAdmin);
+    free(*service);
+
+    return CELIX_SUCCESS;
 }
 /* ========== IMPLEMENTATION ========== */
 

http://git-wip-us.apache.org/repos/asf/celix/blob/10e5b896/config_admin/service/private/src/configuration_store.c
----------------------------------------------------------------------
diff --git a/config_admin/service/private/src/configuration_store.c b/config_admin/service/private/src/configuration_store.c
index cee51e5..19a416d 100644
--- a/config_admin/service/private/src/configuration_store.c
+++ b/config_admin/service/private/src/configuration_store.c
@@ -109,6 +109,9 @@ celix_status_t configurationStore_create(bundle_context_pt context, configuratio
 
 celix_status_t configurationStore_destroy(configuration_store_pt store) {
     celixThreadMutex_destroy(&store->mutex);
+    hashMap_destroy(store->configurations, true, true);
+    free(store);
+
     return CELIX_SUCCESS;
 }
 


Mime
View raw message