celix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From abroekh...@apache.org
Subject svn commit: r1220683 - in /incubator/celix/trunk: framework/private/include/ framework/private/src/ utils/private/src/ utils/public/include/
Date Mon, 19 Dec 2011 10:53:53 GMT
Author: abroekhuis
Date: Mon Dec 19 10:53:52 2011
New Revision: 1220683

URL: http://svn.apache.org/viewvc?rev=1220683&view=rev
Log:
Applied patch from CELIX-24

Modified:
    incubator/celix/trunk/framework/private/include/framework_log.h
    incubator/celix/trunk/framework/private/include/headers.h
    incubator/celix/trunk/framework/private/include/service_registry.h
    incubator/celix/trunk/framework/private/src/bundle.c
    incubator/celix/trunk/framework/private/src/bundle_archive.c
    incubator/celix/trunk/framework/private/src/bundle_cache.c
    incubator/celix/trunk/framework/private/src/capability.c
    incubator/celix/trunk/framework/private/src/filter.c
    incubator/celix/trunk/framework/private/src/framework.c
    incubator/celix/trunk/framework/private/src/manifest.c
    incubator/celix/trunk/framework/private/src/manifest_parser.c
    incubator/celix/trunk/framework/private/src/miniunz.c
    incubator/celix/trunk/framework/private/src/module.c
    incubator/celix/trunk/framework/private/src/properties.c
    incubator/celix/trunk/framework/private/src/requirement.c
    incubator/celix/trunk/framework/private/src/resolver.c
    incubator/celix/trunk/framework/private/src/service_registration.c
    incubator/celix/trunk/framework/private/src/service_registry.c
    incubator/celix/trunk/framework/private/src/service_tracker.c
    incubator/celix/trunk/framework/private/src/version.c
    incubator/celix/trunk/framework/private/src/version_range.c
    incubator/celix/trunk/utils/private/src/array_list.c
    incubator/celix/trunk/utils/private/src/linkedlist.c
    incubator/celix/trunk/utils/public/include/array_list.h

Modified: incubator/celix/trunk/framework/private/include/framework_log.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/include/framework_log.h?rev=1220683&r1=1220682&r2=1220683&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/include/framework_log.h (original)
+++ incubator/celix/trunk/framework/private/include/framework_log.h Mon Dec 19 10:53:52 2011
@@ -7,7 +7,9 @@
 
 #ifndef LOG_H_
 #define LOG_H_
-
+#ifdef _WIN32
+#define celix_log(msg) printf("%s\n", msg);
+#else
 #define celix_log(msg) printf("%s\n\tat %s(%s:%d)\n", msg, __func__, __FILE__, __LINE__);
-
+#endif
 #endif /* LOG_H_ */

Modified: incubator/celix/trunk/framework/private/include/headers.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/include/headers.h?rev=1220683&r1=1220682&r2=1220683&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/include/headers.h (original)
+++ incubator/celix/trunk/framework/private/include/headers.h Mon Dec 19 10:53:52 2011
@@ -27,8 +27,6 @@
 #define HEADERS_H_
 
 #include <stdio.h>
-#include <dirent.h>
-#include <pthread.h>
 
 #include <apr_general.h>
 #include <apr_thread_proc.h>
@@ -53,8 +51,11 @@
 #define ATTRIBUTE_UNUSED
 #endif
 
-
+#if defined(WIN32)
+#define celix_log(msg) printf("%s\n", msg);
+#else
 #define celix_log(msg) printf("%s\n\tat %s(%s:%d)\n", msg, __func__, __FILE__, __LINE__);
+#endif
 
 struct framework {
 	struct bundle * bundle;
@@ -73,7 +74,7 @@ struct framework {
 	apr_thread_mutex_t *mutex;
 	apr_thread_mutex_t *bundleLock;
 
-	pthread_t globalLockThread;
+	apr_os_thread_t globalLockThread;
 	ARRAY_LIST globalLockWaitersList;
 	int globalLockCount;
 
@@ -148,7 +149,7 @@ struct serviceRegistration {
 	void * svcObj;
 	long serviceId;
 
-	pthread_mutex_t mutex;
+	apr_thread_mutex_t *mutex;
 	bool isUnregistering;
 
 	bool isServiceFactory;

Modified: incubator/celix/trunk/framework/private/include/service_registry.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/include/service_registry.h?rev=1220683&r1=1220682&r2=1220683&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/include/service_registry.h (original)
+++ incubator/celix/trunk/framework/private/include/service_registry.h Mon Dec 19 10:53:52 2011
@@ -26,8 +26,6 @@
 #ifndef SERVICE_REGISTRY_H_
 #define SERVICE_REGISTRY_H_
 
-#include <pthread.h>
-
 #include "headers.h"
 #include "properties.h"
 #include "filter.h"

Modified: incubator/celix/trunk/framework/private/src/bundle.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/bundle.c?rev=1220683&r1=1220682&r2=1220683&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/bundle.c (original)
+++ incubator/celix/trunk/framework/private/src/bundle.c Mon Dec 19 10:53:52 2011
@@ -51,7 +51,10 @@ celix_status_t bundle_create(BUNDLE * bu
 	}
 	status = bundleArchive_createSystemBundleArchive(mp, &archive);
 	if (status == CELIX_SUCCESS) {
-        (*bundle)->memoryPool = mp;
+        MODULE module;
+		apr_status_t apr_status;
+
+		(*bundle)->memoryPool = mp;
         (*bundle)->archive = archive;
         (*bundle)->activator = NULL;
         (*bundle)->context = NULL;
@@ -60,11 +63,11 @@ celix_status_t bundle_create(BUNDLE * bu
         (*bundle)->modules = NULL;
         arrayList_create(mp, &(*bundle)->modules);
 
-        MODULE module = module_createFrameworkModule((*bundle));
+        module = module_createFrameworkModule((*bundle));
         bundle_addModule(*bundle, module);
         // (*bundle)->module = module;
 
-        apr_status_t apr_status = apr_thread_mutex_create(&(*bundle)->lock, APR_THREAD_MUTEX_UNNESTED, (*bundle)->memoryPool);
+        apr_status = apr_thread_mutex_create(&(*bundle)->lock, APR_THREAD_MUTEX_UNNESTED, (*bundle)->memoryPool);
         if (apr_status != APR_SUCCESS) {
         	status = CELIX_ILLEGAL_STATE;
         } else {
@@ -81,9 +84,11 @@ celix_status_t bundle_create(BUNDLE * bu
 }
 
 celix_status_t bundle_createFromArchive(BUNDLE * bundle, FRAMEWORK framework, BUNDLE_ARCHIVE archive, apr_pool_t *bundlePool) {
-    celix_status_t status = CELIX_SUCCESS;
+    MODULE module;
+	
+	celix_status_t status = CELIX_SUCCESS;
 
-    *bundle = (BUNDLE) apr_pcalloc(bundlePool, sizeof(**bundle));
+	*bundle = (BUNDLE) apr_pcalloc(bundlePool, sizeof(**bundle));
 	if (*bundle == NULL) {
 		return CELIX_ENOMEM;
 	}
@@ -96,12 +101,13 @@ celix_status_t bundle_createFromArchive(
 	(*bundle)->modules = NULL;
 	arrayList_create(bundlePool, &(*bundle)->modules);
 
-	MODULE module;
+	
 	status = bundle_createModule(*bundle, &module);
 	if (status == CELIX_SUCCESS) {
-        bundle_addModule(*bundle, module);
-
-        apr_status_t apr_status = apr_thread_mutex_create(&(*bundle)->lock, APR_THREAD_MUTEX_UNNESTED, (*bundle)->memoryPool);
+        apr_status_t apr_status;
+		
+		bundle_addModule(*bundle, module);
+        apr_status = apr_thread_mutex_create(&(*bundle)->lock, APR_THREAD_MUTEX_UNNESTED, (*bundle)->memoryPool);
         if (apr_status != APR_SUCCESS) {
 			status = CELIX_ILLEGAL_STATE;
 		} else {
@@ -208,7 +214,7 @@ celix_status_t bundle_createModule(BUNDL
         status = bundleArchive_getId(bundle->archive, &bundleId);
         if (status == CELIX_SUCCESS) {
 			int revision = 0;
-			char moduleId[sizeof(bundleId) + sizeof(revision) + 2];
+			char * moduleId = (char *)malloc(sizeof(bundleId) + sizeof(revision) + 2);
 			sprintf(moduleId, "%ld.%d", bundleId, revision);
 
 			*module = module_create(headerMap, apr_pstrdup(bundle->memoryPool, moduleId), bundle);
@@ -228,11 +234,12 @@ celix_status_t bundle_createModule(BUNDL
 							if (id != bundleId) {
 								MODULE mod = NULL;
 								char * sym = NULL;
+								VERSION version;
+								int cmp;
 								status = bundle_getCurrentModule(check, &mod);
 								status = module_getSymbolicName(mod, &sym);
 
-								VERSION version = module_getVersion(mod);
-								int cmp;
+								version = module_getVersion(mod);
 								version_compareTo(bundleVersion, version, &cmp);
 								if ((symName != NULL) && (sym != NULL) && !strcmp(symName, sym) &&
 										!cmp) {
@@ -248,6 +255,7 @@ celix_status_t bundle_createModule(BUNDL
 					arrayList_destroy(bundles);
 				}
 			}
+			free(moduleId);
         }
 	}
 
@@ -457,22 +465,26 @@ celix_status_t bundle_unlock(BUNDLE bund
 }
 
 celix_status_t bundle_close(BUNDLE bundle) {
-    celix_status_t status = CELIX_SUCCESS;
+	BUNDLE_ARCHIVE archive;
+	
+	celix_status_t status = CELIX_SUCCESS;
 
     bundle_closeModules(bundle);
     bundle_closeRevisions(bundle);
-    BUNDLE_ARCHIVE archive = bundle_getArchive(bundle);
+    archive = bundle_getArchive(bundle);
     bundleArchive_close(archive);
 
     return status;
 }
 
 celix_status_t bundle_closeAndDelete(BUNDLE bundle) {
-    celix_status_t status = CELIX_SUCCESS;
+    BUNDLE_ARCHIVE archive;
+	
+	celix_status_t status = CELIX_SUCCESS;
 
     bundle_closeModules(bundle);
     bundle_closeRevisions(bundle);
-    BUNDLE_ARCHIVE archive = bundle_getArchive(bundle);
+    archive = bundle_getArchive(bundle);
     bundleArchive_closeAndDelete(archive);
 
     return status;

Modified: incubator/celix/trunk/framework/private/src/bundle_archive.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/bundle_archive.c?rev=1220683&r1=1220682&r2=1220683&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/bundle_archive.c (original)
+++ incubator/celix/trunk/framework/private/src/bundle_archive.c Mon Dec 19 10:53:52 2011
@@ -173,7 +173,8 @@ celix_status_t bundleArchive_recreate(ch
 	if (archive != NULL) {
 	    if (apr_pool_create(&revisions_pool, mp) == APR_SUCCESS) {
 	        if (linkedList_create(revisions_pool, &archive->revisions) == CELIX_SUCCESS) {
-                archive->archiveRoot = archiveRoot;
+                apr_dir_t *dir;
+				archive->archiveRoot = archiveRoot;
                 apr_dir_open(&archive->archiveRootDir, archiveRoot, mp);
                 archive->id = -1;
                 archive->persistentState = -1;
@@ -182,17 +183,18 @@ celix_status_t bundleArchive_recreate(ch
                 archive->refreshCount = -1;
                 archive->lastModified = (time_t) NULL;
 
-                apr_dir_t *dir;
+                
                 if (apr_dir_open(&dir, archiveRoot, mp) == APR_SUCCESS) {
                     apr_finfo_t dp;
                     long idx;
+					char *location;
+
                     while ((apr_dir_read(&dp, APR_FINFO_DIRENT|APR_FINFO_TYPE, dir)) == APR_SUCCESS) {
                         if (dp.filetype == APR_DIR && (strncmp(dp.name, "version", 7) == 0)) {
                             sscanf(dp.name, "version%*d.%ld", &idx);
                         }
                     }
-
-                    char *location;
+                    
                     status = bundleArchive_getRevisionLocation(archive, 0, &location);
                     if (status == CELIX_SUCCESS) {
                         bundleArchive_reviseInternal(archive, true, idx, location, NULL);
@@ -221,12 +223,12 @@ celix_status_t bundleArchive_getId(BUNDL
 	celix_status_t status = CELIX_SUCCESS;
 
 	if (archive->id < 0) {
-		char bundleId[strlen(archive->archiveRoot) + 11];
-		strcpy(bundleId, archive->archiveRoot);
-		strcat(bundleId, "/bundle.id");
-
 		apr_file_t *bundleIdFile;
 		apr_status_t rv;
+		char * bundleId = (char *)malloc(strlen(archive->archiveRoot) + 11);
+		strcpy(bundleId, archive->archiveRoot);
+		strcat(bundleId, "/bundle.id");
+		
 		if ((rv = apr_file_open(&bundleIdFile, bundleId, APR_FOPEN_READ, APR_OS_DEFAULT, archive->mp)) != APR_SUCCESS) {
 			status = CELIX_FILE_IO_EXCEPTION;
 		} else {
@@ -235,6 +237,7 @@ celix_status_t bundleArchive_getId(BUNDL
 			apr_file_close(bundleIdFile);
 			sscanf(id, "%ld", &archive->id);
 		}
+		free(bundleId);
 	}
 	if (status == CELIX_SUCCESS) {
 		*id = archive->id;
@@ -246,11 +249,12 @@ celix_status_t bundleArchive_getId(BUNDL
 celix_status_t bundleArchive_getLocation(BUNDLE_ARCHIVE archive, char **location) {
 	celix_status_t status = CELIX_SUCCESS;
 	if (archive->location == NULL) {
-		char bundleLocation[strlen(archive->archiveRoot) + 16];
-		strcpy(bundleLocation,archive->archiveRoot);
-		strcat(bundleLocation, "/bundle.location");
 		apr_file_t *bundleLocationFile;
 		apr_status_t rv;
+		char * bundleLocation = (char *)malloc(strlen(archive->archiveRoot) + 16);
+		strcpy(bundleLocation,archive->archiveRoot);
+		strcat(bundleLocation, "/bundle.location");
+		
 		if ((rv = apr_file_open(&bundleLocationFile, bundleLocation, APR_FOPEN_READ, APR_OS_DEFAULT, archive->mp)) != APR_SUCCESS) {
 			status = CELIX_FILE_IO_EXCEPTION;
 		} else {
@@ -260,6 +264,7 @@ celix_status_t bundleArchive_getLocation
 
 			archive->location = apr_pstrdup(archive->mp, location);
 		}
+		free(bundleLocation);
 	}
 
 	if (status == CELIX_SUCCESS) {
@@ -276,9 +281,9 @@ celix_status_t bundleArchive_getArchiveR
 
 celix_status_t bundleArchive_getCurrentRevisionNumber(BUNDLE_ARCHIVE archive, long *revisionNumber) {
 	celix_status_t status = CELIX_SUCCESS;
-	*revisionNumber = -1;
 	BUNDLE_REVISION revision;
-
+	*revisionNumber = -1;
+	
 	status = bundleArchive_getCurrentRevision(archive, &revision);
 	if (status == CELIX_SUCCESS) {
 		status = bundleRevision_getNumber(revision, revisionNumber);
@@ -304,10 +309,12 @@ celix_status_t bundleArchive_getPersiste
 	if (archive->persistentState >= 0) {
 		*state = archive->persistentState;
 	} else {
-		char persistentStateLocation[strlen(archive->archiveRoot) + 14];
+		apr_file_t *persistentStateLocationFile;
+		
+		char * persistentStateLocation = malloc(strlen(archive->archiveRoot) + 14);
 		strcpy(persistentStateLocation, archive->archiveRoot);
 		strcat(persistentStateLocation, "/bundle.state");
-		apr_file_t *persistentStateLocationFile;
+		
 		apr_status = apr_file_open(&persistentStateLocationFile, persistentStateLocation, APR_FOPEN_READ, APR_OS_DEFAULT, archive->mp);
 		if (apr_status != APR_SUCCESS) {
 			status = CELIX_FILE_IO_EXCEPTION;
@@ -328,6 +335,7 @@ celix_status_t bundleArchive_getPersiste
 
 			*state = archive->persistentState;
 		}
+		free(persistentStateLocation);
 	}
 
 	return status;
@@ -336,11 +344,12 @@ celix_status_t bundleArchive_getPersiste
 celix_status_t bundleArchive_setPersistentState(BUNDLE_ARCHIVE archive, BUNDLE_STATE state) {
 	celix_status_t status = CELIX_SUCCESS;
 	apr_status_t apr_status;
-
-	char persistentStateLocation[strlen(archive->archiveRoot) + 14];
+	apr_file_t *persistentStateLocationFile;
+	
+	char * persistentStateLocation = (char *)malloc(strlen(archive->archiveRoot) + 14);
 	strcpy(persistentStateLocation, archive->archiveRoot);
 	strcat(persistentStateLocation, "/bundle.state");
-	apr_file_t *persistentStateLocationFile;
+	
 	apr_status = apr_file_open(&persistentStateLocationFile, persistentStateLocation, APR_FOPEN_CREATE|APR_FOPEN_WRITE, APR_OS_DEFAULT, archive->mp);
 	if (apr_status != APR_SUCCESS) {
 		status = CELIX_FILE_IO_EXCEPTION;
@@ -365,6 +374,7 @@ celix_status_t bundleArchive_setPersiste
 
 		archive->persistentState = state;
 	}
+	free(persistentStateLocation);
 	return status;
 }
 
@@ -372,11 +382,13 @@ celix_status_t bundleArchive_getRefreshC
 	celix_status_t status = CELIX_SUCCESS;
 
 	if (archive->refreshCount == -1) {
-		char refreshCounter[strlen(archive->archiveRoot) + 17];
-		strcpy(refreshCounter,archive->archiveRoot);
-		strcat(refreshCounter, "/refresh.counter");
 		apr_file_t * refreshCounterFile;
 		apr_status_t rv;
+		
+		char * refreshCounter = (char *)malloc(strlen(archive->archiveRoot) + 17);
+		strcpy(refreshCounter,archive->archiveRoot);
+		strcat(refreshCounter, "/refresh.counter");
+		
 		if ((rv = apr_file_open(&refreshCounterFile, refreshCounter, APR_FOPEN_READ, APR_OS_DEFAULT, archive->mp)) != APR_SUCCESS) {
 			archive->refreshCount = 0;
 		} else {
@@ -385,6 +397,7 @@ celix_status_t bundleArchive_getRefreshC
 			apr_file_close(refreshCounterFile);
 			sscanf(counterStr, "%ld", &archive->refreshCount);
 		}
+		free(refreshCounter);
 	}
 
 	if (status == CELIX_SUCCESS) {
@@ -395,12 +408,15 @@ celix_status_t bundleArchive_getRefreshC
 }
 
 celix_status_t bundleArchive_setRefreshCount(BUNDLE_ARCHIVE archive) {
+	apr_file_t * refreshCounterFile;
+	apr_status_t apr_status;
 	celix_status_t status = CELIX_SUCCESS;
-	char refreshCounter[strlen(archive->archiveRoot) + 17];
+	char * refreshCounter = (char *)malloc(strlen(archive->archiveRoot) + 17);
 	strcpy(refreshCounter, archive->archiveRoot);
 	strcat(refreshCounter, "/refresh.counter");
-	apr_file_t * refreshCounterFile;
-	apr_status_t apr_status = apr_file_open(&refreshCounterFile, refreshCounter, APR_FOPEN_CREATE|APR_FOPEN_WRITE, APR_OS_DEFAULT, archive->mp);
+	
+	apr_status = apr_file_open(&refreshCounterFile, refreshCounter, APR_FOPEN_CREATE|APR_FOPEN_WRITE, APR_OS_DEFAULT, archive->mp);
+	free(refreshCounter);
 	if (apr_status != APR_SUCCESS) {
 		status = CELIX_FILE_IO_EXCEPTION;
 	} else {
@@ -435,24 +451,27 @@ celix_status_t bundleArchive_setLastModi
 }
 
 celix_status_t bundleArchive_readLastModified(BUNDLE_ARCHIVE archive, time_t *time) {
+	char timeStr[20];
+	apr_file_t *lastModifiedFile;
+	apr_status_t apr_status;
+
 	celix_status_t status = CELIX_SUCCESS;
 
-	char lastModified[strlen(archive->archiveRoot) + 21];
+	char * lastModified = (char *)malloc(strlen(archive->archiveRoot) + 21);
 	sprintf(lastModified, "%s/bundle.lastmodified", archive->archiveRoot);
 
-	char timeStr[20];
-	apr_file_t *lastModifiedFile;
-	apr_status_t apr_status = apr_file_open(&lastModifiedFile, lastModified, APR_FOPEN_READ, APR_OS_DEFAULT, archive->mp);
+	apr_status = apr_file_open(&lastModifiedFile, lastModified, APR_FOPEN_READ, APR_OS_DEFAULT, archive->mp);
+	free(lastModified);
 	if (apr_status != APR_SUCCESS) {
 		status = CELIX_FILE_IO_EXCEPTION;
 	} else {
+		int year, month, day, hours, minutes, seconds;
+		struct tm tm_time;
+
 		apr_file_gets(timeStr, sizeof(timeStr), lastModifiedFile);
 		apr_file_close(lastModifiedFile);
-
-		int year, month, day, hours, minutes, seconds;
+		
 		sscanf(timeStr, "%d %d %d %d:%d:%d", &year, &month, &day, &hours, &minutes, &seconds);
-
-		struct tm tm_time;
 		tm_time.tm_year = year - 1900;
 		tm_time.tm_mon = month - 1;
 		tm_time.tm_mday = day;
@@ -468,14 +487,16 @@ celix_status_t bundleArchive_readLastMod
 
 celix_status_t bundleArchive_writeLastModified(BUNDLE_ARCHIVE archive) {
 	celix_status_t status = CELIX_SUCCESS;
-
-	char lastModified[strlen(archive->archiveRoot) + 21];
-	sprintf(lastModified, "%s/bundle.lastmodified", archive->archiveRoot);
+	apr_file_t *lastModifiedFile;
 	char timeStr[20];
-	strftime(timeStr, 20, "%Y %m %d %H:%M:%S", localtime(&archive->lastModified));
+	char * lastModified = (char *)malloc(strlen(archive->archiveRoot) + 21);
+	apr_status_t apr_status;
 
-	apr_file_t *lastModifiedFile;
-	apr_status_t apr_status = apr_file_open(&lastModifiedFile, lastModified, APR_FOPEN_CREATE|APR_FOPEN_WRITE, APR_OS_DEFAULT, archive->mp);
+	sprintf(lastModified, "%s/bundle.lastmodified", archive->archiveRoot);	
+	strftime(timeStr, 20, "%Y %m %d %H:%M:%S", localtime(&archive->lastModified));
+	
+	apr_status = apr_file_open(&lastModifiedFile, lastModified, APR_FOPEN_CREATE|APR_FOPEN_WRITE, APR_OS_DEFAULT, archive->mp);
+	free(lastModified);
 	if (apr_status != APR_SUCCESS) {
 		status = CELIX_FILE_IO_EXCEPTION;
 	} else {
@@ -533,10 +554,10 @@ celix_status_t bundleArchive_createRevis
 
     status = bundleArchive_getRefreshCount(archive, &refreshCount);
     if (status == CELIX_SUCCESS) {
-		sprintf(root, "%s/version%ld.%ld", archive->archiveRoot, refreshCount, revNr);
-
 		BUNDLE_REVISION revision = NULL;
 		apr_pool_t *pool = NULL;
+		
+		sprintf(root, "%s/version%ld.%ld", archive->archiveRoot, refreshCount, revNr);
 		if (apr_pool_create(&pool, archive->mp) == APR_SUCCESS) {
 			status = bundleRevision_create(root, location, revNr, inputFile, pool, &revision);
 
@@ -562,9 +583,10 @@ celix_status_t bundleArchive_getRevision
 
 	status = bundleArchive_getRefreshCount(archive, &refreshCount);
 	if (status == CELIX_SUCCESS) {
-		sprintf(revisionLocation, "%s/version%ld.%ld/revision.location", archive->archiveRoot, refreshCount, revNr);
-
 		apr_file_t * revisionLocationFile;
+
+		sprintf(revisionLocation, "%s/version%ld.%ld/revision.location", archive->archiveRoot, refreshCount, revNr);
+		
 		if (apr_file_open(&revisionLocationFile, revisionLocation, APR_FOPEN_READ, APR_OS_DEFAULT, archive->mp) == APR_SUCCESS) {
 			char location[256];
 			apr_file_gets (location , sizeof(location) , revisionLocationFile);
@@ -590,9 +612,10 @@ celix_status_t bundleArchive_setRevision
 
 	status = bundleArchive_getRefreshCount(archive, &refreshCount);
 	if (status == CELIX_SUCCESS) {
-		sprintf(revisionLocation, "%s/version%ld.%ld/revision.location", archive->archiveRoot, refreshCount, revNr);
-
 		apr_file_t * revisionLocationFile;
+
+		sprintf(revisionLocation, "%s/version%ld.%ld/revision.location", archive->archiveRoot, refreshCount, revNr);
+		
 		if (apr_file_open(&revisionLocationFile, revisionLocation, APR_FOPEN_CREATE|APR_FOPEN_WRITE, APR_OS_DEFAULT, archive->mp) != APR_SUCCESS) {
 			status = CELIX_FILE_IO_EXCEPTION;
 		} else {
@@ -632,23 +655,28 @@ celix_status_t bundleArchive_initialize(
 			if (apr_status != APR_SUCCESS) {
 				status = CELIX_FILE_IO_EXCEPTION;
 			} else {
-				char bundleId[strlen(archive->archiveRoot) + 10];
+				apr_file_t *bundleIdFile;
+				apr_status_t apr_status;
+
+				char * bundleId = (char *)malloc(strlen(archive->archiveRoot) + 10);
 				strcpy(bundleId, archive->archiveRoot);
 				strcat(bundleId, "/bundle.id");
-				apr_file_t *bundleIdFile;
-				apr_status_t apr_status = apr_file_open(&bundleIdFile, bundleId, APR_FOPEN_CREATE|APR_FOPEN_WRITE, APR_OS_DEFAULT, archive->mp);
+				
+				apr_status = apr_file_open(&bundleIdFile, bundleId, APR_FOPEN_CREATE|APR_FOPEN_WRITE, APR_OS_DEFAULT, archive->mp);
+				free(bundleId);
 				if (apr_status != APR_SUCCESS) {
 					status = CELIX_FILE_IO_EXCEPTION;
 				} else {
+					char * bundleLocation;
+					apr_file_t *bundleLocationFile;
 					apr_file_printf(bundleIdFile, "%ld", archive->id);
 					// Ignore close status, let it fail if needed again
 					apr_file_close(bundleIdFile);
 
-					char bundleLocation[strlen(archive->archiveRoot) + 16];
+					bundleLocation = (char *)malloc(strlen(archive->archiveRoot) + 16);
 					strcpy(bundleLocation,archive->archiveRoot);
 					strcat(bundleLocation, "/bundle.location");
-					apr_file_t *bundleLocationFile;
-
+					
 					apr_status = apr_file_open(&bundleLocationFile, bundleLocation, APR_FOPEN_CREATE|APR_FOPEN_WRITE, APR_OS_DEFAULT, archive->mp);
 					if (apr_status != APR_SUCCESS) {
 						status = CELIX_FILE_IO_EXCEPTION;
@@ -659,6 +687,7 @@ celix_status_t bundleArchive_initialize(
 
 						status = bundleArchive_writeLastModified(archive);
 					}
+					free(bundleLocation);
 				}
 			}
 		}
@@ -668,8 +697,8 @@ celix_status_t bundleArchive_initialize(
 }
 
 celix_status_t bundleArchive_deleteTree(char * directory, apr_pool_t *mp) {
-	celix_status_t status = CELIX_SUCCESS;
 	apr_dir_t *dir;
+	celix_status_t status = CELIX_SUCCESS;
 	apr_status_t stat = apr_dir_open(&dir, directory, mp);
 	if (stat != APR_SUCCESS) {
 	    printf("ERROR opening: %d\n", stat);
@@ -679,7 +708,7 @@ celix_status_t bundleArchive_deleteTree(
 		apr_status_t apr_status;
 		while ((apr_status = apr_dir_read(&dp, APR_FINFO_DIRENT|APR_FINFO_TYPE, dir)) == APR_SUCCESS) {
 			if ((strcmp((dp.name), ".") != 0) && (strcmp((dp.name), "..") != 0)) {
-				char subdir[strlen(directory) + strlen(dp.name) + 2];
+				char * subdir = (char *)malloc(strlen(directory) + strlen(dp.name) + 2);
 				strcpy(subdir, directory);
 				strcat(subdir, "/");
 				strcat(subdir, dp.name);
@@ -689,9 +718,11 @@ celix_status_t bundleArchive_deleteTree(
 				} else {
 					if (apr_file_remove(subdir, mp) != APR_SUCCESS) {
 						status = CELIX_FILE_IO_EXCEPTION;
+						free(subdir);
 						break;
 					}
 				}
+				free(subdir);
 			}
 		}
 		if (apr_status != APR_SUCCESS && apr_status != APR_ENOENT) {

Modified: incubator/celix/trunk/framework/private/src/bundle_cache.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/bundle_cache.c?rev=1220683&r1=1220682&r2=1220683&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/bundle_cache.c (original)
+++ incubator/celix/trunk/framework/private/src/bundle_cache.c Mon Dec 19 10:53:52 2011
@@ -22,7 +22,9 @@
  *  Created on: Aug 6, 2010
  *      Author: alexanderb
  */
+#ifndef _WIN32
 #include <dirent.h>
+#endif
 #include <string.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -52,8 +54,8 @@ celix_status_t bundleCache_create(PROPER
         status = CELIX_ENOMEM;
     } else {
 		if (configurationMap != NULL && mp != NULL && *bundle_cache == NULL) {
-            cache->configurationMap = configurationMap;
             char * cacheDir = properties_get(configurationMap, (char *) FRAMEWORK_STORAGE);
+			cache->configurationMap = configurationMap;
             if (cacheDir == NULL) {
                 cacheDir = ".cache";
             }
@@ -88,7 +90,7 @@ static celix_status_t bundleCache_delete
             apr_finfo_t dp;
             while ((apr_dir_read(&dp, APR_FINFO_DIRENT|APR_FINFO_TYPE, dir)) == APR_SUCCESS) {
                 if ((strcmp((dp.name), ".") != 0) && (strcmp((dp.name), "..") != 0)) {
-                    char subdir[strlen(directory) + strlen(dp.name) + 2];
+                    char * subdir = (char *)malloc(strlen(directory) + strlen(dp.name) + 2);
                     strcpy(subdir, directory);
                     strcat(subdir, "/");
                     strcat(subdir, dp.name);
@@ -98,6 +100,7 @@ static celix_status_t bundleCache_delete
                     } else {
                         remove(subdir);
                     }
+					free(subdir);
                 }
             }
             remove(directory);
@@ -122,10 +125,11 @@ celix_status_t bundleCache_getArchives(B
 
 	if (status == APR_SUCCESS) {
         ARRAY_LIST list = NULL;
+		apr_finfo_t dp;
         arrayList_create(cache->mp, &list);
-        apr_finfo_t dp;
+        
         while ((apr_dir_read(&dp, APR_FINFO_DIRENT|APR_FINFO_TYPE, dir)) == APR_SUCCESS) {
-            char archiveRoot[strlen(cache->cacheDir) + strlen(dp.name) + 2];
+            char * archiveRoot = (char *)malloc(strlen(cache->cacheDir) + strlen(dp.name) + 2);
             strcpy(archiveRoot, cache->cacheDir);
             strcat(archiveRoot, "/");
             strcat(archiveRoot, dp.name);
@@ -142,6 +146,7 @@ celix_status_t bundleCache_getArchives(B
                     arrayList_add(list, archive);
                 }
             }
+			free(archiveRoot);
         }
 
         apr_dir_close(dir);

Modified: incubator/celix/trunk/framework/private/src/capability.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/capability.c?rev=1220683&r1=1220682&r2=1220683&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/capability.c (original)
+++ incubator/celix/trunk/framework/private/src/capability.c Mon Dec 19 10:53:52 2011
@@ -52,10 +52,11 @@ celix_status_t capability_create(apr_poo
 		(*capability)->version = NULL;
 		status = version_createEmptyVersion(pool, &(*capability)->version);
 		if (status == CELIX_SUCCESS) {
+			ATTRIBUTE versionAttribute;
 			ATTRIBUTE serviceAttribute = (ATTRIBUTE) hashMap_get(attributes, "service");
 			(*capability)->serviceName = serviceAttribute->value;
 
-			ATTRIBUTE versionAttribute = (ATTRIBUTE) hashMap_get(attributes, "version");
+			versionAttribute = (ATTRIBUTE) hashMap_get(attributes, "version");
 			if (versionAttribute != NULL) {
 				(*capability)->version = NULL;
 				status = version_createVersionFromString(pool, versionAttribute->value, &(*capability)->version);

Modified: incubator/celix/trunk/framework/private/src/filter.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/filter.c?rev=1220683&r1=1220682&r2=1220683&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/filter.c (original)
+++ incubator/celix/trunk/framework/private/src/filter.c Mon Dec 19 10:53:52 2011
@@ -125,9 +125,10 @@ FILTER filter_parseFilter(char * filterS
 }
 
 FILTER filter_parseFilterComp(char * filterString, int * pos, apr_pool_t *pool) {
+	char c;
 	filter_skipWhiteSpace(filterString, pos);
 
-	char c = filterString[*pos];
+	c = filterString[*pos];
 
 	switch (c) {
 		case '&': {
@@ -193,6 +194,7 @@ FILTER filter_parseOr(char * filterStrin
 }
 
 FILTER filter_parseNot(char * filterString, int * pos, apr_pool_t *pool) {
+	FILTER child = NULL;
 	FILTER filter = (FILTER) malloc(sizeof(*filter));
 	filter_skipWhiteSpace(filterString, pos);
 
@@ -201,7 +203,7 @@ FILTER filter_parseNot(char * filterStri
 		return NULL;
 	}
 
-	FILTER child = filter_parseFilter(filterString, pos, pool);
+	child = filter_parseFilter(filterString, pos, pool);
 
 	filter->operand = NOT;
 	filter->attribute = NULL;
@@ -248,7 +250,8 @@ FILTER filter_parseItem(char * filterStr
 			break;
 		}
 		case '=': {
-
+			FILTER filter = NULL;
+			ARRAY_LIST subs;
 			if (filterString[*pos + 1] == '*') {
 				int oldPos = *pos;
 				*pos += 2;
@@ -262,8 +265,7 @@ FILTER filter_parseItem(char * filterStr
 				}
 				*pos = oldPos;
 			}
-			FILTER filter = (FILTER) malloc(sizeof(*filter));
-			ARRAY_LIST subs;
+			filter = (FILTER) malloc(sizeof(*filter));			
 			(*pos)++;
 			subs = filter_parseSubstring(filterString, pos, pool);
 			if (arrayList_size(subs) == 1) {
@@ -290,12 +292,13 @@ FILTER filter_parseItem(char * filterStr
 }
 
 char * filter_parseAttr(char * filterString, int * pos) {
-	filter_skipWhiteSpace(filterString, pos);
+	char c;
 	int begin = *pos;
 	int end = *pos;
 	int length = 0;
 
-	char c = filterString[*pos];
+	filter_skipWhiteSpace(filterString, pos);
+	c = filterString[*pos];
 
 	while (c != '~' && c != '<' && c != '>' && c != '=' && c != '(' && c != ')') {
 		(*pos)++;
@@ -362,11 +365,14 @@ char * filter_parseValue(char * filterSt
 ARRAY_LIST filter_parseSubstring(char * filterString, int * pos, apr_pool_t *pool) {
 	char * sub = (char *) malloc(strlen(filterString));
 	ARRAY_LIST operands = NULL;
-	arrayList_create(pool, &operands);
 	int keepRunning = 1;
+	int size;
+
+	arrayList_create(pool, &operands);
 	sub[0] = '\0';
 	while (keepRunning) {
 		char c = filterString[*pos];
+		
 
 		switch (c) {
 			case ')': {
@@ -404,7 +410,7 @@ ARRAY_LIST filter_parseSubstring(char * 
 			}
 		}
 	}
-	int size = arrayList_size(operands);
+	size = arrayList_size(operands);
 
 	if (size == 0) {
 		printf("Missing value");
@@ -479,11 +485,12 @@ int filter_compareString(OPERAND operand
 
 				if (i + 1 < size) {
 					if (substr == NULL) {
+						unsigned int index;
 						char * substr2 = (char *) arrayList_get(subs, i + 1);
 						if (substr2 == NULL) {
 							continue;
 						}
-						unsigned int index = strcspn(string+pos, substr2);
+						index = strcspn(string+pos, substr2);
 						if (index == strlen(string+pos)) {
 							return 0;
 						}
@@ -494,21 +501,26 @@ int filter_compareString(OPERAND operand
 						}
 					} else {
 						unsigned int len = strlen(substr);
-						char region[len+1];
+						char * region = (char *)malloc(len+1);
 						strncpy(region, string+pos, len);
-						region[len] = '\0';
+						region[len]	= '\0';
 						if (strcmp(region, substr) == 0) {
 							pos += len;
 						} else {
+							free(region);
 							return 0;
 						}
+						free(region);
 					}
 				} else {
+					unsigned int len;
+					int begin;
+
 					if (substr == NULL) {
 						return 1;
 					}
-					unsigned int len = strlen(substr);
-					int begin = strlen(string)-len;
+					len = strlen(substr);
+					begin = strlen(string)-len;
 					return (strcmp(string+begin, substr) == 0);
 				}
 			}

Modified: incubator/celix/trunk/framework/private/src/framework.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/framework.c?rev=1220683&r1=1220682&r2=1220683&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/framework.c (original)
+++ incubator/celix/trunk/framework/private/src/framework.c Mon Dec 19 10:53:52 2011
@@ -1408,10 +1408,14 @@ celix_status_t framework_acquireBundleLo
 		status = CELIX_BUNDLE_EXCEPTION;
 	} else {
 		bool lockable = false;
+		bool isSelf = false;
+
 		bundle_isLockable(bundle, &lockable);
+		thread_equalsSelf(framework->globalLockThread, &isSelf);
+
 		while (!lockable
 				|| ((framework->globalLockThread != NULL)
-				&& (framework->globalLockThread != pthread_self()))) {
+				&& !isSelf)) {
 			BUNDLE_STATE state;
 			bundle_getState(bundle, &state);
 			if ((desiredStates & state) == 0) {
@@ -1419,7 +1423,7 @@ celix_status_t framework_acquireBundleLo
 				break;
 			} else
 				bundle_getLockingThread(bundle, &lockingThread);
-				if (framework->globalLockThread == pthread_self()
+				if (isSelf
 					&& (lockingThread != NULL)
 					&& arrayList_contains(framework->globalLockWaitersList, lockingThread)) {
 				framework->interrupted = true;
@@ -1479,10 +1483,13 @@ bool framework_acquireGlobalLock(FRAMEWO
     apr_thread_mutex_lock(framework->bundleLock);
 
 	bool interrupted = false;
+	bool isSelf = false;
+
+	thread_equalsSelf(framework->globalLockThread, &isSelf);
 
 	while (!interrupted
 			&& (framework->globalLockThread != NULL)
-			&& (framework->globalLockThread != pthread_self())) {
+			&& (!isSelf)) {
 		pthread_t currentThread = pthread_self();
 		arrayList_add(framework->globalLockWaitersList, currentThread);
 		apr_thread_cond_broadcast(framework->condition);
@@ -1498,7 +1505,7 @@ bool framework_acquireGlobalLock(FRAMEWO
 
 	if (!interrupted) {
 		framework->globalLockCount++;
-		framework->globalLockThread = pthread_self();
+		framework->globalLockThread = apr_os_thread_current();
 	}
 
 	apr_thread_mutex_unlock(framework->bundleLock);

Modified: incubator/celix/trunk/framework/private/src/manifest.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/manifest.c?rev=1220683&r1=1220682&r2=1220683&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/manifest.c (original)
+++ incubator/celix/trunk/framework/private/src/manifest.c Mon Dec 19 10:53:52 2011
@@ -194,8 +194,9 @@ celix_status_t manifest_readAttributes(M
 
 	int len;
 	while (fgets(lbuf, sizeof(lbuf), file ) != NULL ) {
-		len = strlen(lbuf);
 		bool lineContinued = false;
+		int i = 0;
+		len = strlen(lbuf);
 		if (lbuf[--len] != '\n') {
 			printf("MANIFEST: Line too long\n");
 			return CELIX_FILE_IO_EXCEPTION;
@@ -206,16 +207,18 @@ celix_status_t manifest_readAttributes(M
 		if (len == 0) {
 			break;
 		}
-		int i = 0;
+		
 		if (lbuf[0] == ' ') {
+			int newlen = strlen(lastLine) + len - 1;
+			char * buf = (char *)malloc(newlen);
+
 			// Line continued
 			if (name == NULL) {
+				free(buf);
 				printf("MANIFEST: No continued line expected\n");
 				return CELIX_FILE_IO_EXCEPTION;
 			}
 			lineContinued = true;
-			int newlen = strlen(lastLine) + len;
-			char buf[newlen];
 			strcpy(buf, lastLine);
 			strncat(buf, lbuf+1, len - 1);
 			buf[newlen] = '\0';

Modified: incubator/celix/trunk/framework/private/src/manifest_parser.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/manifest_parser.c?rev=1220683&r1=1220682&r2=1220683&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/manifest_parser.c (original)
+++ incubator/celix/trunk/framework/private/src/manifest_parser.c Mon Dec 19 10:53:52 2011
@@ -59,10 +59,12 @@ celix_status_t manifestParser_create(MOD
     status = CELIX_SUCCESS;
 	parser = (MANIFEST_PARSER) apr_pcalloc(memory_pool, sizeof(*parser));
 	if (parser) {
+		char * bundleVersion = NULL;
+		char * bundleSymbolicName = NULL;
         parser->manifest = manifest;
         parser->owner = owner;
 
-        char * bundleVersion = manifest_getValue(manifest, BUNDLE_VERSION);
+        bundleVersion = manifest_getValue(manifest, BUNDLE_VERSION);
         if (bundleVersion != NULL) {
             parser->bundleVersion = NULL;
             version_createVersionFromString(memory_pool, bundleVersion, &parser->bundleVersion);
@@ -70,7 +72,7 @@ celix_status_t manifestParser_create(MOD
         	parser->bundleVersion = NULL;
 			version_createEmptyVersion(memory_pool, &parser->bundleVersion);
         }
-        char * bundleSymbolicName = manifest_getValue(manifest, BUNDLE_SYMBOLICNAME);
+        bundleSymbolicName = manifest_getValue(manifest, BUNDLE_SYMBOLICNAME);
         if (bundleSymbolicName != NULL) {
             parser->bundleSymbolicName = bundleSymbolicName;
         }
@@ -102,11 +104,11 @@ static LINKED_LIST manifestParser_parseD
 
                 char * buffer = (char *) apr_pcalloc(temp_pool, sizeof(char) * 512);
                 if (buffer != NULL) {
-                    buffer[0] = '\0';
-
                     int expecting = (CHAR | DELIMITER | STARTQUOTE);
+					int i;
 
-                    int i;
+					buffer[0] = '\0';
+                                     
                     for (i = 0; i < strlen(value); i++) {
                         char c = value[i];
 
@@ -169,6 +171,11 @@ static LINKED_LIST manifestParser_parseS
         if (linkedList_create(memory_pool, &paths) == CELIX_SUCCESS) {
             int pathCount = 0;
             int pieceIdx;
+			HASH_MAP dirsMap = NULL;
+			HASH_MAP attrsMap = NULL;
+			char * sepPtr;
+            char * sep;
+
             for (pieceIdx = 0; pieceIdx < linkedList_size(pieces); pieceIdx++) {
                 char * piece = linkedList_get(pieces, pieceIdx);
                 if (strchr(piece, '=') != NULL) {
@@ -183,13 +190,14 @@ static LINKED_LIST manifestParser_parseS
                 return NULL;
             }
 
-            HASH_MAP dirsMap = hashMap_create(string_hash, NULL, string_equals, NULL);
-            HASH_MAP attrsMap = hashMap_create(string_hash, NULL, string_equals, NULL);
+            dirsMap = hashMap_create(string_hash, NULL, string_equals, NULL);
+            attrsMap = hashMap_create(string_hash, NULL, string_equals, NULL);
 
-            char * sepPtr;
-            char * sep;
+            
             for (pieceIdx = pathCount; pieceIdx < linkedList_size(pieces); pieceIdx++) {
-                char * DIRECTIVE_SEP = ":=";
+                char * key;
+				char * value;
+				char * DIRECTIVE_SEP = ":=";
                 char * ATTRIBUTE_SEP = "=";
                 char * piece = linkedList_get(pieces, pieceIdx);
                 if ((sepPtr = strstr(piece, DIRECTIVE_SEP)) != NULL) {
@@ -200,8 +208,8 @@ static LINKED_LIST manifestParser_parseS
                     return NULL;
                 }
 
-                char * key = string_ndup(piece, sepPtr - piece);
-                char * value = apr_pstrdup(temp_pool, sepPtr+strlen(sep));
+                key = string_ndup(piece, sepPtr - piece);
+                value = apr_pstrdup(temp_pool, sepPtr+strlen(sep));
 
                 if (value[0] == '"' && value[strlen(value) -1] == '"') {
                     char * oldV = apr_pstrdup(memory_pool, value);
@@ -215,10 +223,11 @@ static LINKED_LIST manifestParser_parseS
                 if (strcmp(sep, DIRECTIVE_SEP) == 0) {
                     // Not implemented
                 } else {
-                    if (hashMap_containsKey(attrsMap, key)) {
+                    ATTRIBUTE attr = NULL;
+					if (hashMap_containsKey(attrsMap, key)) {
                         return NULL;
                     }
-                    ATTRIBUTE attr = NULL;
+                    
                     if (attribute_create(key, value, memory_pool, &attr) == CELIX_SUCCESS) {
                         hashMap_put(attrsMap, key, attr);
                     }
@@ -271,10 +280,11 @@ static LINKED_LIST manifestParser_parseI
     LINKED_LIST requirements;
 
     if (apr_pool_create(&temp_pool, memory_pool) == APR_SUCCESS) {
-        clauses = manifestParser_parseStandardHeader(header, memory_pool);
-        linkedList_create(memory_pool, &requirements);
-
         int clauseIdx;
+		LINKED_LIST_ITERATOR iter;
+		clauses = manifestParser_parseStandardHeader(header, memory_pool);
+        linkedList_create(memory_pool, &requirements);
+        
         for (clauseIdx = 0; clauseIdx < linkedList_size(clauses); clauseIdx++) {
             LINKED_LIST clause = linkedList_get(clauses, clauseIdx);
 
@@ -284,22 +294,23 @@ static LINKED_LIST manifestParser_parseI
 
             int pathIdx;
             for (pathIdx = 0; pathIdx < linkedList_size(paths); pathIdx++) {
-                char * path = (char *) linkedList_get(paths, pathIdx);
+                ATTRIBUTE name = NULL;
+				REQUIREMENT req = NULL;
+				char * path = (char *) linkedList_get(paths, pathIdx);
                 if (strlen(path) == 0) {
                     return NULL;
                 }
-
-                ATTRIBUTE name = NULL;
+                
                 if (attribute_create(apr_pstrdup(memory_pool, "service"), path, memory_pool, &name) == CELIX_SUCCESS) {
                     hashMap_put(attributes, name->key, name);
                 }
 
-                REQUIREMENT req = requirement_create(memory_pool, directives, attributes);
+                req = requirement_create(memory_pool, directives, attributes);
                 linkedList_addElement(requirements, req);
             }
         }
 
-        LINKED_LIST_ITERATOR iter = linkedListIterator_create(clauses, 0);
+        iter = linkedListIterator_create(clauses, 0);
         while(linkedListIterator_hasNext(iter)) {
             LINKED_LIST clause = linkedListIterator_next(iter);
 
@@ -318,11 +329,12 @@ static LINKED_LIST manifestParser_parseI
 static LINKED_LIST manifestParser_parseExportHeader(MODULE module, char * header, apr_pool_t *memory_pool) {
     LINKED_LIST clauses;
     LINKED_LIST capabilities;
-
+	int clauseIdx;
+	LINKED_LIST_ITERATOR iter;
     clauses = manifestParser_parseStandardHeader(header, memory_pool);
     linkedList_create(memory_pool, &capabilities);
 
-    int clauseIdx;
+    
     for (clauseIdx = 0; clauseIdx < linkedList_size(clauses); clauseIdx++) {
         LINKED_LIST clause = linkedList_get(clauses, clauseIdx);
 
@@ -333,21 +345,21 @@ static LINKED_LIST manifestParser_parseE
         int pathIdx;
         for (pathIdx = 0; pathIdx < linkedList_size(paths); pathIdx++) {
             char * path = (char *) linkedList_get(paths, pathIdx);
-            if (strlen(path) == 0) {
+            ATTRIBUTE name = NULL;
+			CAPABILITY cap = NULL;
+			if (strlen(path) == 0) {
                 return NULL;
             }
 
-            ATTRIBUTE name = NULL;
             if (attribute_create(apr_pstrdup(memory_pool, "service"), path, memory_pool, &name) == CELIX_SUCCESS) {
                 hashMap_put(attributes, name->key, name);
             }
 
-            CAPABILITY cap = NULL;
             capability_create(memory_pool, module, directives, attributes, &cap);
             linkedList_addElement(capabilities, cap);
         }
     }
-    LINKED_LIST_ITERATOR iter = linkedListIterator_create(clauses, 0);
+    iter = linkedListIterator_create(clauses, 0);
     while(linkedListIterator_hasNext(iter)) {
         LINKED_LIST clause = linkedListIterator_next(iter);
 

Modified: incubator/celix/trunk/framework/private/src/miniunz.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/miniunz.c?rev=1220683&r1=1220682&r2=1220683&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/miniunz.c (original)
+++ incubator/celix/trunk/framework/private/src/miniunz.c Mon Dec 19 10:53:52 2011
@@ -34,8 +34,11 @@
 #include <errno.h>
 #include <fcntl.h>
 
-#include <unistd.h>
+#ifdef _WIN32
+#include <sys/utime.h>
+#else
 #include <utime.h>
+#endif
 #include <sys/stat.h>
 
 #include "unzip.h"
@@ -47,7 +50,8 @@
 
 #ifdef _WIN32
 #define USEWIN32IOAPI
-#include "iowin32.h"
+#include <windows.h>
+#include <winbase.h>
 #endif
 /*
   mini unzip, demo of unzip package
@@ -204,21 +208,25 @@ int do_extract_currentfile(unzFile uf, c
     }
 
     if ((*filename_withoutpath)=='\0') {
+		char * dir;
 		printf("creating directory: %s\n",filename_inzip);
-		char dir[strlen(revisionRoot) + strlen(filename_inzip) + 2];
+		dir = (char *)malloc(strlen(revisionRoot) + strlen(filename_inzip) + 2);
 		strcpy(dir, revisionRoot);
 		strcat(dir, "/");
 		strcat(dir, filename_inzip);
 		mymkdir(dir);
+		free(dir);
     }
     else
     {
         const char* write_filename;
         int skip=0;
+		int length;
+		char * fWFN;
         write_filename = filename_inzip;
 
-        int length = strlen(write_filename) + strlen(revisionRoot) + 2;
-        char fWFN[length];
+        length = strlen(write_filename) + strlen(revisionRoot) + 2;
+        fWFN = (char *)malloc(length);
         strcpy(fWFN, revisionRoot);
         strcat(fWFN, "/");
         strcat(fWFN, write_filename);
@@ -236,16 +244,18 @@ int do_extract_currentfile(unzFile uf, c
             /* some zipfile don't contain directory alone before file */
             if ((fout==NULL) && (filename_withoutpath!=(char*)filename_inzip))
             {
+				char * dir;
+				int length;
                 char c=*(filename_withoutpath-1);
                 *(filename_withoutpath-1)='\0';
-                int length = strlen(write_filename) + strlen(revisionRoot) + 2;
-                char dir[length];
+                length = strlen(write_filename) + strlen(revisionRoot) + 2;
+                dir = (char *)malloc(length);
 				strcpy(dir, revisionRoot);
 				strcat(dir, "/");
 				strcat(dir, write_filename);
                 makedir(dir);
                 *(filename_withoutpath-1)=c;
-
+				free(dir);
                 fout=fopen64(fWFN,"wb");
             }
 
@@ -292,6 +302,8 @@ int do_extract_currentfile(unzFile uf, c
         }
         else
             unzCloseCurrentFile(uf); /* don't lose the error */
+
+		free(fWFN);
     }
 
     free(buf);

Modified: incubator/celix/trunk/framework/private/src/module.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/module.c?rev=1220683&r1=1220682&r2=1220683&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/module.c (original)
+++ incubator/celix/trunk/framework/private/src/module.c Mon Dec 19 10:53:52 2011
@@ -141,10 +141,10 @@ WIRE module_getWire(MODULE module, char 
 	if (module->wires != NULL) {
 		LINKED_LIST_ITERATOR iterator = linkedListIterator_create(module->wires, 0);
 		while (linkedListIterator_hasNext(iterator)) {
+			char *name;
 			WIRE next = linkedListIterator_next(iterator);
 			CAPABILITY cap = NULL;
 			wire_getCapability(next, &cap);
-			char *name;
 			capability_getServiceName(cap, &name);
 			if (strcasecmp(name, serviceName) == 0) {
 				wire = next;

Modified: incubator/celix/trunk/framework/private/src/properties.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/properties.c?rev=1220683&r1=1220682&r2=1220683&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/properties.c (original)
+++ incubator/celix/trunk/framework/private/src/properties.c Mon Dec 19 10:53:52 2011
@@ -103,8 +103,9 @@ PROPERTIES properties_load(char * filena
 			if (!split) {
 				unsigned int pos = strcspn(line, "=");
 				if (pos != strlen(line)) {
+					char * ival = NULL;
 					key = string_trim(string_ndup((char *)line, pos));
-					char * ival = string_ndup(line+pos+1, strlen(line));
+					ival = string_ndup(line+pos+1, strlen(line));
 					value = string_trim(ival);
 					if (value != NULL) {
 						char * cmp = string_ndup(value+strlen(value)-1, 1);
@@ -124,9 +125,10 @@ PROPERTIES properties_load(char * filena
 					split = 1;
 					strcat(value, string_ndup(line, strlen(line)-1));
 				} else {
+					char * old = NULL;
 					split = 0;
 					strcat(value, string_trim(line));
-					char * old = hashMap_put(props, strdup(key), strdup(value));
+					old = hashMap_put(props, strdup(key), strdup(value));
 				}
 			}
 		}

Modified: incubator/celix/trunk/framework/private/src/requirement.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/requirement.c?rev=1220683&r1=1220682&r2=1220683&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/requirement.c (original)
+++ incubator/celix/trunk/framework/private/src/requirement.c Mon Dec 19 10:53:52 2011
@@ -36,6 +36,8 @@ struct requirement {
 };
 
 REQUIREMENT requirement_create(apr_pool_t *pool, HASH_MAP directives, HASH_MAP attributes) {
+	ATTRIBUTE versionAttribute = NULL;
+	ATTRIBUTE serviceAttribute = NULL;
 	REQUIREMENT requirement = (REQUIREMENT) malloc(sizeof(*requirement));
 
 	requirement->attributes = attributes;
@@ -43,12 +45,12 @@ REQUIREMENT requirement_create(apr_pool_
 
 	requirement->versionRange = NULL;
 	versionRange_createInfiniteVersionRange(pool, &requirement->versionRange);
-	ATTRIBUTE versionAttribute = (ATTRIBUTE) hashMap_get(attributes, "version");
+	versionAttribute = (ATTRIBUTE) hashMap_get(attributes, "version");
 	if (versionAttribute != NULL) {
 		requirement->versionRange = NULL;
 		versionRange_parse(pool, versionAttribute->value, &requirement->versionRange);
 	}
-	ATTRIBUTE serviceAttribute = (ATTRIBUTE) hashMap_get(attributes, "service");
+	serviceAttribute = (ATTRIBUTE) hashMap_get(attributes, "service");
 	requirement->targetName = serviceAttribute->value;
 
 	return requirement;

Modified: incubator/celix/trunk/framework/private/src/resolver.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/resolver.c?rev=1220683&r1=1220682&r2=1220683&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/resolver.c (original)
+++ incubator/celix/trunk/framework/private/src/resolver.c Mon Dec 19 10:53:52 2011
@@ -58,12 +58,17 @@ void resolver_removeInvalidCandidate(MOD
 HASH_MAP resolver_populateWireMap(HASH_MAP candidates, MODULE importer, HASH_MAP wireMap);
 
 HASH_MAP resolver_resolve(MODULE root) {
+	HASH_MAP candidatesMap = NULL;
+	HASH_MAP wireMap = NULL;
+	HASH_MAP resolved = NULL;
+	HASH_MAP_ITERATOR iter = NULL;
+
 	if (module_isResolved(root)) {
 	    printf("already resolved\n");
 		return NULL;
 	}
 
-	HASH_MAP candidatesMap = hashMap_create(NULL, NULL, NULL, NULL);
+	candidatesMap = hashMap_create(NULL, NULL, NULL, NULL);
 
 	if (resolver_populateCandidatesMap(candidatesMap, root) != 0) {
 		HASH_MAP_ITERATOR iter = hashMapIterator_create(candidatesMap);
@@ -87,9 +92,9 @@ HASH_MAP resolver_resolve(MODULE root) {
 		return NULL;
 	}
 
-	HASH_MAP wireMap = hashMap_create(NULL,NULL,NULL,NULL);
-	HASH_MAP resolved = resolver_populateWireMap(candidatesMap, root, wireMap);
-	HASH_MAP_ITERATOR iter = hashMapIterator_create(candidatesMap);
+	wireMap = hashMap_create(NULL,NULL,NULL,NULL);
+	resolved = resolver_populateWireMap(candidatesMap, root, wireMap);
+	iter = hashMapIterator_create(candidatesMap);
 	while (hashMapIterator_hasNext(iter)) {
 		HASH_MAP_ENTRY entry = hashMapIterator_nextEntry(iter);
 		MODULE key = hashMapEntry_getKey(entry);
@@ -167,10 +172,11 @@ int resolver_populateCandidatesMap(HASH_
                         if (linkedList_size(candidates) == 0) {
                             if (apr_pool_create(&invalid_pool, module_getBundle(targetModule)->memoryPool) == APR_SUCCESS) {
                                 if (linkedList_create(invalid_pool, &invalid) == CELIX_SUCCESS) {
+									char *name = NULL;
                                     resolver_removeInvalidCandidate(targetModule, candidatesMap, invalid);
                                     apr_pool_destroy(invalid_pool);
                                     apr_pool_destroy(candidates_pool);
-                                    char *name = NULL;
+                                    
                                     module_getSymbolicName(targetModule, &name);
 
                                     printf("Unable to resolve: %s, %s\n", name, requirement_getTargetName(req));
@@ -195,9 +201,9 @@ int resolver_populateCandidatesMap(HASH_
 }
 
 void resolver_removeInvalidCandidate(MODULE invalidModule, HASH_MAP candidates, LINKED_LIST invalid) {
-	hashMap_remove(candidates, invalidModule);
-
 	HASH_MAP_ITERATOR iterator;
+	hashMap_remove(candidates, invalidModule);
+	
 	for (iterator = hashMapIterator_create(candidates); hashMapIterator_hasNext(iterator); ) {
 		HASH_MAP_ENTRY entry = hashMapIterator_nextEntry(iterator);
 		MODULE module = (MODULE) hashMapEntry_getKey(entry);
@@ -260,9 +266,9 @@ void resolver_addModule(MODULE module) {
         linkedList_addElement(m_modules, module);
 
         for (i = 0; i < linkedList_size(module_getCapabilities(module)); i++) {
+			char *serviceName = NULL;
             cap = (CAPABILITY) linkedList_get(module_getCapabilities(module), i);
-            char *serviceName = NULL;
-			capability_getServiceName(cap, &serviceName);
+            capability_getServiceName(cap, &serviceName);
             list = resolver_getCapabilityList(m_unresolvedServices, serviceName);
             if (list == NULL) {
                 if (apr_pool_create(&capabilities_pool, module_getBundle(module)->memoryPool) == APR_SUCCESS) {
@@ -281,16 +287,18 @@ void resolver_addModule(MODULE module) {
 }
 
 void resolver_removeModule(MODULE module) {
-    linkedList_removeElement(m_modules, module);
-    LINKED_LIST caps = module_getCapabilities(module);
+    LINKED_LIST caps = NULL;
+	linkedList_removeElement(m_modules, module);
+    caps = module_getCapabilities(module);
     if (caps != NULL)
     {
         int i = 0;
         for (i = 0; i < linkedList_size(caps); i++) {
             CAPABILITY cap = (CAPABILITY) linkedList_get(caps, i);
             char *serviceName = NULL;
+			CAPABILITY_LIST list;
 			capability_getServiceName(cap, &serviceName);
-            CAPABILITY_LIST list = resolver_getCapabilityList(m_unresolvedServices, serviceName);
+            list = resolver_getCapabilityList(m_unresolvedServices, serviceName);
             if (list != NULL) {
                 linkedList_removeElement(list->capabilities, cap);
             }
@@ -311,17 +319,20 @@ void resolver_moduleResolved(MODULE modu
 	if (module_isResolved(module)) {
 	    if (apr_pool_create(&capsCopy_pool, module_getBundle(module)->memoryPool) == APR_SUCCESS) {
 	        if (linkedList_create(capsCopy_pool, &capsCopy) == APR_SUCCESS) {
-                for (capIdx = 0; (module_getCapabilities(module) != NULL) && (capIdx < linkedList_size(module_getCapabilities(module))); capIdx++) {
+                LINKED_LIST wires = NULL;
+
+				for (capIdx = 0; (module_getCapabilities(module) != NULL) && (capIdx < linkedList_size(module_getCapabilities(module))); capIdx++) {
                     CAPABILITY cap = (CAPABILITY) linkedList_get(module_getCapabilities(module), capIdx);
                     char *serviceName = NULL;
+					CAPABILITY_LIST list;
 					capability_getServiceName(cap, &serviceName);
-                    CAPABILITY_LIST list = resolver_getCapabilityList(m_unresolvedServices, serviceName);
+                    list = resolver_getCapabilityList(m_unresolvedServices, serviceName);
                     linkedList_removeElement(list->capabilities, cap);
 
                     linkedList_addElement(capsCopy, cap);
                 }
 
-                LINKED_LIST wires = module_getWires(module);
+                wires = module_getWires(module);
                 for (capIdx = 0; (capsCopy != NULL) && (capIdx < linkedList_size(capsCopy)); capIdx++) {
                     CAPABILITY cap = linkedList_get(capsCopy, capIdx);
 
@@ -342,9 +353,10 @@ void resolver_moduleResolved(MODULE modu
 
                     if (cap != NULL) {
                     	char *serviceName = NULL;
+						CAPABILITY_LIST list;
 						capability_getServiceName(cap, &serviceName);
 
-                        CAPABILITY_LIST list = resolver_getCapabilityList(m_resolvedServices, serviceName);
+                        list = resolver_getCapabilityList(m_resolvedServices, serviceName);
                         if (list == NULL) {
                             if (apr_pool_create(&capabilities_pool, module_getBundle(module)->memoryPool) == APR_SUCCESS) {
                                 list = (CAPABILITY_LIST) apr_palloc(capabilities_pool, sizeof(*list));
@@ -387,19 +399,21 @@ HASH_MAP resolver_populateWireMap(HASH_M
     apr_pool_t *emptyWires_pool;
 
     if (candidates && importer && wireMap) {
-        if (module_isResolved(importer) || (hashMap_get(wireMap, importer))) {
+        LINKED_LIST candSetList = NULL;
+		if (module_isResolved(importer) || (hashMap_get(wireMap, importer))) {
             return wireMap;
         }
 
-        LINKED_LIST candSetList = (LINKED_LIST) hashMap_get(candidates, importer);
+        candSetList = (LINKED_LIST) hashMap_get(candidates, importer);
 
         if (apr_pool_create(&serviceWires_pool, module_getBundle(importer)->memoryPool) == APR_SUCCESS) {
             if (apr_pool_create(&emptyWires_pool, module_getBundle(importer)->memoryPool) == APR_SUCCESS) {
                 if (linkedList_create(serviceWires_pool, &serviceWires) == APR_SUCCESS) {
                     if (linkedList_create(emptyWires_pool, &emptyWires) == APR_SUCCESS) {
-                        hashMap_put(wireMap, importer, emptyWires);
-
                         int candSetIdx = 0;
+						
+						hashMap_put(wireMap, importer, emptyWires);
+                        
                         for (candSetIdx = 0; candSetIdx < linkedList_size(candSetList); candSetIdx++) {
                             CANDIDATE_SET cs = (CANDIDATE_SET) linkedList_get(candSetList, candSetIdx);
 

Modified: incubator/celix/trunk/framework/private/src/service_registration.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/service_registration.c?rev=1220683&r1=1220682&r2=1220683&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/service_registration.c (original)
+++ incubator/celix/trunk/framework/private/src/service_registration.c Mon Dec 19 10:53:52 2011
@@ -49,6 +49,8 @@ SERVICE_REGISTRATION serviceRegistration
 celix_status_t serviceRegistration_createInternal(apr_pool_t *pool, SERVICE_REGISTRY registry, BUNDLE bundle, char * serviceName, long serviceId,
         void * serviceObject, PROPERTIES dictionary, bool isFactory, SERVICE_REGISTRATION *registration) {
     celix_status_t status = CELIX_SUCCESS;
+	char * sId = (char *)malloc(sizeof(serviceId) + 1);
+	SERVICE_REFERENCE reference;
 
     *registration = (SERVICE_REGISTRATION) apr_palloc(pool, sizeof(**registration));
     (*registration)->isServiceFactory = isFactory;
@@ -62,7 +64,7 @@ celix_status_t serviceRegistration_creat
 		dictionary = properties_create();
 	}
 
-	char sId[sizeof(serviceId) + 1];
+	
 	sprintf(sId, "%ld", serviceId);
 	properties_set(dictionary, (char *) SERVICE_ID, sId);
 	properties_set(dictionary, (char *) OBJECTCLASS, serviceName);
@@ -80,8 +82,9 @@ celix_status_t serviceRegistration_creat
 //	serviceReference_create(pool, bundle, *registration, &(*registration)->reference);
 
 	(*registration)->isUnregistering = false;
-	pthread_mutex_init(&(*registration)->mutex, NULL);
+	apr_thread_mutex_create(&(*registration)->mutex, 0, pool);
 
+	free(sId);
 	return CELIX_SUCCESS;
 }
 
@@ -92,31 +95,31 @@ void serviceRegistration_destroy(SERVICE
 	properties_destroy(registration->properties);
 	arrayList_destroy(registration->references);
 
-	pthread_mutex_destroy(&registration->mutex);
+	apr_thread_mutex_destroy(registration->mutex);
 
 //	free(registration);
 }
 
 bool serviceRegistration_isValid(SERVICE_REGISTRATION registration) {
-	return registration->svcObj != NULL;
+	return registration == NULL ? false : registration->svcObj != NULL;
 }
 
 void serviceRegistration_invalidate(SERVICE_REGISTRATION registration) {
-	pthread_mutex_lock(&registration->mutex);
+	apr_thread_mutex_lock(registration->mutex);
 	registration->svcObj = NULL;
-	pthread_mutex_unlock(&registration->mutex);
+	apr_thread_mutex_unlock(registration->mutex);
 }
 
 celix_status_t serviceRegistration_unregister(SERVICE_REGISTRATION registration) {
 	celix_status_t status = CELIX_SUCCESS;
-	pthread_mutex_lock(&registration->mutex);
+	apr_thread_mutex_lock(registration->mutex);
 	if (!serviceRegistration_isValid(registration) || registration->isUnregistering) {
 		printf("Service is already unregistered\n");
 		status = CELIX_ILLEGAL_STATE;
 	} else {
 		registration->isUnregistering = true;
 	}
-	pthread_mutex_unlock(&registration->mutex);
+	apr_thread_mutex_unlock(registration->mutex);
 
 //	BUNDLE bundle = NULL;
 //	status = serviceReference_getBundle(registration->reference, &bundle);

Modified: incubator/celix/trunk/framework/private/src/service_registry.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/service_registry.c?rev=1220683&r1=1220682&r2=1220683&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/service_registry.c (original)
+++ incubator/celix/trunk/framework/private/src/service_registry.c Mon Dec 19 10:53:52 2011
@@ -43,7 +43,7 @@ struct serviceRegistry {
 
 	ARRAY_LIST listenerHooks;
 
-	pthread_mutex_t mutex;
+	apr_thread_mutex_t * mutex;
 };
 
 struct usageCount {
@@ -80,8 +80,8 @@ USAGE_COUNT serviceRegistry_addUsageCoun
 	usage->service = NULL;
 
 	if (usages == NULL) {
-		arrayList_create(bundle->memoryPool, &usages);
 		MODULE mod = NULL;
+		arrayList_create(bundle->memoryPool, &usages);		
 		bundle_getCurrentModule(bundle, &mod);
 	}
 	arrayList_add(usages, usage);
@@ -115,17 +115,16 @@ SERVICE_REGISTRY serviceRegistry_create(
 	if (registry == NULL) {
 	    // no memory
 	} else {
+		apr_status_t mutexattr;
+
         registry->serviceChanged = serviceChanged;
         registry->inUseMap = hashMap_create(NULL, NULL, NULL, NULL);
         registry->serviceRegistrations = hashMap_create(NULL, NULL, NULL, NULL);
         registry->framework = framework;
 
         arrayList_create(framework->mp, &registry->listenerHooks);
+        mutexattr = apr_thread_mutex_create(&registry->mutex, APR_THREAD_MUTEX_NESTED, framework->mp);
 
-        pthread_mutexattr_t mutexattr;
-        pthread_mutexattr_init(&mutexattr);
-        pthread_mutexattr_settype(&mutexattr, PTHREAD_MUTEX_RECURSIVE);
-        pthread_mutex_init(&registry->mutex, &mutexattr);
         registry->currentServiceId = 1l;
 	}
 	return registry;
@@ -135,7 +134,7 @@ celix_status_t serviceRegistry_destroy(S
     hashMap_destroy(registry->inUseMap, false, false);
     hashMap_destroy(registry->serviceRegistrations, false, false);
     arrayList_destroy(registry->listenerHooks);
-    pthread_mutex_destroy(&registry->mutex);
+    apr_thread_mutex_destroy(registry->mutex);
 
     return CELIX_SUCCESS;
 }
@@ -145,8 +144,9 @@ celix_status_t serviceRegistry_getRegist
 
 	ARRAY_LIST regs = (ARRAY_LIST) hashMap_get(registry->serviceRegistrations, bundle);
 	if (regs != NULL) {
-		arrayList_create(pool, services);
 		int i;
+		arrayList_create(pool, services);
+		
 		for (i = 0; i < arrayList_size(regs); i++) {
 			SERVICE_REGISTRATION reg = arrayList_get(regs, i);
 			if (serviceRegistration_isValid(reg)) {
@@ -174,9 +174,11 @@ SERVICE_REGISTRATION serviceRegistry_reg
 }
 
 celix_status_t serviceRegistry_registerServiceInternal(SERVICE_REGISTRY registry, BUNDLE bundle, char * serviceName, void * serviceObject, PROPERTIES dictionary, bool isFactory, SERVICE_REGISTRATION *registration) {
-	pthread_mutex_lock(&registry->mutex);
+	ARRAY_LIST regs;
+	apr_pool_t *pool;
+	apr_thread_mutex_lock(registry->mutex);
 
-	apr_pool_t *pool = bundle->memoryPool;
+	pool = bundle->memoryPool;
 
 	if (isFactory) {
 	    *registration = serviceRegistration_createServiceFactory(pool, registry, bundle, serviceName, ++registry->currentServiceId, serviceObject, dictionary);
@@ -186,7 +188,7 @@ celix_status_t serviceRegistry_registerS
 
 	serviceRegistry_addHooks(registry, serviceName, serviceObject, *registration);
 
-	ARRAY_LIST regs = (ARRAY_LIST) hashMap_get(registry->serviceRegistrations, bundle);
+	regs = (ARRAY_LIST) hashMap_get(registry->serviceRegistrations, bundle);
 	if (regs == NULL) {
 		regs = NULL;
 		arrayList_create(bundle->memoryPool, &regs);
@@ -194,7 +196,7 @@ celix_status_t serviceRegistry_registerS
 	arrayList_add(regs, *registration);
 	hashMap_put(registry->serviceRegistrations, bundle, regs);
 
-	pthread_mutex_unlock(&registry->mutex);
+	apr_thread_mutex_unlock(registry->mutex);
 
 	if (registry->serviceChanged != NULL) {
 //		SERVICE_EVENT event = (SERVICE_EVENT) malloc(sizeof(*event));
@@ -209,26 +211,29 @@ celix_status_t serviceRegistry_registerS
 }
 
 void serviceRegistry_unregisterService(SERVICE_REGISTRY registry, BUNDLE bundle, SERVICE_REGISTRATION registration) {
-	pthread_mutex_lock(&registry->mutex);
+	ARRAY_LIST clients;
+	int i;
+	ARRAY_LIST regs;
+
+	apr_thread_mutex_lock(registry->mutex);
 
 	serviceRegistry_removeHook(registry, registration);
 
-	ARRAY_LIST regs = (ARRAY_LIST) hashMap_get(registry->serviceRegistrations, bundle);
+	regs = (ARRAY_LIST) hashMap_get(registry->serviceRegistrations, bundle);
 	if (regs != NULL) {
 		arrayList_removeElement(regs, registration);
 		hashMap_put(registry->serviceRegistrations, bundle, regs);
 	}
 
-	pthread_mutex_unlock(&registry->mutex);
+	apr_thread_mutex_unlock(registry->mutex);
 
 	if (registry->serviceChanged != NULL) {
 		registry->serviceChanged(registry->framework, UNREGISTERING, registration, NULL);
 	}
 
-	pthread_mutex_lock(&registry->mutex);
+	apr_thread_mutex_lock(registry->mutex);
 	// unget service
 
-	int i;
 	for (i = 0; i < arrayList_size(registration->references); i++) {
 		SERVICE_REFERENCE reference = arrayList_get(registration->references, i);
 		ARRAY_LIST clients = serviceRegistry_getUsingBundles(registry, registry->framework->mp, reference);
@@ -247,17 +252,17 @@ void serviceRegistry_unregisterService(S
 
 	serviceRegistration_destroy(registration);
 
-	pthread_mutex_unlock(&registry->mutex);
+	apr_thread_mutex_unlock(registry->mutex);
 
 }
 
 void serviceRegistry_unregisterServices(SERVICE_REGISTRY registry, BUNDLE bundle) {
 	ARRAY_LIST regs = NULL;
-	pthread_mutex_lock(&registry->mutex);
-	regs = (ARRAY_LIST) hashMap_get(registry->serviceRegistrations, bundle);
-	pthread_mutex_unlock(&registry->mutex);
-
 	int i;
+	apr_thread_mutex_lock(registry->mutex);
+	regs = (ARRAY_LIST) hashMap_get(registry->serviceRegistrations, bundle);
+	apr_thread_mutex_unlock(registry->mutex);
+	
 	for (i = 0; (regs != NULL) && i < arrayList_size(regs); i++) {
 		SERVICE_REGISTRATION reg = arrayList_get(regs, i);
 		if (serviceRegistration_isValid(reg)) {
@@ -271,9 +276,9 @@ void serviceRegistry_unregisterServices(
 		removed = NULL;
 	}
 
-	pthread_mutex_lock(&registry->mutex);
+	apr_thread_mutex_lock(registry->mutex);
 	hashMap_remove(registry->serviceRegistrations, bundle);
-	pthread_mutex_unlock(&registry->mutex);
+	apr_thread_mutex_unlock(registry->mutex);
 }
 
 celix_status_t serviceRegistry_createServiceReference(SERVICE_REGISTRY registry, apr_pool_t *pool, SERVICE_REGISTRATION registration, SERVICE_REFERENCE *reference) {
@@ -293,11 +298,12 @@ celix_status_t serviceRegistry_createSer
 
 celix_status_t serviceRegistry_getServiceReferences(SERVICE_REGISTRY registry, apr_pool_t *pool, const char *serviceName, FILTER filter, ARRAY_LIST *references) {
 	celix_status_t status = CELIX_SUCCESS;
-
+	HASH_MAP_VALUES registrations;
+	HASH_MAP_ITERATOR iterator;
 	arrayList_create(pool, references);
 
-	HASH_MAP_VALUES registrations = hashMapValues_create(registry->serviceRegistrations);
-	HASH_MAP_ITERATOR iterator = hashMapValues_iterator(registrations);
+	registrations = hashMapValues_create(registry->serviceRegistrations);
+	iterator = hashMapValues_iterator(registrations);
 	while (hashMapIterator_hasNext(iterator)) {
 		ARRAY_LIST regs = (ARRAY_LIST) hashMapIterator_nextValue(iterator);
 		int regIdx;
@@ -342,9 +348,10 @@ apr_status_t serviceRegistry_removeRefer
 ARRAY_LIST serviceRegistry_getServicesInUse(SERVICE_REGISTRY registry, BUNDLE bundle) {
 	ARRAY_LIST usages = hashMap_get(registry->inUseMap, bundle);
 	if (usages != NULL) {
+		int i;
 		ARRAY_LIST references = NULL;
 		arrayList_create(bundle->memoryPool, &references);
-		int i;
+		
 		for (i = 0; i < arrayList_size(usages); i++) {
 			USAGE_COUNT usage = arrayList_get(usages, i);
 			arrayList_add(references, usage->reference);
@@ -356,11 +363,11 @@ ARRAY_LIST serviceRegistry_getServicesIn
 
 void * serviceRegistry_getService(SERVICE_REGISTRY registry, BUNDLE bundle, SERVICE_REFERENCE reference) {
 	SERVICE_REGISTRATION registration = NULL;
-	serviceReference_getServiceRegistration(reference, &registration);
 	void * service = NULL;
 	USAGE_COUNT usage = NULL;
-
-	pthread_mutex_lock(&registry->mutex);
+	serviceReference_getServiceRegistration(reference, &registration);
+	
+	apr_thread_mutex_lock(registry->mutex);
 
 	if (serviceRegistration_isValid(registration)) {
 		usage = serviceRegistry_getUsageCount(registry, bundle, reference);
@@ -370,32 +377,32 @@ void * serviceRegistry_getService(SERVIC
 		usage->count++;
 		service = usage->service;
 	}
-	pthread_mutex_unlock(&registry->mutex);
+	apr_thread_mutex_unlock(registry->mutex);
 
 	if ((usage != NULL) && (service == NULL)) {
 		serviceRegistration_getService(registration, bundle, &service);
 	}
-	pthread_mutex_lock(&registry->mutex);
+	apr_thread_mutex_lock(registry->mutex);
 	if ((!serviceRegistration_isValid(registration)) || (service == NULL)) {
 		serviceRegistry_flushUsageCount(registry, bundle, reference);
 	} else {
 		usage->service = service;
 	}
-	pthread_mutex_unlock(&registry->mutex);
+	apr_thread_mutex_unlock(registry->mutex);
 
 	return service;
 }
 
 bool serviceRegistry_ungetService(SERVICE_REGISTRY registry, BUNDLE bundle, SERVICE_REFERENCE reference) {
 	SERVICE_REGISTRATION registration = NULL;
-	serviceReference_getServiceRegistration(reference, &registration);
 	USAGE_COUNT usage = NULL;
-
-	pthread_mutex_lock(&registry->mutex);
+	serviceReference_getServiceRegistration(reference, &registration);
+	
+	apr_thread_mutex_lock(registry->mutex);
 
 	usage = serviceRegistry_getUsageCount(registry, bundle, reference);
 	if (usage == NULL) {
-		pthread_mutex_unlock(&registry->mutex);
+		apr_thread_mutex_unlock(registry->mutex);
 		return false;
 	}
 
@@ -407,24 +414,27 @@ bool serviceRegistry_ungetService(SERVIC
 		serviceRegistry_flushUsageCount(registry, bundle, reference);
 	}
 
-	pthread_mutex_unlock(&registry->mutex);
+	apr_thread_mutex_unlock(registry->mutex);
 
 	return true;
 }
 
 void serviceRegistry_ungetServices(SERVICE_REGISTRY registry, BUNDLE bundle) {
-	pthread_mutex_lock(&registry->mutex);
-	ARRAY_LIST usages = hashMap_get(registry->inUseMap, bundle);
-	pthread_mutex_unlock(&registry->mutex);
+	ARRAY_LIST fusages;
+	ARRAY_LIST usages;
+	int i;
+
+	apr_thread_mutex_lock(registry->mutex);
+	usages = hashMap_get(registry->inUseMap, bundle);
+	apr_thread_mutex_unlock(registry->mutex);
 
 	if (usages == NULL || arrayList_isEmpty(usages)) {
 		return;
 	}
 
 	// usage arrays?
-	ARRAY_LIST fusages = arrayList_clone(bundle->memoryPool, usages);
-
-	int i;
+	fusages = arrayList_clone(bundle->memoryPool, usages);
+	
 	for (i = 0; i < arrayList_size(fusages); i++) {
 		USAGE_COUNT usage = arrayList_get(fusages, i);
 		SERVICE_REFERENCE reference = usage->reference;
@@ -438,10 +448,11 @@ void serviceRegistry_ungetServices(SERVI
 
 ARRAY_LIST serviceRegistry_getUsingBundles(SERVICE_REGISTRY registry, apr_pool_t *pool, SERVICE_REFERENCE reference) {
 	ARRAY_LIST bundles = NULL;
+	HASH_MAP_ITERATOR iter;
 	apr_pool_t *npool;
 	apr_pool_create(&npool, pool);
 	arrayList_create(npool, &bundles);
-	HASH_MAP_ITERATOR iter = hashMapIterator_create(registry->inUseMap);
+	iter = hashMapIterator_create(registry->inUseMap);
 	while (hashMapIterator_hasNext(iter)) {
 		HASH_MAP_ENTRY entry = hashMapIterator_nextEntry(iter);
 		BUNDLE bundle = hashMapEntry_getKey(entry);

Modified: incubator/celix/trunk/framework/private/src/service_tracker.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/service_tracker.c?rev=1220683&r1=1220682&r2=1220683&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/service_tracker.c (original)
+++ incubator/celix/trunk/framework/private/src/service_tracker.c Mon Dec 19 10:53:52 2011
@@ -250,8 +250,8 @@ celix_status_t serviceTracker_track(FW_S
 	int found = -1;
 	unsigned int i;
 	for (i = 0; i < arrayList_size(fwTracker->tracked); i++) {
-		tracked = (TRACKED) arrayList_get(fwTracker->tracked, i);
 		bool equals;
+		tracked = (TRACKED) arrayList_get(fwTracker->tracked, i);
 		serviceReference_equals(reference, tracked->reference, &equals);
 		if (equals) {
 			found = 0;
@@ -299,8 +299,8 @@ celix_status_t serviceTracker_untrack(FW
 	bool result = NULL;
 
 	for (i = 0; i < arrayList_size(fwTracker->tracked); i++) {
-		tracked = (TRACKED) arrayList_get(fwTracker->tracked, i);
 		bool equals;
+		tracked = (TRACKED) arrayList_get(fwTracker->tracked, i);
 		serviceReference_equals(reference, tracked->reference, &equals);
 		if (equals) {
 			if (tracked != NULL) {

Modified: incubator/celix/trunk/framework/private/src/version.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/version.c?rev=1220683&r1=1220682&r2=1220683&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/version.c (original)
+++ incubator/celix/trunk/framework/private/src/version.c Mon Dec 19 10:53:52 2011
@@ -49,6 +49,7 @@ celix_status_t version_createVersion(apr
 	if (!*version) {
 		status = CELIX_ENOMEM;
 	} else {
+		int i;
 		apr_pool_pre_cleanup_register(pool, *version, version_destroy);
 
 		(*version)->pool = pool;
@@ -69,7 +70,7 @@ celix_status_t version_createVersion(apr
 		if (micro < 0) {
 			celix_log("Negative micro");
 		}
-		int i;
+		
 		for (i = 0; i < strlen(qualifier); i++) {
 			char ch = qualifier[i];
 			if (('A' <= ch) && (ch <= 'Z')) {

Modified: incubator/celix/trunk/framework/private/src/version_range.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/version_range.c?rev=1220683&r1=1220682&r2=1220683&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/version_range.c (original)
+++ incubator/celix/trunk/framework/private/src/version_range.c Mon Dec 19 10:53:52 2011
@@ -139,19 +139,21 @@ celix_status_t versionRange_parse(apr_po
 			if (!vlow) {
 				status = CELIX_ENOMEM;
 			} else {
+				int vhighL;
+				char * vhigh;
 				vlow = strncpy(vlow, rangeStr+1, vlowL);
-				int vhighL = strlen(rangeStr+1) - vlowL - 2;
-				char * vhigh = (char *) apr_palloc(spool, sizeof(*vhigh * vhighL));
+				vhighL = strlen(rangeStr+1) - vlowL - 2;
+				vhigh = (char *) apr_palloc(spool, sizeof(*vhigh * vhighL));
 				if (!vhigh) {
 					status = CELIX_ENOMEM;
-				} else {
-					vhigh = strncpy(vhigh, rangeStr+vlowL+2, vhighL);
-
+				} else {					
+					VERSION versionLow = NULL;
 					int rangeL = strlen(rangeStr);
 					char start = rangeStr[0];
 					char end = rangeStr[rangeL-1];
 
-					VERSION versionLow = NULL;
+					vhigh = strncpy(vhigh, rangeStr+vlowL+2, vhighL);
+					
 					status = version_createVersionFromString(pool, vlow, &versionLow);
 					if (status == CELIX_SUCCESS) {
 						VERSION versionHigh = NULL;

Modified: incubator/celix/trunk/utils/private/src/array_list.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/utils/private/src/array_list.c?rev=1220683&r1=1220682&r2=1220683&view=diff
==============================================================================
--- incubator/celix/trunk/utils/private/src/array_list.c (original)
+++ incubator/celix/trunk/utils/private/src/array_list.c Mon Dec 19 10:53:52 2011
@@ -238,12 +238,13 @@ bool arrayList_addAll(ARRAY_LIST list, A
 }
 
 ARRAY_LIST arrayList_clone(apr_pool_t *pool, ARRAY_LIST list) {
+	int i;
 	ARRAY_LIST new = NULL;
 	arrayList_create(pool, &new);
 //	arrayList_ensureCapacity(new, list->size);
 //	memcpy(new->elementData, list->elementData, list->size);
 //	new->size = list->size;
-	int i;
+	
 	for (i = 0; i < arrayList_size(list); i++) {
 		arrayList_add(new, arrayList_get(list, i));
 	}

Modified: incubator/celix/trunk/utils/private/src/linkedlist.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/utils/private/src/linkedlist.c?rev=1220683&r1=1220682&r2=1220683&view=diff
==============================================================================
--- incubator/celix/trunk/utils/private/src/linkedlist.c (original)
+++ incubator/celix/trunk/utils/private/src/linkedlist.c Mon Dec 19 10:53:52 2011
@@ -55,7 +55,8 @@ celix_status_t linkedList_clone(LINKED_L
 
 	status = linkedList_create(pool, clone);
 	if (status == CELIX_SUCCESS) {
-        for (struct linkedListEntry *e = list->header->next; e != list->header; e = e->next) {
+		struct linkedListEntry *e;
+        for (e = list->header->next; e != list->header; e = e->next) {
             linkedList_addElement(*clone, e->element);
         }
 	}

Modified: incubator/celix/trunk/utils/public/include/array_list.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/utils/public/include/array_list.h?rev=1220683&r1=1220682&r2=1220683&view=diff
==============================================================================
--- incubator/celix/trunk/utils/public/include/array_list.h (original)
+++ incubator/celix/trunk/utils/public/include/array_list.h Mon Dec 19 10:53:52 2011
@@ -36,7 +36,7 @@ typedef struct arrayList * ARRAY_LIST;
 
 typedef struct arrayListIterator * ARRAY_LIST_ITERATOR;
 
-celix_status_t arrayList_create(apr_pool_t *pool, ARRAY_LIST *list);
+UTILS_EXPORT celix_status_t arrayList_create(apr_pool_t *pool, ARRAY_LIST *list);
 UTILS_EXPORT void arrayList_destroy(ARRAY_LIST list);
 UTILS_EXPORT void arrayList_trimToSize(ARRAY_LIST list);
 UTILS_EXPORT void arrayList_ensureCapacity(ARRAY_LIST list, int capacity);



Mime
View raw message