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 2014/06/04 13:27:08 UTC
svn commit: r1600110 - in /incubator/celix/trunk/framework: private/include/
private/mock/ private/src/ public/include/
Author: abroekhuis
Date: Wed Jun 4 11:27:07 2014
New Revision: 1600110
URL: http://svn.apache.org/r1600110
Log:
CELIX-119: Updated resolver and related files to remove APR.
Modified:
incubator/celix/trunk/framework/private/include/attribute.h
incubator/celix/trunk/framework/private/mock/wire_mock.c
incubator/celix/trunk/framework/private/src/attribute.c
incubator/celix/trunk/framework/private/src/bundle.c
incubator/celix/trunk/framework/private/src/capability.c
incubator/celix/trunk/framework/private/src/manifest_parser.c
incubator/celix/trunk/framework/private/src/module.c
incubator/celix/trunk/framework/private/src/requirement.c
incubator/celix/trunk/framework/private/src/resolver.c
incubator/celix/trunk/framework/private/src/version.c
incubator/celix/trunk/framework/private/src/version_range.c
incubator/celix/trunk/framework/private/src/wire.c
incubator/celix/trunk/framework/public/include/capability.h
incubator/celix/trunk/framework/public/include/requirement.h
incubator/celix/trunk/framework/public/include/version.h
incubator/celix/trunk/framework/public/include/version_range.h
incubator/celix/trunk/framework/public/include/wire.h
Modified: incubator/celix/trunk/framework/private/include/attribute.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/include/attribute.h?rev=1600110&r1=1600109&r2=1600110&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/include/attribute.h (original)
+++ incubator/celix/trunk/framework/private/include/attribute.h Wed Jun 4 11:27:07 2014
@@ -31,7 +31,7 @@
typedef struct attribute *attribute_pt;
-celix_status_t attribute_create(apr_pool_t *memory_pool, char * key, char * value, attribute_pt *attribute);
+celix_status_t attribute_create(char * key, char * value, attribute_pt *attribute);
celix_status_t attribute_getKey(attribute_pt attribute, char **key);
celix_status_t attribute_getValue(attribute_pt attribute, char **value);
Modified: incubator/celix/trunk/framework/private/mock/wire_mock.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/mock/wire_mock.c?rev=1600110&r1=1600109&r2=1600110&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/mock/wire_mock.c (original)
+++ incubator/celix/trunk/framework/private/mock/wire_mock.c Wed Jun 4 11:27:07 2014
@@ -27,7 +27,7 @@
#include "wire.h"
-celix_status_t wire_create(apr_pool_t *pool, module_pt importer, requirement_pt requirement,
+celix_status_t wire_create(module_pt importer, requirement_pt requirement,
module_pt exporter, capability_pt capability, wire_pt *wire) {
mock_c()->actualCall("requirement_create");
return mock_c()->returnValue().value.intValue;
Modified: incubator/celix/trunk/framework/private/src/attribute.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/attribute.c?rev=1600110&r1=1600109&r2=1600110&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/attribute.c (original)
+++ incubator/celix/trunk/framework/private/src/attribute.c Wed Jun 4 11:27:07 2014
@@ -29,15 +29,15 @@
#include "attribute_private.h"
#include "celix_log.h"
-celix_status_t attribute_create(apr_pool_t *memory_pool, char * key, char * value, attribute_pt *attribute) {
+celix_status_t attribute_create(char * key, char * value, attribute_pt *attribute) {
celix_status_t status = CELIX_SUCCESS;
char *error = NULL;
- if (key == NULL || value == NULL || memory_pool == NULL || *attribute != NULL) {
+ if (key == NULL || value == NULL || *attribute != NULL) {
status = CELIX_ILLEGAL_ARGUMENT;
error = "Missing required arguments and/or values";
} else {
- attribute_pt attr = apr_palloc(memory_pool, sizeof(*attr));
+ attribute_pt attr = malloc(sizeof(*attr));
if (!attr) {
status = CELIX_ENOMEM;
} else {
Modified: incubator/celix/trunk/framework/private/src/bundle.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/bundle.c?rev=1600110&r1=1600109&r2=1600110&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/bundle.c (original)
+++ incubator/celix/trunk/framework/private/src/bundle.c Wed Jun 4 11:27:07 2014
@@ -264,8 +264,9 @@ celix_status_t bundle_createModule(bundl
if ((symName != NULL) && (sym != NULL) && !strcmp(symName, sym) &&
!cmp) {
char *versionString = NULL;
- version_toString(version, bundle->memoryPool, &versionString);
+ version_toString(version, &versionString);
printf("Bundle symbolic name and version are not unique: %s:%s\n", sym, versionString);
+ free(versionString);
status = CELIX_BUNDLE_EXCEPTION;
break;
}
Modified: incubator/celix/trunk/framework/private/src/capability.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/capability.c?rev=1600110&r1=1600109&r2=1600110&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/capability.c (original)
+++ incubator/celix/trunk/framework/private/src/capability.c Wed Jun 4 11:27:07 2014
@@ -29,22 +29,18 @@
#include "attribute.h"
#include "celix_log.h"
-apr_status_t capability_destroy(void *capabilityP);
-
-celix_status_t capability_create(apr_pool_t *pool, module_pt module, hash_map_pt directives, hash_map_pt attributes, capability_pt *capability) {
+celix_status_t capability_create(module_pt module, hash_map_pt directives, hash_map_pt attributes, capability_pt *capability) {
celix_status_t status = CELIX_SUCCESS;
- *capability = (capability_pt) apr_palloc(pool, sizeof(**capability));
+ *capability = (capability_pt) malloc(sizeof(**capability));
if (!*capability) {
status = CELIX_ENOMEM;
} else {
- apr_pool_pre_cleanup_register(pool, *capability, capability_destroy);
-
(*capability)->module = module;
(*capability)->attributes = attributes;
(*capability)->directives = directives;
(*capability)->version = NULL;
- status = version_createEmptyVersion(pool, &(*capability)->version);
+ status = version_createEmptyVersion(&(*capability)->version);
if (status == CELIX_SUCCESS) {
attribute_pt versionAttribute = NULL;
attribute_pt serviceAttribute = (attribute_pt) hashMap_get(attributes, "service");
@@ -55,7 +51,7 @@ celix_status_t capability_create(apr_poo
char *versionStr = NULL;
attribute_getValue(versionAttribute, &versionStr);
(*capability)->version = NULL;
- status = version_createVersionFromString(pool, versionStr, &(*capability)->version);
+ status = version_createVersionFromString(versionStr, &(*capability)->version);
}
}
}
@@ -66,9 +62,7 @@ celix_status_t capability_create(apr_poo
return status;
}
-apr_status_t capability_destroy(void *capabilityP) {
- capability_pt capability = capabilityP;
-
+celix_status_t capability_destroy(capability_pt capability) {
hash_map_iterator_pt attrIter = hashMapIterator_create(capability->attributes);
while (hashMapIterator_hasNext(attrIter)) {
attribute_pt attr = hashMapIterator_nextValue(attrIter);
@@ -81,9 +75,11 @@ apr_status_t capability_destroy(void *ca
capability->attributes = NULL;
capability->directives = NULL;
capability->module = NULL;
+
+ version_destroy(capability->version);
capability->version = NULL;
- return APR_SUCCESS;
+ return CELIX_SUCCESS;
}
celix_status_t capability_getServiceName(capability_pt capability, char **serviceName) {
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=1600110&r1=1600109&r2=1600110&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/manifest_parser.c (original)
+++ incubator/celix/trunk/framework/private/src/manifest_parser.c Wed Jun 4 11:27:07 2014
@@ -71,10 +71,10 @@ celix_status_t manifestParser_create(mod
bundleVersion = manifest_getValue(manifest, OSGI_FRAMEWORK_BUNDLE_VERSION);
if (bundleVersion != NULL) {
parser->bundleVersion = NULL;
- version_createVersionFromString(memory_pool, bundleVersion, &parser->bundleVersion);
+ version_createVersionFromString(bundleVersion, &parser->bundleVersion);
} else {
parser->bundleVersion = NULL;
- version_createEmptyVersion(memory_pool, &parser->bundleVersion);
+ version_createEmptyVersion(&parser->bundleVersion);
}
bundleSymbolicName = manifest_getValue(manifest, OSGI_FRAMEWORK_BUNDLE_SYMBOLICNAME);
if (bundleSymbolicName != NULL) {
@@ -234,7 +234,7 @@ static linked_list_pt manifestParser_par
return NULL;
}
- if (attribute_create(memory_pool, key, value, &attr) == CELIX_SUCCESS) {
+ if (attribute_create(key, value, &attr) == CELIX_SUCCESS) {
hashMap_put(attrsMap, key, attr);
}
}
@@ -307,13 +307,13 @@ static linked_list_pt manifestParser_par
return NULL;
}
- if (attribute_create(memory_pool, apr_pstrdup(memory_pool, "service"), path, &name) == CELIX_SUCCESS) {
+ if (attribute_create(apr_pstrdup(memory_pool, "service"), path, &name) == CELIX_SUCCESS) {
char *key = NULL;
attribute_getKey(name, &key);
hashMap_put(attributes, key, name);
}
- requirement_create(memory_pool, directives, attributes, &req);
+ requirement_create(directives, attributes, &req);
linkedList_addElement(requirements, req);
}
}
@@ -359,13 +359,13 @@ static linked_list_pt manifestParser_par
return NULL;
}
- if (attribute_create(memory_pool, apr_pstrdup(memory_pool, "service"), path, &name) == CELIX_SUCCESS) {
+ if (attribute_create(apr_pstrdup(memory_pool, "service"), path, &name) == CELIX_SUCCESS) {
char *key = NULL;
attribute_getKey(name, &key);
hashMap_put(attributes, key, name);
}
- capability_create(memory_pool, module, directives, attributes, &cap);
+ capability_create(module, directives, attributes, &cap);
linkedList_addElement(capabilities, cap);
}
}
@@ -388,7 +388,7 @@ celix_status_t manifestParser_getSymboli
}
celix_status_t manifestParser_getBundleVersion(manifest_parser_pt parser, apr_pool_t *pool, version_pt *version) {
- return version_clone(parser->bundleVersion, pool, version);
+ return version_clone(parser->bundleVersion, version);
}
celix_status_t manifestParser_getCapabilities(manifest_parser_pt parser, apr_pool_t *pool, linked_list_pt *capabilities) {
Modified: incubator/celix/trunk/framework/private/src/module.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/module.c?rev=1600110&r1=1600109&r2=1600110&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/module.c (original)
+++ incubator/celix/trunk/framework/private/src/module.c Wed Jun 4 11:27:07 2014
@@ -110,7 +110,7 @@ module_pt module_createFrameworkModule(b
module->id = apr_pstrdup(bundlePool, "0");
module->symbolicName = apr_pstrdup(bundlePool, "framework");
module->version = NULL;
- version_createVersion(bundlePool, 1, 0, 0, "", &module->version);
+ version_createVersion(1, 0, 0, "", &module->version);
linkedList_create(&module->capabilities);
linkedList_create(&module->requirements);
Modified: incubator/celix/trunk/framework/private/src/requirement.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/requirement.c?rev=1600110&r1=1600109&r2=1600110&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/requirement.c (original)
+++ incubator/celix/trunk/framework/private/src/requirement.c Wed Jun 4 11:27:07 2014
@@ -30,20 +30,16 @@
#include "attribute.h"
#include "celix_log.h"
-apr_status_t requirement_destroy(void *requirementP);
-
-celix_status_t requirement_create(apr_pool_t *pool, hash_map_pt directives, hash_map_pt attributes, requirement_pt *requirement) {
+celix_status_t requirement_create(hash_map_pt directives, hash_map_pt attributes, requirement_pt *requirement) {
celix_status_t status = CELIX_SUCCESS;
- *requirement = (requirement_pt) apr_palloc(pool, sizeof(**requirement));
+ *requirement = (requirement_pt) malloc(sizeof(**requirement));
if (!*requirement) {
status = CELIX_ENOMEM;
} else {
attribute_pt serviceAttribute = NULL;
attribute_pt versionAttribute = NULL;
- apr_pool_pre_cleanup_register(pool, *requirement, requirement_destroy);
-
(*requirement)->attributes = attributes;
(*requirement)->directives = directives;
@@ -51,14 +47,14 @@ celix_status_t requirement_create(apr_po
status = attribute_getValue(serviceAttribute, &(*requirement)->targetName);
if (status == CELIX_SUCCESS) {
(*requirement)->versionRange = NULL;
- status = versionRange_createInfiniteVersionRange(pool, &(*requirement)->versionRange);
+ status = versionRange_createInfiniteVersionRange(&(*requirement)->versionRange);
if (status == CELIX_SUCCESS) {
versionAttribute = (attribute_pt) hashMap_get(attributes, "version");
if (versionAttribute != NULL) {
char *versionStr = NULL;
attribute_getValue(versionAttribute, &versionStr);
(*requirement)->versionRange = NULL;
- status = versionRange_parse(pool, versionStr, &(*requirement)->versionRange);
+ status = versionRange_parse(versionStr, &(*requirement)->versionRange);
}
}
}
@@ -69,8 +65,7 @@ celix_status_t requirement_create(apr_po
return status;
}
-apr_status_t requirement_destroy(void *requirementP) {
- requirement_pt requirement = requirementP;
+celix_status_t requirement_destroy(requirement_pt requirement) {
hash_map_iterator_pt attrIter = hashMapIterator_create(requirement->attributes);
while (hashMapIterator_hasNext(attrIter)) {
attribute_pt attr = hashMapIterator_nextValue(attrIter);
@@ -84,7 +79,7 @@ apr_status_t requirement_destroy(void *r
requirement->directives = NULL;
requirement->versionRange = NULL;
- return APR_SUCCESS;
+ return CELIX_SUCCESS;
}
celix_status_t requirement_getVersionRange(requirement_pt requirement, version_range_pt *range) {
Modified: incubator/celix/trunk/framework/private/src/resolver.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/resolver.c?rev=1600110&r1=1600109&r2=1600110&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/resolver.c (original)
+++ incubator/celix/trunk/framework/private/src/resolver.c Wed Jun 4 11:27:07 2014
@@ -94,9 +94,7 @@ linked_list_pt resolver_resolve(module_p
}
bundle_pt bundle = module_getBundle(root);
- apr_pool_t *pool = NULL;
- bundle_getMemoryPool(bundle, &pool);
- linkedList_create(pool, &wireMap);
+ linkedList_create(&wireMap);
resolved = resolver_populateWireMap(candidatesMap, root, wireMap);
iter = hashMapIterator_create(candidatesMap);
while (hashMapIterator_hasNext(iter)) {
@@ -120,21 +118,15 @@ linked_list_pt resolver_resolve(module_p
int resolver_populateCandidatesMap(hash_map_pt candidatesMap, module_pt targetModule) {
linked_list_pt candSetList;
- apr_pool_t *candSetList_pool;
linked_list_pt candidates;
- apr_pool_t *candidates_pool;
linked_list_pt invalid;
- apr_pool_t *invalid_pool;
int i;
int c;
requirement_pt req;
capability_list_pt capList;
- apr_pool_t *bundlePool = NULL;
bundle_pt bundle = NULL;
bundle = module_getBundle(targetModule);
- bundle_getMemoryPool(bundle, &bundlePool);
-
if (hashMap_containsKey(candidatesMap, targetModule)) {
return 0;
@@ -142,16 +134,14 @@ int resolver_populateCandidatesMap(hash_
hashMap_put(candidatesMap, targetModule, NULL);
- if (apr_pool_create(&candSetList_pool, bundlePool) == APR_SUCCESS) {
- if (linkedList_create(candSetList_pool, &candSetList) == CELIX_SUCCESS) {
+ if (linkedList_create(&candSetList) == CELIX_SUCCESS) {
for (i = 0; i < linkedList_size(module_getRequirements(targetModule)); i++) {
char *targetName = NULL;
req = (requirement_pt) linkedList_get(module_getRequirements(targetModule), i);
requirement_getTargetName(req, &targetName);
capList = resolver_getCapabilityList(m_resolvedServices, targetName);
- if (apr_pool_create(&candidates_pool, bundlePool) == APR_SUCCESS) {
- if (linkedList_create(candidates_pool, &candidates) == CELIX_SUCCESS) {
+ if (linkedList_create(&candidates) == CELIX_SUCCESS) {
for (c = 0; (capList != NULL) && (c < linkedList_size(capList->capabilities)); c++) {
capability_pt cap = (capability_pt) linkedList_get(capList->capabilities, c);
bool satisfied = false;
@@ -186,17 +176,13 @@ int resolver_populateCandidatesMap(hash_
}
if (linkedList_size(candidates) == 0) {
- if (apr_pool_create(&invalid_pool, bundlePool) == APR_SUCCESS) {
- if (linkedList_create(invalid_pool, &invalid) == CELIX_SUCCESS) {
+ if (linkedList_create(&invalid) == CELIX_SUCCESS) {
char *name = NULL;
resolver_removeInvalidCandidate(targetModule, candidatesMap, invalid);
- apr_pool_destroy(invalid_pool);
- apr_pool_destroy(candidates_pool);
module_getSymbolicName(targetModule, &name);
printf("Unable to resolve: %s, %s\n", name, targetName);
- }
}
return -1;
} else if (linkedList_size(candidates) > 0) {
@@ -207,12 +193,10 @@ int resolver_populateCandidatesMap(hash_
linkedList_addElement(candSetList, cs);
}
- }
}
}
hashMap_put(candidatesMap, targetModule, candSetList);
}
- }
return 0;
}
@@ -258,29 +242,17 @@ void resolver_removeInvalidCandidate(mod
}
void resolver_addModule(module_pt module) {
- apr_pool_t *modules_pool;
- apr_pool_t *unresolvedServices_pool;
- apr_pool_t *resolvedServices_pool;
int i;
capability_pt cap;
capability_list_pt list;
- apr_pool_t *capabilities_pool;
- apr_pool_t *bundlePool = NULL;
bundle_pt bundle = NULL;
bundle = module_getBundle(module);
- bundle_getMemoryPool(bundle, &bundlePool);
if (m_modules == NULL) {
- if (apr_pool_create(&modules_pool, bundlePool) == APR_SUCCESS) {
- if (apr_pool_create(&unresolvedServices_pool, bundlePool) == APR_SUCCESS) {
- if (apr_pool_create(&resolvedServices_pool, bundlePool) == APR_SUCCESS) {
- linkedList_create(modules_pool, &m_modules);
- linkedList_create(unresolvedServices_pool, &m_unresolvedServices);
- linkedList_create(resolvedServices_pool, &m_resolvedServices);
- }
- }
- }
+ linkedList_create(&m_modules);
+ linkedList_create(&m_unresolvedServices);
+ linkedList_create(&m_resolvedServices);
}
if (m_modules != NULL && m_unresolvedServices != NULL) {
@@ -292,13 +264,11 @@ void resolver_addModule(module_pt module
capability_getServiceName(cap, &serviceName);
list = resolver_getCapabilityList(m_unresolvedServices, serviceName);
if (list == NULL) {
- if (apr_pool_create(&capabilities_pool, bundlePool) == APR_SUCCESS) {
- list = (capability_list_pt) apr_palloc(capabilities_pool, sizeof(*list));
- if (list != NULL) {
- list->serviceName = apr_pstrdup(capabilities_pool, serviceName);
- if (linkedList_create(capabilities_pool, &list->capabilities) == APR_SUCCESS) {
- linkedList_addElement(m_unresolvedServices, list);
- }
+ list = (capability_list_pt) malloc(sizeof(*list));
+ if (list != NULL) {
+ list->serviceName = strdup(serviceName);
+ if (linkedList_create(&list->capabilities) == APR_SUCCESS) {
+ linkedList_addElement(m_unresolvedServices, list);
}
}
}
@@ -334,17 +304,12 @@ void resolver_removeModule(module_pt mod
void resolver_moduleResolved(module_pt module) {
int capIdx;
linked_list_pt capsCopy;
- apr_pool_t *capsCopy_pool;
- apr_pool_t *capabilities_pool;
- apr_pool_t *bundlePool = NULL;
bundle_pt bundle = NULL;
bundle = module_getBundle(module);
- bundle_getMemoryPool(bundle, &bundlePool);
if (module_isResolved(module)) {
- if (apr_pool_create(&capsCopy_pool, bundlePool) == APR_SUCCESS) {
- if (linkedList_create(capsCopy_pool, &capsCopy) == APR_SUCCESS) {
+ if (linkedList_create(&capsCopy) == APR_SUCCESS) {
linked_list_pt wires = NULL;
for (capIdx = 0; (module_getCapabilities(module) != NULL) && (capIdx < linkedList_size(module_getCapabilities(module))); capIdx++) {
@@ -386,22 +351,18 @@ void resolver_moduleResolved(module_pt m
list = resolver_getCapabilityList(m_resolvedServices, serviceName);
if (list == NULL) {
- if (apr_pool_create(&capabilities_pool, bundlePool) == APR_SUCCESS) {
- list = (capability_list_pt) apr_palloc(capabilities_pool, sizeof(*list));
+ list = (capability_list_pt) malloc(sizeof(*list));
if (list != NULL) {
- list->serviceName = apr_pstrdup(capabilities_pool, serviceName);
- if (linkedList_create(capabilities_pool, &list->capabilities) == APR_SUCCESS) {
+ list->serviceName = strdup(serviceName);
+ if (linkedList_create(&list->capabilities) == APR_SUCCESS) {
linkedList_addElement(m_resolvedServices, list);
}
}
- }
}
linkedList_addElement(list->capabilities, cap);
}
}
- apr_pool_destroy(capsCopy_pool);
- }
}
}
}
@@ -422,14 +383,10 @@ capability_list_pt resolver_getCapabilit
linked_list_pt resolver_populateWireMap(hash_map_pt candidates, module_pt importer, linked_list_pt wireMap) {
linked_list_pt serviceWires;
- apr_pool_t *serviceWires_pool;
linked_list_pt emptyWires;
- apr_pool_t *emptyWires_pool;
- apr_pool_t *bundlePool = NULL;
bundle_pt bundle = NULL;
bundle = module_getBundle(importer);
- bundle_getMemoryPool(bundle, &bundlePool);
if (candidates && importer && wireMap) {
linked_list_pt candSetList = NULL;
@@ -446,10 +403,8 @@ linked_list_pt resolver_populateWireMap(
candSetList = (linked_list_pt) hashMap_get(candidates, importer);
- if (apr_pool_create(&serviceWires_pool, bundlePool) == APR_SUCCESS) {
- if (apr_pool_create(&emptyWires_pool, bundlePool) == APR_SUCCESS) {
- if (linkedList_create(serviceWires_pool, &serviceWires) == APR_SUCCESS) {
- if (linkedList_create(emptyWires_pool, &emptyWires) == APR_SUCCESS) {
+ if (linkedList_create(&serviceWires) == APR_SUCCESS) {
+ if (linkedList_create(&emptyWires) == APR_SUCCESS) {
int candSetIdx = 0;
// hashMap_put(wireMap, importer, emptyWires);
@@ -457,7 +412,7 @@ linked_list_pt resolver_populateWireMap(
char *mname = NULL;
module_getSymbolicName(importer, &mname);
- importer_wires_pt importerWires = apr_palloc(bundlePool, sizeof(*importerWires));
+ importer_wires_pt importerWires = malloc(sizeof(*importerWires));
importerWires->importer = importer;
importerWires->wires = emptyWires;
linkedList_addElement(wireMap, importerWires);
@@ -469,8 +424,7 @@ linked_list_pt resolver_populateWireMap(
capability_getModule(((capability_pt) linkedList_get(cs->candidates, 0)), &module);
if (importer != module) {
wire_pt wire = NULL;
- wire_create(serviceWires_pool, importer, cs->requirement,
- module,
+ wire_create(importer, cs->requirement, module,
((capability_pt) linkedList_get(cs->candidates, 0)), &wire);
linkedList_addElement(serviceWires, wire);
}
@@ -483,8 +437,6 @@ linked_list_pt resolver_populateWireMap(
importerWires->wires = serviceWires;
// hashMap_put(wireMap, importer, serviceWires);
}
- }
- }
}
}
Modified: incubator/celix/trunk/framework/private/src/version.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/version.c?rev=1600110&r1=1600109&r2=1600110&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/version.c (original)
+++ incubator/celix/trunk/framework/private/src/version.c Wed Jun 4 11:27:07 2014
@@ -31,29 +31,25 @@
#include "version_private.h"
#include "celix_log.h"
-static apr_status_t version_destroy(void *handle);
-
-celix_status_t version_createVersion(apr_pool_t *pool, int major, int minor, int micro, char * qualifier, version_pt *version) {
+celix_status_t version_createVersion(int major, int minor, int micro, char * qualifier, version_pt *version) {
celix_status_t status = CELIX_SUCCESS;
- if (*version != NULL || pool == NULL) {
+ if (*version != NULL) {
status = CELIX_ILLEGAL_ARGUMENT;
} else {
- *version = (version_pt) apr_palloc(pool, sizeof(**version));
+ *version = (version_pt) malloc(sizeof(**version));
if (!*version) {
status = CELIX_ENOMEM;
} else {
unsigned int i;
- apr_pool_pre_cleanup_register(pool, *version, version_destroy);
- (*version)->pool = pool;
(*version)->major = major;
(*version)->minor = minor;
(*version)->micro = micro;
if (qualifier == NULL) {
qualifier = "";
}
- (*version)->qualifier = apr_pstrdup(pool, qualifier);
+ (*version)->qualifier = strdup(qualifier);
if (major < 0) {
fw_log(logger, OSGI_FRAMEWORK_LOG_ERROR, "Negative major");
@@ -94,20 +90,20 @@ celix_status_t version_createVersion(apr
return status;
}
-celix_status_t version_clone(version_pt version, apr_pool_t *pool, version_pt *clone) {
- return version_createVersion(pool, version->major, version->minor, version->micro, version->qualifier, clone);
+celix_status_t version_clone(version_pt version, version_pt *clone) {
+ return version_createVersion(version->major, version->minor, version->micro, version->qualifier, clone);
}
-apr_status_t version_destroy(void *handle) {
- version_pt version = (version_pt) handle;
+celix_status_t version_destroy(version_pt version) {
version->major = 0;
version->minor = 0;
version->micro = 0;
+ free(version->qualifier);
version->qualifier = NULL;
- return APR_SUCCESS;
+ return CELIX_SUCCESS;
}
-celix_status_t version_createVersionFromString(apr_pool_t *pool, char * versionStr, version_pt *version) {
+celix_status_t version_createVersionFromString(char * versionStr, version_pt *version) {
celix_status_t status = CELIX_SUCCESS;
int major = 0;
@@ -159,7 +155,7 @@ celix_status_t version_createVersionFrom
micro = atoi(token);
token = apr_strtok(NULL, delims, &last);
if (token != NULL) {
- qualifier = apr_pstrdup(pool, token);
+ qualifier = strdup(token);
token = apr_strtok(NULL, delims, &last);
if (token != NULL) {
printf("invalid format");
@@ -171,7 +167,7 @@ celix_status_t version_createVersionFrom
}
}
if (status == CELIX_SUCCESS) {
- status = version_createVersion(pool, major, minor, micro, qualifier, version);
+ status = version_createVersion(major, minor, micro, qualifier, version);
}
framework_logIfError(logger, status, NULL, "Cannot create version [versionString=%s]", versionStr);
@@ -179,8 +175,8 @@ celix_status_t version_createVersionFrom
return status;
}
-celix_status_t version_createEmptyVersion(apr_pool_t *pool, version_pt *version) {
- return version_createVersion(pool, 0, 0, 0, "", version);
+celix_status_t version_createEmptyVersion(version_pt *version) {
+ return version_createVersion(0, 0, 0, "", version);
}
celix_status_t version_getMajor(version_pt version, int *major) {
@@ -235,11 +231,22 @@ celix_status_t version_compareTo(version
return status;
}
-celix_status_t version_toString(version_pt version, apr_pool_t *pool, char **string) {
+celix_status_t version_toString(version_pt version, char **string) {
+ celix_status_t status = CELIX_SUCCESS;
if (strlen(version->qualifier) > 0) {
- *string = apr_psprintf(pool, "%d.%d.%d.%s", version->major, version->minor, version->micro, version->qualifier);
+ char str[512];
+ int written = snprintf(str, 512, "%d.%d.%d.%s", version->major, version->minor, version->micro, version->qualifier);
+ if (written >= 512 || written < 0) {
+ status = CELIX_BUNDLE_EXCEPTION;
+ }
+ *string = str;
} else {
- *string = apr_psprintf(pool, "%d.%d.%d", version->major, version->minor, version->micro);
+ char str[512];
+ int written = snprintf(str, 512, "%d.%d.%d", version->major, version->minor, version->micro);
+ if (written >= 512 || written < 0) {
+ status = CELIX_BUNDLE_EXCEPTION;
+ }
+ *string = str;
}
- return CELIX_SUCCESS;
+ return status;
}
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=1600110&r1=1600109&r2=1600110&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/version_range.c (original)
+++ incubator/celix/trunk/framework/private/src/version_range.c Wed Jun 4 11:27:07 2014
@@ -30,17 +30,13 @@
#include "version_range_private.h"
#include "celix_log.h"
-apr_status_t versionRange_destroy(void *rangeP);
-
-celix_status_t versionRange_createVersionRange(apr_pool_t *pool, version_pt low, bool isLowInclusive,
+celix_status_t versionRange_createVersionRange(version_pt low, bool isLowInclusive,
version_pt high, bool isHighInclusive, version_range_pt *range) {
celix_status_t status = CELIX_SUCCESS;
- *range = (version_range_pt) apr_palloc(pool, sizeof(**range));
+ *range = (version_range_pt) malloc(sizeof(**range));
if (!*range) {
status = CELIX_ENOMEM;
} else {
- apr_pool_pre_cleanup_register(pool, *range, versionRange_destroy);
-
(*range)->low = low;
(*range)->isLowInclusive = isLowInclusive;
(*range)->high = high;
@@ -52,8 +48,7 @@ celix_status_t versionRange_createVersio
return status;
}
-apr_status_t versionRange_destroy(void *rangeP) {
- version_range_pt range = rangeP;
+celix_status_t versionRange_destroy(version_range_pt range) {
range->high = NULL;
range->isHighInclusive = false;
range->low = NULL;
@@ -61,13 +56,13 @@ apr_status_t versionRange_destroy(void *
return APR_SUCCESS;
}
-celix_status_t versionRange_createInfiniteVersionRange(apr_pool_t *pool, version_range_pt *range) {
+celix_status_t versionRange_createInfiniteVersionRange(version_range_pt *range) {
celix_status_t status = CELIX_SUCCESS;
version_pt version = NULL;
- status = version_createEmptyVersion(pool, &version);
+ status = version_createEmptyVersion(&version);
if (status == CELIX_SUCCESS) {
- status = versionRange_createVersionRange(pool, version, true, NULL, true, range);
+ status = versionRange_createVersionRange(version, true, NULL, true, range);
}
framework_logIfError(logger, status, NULL, "Cannot create infinite range");
@@ -126,16 +121,11 @@ celix_status_t versionRange_isInRange(ve
return status;
}
-celix_status_t versionRange_parse(apr_pool_t *pool, char * rangeStr, version_range_pt *range) {
+celix_status_t versionRange_parse(char * rangeStr, version_range_pt *range) {
celix_status_t status = CELIX_SUCCESS;
if (strchr(rangeStr, ',') != NULL) {
- apr_pool_t *spool;
- apr_status_t aprStatus = apr_pool_create(&spool, pool);
- if (aprStatus != APR_SUCCESS) {
- status = CELIX_ILLEGAL_STATE;
- } else {
int vlowL = strcspn(rangeStr+1, ",");
- char * vlow = (char *) apr_palloc(spool, sizeof(*vlow * (vlowL + 1)));
+ char * vlow = (char *) malloc(sizeof(*vlow * (vlowL + 1)));
if (!vlow) {
status = CELIX_ENOMEM;
} else {
@@ -144,7 +134,7 @@ celix_status_t versionRange_parse(apr_po
vlow = strncpy(vlow, rangeStr+1, vlowL);
vlow[vlowL] = '\0';
vhighL = strlen(rangeStr+1) - vlowL - 2;
- vhigh = (char *) apr_palloc(spool, sizeof(*vhigh * (vhighL+1)));
+ vhigh = (char *) malloc(sizeof(*vhigh * (vhighL+1)));
if (!vhigh) {
status = CELIX_ENOMEM;
} else {
@@ -155,12 +145,12 @@ celix_status_t versionRange_parse(apr_po
vhigh = strncpy(vhigh, rangeStr+vlowL+2, vhighL);
vhigh[vhighL] = '\0';
- status = version_createVersionFromString(pool, vlow, &versionLow);
+ status = version_createVersionFromString(vlow, &versionLow);
if (status == CELIX_SUCCESS) {
version_pt versionHigh = NULL;
- status = version_createVersionFromString(pool, vhigh, &versionHigh);
+ status = version_createVersionFromString(vhigh, &versionHigh);
if (status == CELIX_SUCCESS) {
- status = versionRange_createVersionRange(pool,
+ status = versionRange_createVersionRange(
versionLow,
start == '[',
versionHigh,
@@ -170,14 +160,12 @@ celix_status_t versionRange_parse(apr_po
}
}
}
- }
- apr_pool_destroy(spool);
}
} else {
version_pt version = NULL;
- status = version_createVersionFromString(pool, rangeStr, &version);
+ status = version_createVersionFromString(rangeStr, &version);
if (status == CELIX_SUCCESS) {
- status = versionRange_createVersionRange(pool, version, true, NULL, false, range);
+ status = versionRange_createVersionRange(version, true, NULL, false, range);
}
}
Modified: incubator/celix/trunk/framework/private/src/wire.c
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/private/src/wire.c?rev=1600110&r1=1600109&r2=1600110&view=diff
==============================================================================
--- incubator/celix/trunk/framework/private/src/wire.c (original)
+++ incubator/celix/trunk/framework/private/src/wire.c Wed Jun 4 11:27:07 2014
@@ -36,21 +36,17 @@ struct wire {
capability_pt capability;
};
-apr_status_t wire_destroy(void *handle);
-
-celix_status_t wire_create(apr_pool_t *pool, module_pt importer, requirement_pt requirement,
+celix_status_t wire_create(module_pt importer, requirement_pt requirement,
module_pt exporter, capability_pt capability, wire_pt *wire) {
celix_status_t status = CELIX_SUCCESS;
- if (*wire != NULL || pool == NULL) {
+ if (*wire != NULL) {
status = CELIX_ILLEGAL_ARGUMENT;
} else {
- (*wire) = (wire_pt) apr_palloc(pool, sizeof(**wire));
+ (*wire) = (wire_pt) malloc(sizeof(**wire));
if (!*wire) {
status = CELIX_ENOMEM;
} else {
- apr_pool_pre_cleanup_register(pool, *wire, wire_destroy);
-
(*wire)->importer = importer;
(*wire)->requirement = requirement;
(*wire)->exporter = exporter;
@@ -63,13 +59,12 @@ celix_status_t wire_create(apr_pool_t *p
return status;
}
-apr_status_t wire_destroy(void *handle) {
- wire_pt wire = (wire_pt) handle;
+celix_status_t wire_destroy(wire_pt wire) {
wire->importer = NULL;
wire->requirement = NULL;
wire->exporter = NULL;
wire->capability = NULL;
- return APR_SUCCESS;
+ return CELIX_SUCCESS;
}
celix_status_t wire_getCapability(wire_pt wire, capability_pt *capability) {
Modified: incubator/celix/trunk/framework/public/include/capability.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/public/include/capability.h?rev=1600110&r1=1600109&r2=1600110&view=diff
==============================================================================
--- incubator/celix/trunk/framework/public/include/capability.h (original)
+++ incubator/celix/trunk/framework/public/include/capability.h Wed Jun 4 11:27:07 2014
@@ -32,7 +32,8 @@ typedef struct capability *capability_pt
#include "hash_map.h"
#include "module.h"
-celix_status_t capability_create(apr_pool_t *pool, module_pt module, hash_map_pt directives, hash_map_pt attributes, capability_pt *capability);
+celix_status_t capability_create(module_pt module, hash_map_pt directives, hash_map_pt attributes, capability_pt *capability);
+celix_status_t capability_destroy(capability_pt capability);
celix_status_t capability_getServiceName(capability_pt capability, char **serviceName);
celix_status_t capability_getVersion(capability_pt capability, version_pt *version);
celix_status_t capability_getModule(capability_pt capability, module_pt *module);
Modified: incubator/celix/trunk/framework/public/include/requirement.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/public/include/requirement.h?rev=1600110&r1=1600109&r2=1600110&view=diff
==============================================================================
--- incubator/celix/trunk/framework/public/include/requirement.h (original)
+++ incubator/celix/trunk/framework/public/include/requirement.h Wed Jun 4 11:27:07 2014
@@ -33,7 +33,8 @@ typedef struct requirement *requirement_
#include "hash_map.h"
#include "version_range.h"
-celix_status_t requirement_create(apr_pool_t *pool, hash_map_pt directives, hash_map_pt attributes, requirement_pt *requirement);
+celix_status_t requirement_create(hash_map_pt directives, hash_map_pt attributes, requirement_pt *requirement);
+celix_status_t requirement_destroy(requirement_pt requirement);
celix_status_t requirement_getVersionRange(requirement_pt requirement, version_range_pt *range);
celix_status_t requirement_getTargetName(requirement_pt requirement, char **targetName);
Modified: incubator/celix/trunk/framework/public/include/version.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/public/include/version.h?rev=1600110&r1=1600109&r2=1600110&view=diff
==============================================================================
--- incubator/celix/trunk/framework/public/include/version.h (original)
+++ incubator/celix/trunk/framework/public/include/version.h Wed Jun 4 11:27:07 2014
@@ -46,7 +46,6 @@ typedef struct version * version_pt;
/**
* Creates a new version_pt using the supplied arguments.
*
- * @param pool The pool to create the version on.
* @param major Major component of the version identifier.
* @param minor Minor component of the version identifier.
* @param micro Micro component of the version identifier.
@@ -60,13 +59,14 @@ typedef struct version * version_pt;
* - CELIX_ILLEGAL_ARGUMENT If the numerical components are negative
* or the qualifier string is invalid.
*/
-FRAMEWORK_EXPORT celix_status_t version_createVersion(apr_pool_t *pool, int major, int minor, int micro, char * qualifier, version_pt *version);
+FRAMEWORK_EXPORT celix_status_t version_createVersion(int major, int minor, int micro, char * qualifier, version_pt *version);
+
+FRAMEWORK_EXPORT celix_status_t version_destroy(version_pt version);
/**
- * Creates a clone of <code>version</code> allocated on <code>pool</code>.
+ * Creates a clone of <code>version</code>.
*
* @param version The version to clone
- * @param pool The pool in which the clone must be allocated
* @param clone The cloned version
* @return Status code indication failure or success:
* - CELIX_SUCCESS when no errors are encountered.
@@ -74,7 +74,7 @@ FRAMEWORK_EXPORT celix_status_t version_
* - CELIX_ILLEGAL_ARGUMENT If the numerical components are negative
* or the qualifier string is invalid.
*/
-FRAMEWORK_EXPORT celix_status_t version_clone(version_pt version, apr_pool_t *pool, version_pt *clone);
+FRAMEWORK_EXPORT celix_status_t version_clone(version_pt version, version_pt *clone);
/**
* Creates a version identifier from the specified string.
@@ -94,7 +94,6 @@ FRAMEWORK_EXPORT celix_status_t version_
*
* There must be no whitespace in version.
*
- * @param pool The pool to create the version on.
* @param versionStr String representation of the version identifier.
* @param version The created version_pt
* @return Status code indication failure or success:
@@ -103,12 +102,11 @@ FRAMEWORK_EXPORT celix_status_t version_
* - CELIX_ILLEGAL_ARGUMENT If the numerical components are negative,
* the qualifier string is invalid or <code>versionStr</code> is improperly formatted.
*/
-FRAMEWORK_EXPORT celix_status_t version_createVersionFromString(apr_pool_t *pool, char * versionStr, version_pt *version);
+FRAMEWORK_EXPORT celix_status_t version_createVersionFromString(char * versionStr, version_pt *version);
/**
* The empty version "0.0.0".
*
- * @param pool The pool to create the version on.
* @param version The created version_pt
* @return Status code indication failure or success:
* - CELIX_SUCCESS when no errors are encountered.
@@ -116,7 +114,7 @@ FRAMEWORK_EXPORT celix_status_t version_
* - CELIX_ILLEGAL_ARGUMENT If the numerical components are negative,
* the qualifier string is invalid or <code>versionStr</code> is improperly formatted.
*/
-FRAMEWORK_EXPORT celix_status_t version_createEmptyVersion(apr_pool_t *pool, version_pt *version);
+FRAMEWORK_EXPORT celix_status_t version_createEmptyVersion(version_pt *version);
FRAMEWORK_EXPORT celix_status_t version_getMajor(version_pt version, int *major);
FRAMEWORK_EXPORT celix_status_t version_getMinor(version_pt version, int *minor);
@@ -160,12 +158,11 @@ FRAMEWORK_EXPORT celix_status_t version_
*
* @return The string representation of this version identifier.
* @param version The <code>version_pt</code> to get the string representation from.
- * @param pool The pool on which the string has to be allocated.
* @param string Pointer to the string (char *) in which the result will be placed.
* @return Status code indication failure or success:
* - CELIX_SUCCESS when no errors are encountered.
*/
-FRAMEWORK_EXPORT celix_status_t version_toString(version_pt version, apr_pool_t *pool, char **string);
+FRAMEWORK_EXPORT celix_status_t version_toString(version_pt version, char **string);
/**
* @}
Modified: incubator/celix/trunk/framework/public/include/version_range.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/public/include/version_range.h?rev=1600110&r1=1600109&r2=1600110&view=diff
==============================================================================
--- incubator/celix/trunk/framework/public/include/version_range.h (original)
+++ incubator/celix/trunk/framework/public/include/version_range.h Wed Jun 4 11:27:07 2014
@@ -46,7 +46,6 @@ typedef struct versionRange * version_ra
/**
* Creates a new <code>version_range_pt</code>.
*
- * @param pool The pool in which the version range is created
* @param low Lower bound version
* @param isLowInclusive True if lower bound should be included in the range
* @param high Upper bound version
@@ -56,19 +55,20 @@ typedef struct versionRange * version_ra
* - CELIX_SUCCESS when no errors are encountered.
* - CELIX_ENOMEM If allocating memory for <code>versionRange</code> failed.
*/
-celix_status_t versionRange_createVersionRange(apr_pool_t *pool, version_pt low, bool isLowInclusive, version_pt high, bool isHighInclusive, version_range_pt *versionRange);
+celix_status_t versionRange_createVersionRange(version_pt low, bool isLowInclusive, version_pt high, bool isHighInclusive, version_range_pt *versionRange);
/**
* Creates an infinite version range using ::version_createEmptyVersion for the low version,
* NULL for the high version and high and low inclusive set to true.
*
- * @param pool The pool in which the version range is created
* @param range The created range
* @return Status code indication failure or success:
* - CELIX_SUCCESS when no errors are encountered.
* - CELIX_ENOMEM If allocating memory for <code>range</code> failed.
*/
-celix_status_t versionRange_createInfiniteVersionRange(apr_pool_t *pool, version_range_pt *range);
+celix_status_t versionRange_createInfiniteVersionRange(version_range_pt *range);
+
+celix_status_t versionRange_destroy(version_range_pt range);
/**
* Determine if the specified version is part of the version range or not.
@@ -95,7 +95,6 @@ celix_status_t versionRange_isInRange(ve
* ceiling ::= version
* </pre>
*
- * @param pool The pool in which the range is created.
* @param rangeStr String representation of the version range.
* @param range The created version_range_pt.
* @return Status code indication failure or success:
@@ -104,7 +103,7 @@ celix_status_t versionRange_isInRange(ve
* - CELIX_ILLEGAL_ARGUMENT If the numerical components are negative,
* the qualifier string is invalid or <code>versionStr</code> is impropertly formatted.
*/
-celix_status_t versionRange_parse(apr_pool_t *pool, char * rangeStr, version_range_pt *range);
+celix_status_t versionRange_parse(char * rangeStr, version_range_pt *range);
/**
* @}
Modified: incubator/celix/trunk/framework/public/include/wire.h
URL: http://svn.apache.org/viewvc/incubator/celix/trunk/framework/public/include/wire.h?rev=1600110&r1=1600109&r2=1600110&view=diff
==============================================================================
--- incubator/celix/trunk/framework/public/include/wire.h (original)
+++ incubator/celix/trunk/framework/public/include/wire.h Wed Jun 4 11:27:07 2014
@@ -44,7 +44,6 @@ typedef struct wire *wire_pt;
/**
* Create a wire between two modules using a requirement and capability.
*
- * @param pool The pool in which the wire is created.
* @param importer The importer module of the wire.
* @param requirement The requirement of the importer.
* @param exporter The exporter module of the wire.
@@ -54,7 +53,7 @@ typedef struct wire *wire_pt;
* - CELIX_SUCCESS when no errors are encountered.
* - CELIX_ENOMEM If allocating memory for <code>wire</code> failed.
*/
-celix_status_t wire_create(apr_pool_t *pool, module_pt importer, requirement_pt requirement,
+celix_status_t wire_create(module_pt importer, requirement_pt requirement,
module_pt exporter, capability_pt capability, wire_pt *wire);
/**
@@ -63,6 +62,16 @@ celix_status_t wire_create(apr_pool_t *p
* @param wire The wire to get the capability from.
* @param capability The capability
* @return Status code indication failure or success:
+ * - CELIX_SUCCESS when no errors are encountered.
+ */
+celix_status_t wire_destroy(wire_pt wire);
+
+/**
+ * Getter for the capability of the exporting module.
+ *
+ * @param wire The wire to get the capability from.
+ * @param capability The capability
+ * @return Status code indication failure or success:
* - CELIX_SUCCESS when no errors are encountered.
*/
celix_status_t wire_getCapability(wire_pt wire, capability_pt *capability);