celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From abroekh...@apache.org
Subject svn commit: r1620920 - in /celix/trunk: examples/osgi-in-action/chapter04-correct-listener/private/src/ framework/private/src/
Date Wed, 27 Aug 2014 15:55:50 GMT
Author: abroekhuis
Date: Wed Aug 27 15:55:50 2014
New Revision: 1620920

URL: http://svn.apache.org/r1620920
Log:
Fixed several memory leaks.

Modified:
    celix/trunk/examples/osgi-in-action/chapter04-correct-listener/private/src/listener_example.c
    celix/trunk/framework/private/src/bundle_archive.c
    celix/trunk/framework/private/src/bundle_context.c
    celix/trunk/framework/private/src/bundle_revision.c
    celix/trunk/framework/private/src/framework.c
    celix/trunk/framework/private/src/manifest.c
    celix/trunk/framework/private/src/service_registration.c

Modified: celix/trunk/examples/osgi-in-action/chapter04-correct-listener/private/src/listener_example.c
URL: http://svn.apache.org/viewvc/celix/trunk/examples/osgi-in-action/chapter04-correct-listener/private/src/listener_example.c?rev=1620920&r1=1620919&r2=1620920&view=diff
==============================================================================
--- celix/trunk/examples/osgi-in-action/chapter04-correct-listener/private/src/listener_example.c
(original)
+++ celix/trunk/examples/osgi-in-action/chapter04-correct-listener/private/src/listener_example.c
Wed Aug 27 15:55:50 2014
@@ -117,6 +117,7 @@ celix_status_t bundleActivator_start(voi
 
 				listenerExample_serviceChanged(listener, event);
 			}
+			arrayList_destroy(logServices);
 		}
 
 		activator->running = true;

Modified: celix/trunk/framework/private/src/bundle_archive.c
URL: http://svn.apache.org/viewvc/celix/trunk/framework/private/src/bundle_archive.c?rev=1620920&r1=1620919&r2=1620920&view=diff
==============================================================================
--- celix/trunk/framework/private/src/bundle_archive.c (original)
+++ celix/trunk/framework/private/src/bundle_archive.c Wed Aug 27 15:55:50 2014
@@ -79,7 +79,7 @@ celix_status_t bundleArchive_createSyste
         	status = linkedList_create(&archive->revisions);
         	if (status == CELIX_SUCCESS) {
                 archive->id = 0l;
-                archive->location = "System Bundle";
+                archive->location = strdup("System Bundle");
                 archive->archiveRoot = NULL;
                 archive->archiveRootDir = NULL;
                 archive->refreshCount = -1;
@@ -146,6 +146,13 @@ celix_status_t bundleArchive_destroy(bun
 	    linkedListIterator_destroy(iter);
 		linkedList_destroy(archive->revisions);
 	}
+	if (archive->archiveRoot != NULL) {
+	    free(archive->archiveRoot);
+	}
+	if (archive->location != NULL) {
+        free(archive->location);
+    }
+
 	free(archive);
 	archive = NULL;
 
@@ -233,14 +240,14 @@ celix_status_t bundleArchive_getLocation
 	if (archive->location == NULL) {
 		FILE *bundleLocationFile;
 		char bundleLocation[512];
-        char location[256];
+        char loc[256];
 
         snprintf(bundleLocation, sizeof(bundleLocation), "%s/bundle.location", archive->archiveRoot);
 
         bundleLocationFile = fopen(bundleLocation, "r");
-        fgets(location, sizeof(location), bundleLocationFile);
+        fgets(loc, sizeof(loc), bundleLocationFile);
         fclose(bundleLocationFile);
-        archive->location = strdup(location);
+        archive->location = strdup(loc);
 	}
 
 	if (status == CELIX_SUCCESS) {

Modified: celix/trunk/framework/private/src/bundle_context.c
URL: http://svn.apache.org/viewvc/celix/trunk/framework/private/src/bundle_context.c?rev=1620920&r1=1620919&r2=1620920&view=diff
==============================================================================
--- celix/trunk/framework/private/src/bundle_context.c (original)
+++ celix/trunk/framework/private/src/bundle_context.c Wed Aug 27 15:55:50 2014
@@ -60,9 +60,8 @@ celix_status_t bundleContext_create(apr_
 celix_status_t bundleContext_destroy(bundle_context_pt context) {
 	celix_status_t status = CELIX_SUCCESS;
 
-	free(context);
-
 	if (context != NULL) {
+	    free(context);
 		context = NULL;
 	} else {
 		status = CELIX_ILLEGAL_ARGUMENT;

Modified: celix/trunk/framework/private/src/bundle_revision.c
URL: http://svn.apache.org/viewvc/celix/trunk/framework/private/src/bundle_revision.c?rev=1620920&r1=1620919&r2=1620920&view=diff
==============================================================================
--- celix/trunk/framework/private/src/bundle_revision.c (original)
+++ celix/trunk/framework/private/src/bundle_revision.c Wed Aug 27 15:55:50 2014
@@ -62,8 +62,6 @@ celix_status_t bundleRevision_create(fra
                 revision->location = strdup(location);
                 revision->logger = loggera;
 
-                arrayList_create(&(revision->libraryHandles));
-
                 *bundle_revision = revision;
 
                 char manifest[512];

Modified: celix/trunk/framework/private/src/framework.c
URL: http://svn.apache.org/viewvc/celix/trunk/framework/private/src/framework.c?rev=1620920&r1=1620919&r2=1620920&view=diff
==============================================================================
--- celix/trunk/framework/private/src/framework.c (original)
+++ celix/trunk/framework/private/src/framework.c Wed Aug 27 15:55:50 2014
@@ -249,6 +249,13 @@ celix_status_t framework_destroy(framewo
 		if (bundle_getArchive(bundle, &archive) == CELIX_SUCCESS) {
 			bundleArchive_destroy(archive);
 		}
+		bool systemBundle = false;
+		bundle_isSystemBundle(bundle, &systemBundle);
+		if (systemBundle) {
+		    bundle_context_pt context = NULL;
+            bundle_getContext(framework->bundle, &context);
+            bundleContext_destroy(context);
+		}
 		bundle_destroy(bundle);
 		hashMapIterator_remove(iterator);
 	}
@@ -257,7 +264,7 @@ celix_status_t framework_destroy(framewo
 
 	hashMap_destroy(framework->installRequestMap, false, false);
 
-//	serviceRegistry_destroy(framework->registry);
+	serviceRegistry_destroy(framework->registry);
 
 	arrayList_destroy(framework->globalLockWaitersList);
 
@@ -270,6 +277,7 @@ celix_status_t framework_destroy(framewo
 	if(framework->frameworkListeners){
 	arrayList_destroy(framework->frameworkListeners);
 	}
+
 	if(framework->requests){
 	    int i;
 	    for (i = 0; i < arrayList_size(framework->requests); i++) {

Modified: celix/trunk/framework/private/src/manifest.c
URL: http://svn.apache.org/viewvc/celix/trunk/framework/private/src/manifest.c?rev=1620920&r1=1620919&r2=1620920&view=diff
==============================================================================
--- celix/trunk/framework/private/src/manifest.c (original)
+++ celix/trunk/framework/private/src/manifest.c Wed Aug 27 15:55:50 2014
@@ -266,7 +266,7 @@ celix_status_t manifest_readAttributes(m
 			value[len - i] = '\0';
 		}
 
-		if ((properties_set(properties, strdup(name), strdup(value)) != NULL) && (!lineContinued))
{
+		if ((properties_set(properties, name, value) != NULL) && (!lineContinued)) {
 			printf("Duplicate entry: %s", name);
 		}
 	}

Modified: celix/trunk/framework/private/src/service_registration.c
URL: http://svn.apache.org/viewvc/celix/trunk/framework/private/src/service_registration.c?rev=1620920&r1=1620919&r2=1620920&view=diff
==============================================================================
--- celix/trunk/framework/private/src/service_registration.c (original)
+++ celix/trunk/framework/private/src/service_registration.c Wed Aug 27 15:55:50 2014
@@ -92,8 +92,8 @@ celix_status_t serviceRegistration_destr
 
 	celixThreadMutex_destroy(&registration->mutex);
 
-	registration = NULL;
 	free(registration);
+	registration = NULL;
 
 	return CELIX_SUCCESS;
 }



Mime
View raw message