You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by ab...@apache.org on 2011/11/07 19:06:39 UTC
svn commit: r1198848 - in /incubator/celix/trunk: ./ dependency_manager/
examples/osgi-in-action/chapter04-correct-listener/private/src/
examples/whiteboard/tracker/ examples/whiteboard/tracker_depman/
framework/private/include/ framework/private/src/ ...
Author: abroekhuis
Date: Mon Nov 7 18:06:38 2011
New Revision: 1198848
URL: http://svn.apache.org/viewvc?rev=1198848&view=rev
Log:
Updated arraylist to use APR pools
Modified:
incubator/celix/trunk/Remote Services Client.launch
incubator/celix/trunk/dependency_manager/dependency_manager.c
incubator/celix/trunk/dependency_manager/service_component.c
incubator/celix/trunk/examples/osgi-in-action/chapter04-correct-listener/private/src/listener_example.c
incubator/celix/trunk/examples/whiteboard/tracker/activator.c
incubator/celix/trunk/examples/whiteboard/tracker_depman/dependency_activator.c
incubator/celix/trunk/framework/private/include/filter.h
incubator/celix/trunk/framework/private/include/service_tracker.h
incubator/celix/trunk/framework/private/src/attribute.c
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/filter.c
incubator/celix/trunk/framework/private/src/framework.c
incubator/celix/trunk/framework/private/src/module.c
incubator/celix/trunk/framework/private/src/service_reference.c
incubator/celix/trunk/framework/private/src/service_registry.c
incubator/celix/trunk/framework/private/src/service_tracker.c
incubator/celix/trunk/launcher/launcher.c
incubator/celix/trunk/log_service/private/src/log.c
incubator/celix/trunk/remote_services/discovery/private/src/discovery.c
incubator/celix/trunk/remote_services/remote_service_admin/private/src/remote_service_admin_impl.c
incubator/celix/trunk/remote_services/topology_manager/private/src/activator.c
incubator/celix/trunk/remote_services/topology_manager/private/src/topology_manager.c
incubator/celix/trunk/shell/inspect_command.c
incubator/celix/trunk/shell/shell.c
incubator/celix/trunk/shell/shell_private.h
incubator/celix/trunk/utils/private/src/array_list.c
incubator/celix/trunk/utils/private/test/array_list_test.c
incubator/celix/trunk/utils/public/include/array_list.h
Modified: incubator/celix/trunk/Remote Services Client.launch
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/Remote%20Services%20Client.launch?rev=1198848&r1=1198847&r2=1198848&view=diff
==============================================================================
--- incubator/celix/trunk/Remote Services Client.launch (original)
+++ incubator/celix/trunk/Remote Services Client.launch Mon Nov 7 18:06:38 2011
@@ -29,7 +29,7 @@
<stringAttribute key="org.eclipse.cdt.launch.DEBUGGER_STOP_AT_MAIN_SYMBOL" value="main"/>
<booleanAttribute key="org.eclipse.cdt.launch.ENABLE_REGISTER_BOOKKEEPING" value="false"/>
<booleanAttribute key="org.eclipse.cdt.launch.ENABLE_VARIABLE_BOOKKEEPING" value="false"/>
-<stringAttribute key="org.eclipse.cdt.launch.FORMAT" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?><contentList><content id="userData-userData-bundleActivator_stop-(cast)" val="log_writer_t"/><content id="userData-fw_startBundle-(cast)" val="DEPENDENCY_ACTIVATOR_BASE"/><content id="userData-data-bundleActivator_start-(cast)" val="log_writer_t"/><content id="userData-*userData-userData-bundleActivator_create-(cast)" val="log_writer_t"/><content id="*userData-userData-bundleActivator_create-(cast)" val="DEPENDENCY_ACTIVATOR_BASE"/><content id="userData-userData-fw_startBundle-(cast)" val="log_writer_t"/><content id="key-hashMapIterator_remove-(cast)" val="char *"/><content id="componentData-bundleActivator_create-(cast)" val=&quo
t;log_writer_t"/><content id="userData-bundleActivator_stop-(cast)" val="DEPENDENCY_ACTIVATOR_BASE"/><content id="value-filter-filter_match-(cast)" val="char *"/></contentList>"/>
+<stringAttribute key="org.eclipse.cdt.launch.FORMAT" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?><contentList><content id="userData-bundleActivator_stop-(cast)" val="DEPENDENCY_ACTIVATOR_BASE"/><content id="userData-userData-bundleActivator_stop-(cast)" val="log_writer_t"/><content id="userData-fw_startBundle-(cast)" val="DEPENDENCY_ACTIVATOR_BASE"/><content id="userData-data-bundleActivator_start-(cast)" val="log_writer_t"/><content id="userData-*userData-userData-bundleActivator_create-(cast)" val="log_writer_t"/><content id="*userData-userData-bundleActivator_create-(cast)" val="DEPENDENCY_ACTIVATOR_BASE"/><content id="userData-userData-fw_startBundle-(cast)" val="log_writer_t"/><content id="key-hashMapIterator_remove-(cast)&qu
ot; val="char *"/><content id="componentData-bundleActivator_create-(cast)" val="log_writer_t"/><content id="value-filter-filter_match-(cast)" val="char *"/></contentList>"/>
<stringAttribute key="org.eclipse.cdt.launch.GLOBAL_VARIABLES" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <globalVariableList/> "/>
<stringAttribute key="org.eclipse.cdt.launch.MEMORY_BLOCKS" value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <memoryBlockExpressionList/> "/>
<stringAttribute key="org.eclipse.cdt.launch.PROGRAM_NAME" value="build/launcher/launcher"/>
Modified: incubator/celix/trunk/dependency_manager/dependency_manager.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/dependency_manager/dependency_manager.c?rev=1198848&r1=1198847&r2=1198848&view=diff
==============================================================================
--- incubator/celix/trunk/dependency_manager/dependency_manager.c (original)
+++ incubator/celix/trunk/dependency_manager/dependency_manager.c Mon Nov 7 18:06:38 2011
@@ -32,8 +32,11 @@
DEPENDENCY_MANAGER dependencyManager_create(BUNDLE_CONTEXT context) {
DEPENDENCY_MANAGER manager = (DEPENDENCY_MANAGER) malloc(sizeof(*manager));
+ apr_pool_t *pool = NULL;
+ bundleContext_getMemoryPool(context, &pool);
manager->context = context;
- manager->services = arrayList_create();
+ manager->services = NULL;
+ arrayList_create(pool, &manager->services);
return manager;
}
Modified: incubator/celix/trunk/dependency_manager/service_component.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/dependency_manager/service_component.c?rev=1198848&r1=1198847&r2=1198848&view=diff
==============================================================================
--- incubator/celix/trunk/dependency_manager/service_component.c (original)
+++ incubator/celix/trunk/dependency_manager/service_component.c Mon Nov 7 18:06:38 2011
@@ -72,7 +72,8 @@ SERVICE serviceComponent_create(BUNDLE_C
service->impl = NULL;
service->serviceName = NULL;
service->serviceRegistration = NULL;
- service->dependencies = arrayList_create();
+ service->dependencies = NULL;
+ arrayList_create(mypool, &service->dependencies);
service->init = service_init;
service->start= service_start;
@@ -81,7 +82,7 @@ SERVICE serviceComponent_create(BUNDLE_C
service->context = context;
service->manager = manager;
- service->state = state_create(arrayList_clone(service->dependencies), false);
+ service->state = state_create(arrayList_clone(mypool, service->dependencies), false);
service->executor = executor_create(mypool);
pthread_mutex_init(&service->mutex, NULL);
@@ -124,8 +125,10 @@ SERVICE serviceComponent_addServiceDepen
serviceDependency_start(dependency, service);
}
+ apr_pool_t *pool = NULL;
+ bundleContext_getMemoryPool(service->context, &pool);
pthread_mutex_lock(&service->mutex);
- new = state_create(arrayList_clone(service->dependencies), !state_isInactive(old));
+ new = state_create(arrayList_clone(pool, service->dependencies), !state_isInactive(old));
service->state = new;
pthread_mutex_unlock(&service->mutex);
serviceComponent_calculateStateChanges(service, old, new);
@@ -145,8 +148,10 @@ SERVICE serviceComponent_removeServiceDe
serviceDependency_stop(dependency, service);
}
+ apr_pool_t *pool = NULL;
+ bundleContext_getMemoryPool(service->context, &pool);
pthread_mutex_lock(&service->mutex);
- new = state_create(arrayList_clone(service->dependencies), !state_isInactive(old));
+ new = state_create(arrayList_clone(pool, service->dependencies), !state_isInactive(old));
service->state = new;
pthread_mutex_unlock(&service->mutex);
serviceComponent_calculateStateChanges(service, old, new);
@@ -158,8 +163,10 @@ SERVICE serviceComponent_removeServiceDe
void serviceComponent_dependencyAvailable(SERVICE service, SERVICE_DEPENDENCY dependency) {
STATE old, new;
pthread_mutex_lock(&service->mutex);
+ apr_pool_t *pool = NULL;
+ bundleContext_getMemoryPool(service->context, &pool);
old = service->state;
- new = state_create(arrayList_clone(service->dependencies), !state_isInactive(old));
+ new = state_create(arrayList_clone(pool, service->dependencies), !state_isInactive(old));
service->state = new;
pthread_mutex_unlock(&service->mutex);
serviceComponent_calculateStateChanges(service, old, new);
@@ -183,9 +190,11 @@ void serviceComponent_dependencyChanged(
void serviceComponent_dependencyUnavailable(SERVICE service, SERVICE_DEPENDENCY dependency) {
STATE old, new;
+ apr_pool_t *pool = NULL;
+ bundleContext_getMemoryPool(service->context, &pool);
pthread_mutex_lock(&service->mutex);
old = service->state;
- new = state_create(arrayList_clone(service->dependencies), !state_isInactive(old));
+ new = state_create(arrayList_clone(pool, service->dependencies), !state_isInactive(old));
service->state = new;
pthread_mutex_unlock(&service->mutex);
serviceComponent_calculateStateChanges(service, old, new);
@@ -199,9 +208,11 @@ void serviceComponent_dependencyUnavaila
void serviceComponent_start(SERVICE service) {
bundleContext_registerService(service->context, SERVICE_COMPONENT_NAME, service, NULL, &service->serviceRegistration);
STATE old, new;
+ apr_pool_t *pool = NULL;
+ bundleContext_getMemoryPool(service->context, &pool);
pthread_mutex_lock(&service->mutex);
old = service->state;
- new = state_create(arrayList_clone(service->dependencies), true);
+ new = state_create(arrayList_clone(pool, service->dependencies), true);
service->state = new;
pthread_mutex_unlock(&service->mutex);
serviceComponent_calculateStateChanges(service, old, new);
@@ -210,9 +221,11 @@ void serviceComponent_start(SERVICE serv
void serviceComponent_stop(SERVICE service) {
STATE old, new;
+ apr_pool_t *pool = NULL;
+ bundleContext_getMemoryPool(service->context, &pool);
pthread_mutex_lock(&service->mutex);
old = service->state;
- new = state_create(arrayList_clone(service->dependencies), false);
+ new = state_create(arrayList_clone(pool, service->dependencies), false);
service->state = new;
pthread_mutex_unlock(&service->mutex);
serviceComponent_calculateStateChanges(service, old, new);
@@ -252,7 +265,9 @@ void serviceComponent_deactivateService(
}
void serviceComponent_startTrackingOptional(SERVICE service, STATE state) {
- ARRAY_LIST deps = arrayList_clone(state->dependencies);
+ apr_pool_t *pool = NULL;
+ bundleContext_getMemoryPool(service->context, &pool);
+ ARRAY_LIST deps = arrayList_clone(pool, state->dependencies);
ARRAY_LIST_ITERATOR i = arrayListIterator_create(deps);
while (arrayListIterator_hasNext(i)) {
SERVICE_DEPENDENCY dependency = (SERVICE_DEPENDENCY) arrayListIterator_next(i);
@@ -265,7 +280,9 @@ void serviceComponent_startTrackingOptio
}
void serviceComponent_stopTrackingOptional(SERVICE service, STATE state) {
- ARRAY_LIST deps = arrayList_clone(state->dependencies);
+ apr_pool_t *pool = NULL;
+ bundleContext_getMemoryPool(service->context, &pool);
+ ARRAY_LIST deps = arrayList_clone(pool, state->dependencies);
ARRAY_LIST_ITERATOR i = arrayListIterator_create(deps);
while (arrayListIterator_hasNext(i)) {
SERVICE_DEPENDENCY dependency = (SERVICE_DEPENDENCY) arrayListIterator_next(i);
@@ -279,7 +296,9 @@ void serviceComponent_stopTrackingOption
void serviceComponent_startTrackingRequired(SERVICE service, void * arg) {
STATE state = (STATE) arg;
- ARRAY_LIST deps = arrayList_clone(state->dependencies);
+ apr_pool_t *pool = NULL;
+ bundleContext_getMemoryPool(service->context, &pool);
+ ARRAY_LIST deps = arrayList_clone(pool, state->dependencies);
ARRAY_LIST_ITERATOR i = arrayListIterator_create(deps);
while (arrayListIterator_hasNext(i)) {
SERVICE_DEPENDENCY dependency = (SERVICE_DEPENDENCY) arrayListIterator_next(i);
@@ -293,7 +312,9 @@ void serviceComponent_startTrackingRequi
void serviceComponent_stopTrackingRequired(SERVICE service, void * arg) {
STATE state = (STATE) arg;
- ARRAY_LIST deps = arrayList_clone(state->dependencies);
+ apr_pool_t *pool = NULL;
+ bundleContext_getMemoryPool(service->context, &pool);
+ ARRAY_LIST deps = arrayList_clone(pool, state->dependencies);
ARRAY_LIST_ITERATOR i = arrayListIterator_create(deps);
while (arrayListIterator_hasNext(i)) {
SERVICE_DEPENDENCY dependency = (SERVICE_DEPENDENCY) arrayListIterator_next(i);
Modified: incubator/celix/trunk/examples/osgi-in-action/chapter04-correct-listener/private/src/listener_example.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/examples/osgi-in-action/chapter04-correct-listener/private/src/listener_example.c?rev=1198848&r1=1198847&r2=1198848&view=diff
==============================================================================
--- incubator/celix/trunk/examples/osgi-in-action/chapter04-correct-listener/private/src/listener_example.c (original)
+++ incubator/celix/trunk/examples/osgi-in-action/chapter04-correct-listener/private/src/listener_example.c Mon Nov 7 18:06:38 2011
@@ -49,7 +49,8 @@ celix_status_t bundleActivator_create(BU
activator->context = context;
activator->listener = NULL;
apr_thread_mutex_create(&activator->logServiceReferencesLock, 0, subpool);
- activator->logServiceReferences = arrayList_create();
+ activator->logServiceReferences = NULL;
+ arrayList_create(subpool, &activator->logServiceReferences);
activator->running = false;
activator->logger = NULL;
}
Modified: incubator/celix/trunk/examples/whiteboard/tracker/activator.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/examples/whiteboard/tracker/activator.c?rev=1198848&r1=1198847&r2=1198848&view=diff
==============================================================================
--- incubator/celix/trunk/examples/whiteboard/tracker/activator.c (original)
+++ incubator/celix/trunk/examples/whiteboard/tracker/activator.c Mon Nov 7 18:06:38 2011
@@ -88,7 +88,8 @@ celix_status_t bundleActivator_create(BU
celix_status_t status = bundleContext_getMemoryPool(context, &pool);
if (status == CELIX_SUCCESS) {
*userData = apr_palloc(pool, sizeof(struct data));
- ((struct data *) (*userData))->publishers = arrayList_create();
+ ((struct data *) (*userData))->publishers = NULL;
+ arrayList_create(pool, &((struct data *) (*userData))->publishers);
} else {
status = CELIX_START_ERROR;
}
Modified: incubator/celix/trunk/examples/whiteboard/tracker_depman/dependency_activator.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/examples/whiteboard/tracker_depman/dependency_activator.c?rev=1198848&r1=1198847&r2=1198848&view=diff
==============================================================================
--- incubator/celix/trunk/examples/whiteboard/tracker_depman/dependency_activator.c (original)
+++ incubator/celix/trunk/examples/whiteboard/tracker_depman/dependency_activator.c Mon Nov 7 18:06:38 2011
@@ -33,10 +33,14 @@
#include "publisher.h"
#include "tracker.h"
#include "log_service.h"
+#include "bundle_context.h"
void * dm_create(BUNDLE_CONTEXT context) {
struct data * data = malloc(sizeof(*data));
- data->publishers = arrayList_create();
+ apr_pool_t *pool = NULL;
+ bundleContext_getMemoryPool(context, &pool);
+ data->publishers = NULL;
+ arrayList_create(pool, &data->publishers);
data->context = NULL;
data->running = false;
data->sender = NULL;
Modified: incubator/celix/trunk/framework/private/include/filter.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/include/filter.h?rev=1198848&r1=1198847&r2=1198848&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/include/filter.h (original)
+++ incubator/celix/trunk/framework/private/include/filter.h Mon Nov 7 18:06:38 2011
@@ -28,7 +28,7 @@
typedef struct filter * FILTER;
-FILTER filter_create(char * filterString);
+FILTER filter_create(char * filterString, apr_pool_t *pool);
void filter_destroy(FILTER filter);
int filter_match(FILTER filter, PROPERTIES properties);
Modified: incubator/celix/trunk/framework/private/include/service_tracker.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/include/service_tracker.h?rev=1198848&r1=1198847&r2=1198848&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/include/service_tracker.h (original)
+++ incubator/celix/trunk/framework/private/include/service_tracker.h Mon Nov 7 18:06:38 2011
@@ -29,6 +29,7 @@
#include "headers.h"
struct fwServiceTracker {
+ apr_pool_t *pool;
SERVICE_TRACKER tracker;
SERVICE_TRACKER_CUSTOMIZER customizer;
SERVICE_LISTENER listener;
Modified: incubator/celix/trunk/framework/private/src/attribute.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/attribute.c?rev=1198848&r1=1198847&r2=1198848&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/attribute.c (original)
+++ incubator/celix/trunk/framework/private/src/attribute.c Mon Nov 7 18:06:38 2011
@@ -30,14 +30,18 @@
celix_status_t attribute_create(char * key, char * value, apr_pool_t *memory_pool, ATTRIBUTE *attribute) {
celix_status_t status = CELIX_SUCCESS;
- ATTRIBUTE attr = apr_palloc(memory_pool, sizeof(*attr));
- if (!attr) {
- status = CELIX_ENOMEM;
+ if (key == NULL || value == NULL || memory_pool == NULL || *attribute != NULL) {
+ status = CELIX_ILLEGAL_ARGUMENT;
} else {
- attr->key = key;
- attr->value = value;
+ ATTRIBUTE attr = apr_palloc(memory_pool, sizeof(*attr));
+ if (!attr) {
+ status = CELIX_ENOMEM;
+ } else {
+ attr->key = key;
+ attr->value = value;
- *attribute = attr;
+ *attribute = attr;
+ }
}
return status;
Modified: incubator/celix/trunk/framework/private/src/bundle.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/bundle.c?rev=1198848&r1=1198847&r2=1198848&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/bundle.c (original)
+++ incubator/celix/trunk/framework/private/src/bundle.c Mon Nov 7 18:06:38 2011
@@ -57,7 +57,8 @@ celix_status_t bundle_create(BUNDLE * bu
(*bundle)->context = NULL;
(*bundle)->framework = NULL;
(*bundle)->state = BUNDLE_INSTALLED;
- (*bundle)->modules = arrayList_create();
+ (*bundle)->modules = NULL;
+ arrayList_create(mp, &(*bundle)->modules);
MODULE module = module_createFrameworkModule((*bundle));
bundle_addModule(*bundle, module);
@@ -92,7 +93,8 @@ celix_status_t bundle_createFromArchive(
(*bundle)->context = NULL;
(*bundle)->framework = framework;
(*bundle)->state = BUNDLE_INSTALLED;
- (*bundle)->modules = arrayList_create();
+ (*bundle)->modules = NULL;
+ arrayList_create(bundlePool, &(*bundle)->modules);
MODULE module;
status = bundle_createModule(*bundle, &module);
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=1198848&r1=1198847&r2=1198848&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/bundle_archive.c (original)
+++ incubator/celix/trunk/framework/private/src/bundle_archive.c Mon Nov 7 18:06:38 2011
@@ -55,7 +55,7 @@ celix_status_t bundleArchive_createSyste
BUNDLE_ARCHIVE archive;
apr_pool_t *revisions_pool;
- if (!mp || *bundle_archive) {
+ if (mp == NULL || *bundle_archive != NULL) {
status = CELIX_ILLEGAL_ARGUMENT;
} else {
archive = (BUNDLE_ARCHIVE) apr_palloc(mp, sizeof(*archive));
@@ -101,57 +101,66 @@ celix_status_t bundleArchive_readLastMod
celix_status_t bundleArchive_writeLastModified(BUNDLE_ARCHIVE archive);
celix_status_t bundleArchive_create(char * archiveRoot, long id, char * location, apr_pool_t *mp, BUNDLE_ARCHIVE *bundle_archive) {
+ celix_status_t status = CELIX_SUCCESS;
apr_pool_t *revisions_pool;
- celix_status_t status;
BUNDLE_ARCHIVE archive;
- status = CELIX_SUCCESS;
- archive = (BUNDLE_ARCHIVE) apr_pcalloc(mp, sizeof(*archive));
- if (archive != NULL) {
- if (apr_pool_create(&revisions_pool, mp) == APR_SUCCESS) {
- if (linkedList_create(revisions_pool, &archive->revisions) == CELIX_SUCCESS) {
- archive->id = id;
- archive->location = location;
- archive->archiveRootDir = NULL;
- archive->archiveRoot = archiveRoot;
- archive->refreshCount = -1;
- time(&archive->lastModified);
+ if (*bundle_archive != NULL) {
+ status = CELIX_ILLEGAL_ARGUMENT;
+ } else {
+ archive = (BUNDLE_ARCHIVE) apr_pcalloc(mp, sizeof(*archive));
+ if (archive != NULL) {
+ if (apr_pool_create(&revisions_pool, mp) == APR_SUCCESS) {
+ if (linkedList_create(revisions_pool, &archive->revisions) == CELIX_SUCCESS) {
+ archive->id = id;
+ archive->location = location;
+ archive->archiveRootDir = NULL;
+ archive->archiveRoot = archiveRoot;
+ archive->refreshCount = -1;
+ time(&archive->lastModified);
- archive->mp = mp;
+ archive->mp = mp;
- bundleArchive_initialize(archive);
+ bundleArchive_initialize(archive);
- bundleArchive_revise(archive, location, NULL);
+ bundleArchive_revise(archive, location, NULL);
- *bundle_archive = archive;
- } else {
- apr_pool_destroy(revisions_pool);
- status = CELIX_ENOMEM;
- }
- }
- } else {
- status = CELIX_ENOMEM;
+ *bundle_archive = archive;
+ } else {
+ apr_pool_destroy(revisions_pool);
+ status = CELIX_ENOMEM;
+ }
+ }
+ } else {
+ status = CELIX_ENOMEM;
+
+ }
}
return status;
}
celix_status_t bundleArchive_destroy(BUNDLE_ARCHIVE archive) {
- if (archive->archiveRootDir != NULL) {
- // closedir(archive->archiveRootDir);
- apr_dir_close(archive->archiveRootDir);
- }
- if (archive->revisions != NULL) {
- LINKED_LIST_ITERATOR iter = linkedListIterator_create(archive->revisions, 0);
- while (linkedListIterator_hasNext(iter)) {
- BUNDLE_REVISION revision = linkedListIterator_next(iter);
- bundleRevision_destroy(revision);
+ celix_status_t status = CELIX_SUCCESS;
+
+ if (archive == NULL) {
+ status = CELIX_ILLEGAL_ARGUMENT;
+ } else {
+ if (archive->archiveRootDir != NULL) {
+ apr_dir_close(archive->archiveRootDir);
+ }
+ if (archive->revisions != NULL) {
+ LINKED_LIST_ITERATOR iter = linkedListIterator_create(archive->revisions, 0);
+ while (linkedListIterator_hasNext(iter)) {
+ BUNDLE_REVISION revision = linkedListIterator_next(iter);
+ bundleRevision_destroy(revision);
+ }
+ linkedListIterator_destroy(iter);
}
- linkedListIterator_destroy(iter);
}
archive = NULL;
- return CELIX_SUCCESS;
+ return status;
}
celix_status_t bundleArchive_recreate(char * archiveRoot, apr_pool_t *mp, BUNDLE_ARCHIVE *bundle_archive) {
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=1198848&r1=1198847&r2=1198848&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/bundle_cache.c (original)
+++ incubator/celix/trunk/framework/private/src/bundle_cache.c Mon Nov 7 18:06:38 2011
@@ -121,7 +121,8 @@ celix_status_t bundleCache_getArchives(B
}
if (status == APR_SUCCESS) {
- ARRAY_LIST list = arrayList_create();
+ ARRAY_LIST list = NULL;
+ 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];
Modified: incubator/celix/trunk/framework/private/src/filter.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/filter.c?rev=1198848&r1=1198847&r2=1198848&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/filter.c (original)
+++ incubator/celix/trunk/framework/private/src/filter.c Mon Nov 7 18:06:38 2011
@@ -52,15 +52,15 @@ struct filter {
};
void filter_skipWhiteSpace(char * filterString, int * pos);
-FILTER filter_parseFilter(char * filterString, int * pos);
-FILTER filter_parseFilterComp(char * filterString, int * pos);
-FILTER filter_parseAnd(char * filterString, int * pos);
-FILTER filter_parseOr(char * filterString, int * pos);
-FILTER filter_parseNot(char * filterString, int * pos);
-FILTER filter_parseItem(char * filterString, int * pos);
+FILTER filter_parseFilter(char * filterString, int * pos, apr_pool_t *pool);
+FILTER filter_parseFilterComp(char * filterString, int * pos, apr_pool_t *pool);
+FILTER filter_parseAnd(char * filterString, int * pos, apr_pool_t *pool);
+FILTER filter_parseOr(char * filterString, int * pos, apr_pool_t *pool);
+FILTER filter_parseNot(char * filterString, int * pos, apr_pool_t *pool);
+FILTER filter_parseItem(char * filterString, int * pos, apr_pool_t *pool);
char * filter_parseAttr(char * filterString, int * pos);
char * filter_parseValue(char * filterString, int * pos);
-ARRAY_LIST filter_parseSubstring(char * filterString, int * pos);
+ARRAY_LIST filter_parseSubstring(char * filterString, int * pos, apr_pool_t *pool);
int filter_compare(OPERAND operand, char * string, void * value2);
int filter_compareString(OPERAND operand, char * string, void * value2);
@@ -72,10 +72,10 @@ void filter_skipWhiteSpace(char * filter
}
}
-FILTER filter_create(char * filterString) {
+FILTER filter_create(char * filterString, apr_pool_t *pool) {
FILTER filter = NULL;
int pos = 0;
- filter = filter_parseFilter(filterString, &pos);
+ filter = filter_parseFilter(filterString, &pos, pool);
if (pos != strlen(filterString)) {
printf("Error: Extraneous trailing characters\n");
return NULL;
@@ -101,7 +101,7 @@ void filter_destroy(FILTER filter) {
}
}
-FILTER filter_parseFilter(char * filterString, int * pos) {
+FILTER filter_parseFilter(char * filterString, int * pos, apr_pool_t *pool) {
FILTER filter;
filter_skipWhiteSpace(filterString, pos);
if (filterString[*pos] != '(') {
@@ -110,7 +110,7 @@ FILTER filter_parseFilter(char * filterS
}
(*pos)++;
- filter = filter_parseFilterComp(filterString, pos);
+ filter = filter_parseFilterComp(filterString, pos, pool);
filter_skipWhiteSpace(filterString, pos);
@@ -124,7 +124,7 @@ FILTER filter_parseFilter(char * filterS
return filter;
}
-FILTER filter_parseFilterComp(char * filterString, int * pos) {
+FILTER filter_parseFilterComp(char * filterString, int * pos, apr_pool_t *pool) {
filter_skipWhiteSpace(filterString, pos);
char c = filterString[*pos];
@@ -132,23 +132,24 @@ FILTER filter_parseFilterComp(char * fil
switch (c) {
case '&': {
(*pos)++;
- return filter_parseAnd(filterString, pos);
+ return filter_parseAnd(filterString, pos, pool);
}
case '|': {
(*pos)++;
- return filter_parseOr(filterString, pos);
+ return filter_parseOr(filterString, pos, pool);
}
case '!': {
(*pos)++;
- return filter_parseNot(filterString, pos);
+ return filter_parseNot(filterString, pos, pool);
}
}
- return filter_parseItem(filterString, pos);
+ return filter_parseItem(filterString, pos, pool);
}
-FILTER filter_parseAnd(char * filterString, int * pos) {
+FILTER filter_parseAnd(char * filterString, int * pos, apr_pool_t *pool) {
FILTER filter = (FILTER) malloc(sizeof(*filter));
- ARRAY_LIST operands = arrayList_create();
+ ARRAY_LIST operands = NULL;
+ arrayList_create(pool, &operands);
filter_skipWhiteSpace(filterString, pos);
if (filterString[*pos] != '(') {
@@ -157,7 +158,7 @@ FILTER filter_parseAnd(char * filterStri
}
while(filterString[*pos] == '(') {
- FILTER child = filter_parseFilter(filterString, pos);
+ FILTER child = filter_parseFilter(filterString, pos, pool);
arrayList_add(operands, child);
}
@@ -168,9 +169,10 @@ FILTER filter_parseAnd(char * filterStri
return filter;
}
-FILTER filter_parseOr(char * filterString, int * pos) {
+FILTER filter_parseOr(char * filterString, int * pos, apr_pool_t *pool) {
FILTER filter = (FILTER) malloc(sizeof(*filter));
- ARRAY_LIST operands = arrayList_create();
+ ARRAY_LIST operands = NULL;
+ arrayList_create(pool, &operands);
filter_skipWhiteSpace(filterString, pos);
if (filterString[*pos] != '(') {
@@ -179,7 +181,7 @@ FILTER filter_parseOr(char * filterStrin
}
while(filterString[*pos] == '(') {
- FILTER child = filter_parseFilter(filterString, pos);
+ FILTER child = filter_parseFilter(filterString, pos, pool);
arrayList_add(operands, child);
}
@@ -190,7 +192,7 @@ FILTER filter_parseOr(char * filterStrin
return filter;
}
-FILTER filter_parseNot(char * filterString, int * pos) {
+FILTER filter_parseNot(char * filterString, int * pos, apr_pool_t *pool) {
FILTER filter = (FILTER) malloc(sizeof(*filter));
filter_skipWhiteSpace(filterString, pos);
@@ -199,7 +201,7 @@ FILTER filter_parseNot(char * filterStri
return NULL;
}
- FILTER child = filter_parseFilter(filterString, pos);
+ FILTER child = filter_parseFilter(filterString, pos, pool);
filter->operand = NOT;
filter->attribute = NULL;
@@ -208,7 +210,7 @@ FILTER filter_parseNot(char * filterStri
return filter;
}
-FILTER filter_parseItem(char * filterString, int * pos) {
+FILTER filter_parseItem(char * filterString, int * pos, apr_pool_t *pool) {
char * attr = filter_parseAttr(filterString, pos);
filter_skipWhiteSpace(filterString, pos);
switch(filterString[*pos]) {
@@ -263,7 +265,7 @@ FILTER filter_parseItem(char * filterStr
FILTER filter = (FILTER) malloc(sizeof(*filter));
ARRAY_LIST subs;
(*pos)++;
- subs = filter_parseSubstring(filterString, pos);
+ subs = filter_parseSubstring(filterString, pos, pool);
if (arrayList_size(subs) == 1) {
char * string = (char *) arrayList_get(subs, 0);
if (string != NULL) {
@@ -357,9 +359,10 @@ char * filter_parseValue(char * filterSt
return value;
}
-ARRAY_LIST filter_parseSubstring(char * filterString, int * pos) {
+ARRAY_LIST filter_parseSubstring(char * filterString, int * pos, apr_pool_t *pool) {
char * sub = (char *) malloc(strlen(filterString));
- ARRAY_LIST operands = arrayList_create();
+ ARRAY_LIST operands = NULL;
+ arrayList_create(pool, &operands);
int keepRunning = 1;
sub[0] = '\0';
while (keepRunning) {
Modified: incubator/celix/trunk/framework/private/src/framework.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/framework.c?rev=1198848&r1=1198847&r2=1198848&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/framework.c (original)
+++ incubator/celix/trunk/framework/private/src/framework.c Mon Nov 7 18:06:38 2011
@@ -147,7 +147,8 @@ celix_status_t framework_create(FRAMEWOR
(*framework)->interrupted = false;
(*framework)->shutdown = false;
- (*framework)->globalLockWaitersList = arrayList_create();
+ (*framework)->globalLockWaitersList = NULL;
+ arrayList_create((*framework)->mp, &(*framework)->globalLockWaitersList);
(*framework)->globalLockCount = 0;
(*framework)->globalLockThread = NULL;
(*framework)->nextBundleId = 1l;
@@ -333,7 +334,8 @@ celix_status_t fw_init(FRAMEWORK framewo
start(userData, context);
}
- framework->serviceListeners = arrayList_create();
+ framework->serviceListeners = NULL;
+ arrayList_create(framework->mp, &framework->serviceListeners);
framework_releaseBundleLock(framework, framework->bundle);
status = CELIX_SUCCESS;
@@ -935,7 +937,7 @@ celix_status_t fw_getDependentBundles(FR
celix_status_t status = CELIX_SUCCESS;
if (*list == NULL && exporter != NULL && framework != NULL) {
- *list = arrayList_create();
+ arrayList_create(exporter->memoryPool, list);
ARRAY_LIST modules = bundle_getModules(exporter);
int modIdx = 0;
@@ -996,7 +998,8 @@ celix_status_t fw_registerService(FRAMEW
// If this is a listener hook, invoke the callback with all current listeners
if (strcmp(serviceName, listener_hook_service_name) == 0) {
- ARRAY_LIST infos = arrayList_create();
+ ARRAY_LIST infos = NULL;
+ arrayList_create(bundle->memoryPool, &infos);
int i;
for (i = 0; i > arrayList_size(framework->serviceListeners); i++) {
FW_SERVICE_LISTENER listener = arrayList_get(framework->serviceListeners, i);
@@ -1045,7 +1048,7 @@ celix_status_t fw_registerServiceFactory
celix_status_t fw_getServiceReferences(FRAMEWORK framework, ARRAY_LIST *references, BUNDLE bundle ATTRIBUTE_UNUSED, const char * serviceName, char * sfilter) {
FILTER filter = NULL;
if (sfilter != NULL) {
- filter = filter_create(sfilter);
+ filter = filter_create(sfilter, bundle->memoryPool);
}
*references = serviceRegistry_getServiceReferences(framework->registry, serviceName, filter);
@@ -1093,7 +1096,7 @@ void fw_addServiceListener(FRAMEWORK fra
FW_SERVICE_LISTENER fwListener = (FW_SERVICE_LISTENER) malloc(sizeof(*fwListener));
fwListener->bundle = bundle;
if (sfilter != NULL) {
- FILTER filter = filter_create(sfilter);
+ FILTER filter = filter_create(sfilter, bundle->memoryPool);
fwListener->filter = filter;
} else {
fwListener->filter = NULL;
@@ -1113,7 +1116,8 @@ void fw_addServiceListener(FRAMEWORK fra
for (i = 0; i < arrayList_size(listenerHooks); i++) {
SERVICE_REFERENCE ref = arrayList_get(listenerHooks, i);
listener_hook_service_t hook = fw_getService(framework, framework->bundle, ref);
- ARRAY_LIST infos = arrayList_create();
+ ARRAY_LIST infos = NULL;
+ arrayList_create(bundle->memoryPool, &infos);
arrayList_add(infos, info);
hook->added(hook->handle, infos);
serviceRegistry_ungetService(framework->registry, framework->bundle, ref);
@@ -1157,7 +1161,8 @@ void fw_removeServiceListener(FRAMEWORK
for (i = 0; i < arrayList_size(listenerHooks); i++) {
SERVICE_REFERENCE ref = arrayList_get(listenerHooks, i);
listener_hook_service_t hook = fw_getService(framework, framework->bundle, ref);
- ARRAY_LIST infos = arrayList_create();
+ ARRAY_LIST infos = NULL;
+ arrayList_create(bundle->memoryPool, &infos);
arrayList_add(infos, info);
hook->removed(hook->handle, infos);
serviceRegistry_ungetService(framework->registry, framework->bundle, ref);
@@ -1277,7 +1282,8 @@ celix_status_t framework_markBundleResol
}
ARRAY_LIST framework_getBundles(FRAMEWORK framework) {
- ARRAY_LIST bundles = arrayList_create();
+ ARRAY_LIST bundles = NULL;
+ arrayList_create(framework->mp, &bundles);
HASH_MAP_ITERATOR iterator = hashMapIterator_create(framework->installedBundleMap);
while (hashMapIterator_hasNext(iterator)) {
BUNDLE bundle = hashMapIterator_nextValue(iterator);
Modified: incubator/celix/trunk/framework/private/src/module.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/module.c?rev=1198848&r1=1198847&r2=1198848&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/module.c (original)
+++ incubator/celix/trunk/framework/private/src/module.c Mon Nov 7 18:06:38 2011
@@ -65,7 +65,8 @@ MODULE module_create(MANIFEST headerMap,
module->bundle = bundle;
module->resolved = false;
- module->dependentImporters = arrayList_create();
+ module->dependentImporters = NULL;
+ arrayList_create(bundle->memoryPool, &module->dependentImporters);
if (apr_pool_create(&pool, bundle->memoryPool) == APR_SUCCESS) {
if (manifestParser_create(module, headerMap, pool, &mp) == CELIX_SUCCESS) {
@@ -99,7 +100,8 @@ MODULE module_createFrameworkModule(BUND
module->version = version_createVersion(1, 0, 0, "");
linkedList_create(capabilities_pool, &module->capabilities);
linkedList_create(requirements_pool, &module->requirements);
- module->dependentImporters = arrayList_create();
+ module->dependentImporters = NULL;
+ arrayList_create(bundle->memoryPool, &module->dependentImporters);
module->wires = NULL;
module->headerMap = NULL;
module->resolved = false;
@@ -227,7 +229,8 @@ void module_removeDependentImporter(MODU
}
ARRAY_LIST module_getDependents(MODULE module) {
- ARRAY_LIST dependents = arrayList_create();
+ ARRAY_LIST dependents = NULL;
+ arrayList_create(module->bundle->memoryPool, &dependents);
arrayList_addAll(dependents, module->dependentImporters);
Modified: incubator/celix/trunk/framework/private/src/service_reference.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/service_reference.c?rev=1198848&r1=1198847&r2=1198848&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/service_reference.c (original)
+++ incubator/celix/trunk/framework/private/src/service_reference.c Mon Nov 7 18:06:38 2011
@@ -35,11 +35,6 @@ bool serviceReference_isAssignableTo(SER
if (requester == provider) {
return allow;
}
-<<<<<<< HEAD
-
-=======
-//
->>>>>>> Added initial remote services bundles
// WIRE providerWire = module_getWire(bundle_getCurrentModule(provider), serviceName);
// WIRE requesterWire = module_getWire(bundle_getCurrentModule(requester), serviceName);
//
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=1198848&r1=1198847&r2=1198848&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/service_registry.c (original)
+++ incubator/celix/trunk/framework/private/src/service_registry.c Mon Nov 7 18:06:38 2011
@@ -76,7 +76,7 @@ USAGE_COUNT serviceRegistry_addUsageCoun
usage->service = NULL;
if (usages == NULL) {
- usages = arrayList_create();
+ arrayList_create(bundle->memoryPool, &usages);
MODULE mod = NULL;
bundle_getCurrentModule(bundle, &mod);
}
@@ -116,7 +116,7 @@ SERVICE_REGISTRY serviceRegistry_create(
registry->serviceRegistrations = hashMap_create(NULL, NULL, NULL, NULL);
registry->framework = framework;
- registry->listenerHooks = arrayList_create();
+ arrayList_create(framework->mp, ®istry->listenerHooks);
pthread_mutexattr_t mutexattr;
pthread_mutexattr_init(&mutexattr);
@@ -138,7 +138,8 @@ celix_status_t serviceRegistry_destroy(S
ARRAY_LIST serviceRegistry_getRegisteredServices(SERVICE_REGISTRY registry, BUNDLE bundle) {
ARRAY_LIST regs = (ARRAY_LIST) hashMap_get(registry->serviceRegistrations, bundle);
if (regs != NULL) {
- ARRAY_LIST refs = arrayList_create();
+ ARRAY_LIST refs = NULL;
+ arrayList_create(bundle->memoryPool, &refs);
int i;
for (i = 0; i < arrayList_size(regs); i++) {
SERVICE_REGISTRATION reg = arrayList_get(regs, i);
@@ -176,7 +177,8 @@ celix_status_t serviceRegistry_registerS
ARRAY_LIST regs = (ARRAY_LIST) hashMap_get(registry->serviceRegistrations, bundle);
if (regs == NULL) {
- regs = arrayList_create();
+ regs = NULL;
+ arrayList_create(bundle->memoryPool, ®s);
}
arrayList_add(regs, *registration);
hashMap_put(registry->serviceRegistrations, bundle, regs);
@@ -262,7 +264,8 @@ void serviceRegistry_unregisterServices(
}
ARRAY_LIST serviceRegistry_getServiceReferences(SERVICE_REGISTRY registry, const char * serviceName, FILTER filter) {
- ARRAY_LIST references = arrayList_create();
+ ARRAY_LIST references = NULL;
+ arrayList_create(registry->framework->mp, &references);
HASH_MAP_VALUES registrations = hashMapValues_create(registry->serviceRegistrations);
HASH_MAP_ITERATOR iterator = hashMapValues_iterator(registrations);
@@ -296,7 +299,8 @@ ARRAY_LIST serviceRegistry_getServiceRef
ARRAY_LIST serviceRegistry_getServicesInUse(SERVICE_REGISTRY registry, BUNDLE bundle) {
ARRAY_LIST usages = hashMap_get(registry->inUseMap, bundle);
if (usages != NULL) {
- ARRAY_LIST references = arrayList_create();
+ 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);
@@ -373,7 +377,7 @@ void serviceRegistry_ungetServices(SERVI
}
// usage arrays?
- ARRAY_LIST fusages = arrayList_clone(usages);
+ ARRAY_LIST fusages = arrayList_clone(bundle->memoryPool, usages);
int i;
for (i = 0; i < arrayList_size(fusages); i++) {
@@ -388,7 +392,8 @@ void serviceRegistry_ungetServices(SERVI
}
ARRAY_LIST serviceRegistry_getUsingBundles(SERVICE_REGISTRY registry, SERVICE_REFERENCE reference) {
- ARRAY_LIST bundles = arrayList_create();
+ ARRAY_LIST bundles = NULL;
+ arrayList_create(registry->framework->mp, &bundles);
HASH_MAP_ITERATOR iter = hashMapIterator_create(registry->inUseMap);
while (hashMapIterator_hasNext(iter)) {
HASH_MAP_ENTRY entry = hashMapIterator_nextEntry(iter);
@@ -433,7 +438,7 @@ celix_status_t serviceRegistry_getListen
if (registry == NULL || *hooks != NULL) {
status = CELIX_ILLEGAL_ARGUMENT;
} else {
- *hooks = arrayList_clone(registry->listenerHooks);
+ *hooks = arrayList_clone(registry->framework->mp, registry->listenerHooks);
}
return status;
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=1198848&r1=1198847&r2=1198848&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/service_tracker.c (original)
+++ incubator/celix/trunk/framework/private/src/service_tracker.c Mon Nov 7 18:06:38 2011
@@ -67,14 +67,19 @@ celix_status_t serviceTracker_create(BUN
celix_status_t tracker_createWithFilter(BUNDLE_CONTEXT context, char * filter, SERVICE_TRACKER_CUSTOMIZER customizer, SERVICE_TRACKER *tracker) {
*tracker = (SERVICE_TRACKER) malloc(sizeof(*tracker));
FW_SERVICE_TRACKER fw_tracker = (FW_SERVICE_TRACKER) malloc(sizeof(*fw_tracker));
+ apr_pool_t *pool;
+ bundleContext_getMemoryPool(context, &pool);
+
if (m_trackers == NULL) {
- m_trackers = arrayList_create();
+ arrayList_create(pool, &m_trackers);
}
(*tracker)->context = context;
(*tracker)->filter = filter;
+ fw_tracker->pool = pool;
fw_tracker->tracker = *tracker;
- fw_tracker->tracked = arrayList_create();
+ fw_tracker->tracked = NULL;
+ arrayList_create(pool, &fw_tracker->tracked);
fw_tracker->customizer = customizer;
arrayList_add(m_trackers, fw_tracker);
@@ -153,7 +158,8 @@ SERVICE_REFERENCE tracker_getServiceRefe
ARRAY_LIST tracker_getServiceReferences(SERVICE_TRACKER tracker) {
FW_SERVICE_TRACKER fwTracker = findFwServiceTracker(tracker);
int size = arrayList_size(fwTracker->tracked);
- ARRAY_LIST references = arrayList_create();
+ ARRAY_LIST references = NULL;
+ arrayList_create(fwTracker->pool, &references);
TRACKED tracked;
unsigned int i;
for (i = 0; i < arrayList_size(fwTracker->tracked); i++) {
@@ -179,7 +185,8 @@ void * tracker_getService(SERVICE_TRACKE
ARRAY_LIST tracker_getServices(SERVICE_TRACKER tracker) {
FW_SERVICE_TRACKER fwTracker = findFwServiceTracker(tracker);
int size = arrayList_size(fwTracker->tracked);
- ARRAY_LIST references = arrayList_create();
+ ARRAY_LIST references = NULL;
+ arrayList_create(fwTracker->pool, &references);
TRACKED tracked;
unsigned int i;
for (i = 0; i < arrayList_size(fwTracker->tracked); i++) {
Modified: incubator/celix/trunk/launcher/launcher.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/launcher/launcher.c?rev=1198848&r1=1198847&r2=1198848&view=diff
==============================================================================
--- incubator/celix/trunk/launcher/launcher.c (original)
+++ incubator/celix/trunk/launcher/launcher.c Mon Nov 7 18:06:38 2011
@@ -74,7 +74,8 @@ int main(void) {
}
// First install all bundles
// Afterwards start them
- ARRAY_LIST installed = arrayList_create();
+ ARRAY_LIST installed = NULL;
+ arrayList_create(pool, &installed);
BUNDLE_CONTEXT context = NULL;
bundle_getContext(framework->bundle, &context);
LINKED_LIST_ITERATOR iter = linkedListIterator_create(bundles, 0);
@@ -92,7 +93,6 @@ int main(void) {
linkedListIterator_remove(iter);
}
linkedListIterator_destroy(iter);
- apr_pool_destroy(pool);
int i;
for (i = 0; i < arrayList_size(installed); i++) {
@@ -101,6 +101,7 @@ int main(void) {
}
arrayList_destroy(installed);
+ apr_pool_destroy(pool);
}
framework_waitForStop(framework);
Modified: incubator/celix/trunk/log_service/private/src/log.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/log_service/private/src/log.c?rev=1198848&r1=1198847&r2=1198848&view=diff
==============================================================================
--- incubator/celix/trunk/log_service/private/src/log.c (original)
+++ incubator/celix/trunk/log_service/private/src/log.c Mon Nov 7 18:06:38 2011
@@ -22,6 +22,7 @@
* Created on: Jun 26, 2011
* Author: alexander
*/
+#include <stdlib.h>
#include <apr_thread_cond.h>
#include <apr_thread_mutex.h>
#include <apr_thread_proc.h>
@@ -65,8 +66,10 @@ celix_status_t log_create(apr_pool_t *po
apr_thread_mutex_create(&(*logger)->lock, APR_THREAD_MUTEX_UNNESTED, pool);
(*logger)->pool = pool;
- (*logger)->listeners = arrayList_create();
- (*logger)->listenerEntries = arrayList_create();
+ (*logger)->listeners = NULL;
+ arrayList_create(pool, &(*logger)->listeners);
+ (*logger)->listenerEntries = NULL;
+ arrayList_create(pool, &(*logger)->listenerEntries);
(*logger)->listenerThread = NULL;
(*logger)->running = false;
apr_status = apr_thread_cond_create(&(*logger)->entriesToDeliver, pool);
Modified: incubator/celix/trunk/remote_services/discovery/private/src/discovery.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_services/discovery/private/src/discovery.c?rev=1198848&r1=1198847&r2=1198848&view=diff
==============================================================================
--- incubator/celix/trunk/remote_services/discovery/private/src/discovery.c (original)
+++ incubator/celix/trunk/remote_services/discovery/private/src/discovery.c Mon Nov 7 18:06:38 2011
@@ -69,8 +69,10 @@ celix_status_t discovery_create(apr_pool
(*discovery)->slpServices = hashMap_create(string_hash, NULL, string_equals, NULL);
(*discovery)->running = true;
(*discovery)->rsaPort = getenv("RSA_PORT");
- (*discovery)->handled = arrayList_create();
- (*discovery)->registered = arrayList_create();
+ (*discovery)->handled = NULL;
+ arrayList_create(pool, &(*discovery)->handled);
+ (*discovery)->registered = NULL;
+ arrayList_create(pool, &(*discovery)->registered);
apr_thread_create(&(*discovery)->slpPoll, NULL, discovery_pollSLP, *discovery, (*discovery)->pool);
}
@@ -148,7 +150,7 @@ celix_status_t discovery_addService(disc
endpoint_listener_t listener = NULL;
char *scope = properties_get(reference->registration->properties, (char *) ENDPOINT_LISTENER_SCOPE);
- FILTER filter = filter_create(scope);
+ FILTER filter = filter_create(scope, discovery->pool);
if (filter_match(filter, endpoint->properties)) {
printf("DISCOVERY: Add service (%s)\n", endpoint->service);
bundleContext_getService(discovery->context, reference, (void**)&listener);
@@ -312,7 +314,8 @@ celix_status_t discovery_updateEndpointL
ARRAY_LIST scopes = hashMap_get(discovery->listenerReferences, reference);
if (scopes == NULL) {
- scopes = arrayList_create();
+ scopes = NULL;
+ arrayList_create(discovery->pool, &scopes);
hashMap_put(discovery->listenerReferences, reference, scopes);
}
Modified: incubator/celix/trunk/remote_services/remote_service_admin/private/src/remote_service_admin_impl.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_services/remote_service_admin/private/src/remote_service_admin_impl.c?rev=1198848&r1=1198847&r2=1198848&view=diff
==============================================================================
--- incubator/celix/trunk/remote_services/remote_service_admin/private/src/remote_service_admin_impl.c (original)
+++ incubator/celix/trunk/remote_services/remote_service_admin/private/src/remote_service_admin_impl.c Mon Nov 7 18:06:38 2011
@@ -134,7 +134,7 @@ void *remoteServiceAdmin_callback(enum m
celix_status_t remoteServiceAdmin_exportService(remote_service_admin_t admin, SERVICE_REFERENCE reference, PROPERTIES properties, ARRAY_LIST *registrations) {
celix_status_t status = CELIX_SUCCESS;
- *registrations = arrayList_create();
+ arrayList_create(admin->pool, registrations);
char *exports = properties_get(reference->registration->properties, (char *) SERVICE_EXPORTED_INTERFACES);
@@ -144,7 +144,8 @@ celix_status_t remoteServiceAdmin_export
printf("RSA: No Services to export.\n");
} else {
printf("RSA: Export services (%s)\n", exports);
- ARRAY_LIST interfaces = arrayList_create();
+ ARRAY_LIST interfaces = NULL;
+ arrayList_create(admin->pool, &interfaces);
if (strcmp(string_trim(exports), "*") == 0) {
char *token;
char *interface = apr_strtok(provided, ",", &token);
@@ -258,7 +259,7 @@ celix_status_t remoteServiceAdmin_import
ARRAY_LIST importedRegs = hashMap_get(admin->importedServices, endpoint);
if (importedRegs == NULL) {
- importedRegs = arrayList_create();
+ arrayList_create(admin->pool, &importedRegs);
hashMap_put(admin->importedServices, endpoint, importedRegs);
}
arrayList_add(importedRegs, *registration);
Modified: incubator/celix/trunk/remote_services/topology_manager/private/src/activator.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_services/topology_manager/private/src/activator.c?rev=1198848&r1=1198847&r2=1198848&view=diff
==============================================================================
--- incubator/celix/trunk/remote_services/topology_manager/private/src/activator.c (original)
+++ incubator/celix/trunk/remote_services/topology_manager/private/src/activator.c Mon Nov 7 18:06:38 2011
@@ -53,6 +53,11 @@ celix_status_t bundleActivator_create(BU
} else {
activator->pool = pool;
activator->context = context;
+ activator->endpointListenerService = NULL;
+ activator->hook = NULL;
+ activator->manager = NULL;
+ activator->remoteServiceAdminTracker = NULL;
+ activator->serviceListener = NULL;
topologyManager_create(context, pool, &activator->manager);
Modified: incubator/celix/trunk/remote_services/topology_manager/private/src/topology_manager.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/remote_services/topology_manager/private/src/topology_manager.c?rev=1198848&r1=1198847&r2=1198848&view=diff
==============================================================================
--- incubator/celix/trunk/remote_services/topology_manager/private/src/topology_manager.c (original)
+++ incubator/celix/trunk/remote_services/topology_manager/private/src/topology_manager.c Mon Nov 7 18:06:38 2011
@@ -52,7 +52,8 @@ celix_status_t topologyManager_create(BU
} else {
(*manager)->pool = pool;
(*manager)->context = context;
- (*manager)->rsaList = arrayList_create();
+ (*manager)->rsaList = NULL;
+ arrayList_create(pool, &(*manager)->rsaList);
(*manager)->exportedServices = hashMap_create(NULL, NULL, NULL, NULL);
(*manager)->importedServices = hashMap_create(NULL, NULL, NULL, NULL);
(*manager)->importInterests = hashMap_create(string_hash, NULL, string_equals, NULL);
@@ -194,7 +195,7 @@ celix_status_t topologyManager_notifyLis
for (eplIt = 0; eplIt < arrayList_size(endpointListeners); eplIt++) {
SERVICE_REFERENCE eplRef = arrayList_get(endpointListeners, eplIt);
char *scope = properties_get(eplRef->registration->properties, (char *) ENDPOINT_LISTENER_SCOPE);
- FILTER filter = filter_create(scope);
+ FILTER filter = filter_create(scope, manager->pool);
endpoint_listener_t epl = NULL;
status = bundleContext_getService(manager->context, eplRef, (void **) &epl);
if (status == CELIX_SUCCESS) {
@@ -237,7 +238,9 @@ celix_status_t topologyManager_importSer
import_registration_t import = NULL;
status = rsa->importService(rsa->admin, endpoint, &import);
- hashMap_put(imports, rsa, import);
+ if (status == CELIX_SUCCESS) {
+ hashMap_put(imports, rsa, import);
+ }
}
}
Modified: incubator/celix/trunk/shell/inspect_command.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/shell/inspect_command.c?rev=1198848&r1=1198847&r2=1198848&view=diff
==============================================================================
--- incubator/celix/trunk/shell/inspect_command.c (original)
+++ incubator/celix/trunk/shell/inspect_command.c Mon Nov 7 18:06:38 2011
@@ -46,7 +46,10 @@ void inspectCommand_execute(COMMAND comm
if (type != NULL) {
char *direction = apr_strtok(NULL, " ", &token);
if (direction != NULL) {
- ARRAY_LIST ids = arrayList_create();
+ apr_pool_t *pool = NULL;
+ bundleContext_getMemoryPool(command->bundleContext, &pool);
+ ARRAY_LIST ids = NULL;
+ arrayList_create(pool, &ids);
char *id = apr_strtok(NULL, " ", &token);
while (id != NULL) {
arrayList_add(ids, id);
@@ -80,7 +83,10 @@ celix_status_t inspectCommand_printExpor
if (arrayList_isEmpty(ids)) {
celix_status_t status = bundleContext_getBundles(command->bundleContext, &bundles);
} else {
- bundles = arrayList_create();
+ apr_pool_t *pool = NULL;
+ bundleContext_getMemoryPool(command->bundleContext, &pool);
+ ARRAY_LIST ids = NULL;
+ arrayList_create(pool, &bundles);
int i;
for (i = 0; i < arrayList_size(ids); i++) {
char *idStr = arrayList_get(ids, i);
Modified: incubator/celix/trunk/shell/shell.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/shell/shell.c?rev=1198848&r1=1198847&r2=1198848&view=diff
==============================================================================
--- incubator/celix/trunk/shell/shell.c (original)
+++ incubator/celix/trunk/shell/shell.c Mon Nov 7 18:06:38 2011
@@ -74,8 +74,9 @@ struct shellServiceActivator {
COMMAND inspectCmd;
};
-SHELL shell_create() {
+SHELL shell_create(apr_pool_t *pool) {
SHELL shell = (SHELL) malloc(sizeof(*shell));
+ shell->pool = pool;
shell->commandNameMap = hashMap_create(string_hash, NULL, string_equals, NULL);
shell->commandReferenceMap = hashMap_create(NULL, NULL, NULL, NULL);
return shell;
@@ -88,7 +89,8 @@ void shell_destroy(SHELL shell) {
}
ARRAY_LIST shell_getCommands(SHELL shell) {
- ARRAY_LIST commands = arrayList_create();
+ ARRAY_LIST commands = NULL;
+ arrayList_create(shell->pool, &commands);
HASH_MAP_ITERATOR iter = hashMapIterator_create(shell->commandNameMap);
while (hashMapIterator_hasNext(iter)) {
char * name = hashMapIterator_nextKey(iter);
@@ -160,7 +162,9 @@ void shell_serviceChanged(SERVICE_LISTEN
celix_status_t bundleActivator_create(BUNDLE_CONTEXT context, void **userData) {
*userData = malloc(sizeof(struct shellServiceActivator));
- SHELL shell = shell_create();
+ apr_pool_t *pool = NULL;
+ bundleContext_getMemoryPool(context, &pool);
+ SHELL shell = shell_create(pool);
// struct shellServiceActivator * activator = (struct shellServiceActivator *) (*userData);
((struct shellServiceActivator *) (*userData))->shell = shell;
((struct shellServiceActivator *) (*userData))->listener = NULL;
Modified: incubator/celix/trunk/shell/shell_private.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/shell/shell_private.h?rev=1198848&r1=1198847&r2=1198848&view=diff
==============================================================================
--- incubator/celix/trunk/shell/shell_private.h (original)
+++ incubator/celix/trunk/shell/shell_private.h Mon Nov 7 18:06:38 2011
@@ -32,6 +32,7 @@
#include "command.h"
struct shell {
+ apr_pool_t *pool;
BUNDLE_CONTEXT bundleContext;
HASH_MAP commandReferenceMap;
HASH_MAP commandNameMap;
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=1198848&r1=1198847&r2=1198848&view=diff
==============================================================================
--- incubator/celix/trunk/utils/private/src/array_list.c (original)
+++ incubator/celix/trunk/utils/private/src/array_list.c Mon Nov 7 18:06:38 2011
@@ -29,15 +29,15 @@
#include "array_list.h"
#include "array_list_private.h"
-ARRAY_LIST arrayList_create(void) {
- ARRAY_LIST list = (ARRAY_LIST) malloc(sizeof(*list));
+celix_status_t arrayList_create(apr_pool_t *pool, ARRAY_LIST *list) {
+ *list = (ARRAY_LIST) malloc(sizeof(**list));
- list->size = 0;
- list->capacity = 10;
- list->modCount = 0;
- list->elementData = (void **) malloc(sizeof(void*) * list->capacity);
+ (*list)->size = 0;
+ (*list)->capacity = 10;
+ (*list)->modCount = 0;
+ (*list)->elementData = (void **) malloc(sizeof(void*) * (*list)->capacity);
- return list;
+ return CELIX_SUCCESS;
}
void arrayList_destroy(ARRAY_LIST list) {
@@ -234,8 +234,9 @@ bool arrayList_addAll(ARRAY_LIST list, A
return size != 0;
}
-ARRAY_LIST arrayList_clone(ARRAY_LIST list) {
- ARRAY_LIST new = arrayList_create();
+ARRAY_LIST arrayList_clone(apr_pool_t *pool, ARRAY_LIST list) {
+ ARRAY_LIST new = NULL;
+ arrayList_create(pool, &new);
// arrayList_ensureCapacity(new, list->size);
// memcpy(new->elementData, list->elementData, list->size);
// new->size = list->size;
Modified: incubator/celix/trunk/utils/private/test/array_list_test.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/utils/private/test/array_list_test.c?rev=1198848&r1=1198847&r2=1198848&view=diff
==============================================================================
--- incubator/celix/trunk/utils/private/test/array_list_test.c (original)
+++ incubator/celix/trunk/utils/private/test/array_list_test.c Mon Nov 7 18:06:38 2011
@@ -23,17 +23,23 @@
* Author: alexanderb
*/
#include <stdio.h>
+#include <stdlib.h>
#include <Automated.h>
+#include <apr_general.h>
+
#include "celixbool.h"
#include "array_list.h"
#include "array_list_private.h"
+apr_pool_t *memory_pool;
ARRAY_LIST list;
int setup(void) {
- list = arrayList_create();
+ apr_initialize();
+ apr_pool_create(&memory_pool, NULL);
+ arrayList_create(memory_pool, &list);
if (list == NULL) {
return 1;
}
@@ -61,7 +67,7 @@ void test_arrayList_trimToSize(void) {
void test_arrayList_ensureCapacity(void) {
int i;
- list = arrayList_create();
+ arrayList_create(memory_pool, &list);
arrayList_clear(list);
CU_ASSERT_EQUAL(list->capacity, 10);
CU_ASSERT_EQUAL(list->size, 0);
@@ -70,7 +76,7 @@ void test_arrayList_ensureCapacity(void)
}
CU_ASSERT_EQUAL(list->capacity, 133);
CU_ASSERT_EQUAL(list->size, 100);
- list = arrayList_create();
+ arrayList_create(memory_pool, &list);
}
void test_arrayList_size(void) {
@@ -220,7 +226,7 @@ void test_arrayList_addAll(void) {
arrayList_clear(list);
- toAdd = arrayList_create();
+ arrayList_create(memory_pool, &list);
arrayList_add(toAdd, entry);
arrayList_add(toAdd, entry2);
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=1198848&r1=1198847&r2=1198848&view=diff
==============================================================================
--- incubator/celix/trunk/utils/public/include/array_list.h (original)
+++ incubator/celix/trunk/utils/public/include/array_list.h Mon Nov 7 18:06:38 2011
@@ -26,14 +26,17 @@
#ifndef ARRAY_LIST_H_
#define ARRAY_LIST_H_
+#include <apr_general.h>
+
#include "celixbool.h"
#include "exports.h"
+#include "celix_errno.h"
typedef struct arrayList * ARRAY_LIST;
typedef struct arrayListIterator * ARRAY_LIST_ITERATOR;
-UTILS_EXPORT ARRAY_LIST arrayList_create(void);
+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);
@@ -50,7 +53,7 @@ UTILS_EXPORT bool arrayList_addAll(ARRAY
UTILS_EXPORT void * arrayList_remove(ARRAY_LIST list, unsigned int index);
UTILS_EXPORT bool arrayList_removeElement(ARRAY_LIST list, void * element);
UTILS_EXPORT void arrayList_clear(ARRAY_LIST list);
-UTILS_EXPORT ARRAY_LIST arrayList_clone(ARRAY_LIST list);
+ARRAY_LIST arrayList_clone(apr_pool_t *pool, ARRAY_LIST list);
UTILS_EXPORT ARRAY_LIST_ITERATOR arrayListIterator_create(ARRAY_LIST list);
UTILS_EXPORT void arrayListIterator_destroy(ARRAY_LIST_ITERATOR iterator);