You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@celix.apache.org by pn...@apache.org on 2025/01/04 19:03:43 UTC
(celix) branch feature/674-remove-array-list-type-undefined created (now 6090b7aca)
This is an automated email from the ASF dual-hosted git repository.
pnoltes pushed a change to branch feature/674-remove-array-list-type-undefined
in repository https://gitbox.apache.org/repos/asf/celix.git
at 6090b7aca gh-674: Fix some wrong array element type issues
This branch includes the following new commits:
new c56cd2194 gh-674: Remove celix_arrayList_create symbol and refactor for removed symbol
new 6090b7aca gh-674: Fix some wrong array element type issues
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
(celix) 02/02: gh-674: Fix some wrong array element type issues
Posted by pn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
pnoltes pushed a commit to branch feature/674-remove-array-list-type-undefined
in repository https://gitbox.apache.org/repos/asf/celix.git
commit 6090b7aca1807f2c60cdb2eab9e417372fd02045
Author: Pepijn Noltes <pn...@apache.org>
AuthorDate: Sat Jan 4 19:57:03 2025 +0100
gh-674: Fix some wrong array element type issues
---
CHANGES.md | 1 +
libs/framework/src/framework.c | 2 +-
libs/utils/gtest/src/ArrayListTestSuite.cc | 48 +-----------------------------
libs/utils/include/celix_array_list.h | 2 +-
4 files changed, 4 insertions(+), 49 deletions(-)
diff --git a/CHANGES.md b/CHANGES.md
index 7da716829..0af6bd381 100644
--- a/CHANGES.md
+++ b/CHANGES.md
@@ -80,6 +80,7 @@ limitations under the License.
- The manifest format has been changed to JSON, and the manifest attribute names have been changed.
The old manifest format is no longer supported.
The old manifest attribute names are also no longer defined in `celix_constants.h`.
+- The funnction `celix_arrayList_create` has been removed, use the element type specific create functions instead.
## New Features
diff --git a/libs/framework/src/framework.c b/libs/framework/src/framework.c
index 7956e5379..8a0a0ac11 100644
--- a/libs/framework/src/framework.c
+++ b/libs/framework/src/framework.c
@@ -497,7 +497,7 @@ celix_status_t framework_start(celix_framework_t* framework) {
static celix_status_t framework_autoStartConfiguredBundles(celix_framework_t* fw, bool *startedAllBundles) {
celix_status_t status = CELIX_SUCCESS;
const char* const celixKeys[] = {CELIX_AUTO_START_0, CELIX_AUTO_START_1, CELIX_AUTO_START_2, CELIX_AUTO_START_3, CELIX_AUTO_START_4, CELIX_AUTO_START_5, CELIX_AUTO_START_6, NULL};
- celix_autoptr(celix_array_list_t) installedBundles = celix_arrayList_createPointerArray();
+ celix_autoptr(celix_array_list_t) installedBundles = celix_arrayList_createLongArray();
if (!installedBundles) {
celix_framework_logTssErrors(fw->logger, CELIX_LOG_LEVEL_ERROR);
return ENOMEM;
diff --git a/libs/utils/gtest/src/ArrayListTestSuite.cc b/libs/utils/gtest/src/ArrayListTestSuite.cc
index c77c3efe6..c16655c64 100644
--- a/libs/utils/gtest/src/ArrayListTestSuite.cc
+++ b/libs/utils/gtest/src/ArrayListTestSuite.cc
@@ -380,35 +380,10 @@ TEST_F(ArrayListTestSuite, SimpleRemovedCallbacksForArrayListTest) {
celix_arrayList_destroy(list); //will call free for every entry
}
-TEST_F(ArrayListTestSuite, AddStringToArrayListOfUndefinedTypeTest) {
- celix_array_list_create_options_t opts{};
- opts.simpleRemovedCallback = free;
- auto* list = celix_arrayList_createWithOptions(&opts);
- celix_arrayList_addString(list, celix_utils_strdup("value"));
- celix_arrayList_addString(list, celix_utils_strdup("value"));
- celix_arrayList_addString(list, celix_utils_strdup("value"));
- celix_arrayList_addString(list, celix_utils_strdup("value"));
- EXPECT_EQ(celix_arrayList_size(list), 4);
- celix_arrayList_destroy(list); //will call free for every entry
-}
-
-TEST_F(ArrayListTestSuite, AddVersionToArrayListOfUndefinedTypeTest) {
- celix_array_list_create_options_t opts{};
- opts.simpleRemovedCallback = [](void* data) {
- celix_version_destroy((celix_version_t*)data);
- };
- auto* list = celix_arrayList_createWithOptions(&opts);
- celix_arrayList_addVersion(list, celix_version_create(1, 3, 0, nullptr));
- celix_arrayList_addVersion(list, celix_version_create(1, 3, 0, nullptr));
- celix_arrayList_addVersion(list, celix_version_create(1, 3, 0, nullptr));
- celix_arrayList_addVersion(list, celix_version_create(1, 3, 0, nullptr));
- EXPECT_EQ(celix_arrayList_size(list), 4);
- celix_arrayList_destroy(list); //will call free for every entry
-}
-
TEST_F(ArrayListTestSuite, RemovedCallbacksForArrayListTest) {
int count = 0 ;
celix_array_list_create_options_t opts{};
+ opts.elementType = CELIX_ARRAY_LIST_ELEMENT_TYPE_LONG;
opts.removedCallbackData = &count;
opts.removedCallback = [](void *data, celix_array_list_entry_t entry) {
int* c = (int*)data;
@@ -454,27 +429,6 @@ TEST_F(ArrayListTestSuite, SortForArrayListTest) {
celix_arrayList_destroy(list);
}
-TEST_F(ArrayListTestSuite, ReturnStatusAddFunctionsTest) {
- auto* list = celix_arrayList_createLongArray();
- ASSERT_TRUE(list != nullptr);
- EXPECT_EQ(0, celix_arrayList_size(list));
-
- //no error, return status is CELIX_SUCCESS
- EXPECT_EQ(CELIX_SUCCESS, celix_arrayList_addLong(list, 2L));
- EXPECT_EQ(1, celix_arrayList_size(list));
-
- EXPECT_EQ(CELIX_SUCCESS, celix_arrayList_addDouble(list, 4.0));
- EXPECT_EQ(2, celix_arrayList_size(list));
-
- EXPECT_EQ(CELIX_SUCCESS, celix_arrayList_addBool(list, true));
- EXPECT_EQ(3, celix_arrayList_size(list));
-
- EXPECT_EQ(CELIX_SUCCESS, celix_arrayList_add(list, (void*)0x42));
- EXPECT_EQ(4, celix_arrayList_size(list));
-
- celix_arrayList_destroy(list);
-}
-
TEST_F(ArrayListTestSuite, AutoCleanupTest) {
celix_autoptr(celix_array_list_t) list = celix_arrayList_createPointerArray();
EXPECT_NE(nullptr, list);
diff --git a/libs/utils/include/celix_array_list.h b/libs/utils/include/celix_array_list.h
index d1390c759..630a6b65d 100644
--- a/libs/utils/include/celix_array_list.h
+++ b/libs/utils/include/celix_array_list.h
@@ -170,7 +170,7 @@ celix_array_list_t* celix_arrayList_createVersionArray();
*/
typedef struct celix_array_list_create_options {
/**
- * The element type of the array list. Default is CELIX_ARRAY_LIST_ELEMENT_TYPE_UNDEFINED.
+ * The element type of the array list. Default is CELIX_ARRAY_LIST_ELEMENT_TYPE_POINTER.
*/
celix_array_list_element_type_t elementType CELIX_OPTS_INIT;
(celix) 01/02: gh-674: Remove celix_arrayList_create symbol and refactor for removed symbol
Posted by pn...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
pnoltes pushed a commit to branch feature/674-remove-array-list-type-undefined
in repository https://gitbox.apache.org/repos/asf/celix.git
commit c56cd2194d547dcdb885b65522ea3064af23d0a3
Author: Pepijn Noltes <pn...@apache.org>
AuthorDate: Sat Jan 4 19:49:23 2025 +0100
gh-674: Remove celix_arrayList_create symbol and refactor for removed symbol
---
.../src/CelixEventAdminErrorInjectionTestSuite.cc | 6 +-
.../event_admin/src/celix_event_admin.c | 4 +-
bundles/http_admin/http_admin/src/http_admin.c | 2 +-
.../src/endpoint_descriptor_reader.c | 4 +-
.../src/endpoint_discovery_server.c | 2 +-
.../gtest/src/rsa_tests.cc | 4 +-
.../src/remote_service_admin_dfi.c | 8 +-
.../rsa_common/src/import_registration_impl.c | 2 +-
.../rsa_common/src/remote_interceptors_handler.c | 2 +-
.../src/TopologyManagerErrorInjectionTestSuite.cc | 6 +-
.../gtest/src/TopologyManagerTestSuite.cc | 4 +-
.../gtest/src/TopologyManagerTestSuiteBaseClass.h | 2 +-
.../topology_manager/src/topology_manager.c | 4 +-
.../tms_tst/disc_mock/disc_mock_activator.c | 2 +-
bundles/shell/remote_shell/src/remote_shell.c | 2 +-
bundles/shell/shell/src/Shell.cc | 2 +-
bundles/shell/shell/src/bundle_command.c | 2 +-
bundles/shell/shell/src/c_shell.c | 2 +-
bundles/shell/shell/src/dm_shell_list_command.c | 2 +-
bundles/shell/shell/src/query_command.c | 6 +-
bundles/shell/shell_tui/src/shell_tui.c | 2 +-
documents/components.md | 2 +-
documents/services.md | 2 +-
.../dm_example/phase3/src/phase3_cmp.c | 2 +-
.../component_with_service_dependency_activator.c | 2 +-
.../src/track_command_services_example.c | 2 +-
libs/framework/src/bundle.c | 4 +-
libs/framework/src/bundle_context.c | 10 +-
libs/framework/src/celix_framework_utils.c | 2 +-
libs/framework/src/celix_log.c | 2 +-
libs/framework/src/dm_component_impl.c | 12 +-
libs/framework/src/dm_dependency_manager_impl.c | 4 +-
libs/framework/src/framework.c | 24 ++--
libs/framework/src/service_registry.c | 88 +++++++------
libs/framework/src/service_tracker.c | 8 +-
...ntCapabilityModelWithErrorInjectionTestSuite.cc | 6 +-
libs/rcm/src/celix_resource.c | 4 +-
.../error_injector/celix_array_list/CMakeLists.txt | 1 +
.../celix_array_list/include/celix_array_list_ei.h | 4 +-
.../celix_array_list/src/celix_array_list_ei.cc | 14 +-
.../gtest/src/ArrayListErrorInjectionTestSuite.cc | 4 +-
libs/utils/gtest/src/ArrayListTestSuite.cc | 9 +-
.../src/ConvertUtilsErrorInjectionTestSuite.cc | 2 +-
libs/utils/gtest/src/ConvertUtilsTestSuite.cc | 4 +-
libs/utils/gtest/src/PropertiesTestSuite.cc | 2 +-
libs/utils/include/celix_array_list.h | 56 +++-----
libs/utils/src/array_list.c | 141 +++++++--------------
libs/utils/src/properties.c | 6 +-
48 files changed, 211 insertions(+), 276 deletions(-)
diff --git a/bundles/event_admin/event_admin/gtest/src/CelixEventAdminErrorInjectionTestSuite.cc b/bundles/event_admin/event_admin/gtest/src/CelixEventAdminErrorInjectionTestSuite.cc
index 248adba8a..71eabc71b 100644
--- a/bundles/event_admin/event_admin/gtest/src/CelixEventAdminErrorInjectionTestSuite.cc
+++ b/bundles/event_admin/event_admin/gtest/src/CelixEventAdminErrorInjectionTestSuite.cc
@@ -41,7 +41,7 @@ public:
celix_ei_expect_celixThreadRwlock_create(nullptr, 0, 0);
celix_ei_expect_celixThreadMutex_create(nullptr, 0, 0);
celix_ei_expect_celixThreadCondition_init(nullptr, 0, 0);
- celix_ei_expect_celix_arrayList_create(nullptr, 0, nullptr);
+ celix_ei_expect_celix_arrayList_createLongArray(nullptr, 0, nullptr);
celix_ei_expect_celix_stringHashMap_create(nullptr, 0, nullptr);
celix_ei_expect_celix_longHashMap_create(nullptr, 0, nullptr);
celix_ei_expect_celixThread_create(nullptr, 0, 0);
@@ -96,7 +96,7 @@ TEST_F(CelixEventAdminErrorInjectionTestSuite, FailedToCreateLockForEventAdminTe
}
TEST_F(CelixEventAdminErrorInjectionTestSuite, FailedToCreateChannelMatchingAllEventsForEventAdminTest) {
- celix_ei_expect_celix_arrayList_create((void*)&celix_eventAdmin_create, 0, nullptr);
+ celix_ei_expect_celix_arrayList_createLongArray((void*)&celix_eventAdmin_create, 0, nullptr);
auto ea = celix_eventAdmin_create(ctx.get());
EXPECT_EQ(nullptr, ea);
}
@@ -203,7 +203,7 @@ TEST_F(CelixEventAdminErrorInjectionTestSuite, FailedToSubscribeTopicTest) {
celix_ei_expect_calloc((void*)&celix_eventAdmin_addEventHandlerWithProperties, 2, nullptr);
TestSubscribeEvent("org/celix/test");
- celix_ei_expect_celix_arrayList_create((void*)&celix_eventAdmin_addEventHandlerWithProperties, 2, nullptr);
+ celix_ei_expect_celix_arrayList_createLongArray((void*)&celix_eventAdmin_addEventHandlerWithProperties, 2, nullptr);
TestSubscribeEvent("org/celix/test");
celix_ei_expect_celix_arrayList_addLong((void*)&celix_eventAdmin_addEventHandlerWithProperties, 2, CELIX_ENOMEM);
diff --git a/bundles/event_admin/event_admin/src/celix_event_admin.c b/bundles/event_admin/event_admin/src/celix_event_admin.c
index 2d02824a6..c01ea1269 100644
--- a/bundles/event_admin/event_admin/src/celix_event_admin.c
+++ b/bundles/event_admin/event_admin/src/celix_event_admin.c
@@ -103,7 +103,7 @@ celix_event_admin_t* celix_eventAdmin_create(celix_bundle_context_t* ctx) {
return NULL;
}
celix_autoptr(celix_thread_rwlock_t) lock = &ea->lock;
- celix_autoptr(celix_array_list_t) channelMatchingAllEvents = ea->channelMatchingAllEvents.eventHandlerSvcIdList = celix_arrayList_create();
+ celix_autoptr(celix_array_list_t) channelMatchingAllEvents = ea->channelMatchingAllEvents.eventHandlerSvcIdList = celix_arrayList_createLongArray();
if (channelMatchingAllEvents == NULL) {
celix_logHelper_logTssErrors(logHelper, CELIX_LOG_LEVEL_ERROR);
celix_logHelper_error(logHelper, "Failed to create event channel matching all events.");
@@ -233,7 +233,7 @@ static void celix_eventAdmin_addEventHandlerToChannels(celix_event_admin_t* ea,
celix_logHelper_error(ea->logHelper, "Failed to create event channel for topic %s", topic);
return;
}
- celix_autoptr(celix_array_list_t) eventHandlerSvcIdList = channel->eventHandlerSvcIdList = celix_arrayList_create();
+ celix_autoptr(celix_array_list_t) eventHandlerSvcIdList = channel->eventHandlerSvcIdList = celix_arrayList_createLongArray();
if (eventHandlerSvcIdList == NULL) {
celix_logHelper_logTssErrors(ea->logHelper, CELIX_LOG_LEVEL_ERROR);
celix_logHelper_error(ea->logHelper, "Failed to create event handlers list for topic %s", topic);
diff --git a/bundles/http_admin/http_admin/src/http_admin.c b/bundles/http_admin/http_admin/src/http_admin.c
index 7db8e1ea5..cf74701ee 100755
--- a/bundles/http_admin/http_admin/src/http_admin.c
+++ b/bundles/http_admin/http_admin/src/http_admin.c
@@ -72,7 +72,7 @@ http_admin_manager_t *httpAdmin_create(celix_bundle_context_t *context, char *ro
admin->infoSvcId = -1L;
status = celixThreadRwlock_create(&admin->admin_lock, NULL);
- admin->aliasList = celix_arrayList_create();
+ admin->aliasList = celix_arrayList_createPointerArray();
if (status == CELIX_SUCCESS) {
//Use only begin_request callback
diff --git a/bundles/remote_services/discovery_common/src/endpoint_descriptor_reader.c b/bundles/remote_services/discovery_common/src/endpoint_descriptor_reader.c
index 572305150..3558d5480 100644
--- a/bundles/remote_services/discovery_common/src/endpoint_descriptor_reader.c
+++ b/bundles/remote_services/discovery_common/src/endpoint_descriptor_reader.c
@@ -110,14 +110,14 @@ celix_status_t endpointDescriptorReader_parseDocument(endpoint_descriptor_reader
xmlChar *valueBuffer = xmlMalloc(256);
valueBuffer[0] = '\0';
- celix_array_list_t* propertyValues = celix_arrayList_create();
+ celix_array_list_t* propertyValues = celix_arrayList_createPointerArray();
celix_array_list_t* endpointDescriptions = NULL;
if (*endpoints) {
// use the given arraylist...
endpointDescriptions = *endpoints;
} else {
- endpointDescriptions = celix_arrayList_create();
+ endpointDescriptions = celix_arrayList_createPointerArray();
// return the read endpoints...
*endpoints = endpointDescriptions;
}
diff --git a/bundles/remote_services/discovery_common/src/endpoint_discovery_server.c b/bundles/remote_services/discovery_common/src/endpoint_discovery_server.c
index 4d6043cce..1afa2ad2f 100644
--- a/bundles/remote_services/discovery_common/src/endpoint_discovery_server.c
+++ b/bundles/remote_services/discovery_common/src/endpoint_discovery_server.c
@@ -307,7 +307,7 @@ static char* format_path(const char* path) {
}
static celix_status_t endpointDiscoveryServer_getEndpoints(endpoint_discovery_server_t *server, const char* the_endpoint_id, celix_array_list_t** endpoints) {
- *endpoints = celix_arrayList_create();
+ *endpoints = celix_arrayList_createPointerArray();
if (!(*endpoints)) {
return CELIX_ENOMEM;
}
diff --git a/bundles/remote_services/remote_service_admin_dfi/gtest/src/rsa_tests.cc b/bundles/remote_services/remote_service_admin_dfi/gtest/src/rsa_tests.cc
index 8d21c445b..7f4df3ac5 100644
--- a/bundles/remote_services/remote_service_admin_dfi/gtest/src/rsa_tests.cc
+++ b/bundles/remote_services/remote_service_admin_dfi/gtest/src/rsa_tests.cc
@@ -58,8 +58,8 @@ extern "C" {
static void testServicesCallback(void *handle CELIX_UNUSED, void *svc) {
auto* rsa = static_cast<remote_service_admin_service_t*>(svc);
- celix_array_list_t *exported = celix_arrayList_create();
- celix_array_list_t *imported = celix_arrayList_create();
+ celix_array_list_t *exported = celix_arrayList_createPointerArray();
+ celix_array_list_t *imported = celix_arrayList_createPointerArray();
int rc = rsa->getExportedServices(rsa->admin, &exported);
ASSERT_EQ(CELIX_SUCCESS, rc);
diff --git a/bundles/remote_services/remote_service_admin_dfi/src/remote_service_admin_dfi.c b/bundles/remote_services/remote_service_admin_dfi/src/remote_service_admin_dfi.c
index ee4400c95..e1427bf88 100644
--- a/bundles/remote_services/remote_service_admin_dfi/src/remote_service_admin_dfi.c
+++ b/bundles/remote_services/remote_service_admin_dfi/src/remote_service_admin_dfi.c
@@ -201,7 +201,7 @@ celix_status_t remoteServiceAdmin_create(celix_bundle_context_t *context, remote
} else {
(*admin)->context = context;
(*admin)->exportedServices = hashMap_create(NULL, NULL, NULL, NULL);
- (*admin)->importedServices = celix_arrayList_create();
+ (*admin)->importedServices = celix_arrayList_createPointerArray();
celixThreadRwlock_create(&(*admin)->exportedServicesLock, NULL);
celixThreadMutex_create(&(*admin)->importedServicesLock, NULL);
@@ -370,7 +370,7 @@ static void remoteServiceAdmin_setupStopExportsThread(remote_service_admin_t* ad
if (CELIX_RSA_USE_STOP_EXPORT_THREAD) {
//setup exports stop thread
celixThreadMutex_create(&admin->stopExportsMutex, NULL);
- admin->stopExports = celix_arrayList_create();
+ admin->stopExports = celix_arrayList_createPointerArray();
celixThreadCondition_init(&admin->stopExportsCond, NULL);
admin->stopExportsActive = true;
celixThread_create(&admin->stopExportsThread, NULL, remoteServiceAdmin_stopExportsThread, admin);
@@ -606,7 +606,7 @@ celix_status_t remoteServiceAdmin_exportService(remote_service_admin_t *admin, c
celix_array_list_t *registrations = NULL;
if (export) {
- registrations = celix_arrayList_create();
+ registrations = celix_arrayList_createPointerArray();
celix_array_list_t* references = NULL;
service_reference_pt reference = NULL;
char filter[256];
@@ -677,7 +677,7 @@ celix_status_t remoteServiceAdmin_exportService(remote_service_admin_t *admin, c
if (status == CELIX_SUCCESS) {
//We return a empty list of registrations if Remote Service Admin does not recognize any of the configuration types.
- celix_array_list_t *newRegistrations = celix_arrayList_create();
+ celix_array_list_t *newRegistrations = celix_arrayList_createPointerArray();
if (registrations != NULL) {
int regSize = celix_arrayList_size(registrations);
for (int i = 0; i < regSize; ++i) {
diff --git a/bundles/remote_services/rsa_common/src/import_registration_impl.c b/bundles/remote_services/rsa_common/src/import_registration_impl.c
index cea5ca365..3b32dfeec 100644
--- a/bundles/remote_services/rsa_common/src/import_registration_impl.c
+++ b/bundles/remote_services/rsa_common/src/import_registration_impl.c
@@ -86,7 +86,7 @@ celix_status_t importRegistrationFactory_create(celix_log_helper_t *helper, char
(*registration_factory)->context = context;
(*registration_factory)->bundle = NULL;
(*registration_factory)->loghelper = helper;
- (*registration_factory)->registrations = celix_arrayList_create();
+ (*registration_factory)->registrations = celix_arrayList_createPointerArray();
}
return status;
diff --git a/bundles/remote_services/rsa_common/src/remote_interceptors_handler.c b/bundles/remote_services/rsa_common/src/remote_interceptors_handler.c
index 25b700876..624df4875 100644
--- a/bundles/remote_services/rsa_common/src/remote_interceptors_handler.c
+++ b/bundles/remote_services/rsa_common/src/remote_interceptors_handler.c
@@ -56,7 +56,7 @@ celix_status_t remoteInterceptorsHandler_create(celix_bundle_context_t *ctx, rem
} else {
(*handler)->ctx = ctx;
- (*handler)->interceptors = celix_arrayList_create();
+ (*handler)->interceptors = celix_arrayList_createPointerArray();
status = celixThreadMutex_create(&(*handler)->lock, NULL);
diff --git a/bundles/remote_services/topology_manager/gtest/src/TopologyManagerErrorInjectionTestSuite.cc b/bundles/remote_services/topology_manager/gtest/src/TopologyManagerErrorInjectionTestSuite.cc
index 1faddaec2..4d8d23d43 100644
--- a/bundles/remote_services/topology_manager/gtest/src/TopologyManagerErrorInjectionTestSuite.cc
+++ b/bundles/remote_services/topology_manager/gtest/src/TopologyManagerErrorInjectionTestSuite.cc
@@ -116,7 +116,7 @@ public:
celix_ei_expect_calloc(nullptr, 0, nullptr);
celix_ei_expect_celix_longHashMap_put(nullptr, 0, 0);
celix_ei_expect_celix_longHashMap_create(nullptr, 0, nullptr);
- celix_ei_expect_celix_arrayList_create(nullptr, 0, nullptr);
+ celix_ei_expect_celix_arrayList_createPointerArray(nullptr, 0, nullptr);
celix_ei_expect_celix_properties_copy(nullptr, 0, nullptr);
celix_ei_expect_celix_properties_set(nullptr, 0, 0);
celix_ei_expect_celix_utils_strdup(nullptr, 0, nullptr);
@@ -193,7 +193,7 @@ TEST_F(TopologyManagerErrorInjectionTestSuite, PutingDynamicIpEndpointToRsaMapEr
TEST_F(TopologyManagerErrorInjectionTestSuite, CreateDynamicIpEndpointListErrorTest) {
TestExportServiceFailure([]() {
- celix_ei_expect_celix_arrayList_create((void*)&topologyManager_rsaAdded, 1, nullptr);
+ celix_ei_expect_celix_arrayList_createPointerArray((void*)&topologyManager_rsaAdded, 1, nullptr);
});
}
@@ -205,7 +205,7 @@ TEST_F(TopologyManagerErrorInjectionTestSuite, PutingDynamicIpEndpointListToMapE
TEST_F(TopologyManagerErrorInjectionTestSuite, CreatingRsaIfNameListErrorTest) {
TestExportServiceFailure([]() {
- celix_ei_expect_celix_arrayList_create((void*)&topologyManager_rsaAdded, 3, nullptr);
+ celix_ei_expect_celix_arrayList_createPointerArray((void*)&topologyManager_rsaAdded, 3, nullptr);
});
}
diff --git a/bundles/remote_services/topology_manager/gtest/src/TopologyManagerTestSuite.cc b/bundles/remote_services/topology_manager/gtest/src/TopologyManagerTestSuite.cc
index 6f3d028a1..370cd4918 100644
--- a/bundles/remote_services/topology_manager/gtest/src/TopologyManagerTestSuite.cc
+++ b/bundles/remote_services/topology_manager/gtest/src/TopologyManagerTestSuite.cc
@@ -274,7 +274,7 @@ TEST_F(TopologyManagerTestSuite, ExportEmptyRegistrationListTest) {
(void)admin;
(void)properties;
(void)serviceId;
- *registrations = celix_arrayList_create();
+ *registrations = celix_arrayList_createPointerArray();
return CELIX_SUCCESS;
},
[](void *handle, endpoint_description_t *endpoint, char *matchedFilter) -> celix_status_t {
@@ -337,7 +337,7 @@ TEST_F(TopologyManagerTestSuite, DynamicIpEndpointRsaPortNotSpecifiedTest) {
status = endpointDescription_create(endpointProps, &exportReg->exportReference.endpoint);
EXPECT_EQ(CELIX_SUCCESS, status);
exportReg->exportReference.reference = reference;
- *registrations = celix_arrayList_create();
+ *registrations = celix_arrayList_createPointerArray();
celix_arrayList_add(*registrations, exportReg);
bundleContext_ungetServiceReference(admin->ctx, reference);
diff --git a/bundles/remote_services/topology_manager/gtest/src/TopologyManagerTestSuiteBaseClass.h b/bundles/remote_services/topology_manager/gtest/src/TopologyManagerTestSuiteBaseClass.h
index 27540175e..bb026d3e2 100644
--- a/bundles/remote_services/topology_manager/gtest/src/TopologyManagerTestSuiteBaseClass.h
+++ b/bundles/remote_services/topology_manager/gtest/src/TopologyManagerTestSuiteBaseClass.h
@@ -124,7 +124,7 @@ public:
status = endpointDescription_create(endpointProps, &exportReg->exportReference.endpoint);
EXPECT_EQ(CELIX_SUCCESS, status);
exportReg->exportReference.reference = reference;
- *registrations = celix_arrayList_create();
+ *registrations = celix_arrayList_createPointerArray();
celix_arrayList_add(*registrations, exportReg);
bundleContext_ungetServiceReference(admin->ctx, reference);
diff --git a/bundles/remote_services/topology_manager/src/topology_manager.c b/bundles/remote_services/topology_manager/src/topology_manager.c
index 799017b8a..4ee5e8524 100644
--- a/bundles/remote_services/topology_manager/src/topology_manager.c
+++ b/bundles/remote_services/topology_manager/src/topology_manager.c
@@ -265,7 +265,7 @@ static celix_array_list_t* topologyManager_getNetworkInterfacesForPort(topology
celix_logHelper_error(tm->loghelper, "TOPOLOGY_MANAGER: Error getting interface names from config properties.");
return NULL;
}
- celix_autoptr(celix_array_list_t) _ifNames = celix_arrayList_create();
+ celix_autoptr(celix_array_list_t) _ifNames = celix_arrayList_createPointerArray();
if (_ifNames == NULL) {
celix_logHelper_error(tm->loghelper, "TOPOLOGY_MANAGER: Error creating array list for interface names.");
return NULL;
@@ -476,7 +476,7 @@ static void topologyManager_addDynamicIpEndpointsForExportedService(topology_man
return;
}
- celix_array_list_t* endpointList = celix_arrayList_create();
+ celix_array_list_t* endpointList = celix_arrayList_createPointerArray();
if (endpointList == NULL) {
celix_logHelper_error(tm->loghelper, "TOPOLOGY_MANAGER: Error creating array list for dynamic ip endpoints.");
return;
diff --git a/bundles/remote_services/topology_manager/tms_tst/disc_mock/disc_mock_activator.c b/bundles/remote_services/topology_manager/tms_tst/disc_mock/disc_mock_activator.c
index 5a8029ae2..27ae614b2 100644
--- a/bundles/remote_services/topology_manager/tms_tst/disc_mock/disc_mock_activator.c
+++ b/bundles/remote_services/topology_manager/tms_tst/disc_mock/disc_mock_activator.c
@@ -44,7 +44,7 @@ celix_status_t celix_bundleActivator_create(celix_bundle_context_t *context, voi
discMockService_create(act, &act->serv);
act->endpointListener = NULL;
act->endpointListenerService = NULL;
- act->endpointList = celix_arrayList_create();
+ act->endpointList = celix_arrayList_createPointerArray();
} else {
status = CELIX_ENOMEM;
}
diff --git a/bundles/shell/remote_shell/src/remote_shell.c b/bundles/shell/remote_shell/src/remote_shell.c
index e16ef2148..fc002de3d 100644
--- a/bundles/shell/remote_shell/src/remote_shell.c
+++ b/bundles/shell/remote_shell/src/remote_shell.c
@@ -65,7 +65,7 @@ celix_status_t remoteShell_create(shell_mediator_pt mediator, int maximumConnect
status = celixThreadMutex_create(&(*instance)->mutex, NULL);
if (status == CELIX_SUCCESS) {
- (*instance)->connections = celix_arrayList_create();
+ (*instance)->connections = celix_arrayList_createPointerArray();
if (!(*instance)->connections) {
free(*instance);
(*instance) = NULL;
diff --git a/bundles/shell/shell/src/Shell.cc b/bundles/shell/shell/src/Shell.cc
index b6df4e194..4f48b7dff 100644
--- a/bundles/shell/shell/src/Shell.cc
+++ b/bundles/shell/shell/src/Shell.cc
@@ -64,7 +64,7 @@ namespace celix {
* @return A celix array list with char*.
*/
celix_status_t getCommands(celix_array_list_t **commands) {
- auto* result = celix_arrayList_create();
+ auto* result = celix_arrayList_createPointerArray();
std::lock_guard<std::mutex> lck{mutex};
for (const auto& pair : entries) {
celix_arrayList_add(result, celix_utils_strdup(pair.first.c_str()));
diff --git a/bundles/shell/shell/src/bundle_command.c b/bundles/shell/shell/src/bundle_command.c
index c44e659c3..b17674fb1 100644
--- a/bundles/shell/shell/src/bundle_command.c
+++ b/bundles/shell/shell/src/bundle_command.c
@@ -33,7 +33,7 @@ bool bundleCommand_execute(void *handle, const char *constCommandLine, FILE *out
celix_autofree char* command = celix_utils_strdup(constCommandLine);
strtok_r(command, CELIX_SHELL_COMMAND_SEPARATOR, &savePtr); //ignore command name
sub = strtok_r(NULL, CELIX_SHELL_COMMAND_SEPARATOR, &savePtr);
- celix_autoptr(celix_array_list_t) bundleIds = celix_arrayList_create();
+ celix_autoptr(celix_array_list_t) bundleIds = celix_arrayList_createLongArray();
if (sub == NULL) {
fprintf(errStream, "Incorrect number of arguments.\n");
diff --git a/bundles/shell/shell/src/c_shell.c b/bundles/shell/shell/src/c_shell.c
index 364e5d893..c42d56c7e 100644
--- a/bundles/shell/shell/src/c_shell.c
+++ b/bundles/shell/shell/src/c_shell.c
@@ -113,7 +113,7 @@ celix_status_t shell_removeCommand(shell_t *shell, celix_shell_command_t *svc, c
celix_status_t shell_getCommands(shell_t *shell, celix_array_list_t **outCommands) {
celix_status_t status = CELIX_SUCCESS;
- celix_array_list_t *result = celix_arrayList_create();
+ celix_array_list_t *result = celix_arrayList_createPointerArray();
celixThreadRwlock_readLock(&shell->lock);
hash_map_iterator_t iter = hashMapIterator_construct(shell->commandServices);
diff --git a/bundles/shell/shell/src/dm_shell_list_command.c b/bundles/shell/shell/src/dm_shell_list_command.c
index 7148c27aa..40b60d950 100644
--- a/bundles/shell/shell/src/dm_shell_list_command.c
+++ b/bundles/shell/shell/src/dm_shell_list_command.c
@@ -33,7 +33,7 @@ static void parseCommandLine(const char*line, celix_array_list_t **requestedBund
// skip first argument since this is the command
strtok(str," ");
char* tok = strtok(NULL," ");
- *requestedBundleIds = celix_arrayList_create();
+ *requestedBundleIds = celix_arrayList_createLongArray();
while (tok) {
if (strncmp("wtf", tok, strlen("wtf")) == 0) {
*wtf = true;
diff --git a/bundles/shell/shell/src/query_command.c b/bundles/shell/shell/src/query_command.c
index 49eb73444..d908d7325 100644
--- a/bundles/shell/shell/src/query_command.c
+++ b/bundles/shell/shell/src/query_command.c
@@ -20,6 +20,8 @@
#include <string.h>
#include <stdlib.h>
+#include "celix_array_list_type.h"
+#include "celix_array_list.h"
#include "celix_bundle.h"
#include "celix_bundle_context.h"
#include "celix_constants.h"
@@ -178,8 +180,8 @@ bool queryCommand_execute(void *_ptr, const char *command_line_str, FILE *sout,
opts.queryProvided = true;
opts.queryRequested = true;
- opts.nameQueries = celix_arrayList_create();
- opts.filterQueries = celix_arrayList_create();
+ opts.nameQueries = celix_arrayList_createPointerArray();
+ opts.filterQueries = celix_arrayList_createPointerArray();
opts.useColors = celix_bundleContext_getPropertyAsBool(ctx, CELIX_SHELL_USE_ANSI_COLORS, CELIX_SHELL_USE_ANSI_COLORS_DEFAULT_VALUE);
bool validCommand = true;
diff --git a/bundles/shell/shell_tui/src/shell_tui.c b/bundles/shell/shell_tui/src/shell_tui.c
index 1d8e78f83..1241b1ed1 100644
--- a/bundles/shell/shell_tui/src/shell_tui.c
+++ b/bundles/shell/shell_tui/src/shell_tui.c
@@ -476,7 +476,7 @@ static int autoComplete(shell_tui_t* shellTui, celix_shell_t* shellSvc, char *in
celix_array_list_t* possibleCmdList = NULL;
shellSvc->getCommands(shellSvc->handle, &commandList);
int nrCmds = celix_arrayList_size(commandList);
- possibleCmdList = celix_arrayList_create();
+ possibleCmdList = celix_arrayList_createPointerArray();
for (int i = 0; i < nrCmds; i++) {
char *cmd = celix_arrayList_get(commandList, i);
diff --git a/documents/components.md b/documents/components.md
index 2b78893db..951344528 100644
--- a/documents/components.md
+++ b/documents/components.md
@@ -503,7 +503,7 @@ typedef struct component_with_service_dependency {
static component_with_service_dependency_t* componentWithServiceDependency_create() {
component_with_service_dependency_t* cmp = calloc(1, sizeof(*cmp));
celixThreadMutex_create(&cmp->mutex, NULL); // <-----------------------------------------------------------------<1>
- cmp->cmdShells = celix_arrayList_create();
+ cmp->cmdShells = celix_arrayList_createPointerArray();
return cmp;
}
diff --git a/documents/services.md b/documents/services.md
index 471895915..93235c1fd 100644
--- a/documents/services.md
+++ b/documents/services.md
@@ -566,7 +566,7 @@ static void removeShellCommandService(void* data,void* svc, const celix_properti
static celix_status_t track_command_services_example_start(track_command_services_example_data_t *data, celix_bundle_context_t *ctx) {
celixThreadMutex_create(&data->mutex, NULL);
- data->commandServices = celix_arrayList_create();
+ data->commandServices = celix_arrayList_createPointerArray();
celix_service_tracking_options_t opts = CELIX_EMPTY_SERVICE_TRACKING_OPTIONS;
opts.filter.serviceName = CELIX_SHELL_COMMAND_SERVICE_NAME;
diff --git a/examples/celix-examples/dm_example/phase3/src/phase3_cmp.c b/examples/celix-examples/dm_example/phase3/src/phase3_cmp.c
index 14dfc3043..25e630325 100644
--- a/examples/celix-examples/dm_example/phase3/src/phase3_cmp.c
+++ b/examples/celix-examples/dm_example/phase3/src/phase3_cmp.c
@@ -49,7 +49,7 @@ phase3_cmp_t *phase3_create() {
if (cmp != NULL) {
cmp->currentValue = 0.0;
cmp->running = false;
- cmp->phase2Services = celix_arrayList_create();
+ cmp->phase2Services = celix_arrayList_createPointerArray();
}
return cmp;
}
diff --git a/examples/celix-examples/readme_c_examples/src/component_with_service_dependency_activator.c b/examples/celix-examples/readme_c_examples/src/component_with_service_dependency_activator.c
index c0ccfc3a1..1072a2a80 100644
--- a/examples/celix-examples/readme_c_examples/src/component_with_service_dependency_activator.c
+++ b/examples/celix-examples/readme_c_examples/src/component_with_service_dependency_activator.c
@@ -33,7 +33,7 @@ typedef struct component_with_service_dependency {
static component_with_service_dependency_t* componentWithServiceDependency_create() {
component_with_service_dependency_t* cmp = calloc(1, sizeof(*cmp));
celixThreadMutex_create(&cmp->mutex, NULL); // <-----------------------------------------------------------------<1>
- cmp->cmdShells = celix_arrayList_create();
+ cmp->cmdShells = celix_arrayList_createPointerArray();
return cmp;
}
diff --git a/examples/celix-examples/readme_c_examples/src/track_command_services_example.c b/examples/celix-examples/readme_c_examples/src/track_command_services_example.c
index 815f2fb48..41175b5ee 100644
--- a/examples/celix-examples/readme_c_examples/src/track_command_services_example.c
+++ b/examples/celix-examples/readme_c_examples/src/track_command_services_example.c
@@ -54,7 +54,7 @@ static void removeShellCommandService(void* data,void* svc, const celix_properti
static celix_status_t track_command_services_example_start(track_command_services_example_data_t *data, celix_bundle_context_t *ctx) {
celixThreadMutex_create(&data->mutex, NULL);
- data->commandServices = celix_arrayList_create();
+ data->commandServices = celix_arrayList_createPointerArray();
celix_service_tracking_options_t opts = CELIX_EMPTY_SERVICE_TRACKING_OPTIONS;
opts.filter.serviceName = CELIX_SHELL_COMMAND_SERVICE_NAME;
diff --git a/libs/framework/src/bundle.c b/libs/framework/src/bundle.c
index 054b9bd56..3def4937c 100644
--- a/libs/framework/src/bundle.c
+++ b/libs/framework/src/bundle.c
@@ -52,7 +52,7 @@ celix_status_t celix_bundle_createFromArchive(celix_framework_t *framework, bund
bundle->framework = framework;
bundle->archive = archive;
- bundle->modules = celix_arrayList_create();
+ bundle->modules = celix_arrayList_createPointerArray();
bundle->state = OSGI_FRAMEWORK_BUNDLE_INSTALLED;
bundle->handle = NULL;
bundle->activator = NULL;
@@ -394,7 +394,7 @@ bool celix_bundle_isSystemBundle(const celix_bundle_t *bnd) {
celix_array_list_t* celix_bundle_listRegisteredServices(const celix_bundle_t *bnd) {
long bndId = celix_bundle_getId(bnd);
- celix_array_list_t* result = celix_arrayList_create();
+ celix_array_list_t* result = celix_arrayList_createPointerArray();
celix_array_list_t *svcIds = celix_serviceRegistry_listServiceIdsForOwner(bnd->framework->registry, bndId);
for (int i = 0; i < celix_arrayList_size(svcIds); ++i) {
long svcId = celix_arrayList_getLong(svcIds, i);
diff --git a/libs/framework/src/bundle_context.c b/libs/framework/src/bundle_context.c
index 0cd0d621e..e9e375ff9 100644
--- a/libs/framework/src/bundle_context.c
+++ b/libs/framework/src/bundle_context.c
@@ -68,7 +68,7 @@ celix_status_t bundleContext_create(framework_pt framework, celix_framework_logg
celixThreadRwlock_create(&context->lock, NULL);
- context->svcRegistrations = celix_arrayList_create();
+ context->svcRegistrations = celix_arrayList_createLongArray();
context->bundleTrackers = celix_longHashMap_create();
context->serviceTrackers = celix_longHashMap_create();
context->metaTrackers = celix_longHashMap_create();
@@ -745,7 +745,7 @@ static void bundleContext_cleanupBundleTrackers(bundle_context_t* ctx) {
trkId,
symbolicName);
if (!danglingTrkIds) {
- danglingTrkIds = celix_arrayList_create();
+ danglingTrkIds = celix_arrayList_createLongArray();
}
celix_arrayList_addLong(danglingTrkIds, trkId);
}
@@ -780,7 +780,7 @@ static void bundleContext_cleanupServiceTrackers(bundle_context_t* ctx) {
symbolicName,
entry->tracker ? entry->tracker->filter : "unknown");
if (danglingTrkIds == NULL) {
- danglingTrkIds = celix_arrayList_create();
+ danglingTrkIds = celix_arrayList_createLongArray();
}
celix_arrayList_addLong(danglingTrkIds, trkId);
}
@@ -815,7 +815,7 @@ static void bundleContext_cleanupServiceTrackerTrackers(bundle_context_t* ctx) {
symbolicName,
entry->serviceName ? entry->serviceName : "all");
if (danglingTrkIds == NULL) {
- danglingTrkIds = celix_arrayList_create();
+ danglingTrkIds = celix_arrayList_createLongArray();
}
celix_arrayList_addLong(danglingTrkIds, trkId);
}
@@ -845,7 +845,7 @@ static void bundleContext_cleanupServiceRegistration(bundle_context_t* ctx) {
"Dangling service registration with svcId %li, for bundle %s. "
"Add missing 'celix_bundleContext_unregisterService' calls.", svcId, symbolicName);
if (danglingSvcIds == NULL) {
- danglingSvcIds = celix_arrayList_create();
+ danglingSvcIds = celix_arrayList_createLongArray();
}
celix_arrayList_addLong(danglingSvcIds, svcId);
}
diff --git a/libs/framework/src/celix_framework_utils.c b/libs/framework/src/celix_framework_utils.c
index c49614069..693699753 100644
--- a/libs/framework/src/celix_framework_utils.c
+++ b/libs/framework/src/celix_framework_utils.c
@@ -209,7 +209,7 @@ bool celix_framework_utils_isBundleUrlValid(celix_framework_t *fw, const char *b
size_t celix_framework_utils_installBundleSet(celix_framework_t* fw, const char* bundleSet, bool autoStart) {
size_t installed = 0;
- celix_array_list_t* bundleIds = celix_arrayList_create();
+ celix_array_list_t* bundleIds = celix_arrayList_createLongArray();
char delims[] = ",";
char *savePtr = NULL;
char *bundles = celix_utils_strdup(bundleSet);
diff --git a/libs/framework/src/celix_log.c b/libs/framework/src/celix_log.c
index ebe3f236d..10f943a44 100644
--- a/libs/framework/src/celix_log.c
+++ b/libs/framework/src/celix_log.c
@@ -61,7 +61,7 @@ celix_framework_logger_t* celix_frameworkLogger_create(celix_log_level_e activeL
pthread_mutex_lock(&globalMutex);
if (globalLoggers == NULL) {
- globalLoggers = celix_arrayList_create();
+ globalLoggers = celix_arrayList_createPointerArray();
}
celix_arrayList_add(globalLoggers, logger);
pthread_mutex_unlock(&globalMutex);
diff --git a/libs/framework/src/dm_component_impl.c b/libs/framework/src/dm_component_impl.c
index f41c0f7f0..52f0be1f9 100644
--- a/libs/framework/src/dm_component_impl.c
+++ b/libs/framework/src/dm_component_impl.c
@@ -144,9 +144,9 @@ celix_dm_component_t* celix_dmComponent_createWithUUID(bundle_context_t *context
component->state = CELIX_DM_CMP_STATE_INACTIVE;
- component->providedInterfaces = celix_arrayList_create();
- component->dependencies = celix_arrayList_create();
- component->removedDependencies = celix_arrayList_create();
+ component->providedInterfaces = celix_arrayList_createPointerArray();
+ component->dependencies = celix_arrayList_createPointerArray();
+ component->removedDependencies = celix_arrayList_createPointerArray();
celixThreadMutex_create(&component->mutex, NULL);
component->isEnabled = false;
component->inTransition = false;
@@ -533,7 +533,7 @@ celix_status_t component_getInterfaces(celix_dm_component_t *component, celix_ar
}
celix_status_t celix_dmComponent_getInterfaces(celix_dm_component_t *component, celix_array_list_t **out) {
- celix_array_list_t* names = celix_arrayList_create();
+ celix_array_list_t* names = celix_arrayList_createPointerArray();
celixThreadMutex_lock(&component->mutex);
int size = celix_arrayList_size(component->providedInterfaces);
@@ -961,7 +961,7 @@ static celix_status_t celix_dmComponent_unregisterServices(celix_dm_component_t
continue;
}
if (ids == NULL) {
- ids = celix_arrayList_create();
+ ids = celix_arrayList_createLongArray();
}
celix_arrayList_addLong(ids, interface->svcId);
interface->svcId = -1L;
@@ -1037,7 +1037,7 @@ celix_status_t component_getComponentInfo(celix_dm_component_t *component, celix
celix_status_t celix_dmComponent_getComponentInfo(celix_dm_component_t *component, celix_dm_component_info_t** out) {
celix_dm_component_info_t* info = calloc(1, sizeof(*info));
- info->dependency_list = celix_arrayList_create();
+ info->dependency_list = celix_arrayList_createPointerArray();
celix_dmComponent_getInterfaces(component, &info->interfaces);
celixThreadMutex_lock(&component->mutex);
diff --git a/libs/framework/src/dm_dependency_manager_impl.c b/libs/framework/src/dm_dependency_manager_impl.c
index 4c27305c4..e72d5ce36 100644
--- a/libs/framework/src/dm_dependency_manager_impl.c
+++ b/libs/framework/src/dm_dependency_manager_impl.c
@@ -37,7 +37,7 @@ celix_dependency_manager_t* celix_private_dependencyManager_create(celix_bundle_
celix_dependency_manager_t *manager = calloc(1, sizeof(*manager));
if (manager != NULL) {
manager->ctx = context;
- manager->components = celix_arrayList_create();
+ manager->components = celix_arrayList_createPointerArray();
pthread_mutex_init(&manager->mutex, NULL);
}
return manager;
@@ -366,7 +366,7 @@ celix_status_t dependencyManager_getInfo(celix_dependency_manager_t *manager, dm
celixThreadMutex_lock(&manager->mutex);
if (info != NULL) {
- info->components = celix_arrayList_create();
+ info->components = celix_arrayList_createPointerArray();
size = celix_arrayList_size(manager->components);
for (i = 0; i < size; i += 1) {
celix_dm_component_t *cmp = celix_arrayList_get(manager->components, i);
diff --git a/libs/framework/src/framework.c b/libs/framework/src/framework.c
index 0bf7bda14..7956e5379 100644
--- a/libs/framework/src/framework.c
+++ b/libs/framework/src/framework.c
@@ -244,13 +244,13 @@ celix_status_t framework_create(framework_pt *out, celix_properties_t* config) {
framework->dispatcher.active = true;
framework->currentBundleId = CELIX_FRAMEWORK_BUNDLE_ID;
framework->installRequestMap = hashMap_create(utils_stringHash, utils_stringHash, utils_stringEquals, utils_stringEquals);
- framework->installedBundles.entries = celix_arrayList_create();
+ framework->installedBundles.entries = celix_arrayList_createPointerArray();
framework->configurationMap = config; //note form now on celix_framework_getConfigProperty* can be used
- framework->bundleListeners = celix_arrayList_create();
- framework->frameworkListeners = celix_arrayList_create();
+ framework->bundleListeners = celix_arrayList_createPointerArray();
+ framework->frameworkListeners = celix_arrayList_createPointerArray();
framework->dispatcher.eventQueueCap = (int)celix_framework_getConfigPropertyAsLong(framework, CELIX_FRAMEWORK_STATIC_EVENT_QUEUE_SIZE, CELIX_FRAMEWORK_DEFAULT_STATIC_EVENT_QUEUE_SIZE, NULL);
framework->dispatcher.eventQueue = malloc(sizeof(celix_framework_event_t) * framework->dispatcher.eventQueueCap);
- framework->dispatcher.dynamicEventQueue = celix_arrayList_create();
+ framework->dispatcher.dynamicEventQueue = celix_arrayList_createPointerArray();
framework->dispatcher.scheduledEvents = celix_longHashMap_create();
celix_framework_createAndStoreFrameworkUUID(framework);
@@ -284,7 +284,7 @@ celix_status_t framework_create(framework_pt *out, celix_properties_t* config) {
//setup framework bundle lifecycle handling
celixThreadCondition_init(&framework->bundleLifecycleHandling.cond, NULL);
celixThreadMutex_create(&framework->bundleLifecycleHandling.mutex, NULL);
- framework->bundleLifecycleHandling.bundleLifecycleHandlers = celix_arrayList_create();
+ framework->bundleLifecycleHandling.bundleLifecycleHandlers = celix_arrayList_createPointerArray();
*out = framework;
return status;
@@ -497,7 +497,7 @@ celix_status_t framework_start(celix_framework_t* framework) {
static celix_status_t framework_autoStartConfiguredBundles(celix_framework_t* fw, bool *startedAllBundles) {
celix_status_t status = CELIX_SUCCESS;
const char* const celixKeys[] = {CELIX_AUTO_START_0, CELIX_AUTO_START_1, CELIX_AUTO_START_2, CELIX_AUTO_START_3, CELIX_AUTO_START_4, CELIX_AUTO_START_5, CELIX_AUTO_START_6, NULL};
- celix_autoptr(celix_array_list_t) installedBundles = celix_arrayList_create();
+ celix_autoptr(celix_array_list_t) installedBundles = celix_arrayList_createPointerArray();
if (!installedBundles) {
celix_framework_logTssErrors(fw->logger, CELIX_LOG_LEVEL_ERROR);
return ENOMEM;
@@ -842,7 +842,7 @@ celix_status_t fw_addBundleListener(framework_pt framework, bundle_pt bundle, bu
celixThreadMutex_create(&bundleListener->useMutex, NULL);
celixThreadCondition_init(&bundleListener->useCond, NULL);
bundleListener->useCount = 1;
- celix_array_list_t* installedBundles = celix_arrayList_create();
+ celix_array_list_t* installedBundles = celix_arrayList_createPointerArray();
celixThreadMutex_lock(&framework->installedBundles.mutex);
int size = celix_arrayList_size(framework->installedBundles.entries);
@@ -1005,7 +1005,7 @@ static celix_status_t framework_markBundleResolved(framework_pt framework, celix
celix_array_list_t* framework_getBundles(framework_pt framework) {
//FIXME Note that this does not increase the use count of the bundle, which can lead to race conditions.
//promote to use the celix_bundleContext_useBundle(s) functions and deprecated this one
- celix_array_list_t* bundles = celix_arrayList_create();
+ celix_array_list_t* bundles = celix_arrayList_createPointerArray();
celixThreadMutex_lock(&framework->installedBundles.mutex);
int size = celix_arrayList_size(framework->installedBundles.entries);
@@ -1062,7 +1062,7 @@ static void* framework_shutdown(void *framework) {
celix_framework_waitForBundleLifecycleHandlers(fw);
- celix_array_list_t *stopEntries = celix_arrayList_create();
+ celix_array_list_t *stopEntries = celix_arrayList_createPointerArray();
celix_bundle_entry_t*fwEntry = NULL;
celixThreadMutex_lock(&fw->installedBundles.mutex);
int size = celix_arrayList_size(fw->installedBundles.entries);
@@ -1202,7 +1202,7 @@ static void celix_framework_addToEventQueue(celix_framework_t *fw, const celix_f
static void fw_handleEventRequest(celix_framework_t *framework, celix_framework_event_t* event) {
if (event->type == CELIX_BUNDLE_EVENT_TYPE) {
- celix_array_list_t *localListeners = celix_arrayList_create();
+ celix_array_list_t *localListeners = celix_arrayList_createPointerArray();
celixThreadMutex_lock(&framework->bundleListenerLock);
for (int i = 0; i < celix_arrayList_size(framework->bundleListeners); ++i) {
fw_bundle_listener_pt listener = celix_arrayList_get(framework->bundleListeners, i);
@@ -1528,7 +1528,7 @@ celix_status_t fw_invokeFrameworkListener(framework_pt framework, framework_list
static size_t celix_framework_useBundlesInternal(framework_t *fw, bool includeFrameworkBundle, bool onlyActive, void *callbackHandle, void(*use)(void *handle, const bundle_t *bnd)) {
size_t count = 0;
- celix_array_list_t *bundleIds = celix_arrayList_create();
+ celix_array_list_t *bundleIds = celix_arrayList_createLongArray();
celixThreadMutex_lock(&fw->installedBundles.mutex);
int size = celix_arrayList_size(fw->installedBundles.entries);
@@ -2389,7 +2389,7 @@ void celix_framework_updateBundleAsync(celix_framework_t *fw, long bndId, const
}
static celix_array_list_t* celix_framework_listBundlesInternal(celix_framework_t* framework, bool activeOnly) {
- celix_array_list_t* result = celix_arrayList_create();
+ celix_array_list_t* result = celix_arrayList_createLongArray();
celix_auto(celix_mutex_lock_guard_t) lock = celixMutexLockGuard_init(&framework->installedBundles.mutex);
for (int i = 0; i < celix_arrayList_size(framework->installedBundles.entries); ++i) {
celix_bundle_entry_t* entry = celix_arrayList_get(framework->installedBundles.entries, i);
diff --git a/libs/framework/src/service_registry.c b/libs/framework/src/service_registry.c
index b7e8e7dd7..d2ca91ab0 100644
--- a/libs/framework/src/service_registry.c
+++ b/libs/framework/src/service_registry.c
@@ -70,8 +70,8 @@ celix_service_registry_t* celix_serviceRegistry_create(framework_pt framework) {
reg->nextServiceId = 1L;
reg->serviceReferences = hashMap_create(NULL, NULL, NULL, NULL);
- reg->listenerHooks = celix_arrayList_create();
- reg->serviceListeners = celix_arrayList_create();
+ reg->listenerHooks = celix_arrayList_createPointerArray();
+ reg->serviceListeners = celix_arrayList_createPointerArray();
celixThreadMutex_create(®->pendingRegisterEvents.mutex, NULL);
celixThreadCondition_init(®->pendingRegisterEvents.cond, NULL);
@@ -150,7 +150,7 @@ celix_status_t serviceRegistry_getRegisteredServices(service_registry_pt registr
celix_array_list_t* regs = (celix_array_list_t*) hashMap_get(registry->serviceRegistrations, bundle);
if (regs != NULL) {
unsigned int i;
- *services = celix_arrayList_create();
+ *services = celix_arrayList_createPointerArray();
for (i = 0; i < celix_arrayList_size(regs); i++) {
service_registration_pt reg = celix_arrayList_get(regs, i);
@@ -178,7 +178,14 @@ celix_status_t serviceRegistry_registerServiceFactory(service_registry_pt regist
return serviceRegistry_registerServiceInternal(registry, bundle, serviceName, (const void *) factory, dictionary, 0 /*TODO*/, CELIX_DEPRECATED_FACTORY_SERVICE, registration);
}
-static celix_status_t serviceRegistry_registerServiceInternal(service_registry_pt registry, bundle_pt bundle, const char* serviceName, const void * serviceObject, celix_properties_t* dictionary, long reservedId, enum celix_service_type svcType, service_registration_pt *registration) {
+static celix_status_t serviceRegistry_registerServiceInternal(service_registry_pt registry,
+ bundle_pt bundle,
+ const char* serviceName,
+ const void* serviceObject,
+ celix_properties_t* dictionary,
+ long reservedId,
+ enum celix_service_type svcType,
+ service_registration_pt* registration) {
celix_array_list_t* regs;
long svcId = reservedId > 0 ? reservedId : celix_serviceRegistry_nextSvcId(registry);
@@ -186,44 +193,45 @@ static celix_status_t serviceRegistry_registerServiceInternal(service_registry_p
if (svcType == CELIX_DEPRECATED_FACTORY_SERVICE) {
celix_properties_set(dictionary, CELIX_FRAMEWORK_SERVICE_SCOPE, CELIX_FRAMEWORK_SERVICE_SCOPE_BUNDLE);
- *registration = serviceRegistration_createServiceFactory(registry->callback, bundle, serviceName,
- svcId, serviceObject,
- dictionary);
+ *registration = serviceRegistration_createServiceFactory(
+ registry->callback, bundle, serviceName, svcId, serviceObject, dictionary);
} else if (svcType == CELIX_FACTORY_SERVICE) {
celix_properties_set(dictionary, CELIX_FRAMEWORK_SERVICE_SCOPE, CELIX_FRAMEWORK_SERVICE_SCOPE_BUNDLE);
- *registration = celix_serviceRegistration_createServiceFactory(registry->callback, bundle, serviceName, svcId, (celix_service_factory_t*)serviceObject, dictionary);
- } else { //plain
+ *registration = celix_serviceRegistration_createServiceFactory(
+ registry->callback, bundle, serviceName, svcId, (celix_service_factory_t*)serviceObject, dictionary);
+ } else {
+ // plain
celix_properties_set(dictionary, CELIX_FRAMEWORK_SERVICE_SCOPE, CELIX_FRAMEWORK_SERVICE_SCOPE_SINGLETON);
- *registration = serviceRegistration_create(registry->callback, bundle, serviceName, svcId, serviceObject, dictionary);
+ *registration =
+ serviceRegistration_create(registry->callback, bundle, serviceName, svcId, serviceObject, dictionary);
}
- //printf("Registering service %li with name %s\n", svcId, serviceName);
+ // printf("Registering service %li with name %s\n", svcId, serviceName);
if (strcmp(OSGI_FRAMEWORK_LISTENER_HOOK_SERVICE_NAME, serviceName) == 0) {
serviceRegistry_addHooks(registry, serviceName, serviceObject, *registration);
}
- celixThreadRwlock_writeLock(®istry->lock);
- regs = (celix_array_list_t*) hashMap_get(registry->serviceRegistrations, bundle);
- if (regs == NULL) {
- regs = celix_arrayList_create();
+ celixThreadRwlock_writeLock(®istry->lock);
+ regs = (celix_array_list_t*)hashMap_get(registry->serviceRegistrations, bundle);
+ if (regs == NULL) {
+ regs = celix_arrayList_createPointerArray();
hashMap_put(registry->serviceRegistrations, bundle, regs);
}
celix_arrayList_add(regs, *registration);
- //update pending register event
+ // update pending register event
celix_increasePendingRegisteredEvent(registry, svcId);
celixThreadRwlock_unlock(®istry->lock);
+ // NOTE there is a race condition with celix_serviceRegistry_addServiceListener, as result
+ // a REGISTERED event can be triggered twice instead of once. The service tracker can deal with this.
+ // The handling of pending registered events is to ensure that the UNREGISTERING event is always
+ // after the 1 or 2 REGISTERED events.
- //NOTE there is a race condition with celix_serviceRegistry_addServiceListener, as result
- //a REGISTERED event can be triggered twice instead of once. The service tracker can deal with this.
- //The handling of pending registered events is to ensure that the UNREGISTERING event is always
- //after the 1 or 2 REGISTERED events.
-
- celix_serviceRegistry_serviceChanged(registry, OSGI_FRAMEWORK_SERVICE_EVENT_REGISTERED, *registration);
- //update pending register event count
+ celix_serviceRegistry_serviceChanged(registry, OSGI_FRAMEWORK_SERVICE_EVENT_REGISTERED, *registration);
+ // update pending register event count
celix_decreasePendingRegisteredEvent(registry, svcId);
- return CELIX_SUCCESS;
+ return CELIX_SUCCESS;
}
static celix_status_t serviceRegistry_unregisterService(service_registry_pt registry,
@@ -330,8 +338,8 @@ celix_status_t serviceRegistry_getServiceReferences(service_registry_pt registry
filter_pt filter,
celix_array_list_t** out) {
bool matchResult;
- celix_autoptr(celix_array_list_t) references = celix_arrayList_create();
- celix_autoptr(celix_array_list_t) matchingRegistrations = celix_arrayList_create();
+ celix_autoptr(celix_array_list_t) references = celix_arrayList_createPointerArray();
+ celix_autoptr(celix_array_list_t) matchingRegistrations = celix_arrayList_createPointerArray();
if (!references || !matchingRegistrations) {
fw_log(registry->framework->logger, CELIX_LOG_LEVEL_ERROR, "Cannot create service references, out of memory");
@@ -519,7 +527,7 @@ celix_status_t serviceRegistry_clearReferencesFor(service_registry_pt registry,
celix_status_t
serviceRegistry_getServicesInUse(service_registry_pt registry, bundle_pt bundle, celix_array_list_t** out) {
- celix_array_list_t* result = celix_arrayList_create();
+ celix_array_list_t* result = celix_arrayList_createPointerArray();
// LOCK
celixThreadRwlock_readLock(®istry->lock);
@@ -552,9 +560,9 @@ static celix_status_t serviceRegistry_addHooks(service_registry_pt registry, con
celix_service_registry_listener_hook_entry_t* entry = NULL;
- infos = celix_arrayList_create();
+ infos = celix_arrayList_createPointerArray();
celix_arrayList_add(infos, &info);
- listeners = celix_arrayList_create();
+ listeners = celix_arrayList_createPointerArray();
celixThreadRwlock_writeLock(®istry->lock);
long svcId = serviceRegistration_getServiceId(registration);
@@ -604,9 +612,9 @@ static celix_status_t serviceRegistry_removeHook(service_registry_pt registry, s
}
}
if (removedEntry != NULL) {
- infos = celix_arrayList_create();
+ infos = celix_arrayList_createPointerArray();
celix_arrayList_add(infos, &info);
- listeners = celix_arrayList_create();
+ listeners = celix_arrayList_createPointerArray();
for (int i = 0; i < celix_arrayList_size(registry->serviceListeners); ++i) {
celix_service_registry_service_listener_entry_t *listenerEntry = celix_arrayList_get(registry->serviceListeners, i);
celix_increaseCountServiceListener(listenerEntry);
@@ -640,10 +648,10 @@ static void serviceRegistry_callHooksForListenerFilter(service_registry_pt regis
info.context = ctx;
info.removed = removed;
info.filter = celix_filter_getFilterString(filter);
- celix_array_list_t *infos = celix_arrayList_create();
+ celix_array_list_t *infos = celix_arrayList_createPointerArray();
celix_arrayList_add(infos, &info);
- celix_array_list_t *hookRegistrations = celix_arrayList_create();
+ celix_array_list_t *hookRegistrations = celix_arrayList_createPointerArray();
celixThreadRwlock_readLock(®istry->lock);
unsigned size = celix_arrayList_size(registry->listenerHooks);
@@ -680,7 +688,7 @@ static celix_status_t serviceRegistry_getUsingBundles(service_registry_pt regist
celix_array_list_t* bundles = NULL;
hash_map_iterator_pt iter;
- bundles = celix_arrayList_create();
+ bundles = celix_arrayList_createPointerArray();
if (bundles == NULL) {
return CELIX_ENOMEM;
}
@@ -872,8 +880,8 @@ celix_array_list_t* celix_serviceRegistry_findServices(
return NULL;
}
- celix_array_list_t *result = celix_arrayList_create();
- celix_array_list_t* matchedRegistrations = celix_arrayList_create();
+ celix_array_list_t *result = celix_arrayList_createLongArray();
+ celix_array_list_t* matchedRegistrations = celix_arrayList_createPointerArray();
celixThreadRwlock_readLock(®istry->lock);
@@ -906,7 +914,7 @@ celix_array_list_t* celix_serviceRegistry_findServices(
celix_array_list_t* celix_serviceRegistry_listServiceIdsForOwner(celix_service_registry_t* registry, long bndId) {
- celix_array_list_t *result = celix_arrayList_create();
+ celix_array_list_t *result = celix_arrayList_createLongArray();
celixThreadRwlock_readLock(®istry->lock);
celix_bundle_t *bundle = framework_getBundleById(registry->framework, bndId);
celix_array_list_t *registrations = bundle != NULL ? hashMap_get(registry->serviceRegistrations, bundle) : NULL;
@@ -980,7 +988,7 @@ celix_status_t celix_serviceRegistry_addServiceListener(celix_service_registry_t
celixThreadMutex_create(&entry->mutex, NULL);
celixThreadCondition_init(&entry->cond, NULL);
- celix_array_list_t *references = celix_arrayList_create();
+ celix_array_list_t *references = celix_arrayList_createPointerArray();
celixThreadRwlock_writeLock(®istry->lock);
celix_arrayList_add(registry->serviceListeners, entry); //use count 1
@@ -1056,8 +1064,8 @@ celix_status_t celix_serviceRegistry_removeServiceListener(celix_service_registr
static void celix_serviceRegistry_serviceChanged(celix_service_registry_t *registry, celix_service_event_type_t eventType, service_registration_pt registration) {
celix_service_registry_service_listener_entry_t *entry;
- celix_array_list_t* retainedEntries = celix_arrayList_create();
- celix_array_list_t* matchedEntries = celix_arrayList_create();
+ celix_array_list_t* retainedEntries = celix_arrayList_createPointerArray();
+ celix_array_list_t* matchedEntries = celix_arrayList_createPointerArray();
celixThreadRwlock_readLock(®istry->lock);
for (int i = 0; i < celix_arrayList_size(registry->serviceListeners); ++i) {
diff --git a/libs/framework/src/service_tracker.c b/libs/framework/src/service_tracker.c
index d24d8198b..65c9c52d2 100644
--- a/libs/framework/src/service_tracker.c
+++ b/libs/framework/src/service_tracker.c
@@ -121,7 +121,7 @@ celix_status_t serviceTracker_createWithFilter(bundle_context_pt context, const
celixThreadMutex_create(&tracker->state.mutex, NULL);
celixThreadCondition_init(&tracker->state.condTracked, NULL);
celixThreadCondition_init(&tracker->state.condUntracking, NULL);
- tracker->state.trackedServices = celix_arrayList_create();
+ tracker->state.trackedServices = celix_arrayList_createPointerArray();
tracker->state.untrackedServiceCount = 0;
tracker->state.currentHighestServiceId = -1;
@@ -269,7 +269,7 @@ service_reference_pt serviceTracker_getServiceReference(service_tracker_t* track
celix_array_list_t* serviceTracker_getServiceReferences(service_tracker_t* tracker) {
//TODO deprecated warning -> not locked
- celix_array_list_t* references = celix_arrayList_create();
+ celix_array_list_t* references = celix_arrayList_createPointerArray();
celixThreadMutex_lock(&tracker->state.mutex);
for (int i = 0; i < celix_arrayList_size(tracker->state.trackedServices); i++) {
@@ -297,7 +297,7 @@ void *serviceTracker_getService(service_tracker_t* tracker) {
celix_array_list_t* serviceTracker_getServices(service_tracker_t* tracker) {
//TODO deprecated warning -> not locked, also make locked variant
- celix_array_list_t* references = celix_arrayList_create();
+ celix_array_list_t* references = celix_arrayList_createPointerArray();
celixThreadMutex_lock(&tracker->state.mutex);
for (int i = 0; i < celix_arrayList_size(tracker->state.trackedServices); i++) {
@@ -684,7 +684,7 @@ celix_service_tracker_t* celix_serviceTracker_createClosedWithOptions(celix_bund
celixThreadMutex_create(&tracker->state.mutex, NULL);
celixThreadCondition_init(&tracker->state.condTracked, NULL);
celixThreadCondition_init(&tracker->state.condUntracking, NULL);
- tracker->state.trackedServices = celix_arrayList_create();
+ tracker->state.trackedServices = celix_arrayList_createPointerArray();
tracker->state.untrackedServiceCount = 0;
tracker->state.currentHighestServiceId = -1;
diff --git a/libs/rcm/gtest/src/RequirementCapabilityModelWithErrorInjectionTestSuite.cc b/libs/rcm/gtest/src/RequirementCapabilityModelWithErrorInjectionTestSuite.cc
index 4c827d593..4ac83c092 100644
--- a/libs/rcm/gtest/src/RequirementCapabilityModelWithErrorInjectionTestSuite.cc
+++ b/libs/rcm/gtest/src/RequirementCapabilityModelWithErrorInjectionTestSuite.cc
@@ -39,7 +39,7 @@ public:
celix_ei_expect_malloc(nullptr, 0, nullptr);
celix_ei_expect_celix_utils_strdup(nullptr, 0, nullptr);
celix_ei_expect_celix_arrayList_createWithOptions(nullptr, 0, nullptr);
- celix_ei_expect_celix_arrayList_create(nullptr, 0, nullptr);
+ celix_ei_expect_celix_arrayList_createPointerArray(nullptr, 0, nullptr);
celix_ei_expect_celix_arrayList_add(nullptr, 0, CELIX_SUCCESS);
celix_ei_expect_celix_utils_strdup(nullptr, 0, nullptr);
celix_ei_expect_vasprintf(nullptr, 0, 0);
@@ -96,7 +96,7 @@ TEST_F(RequirementCapabilityModelWithErrorInjectionTestSuite, TestResourceErrorH
//inject error on first celix_arrayList_create call from celix_resource_addCapability
celix_capability_t* cap = celix_capability_create(res, "test");
- celix_ei_expect_celix_arrayList_create((void*)celix_resource_addCapability, 0, nullptr);
+ celix_ei_expect_celix_arrayList_createPointerArray((void*)celix_resource_addCapability, 0, nullptr);
EXPECT_EQ(CELIX_ENOMEM, celix_resource_addCapability(res, cap));
EXPECT_EQ(3, celix_err_getErrorCount());
@@ -114,7 +114,7 @@ TEST_F(RequirementCapabilityModelWithErrorInjectionTestSuite, TestResourceErrorH
//inject error on first celix_arrayList_create call from celix_resource_addRequirement
celix_requirement_t* req = celix_requirement_create(res, "test", nullptr);
- celix_ei_expect_celix_arrayList_create((void*)celix_resource_addRequirement, 0, nullptr);
+ celix_ei_expect_celix_arrayList_createPointerArray((void*)celix_resource_addRequirement, 0, nullptr);
EXPECT_EQ(CELIX_ENOMEM, celix_resource_addRequirement(res, req));
EXPECT_EQ(6, celix_err_getErrorCount());
diff --git a/libs/rcm/src/celix_resource.c b/libs/rcm/src/celix_resource.c
index c5b5c5c67..32e49747f 100644
--- a/libs/rcm/src/celix_resource.c
+++ b/libs/rcm/src/celix_resource.c
@@ -110,7 +110,7 @@ celix_status_t celix_resource_addCapability(celix_resource_t* res, celix_capabil
const char* ns = celix_capability_getNamespace(cap);
celix_array_list_t* caps = celix_stringHashMap_get(res->capabilitiesByNamespace, ns);
if (caps == NULL) {
- caps = celix_arrayList_create();
+ caps = celix_arrayList_createPointerArray();
if (caps == NULL) {
goto err_handling;
}
@@ -140,7 +140,7 @@ celix_status_t celix_resource_addRequirement(celix_resource_t* res, celix_requir
const char* ns = celix_requirement_getNamespace(req);
celix_array_list_t* reqs = celix_stringHashMap_get(res->requirementsByNamespace, ns);
if (reqs == NULL) {
- reqs = celix_arrayList_create();
+ reqs = celix_arrayList_createPointerArray();
if (reqs == NULL) {
goto err_handling;
}
diff --git a/libs/utils/error_injector/celix_array_list/CMakeLists.txt b/libs/utils/error_injector/celix_array_list/CMakeLists.txt
index 2962dba59..f9bf9ede1 100644
--- a/libs/utils/error_injector/celix_array_list/CMakeLists.txt
+++ b/libs/utils/error_injector/celix_array_list/CMakeLists.txt
@@ -22,6 +22,7 @@ target_link_libraries(array_list_ei PUBLIC Celix::error_injector Celix::utils)
target_link_options(array_list_ei INTERFACE
LINKER:--wrap,celix_arrayList_create
LINKER:--wrap,celix_arrayList_createWithOptions
+ LINKER:--wrap,celix_arrayList_createPointerArray
LINKER:--wrap,celix_arrayList_createStringArray
LINKER:--wrap,celix_arrayList_createLongArray
LINKER:--wrap,celix_arrayList_copy
diff --git a/libs/utils/error_injector/celix_array_list/include/celix_array_list_ei.h b/libs/utils/error_injector/celix_array_list/include/celix_array_list_ei.h
index 3a6067a6e..8f4d4f85e 100644
--- a/libs/utils/error_injector/celix_array_list/include/celix_array_list_ei.h
+++ b/libs/utils/error_injector/celix_array_list/include/celix_array_list_ei.h
@@ -26,10 +26,10 @@ extern "C" {
#include "celix_array_list.h"
#include "celix_error_injector.h"
-CELIX_EI_DECLARE(celix_arrayList_create, celix_array_list_t*);
-
CELIX_EI_DECLARE(celix_arrayList_createWithOptions, celix_array_list_t*);
+ CELIX_EI_DECLARE(celix_arrayList_createPointerArray, celix_array_list_t*);
+
CELIX_EI_DECLARE(celix_arrayList_createStringArray, celix_array_list_t*);
CELIX_EI_DECLARE(celix_arrayList_createLongArray, celix_array_list_t*);
diff --git a/libs/utils/error_injector/celix_array_list/src/celix_array_list_ei.cc b/libs/utils/error_injector/celix_array_list/src/celix_array_list_ei.cc
index c7d02c055..9d00dfa45 100644
--- a/libs/utils/error_injector/celix_array_list/src/celix_array_list_ei.cc
+++ b/libs/utils/error_injector/celix_array_list/src/celix_array_list_ei.cc
@@ -22,13 +22,6 @@
extern "C" {
-celix_array_list_t* __real_celix_arrayList_create(void);
-CELIX_EI_DEFINE(celix_arrayList_create, celix_array_list_t*)
-celix_array_list_t* __wrap_celix_arrayList_create(void) {
- CELIX_EI_IMPL(celix_arrayList_create);
- return __real_celix_arrayList_create();
-}
-
celix_array_list_t* __real_celix_arrayList_createWithOptions(const celix_array_list_create_options_t* opts);
CELIX_EI_DEFINE(celix_arrayList_createWithOptions, celix_array_list_t*)
celix_array_list_t* __wrap_celix_arrayList_createWithOptions(const celix_array_list_create_options_t* opts) {
@@ -43,6 +36,13 @@ celix_array_list_t* __wrap_celix_arrayList_copy(const celix_array_list_t* list)
return __real_celix_arrayList_copy(list);
}
+void *__real_celix_arrayList_createPointerArray();
+CELIX_EI_DEFINE(celix_arrayList_createPointerArray, celix_array_list_t*)
+void *__wrap_celix_arrayList_createPointerArray() {
+ CELIX_EI_IMPL(celix_arrayList_createPointerArray);
+ return __real_celix_arrayList_createPointerArray();
+}
+
void *__real_celix_arrayList_createStringArray();
CELIX_EI_DEFINE(celix_arrayList_createStringArray, celix_array_list_t*)
void *__wrap_celix_arrayList_createStringArray() {
diff --git a/libs/utils/gtest/src/ArrayListErrorInjectionTestSuite.cc b/libs/utils/gtest/src/ArrayListErrorInjectionTestSuite.cc
index 6f95a4a6d..8fa5c076a 100644
--- a/libs/utils/gtest/src/ArrayListErrorInjectionTestSuite.cc
+++ b/libs/utils/gtest/src/ArrayListErrorInjectionTestSuite.cc
@@ -41,14 +41,14 @@ TEST_F(ArrayListErrorInjectionTestSuite, CreateTest) {
//Given an error is injected for calloc (used for the array struct)
celix_ei_expect_calloc((void *)celix_arrayList_createWithOptions, 0, nullptr);
//Then creating an array list should fail
- EXPECT_EQ(nullptr, celix_arrayList_create());
+ EXPECT_EQ(nullptr, celix_arrayList_createPointerArray());
//And an error is logged to the celix_err
EXPECT_EQ(1, celix_err_getErrorCount());
//Given an error is injected for malloc (used for the element data)
celix_ei_expect_calloc((void *)celix_arrayList_createWithOptions, 0, nullptr, 2);
//Then creating an array list should fail
- EXPECT_EQ(nullptr, celix_arrayList_create());
+ EXPECT_EQ(nullptr, celix_arrayList_createPointerArray());
//And an error is logged to the celix_err
EXPECT_EQ(2, celix_err_getErrorCount());
}
diff --git a/libs/utils/gtest/src/ArrayListTestSuite.cc b/libs/utils/gtest/src/ArrayListTestSuite.cc
index c9219b9fb..c77c3efe6 100644
--- a/libs/utils/gtest/src/ArrayListTestSuite.cc
+++ b/libs/utils/gtest/src/ArrayListTestSuite.cc
@@ -30,7 +30,7 @@ public:
};
TEST_F(ArrayListTestSuite, CreateDestroyArrayListTest) {
- auto* list = celix_arrayList_create();
+ auto* list = celix_arrayList_createPointerArray();
EXPECT_TRUE(list != nullptr);
EXPECT_EQ(0, celix_arrayList_size(list));
celix_arrayList_destroy(list);
@@ -431,7 +431,7 @@ TEST_F(ArrayListTestSuite, RemovedCallbacksForArrayListTest) {
}
TEST_F(ArrayListTestSuite, SortForArrayListTest) {
- auto* list = celix_arrayList_create();
+ auto* list = celix_arrayList_createLongArray();
celix_arrayList_addLong(list, 3);
celix_arrayList_addLong(list, 2);
celix_arrayList_addLong(list, 1);
@@ -455,7 +455,7 @@ TEST_F(ArrayListTestSuite, SortForArrayListTest) {
}
TEST_F(ArrayListTestSuite, ReturnStatusAddFunctionsTest) {
- auto* list = celix_arrayList_create();
+ auto* list = celix_arrayList_createLongArray();
ASSERT_TRUE(list != nullptr);
EXPECT_EQ(0, celix_arrayList_size(list));
@@ -476,7 +476,7 @@ TEST_F(ArrayListTestSuite, ReturnStatusAddFunctionsTest) {
}
TEST_F(ArrayListTestSuite, AutoCleanupTest) {
- celix_autoptr(celix_array_list_t) list = celix_arrayList_create();
+ celix_autoptr(celix_array_list_t) list = celix_arrayList_createPointerArray();
EXPECT_NE(nullptr, list);
}
@@ -497,7 +497,6 @@ TEST_F(ArrayListTestSuite, ReallocTest) {
}
TEST_F(ArrayListTestSuite, ElementTypeToStringTest) {
- EXPECT_STREQ("Undefined", celix_arrayList_elementTypeToString(CELIX_ARRAY_LIST_ELEMENT_TYPE_UNDEFINED));
EXPECT_STREQ("Pointer", celix_arrayList_elementTypeToString(CELIX_ARRAY_LIST_ELEMENT_TYPE_POINTER));
EXPECT_STREQ("String", celix_arrayList_elementTypeToString(CELIX_ARRAY_LIST_ELEMENT_TYPE_STRING));
EXPECT_STREQ("Long", celix_arrayList_elementTypeToString(CELIX_ARRAY_LIST_ELEMENT_TYPE_LONG));
diff --git a/libs/utils/gtest/src/ConvertUtilsErrorInjectionTestSuite.cc b/libs/utils/gtest/src/ConvertUtilsErrorInjectionTestSuite.cc
index 76a3659a1..edb6e85f1 100644
--- a/libs/utils/gtest/src/ConvertUtilsErrorInjectionTestSuite.cc
+++ b/libs/utils/gtest/src/ConvertUtilsErrorInjectionTestSuite.cc
@@ -84,7 +84,7 @@ TEST_F(ConvertUtilsWithErrorInjectionTestSuite, ConvertToLongArrayTest) {
//Then the result is null and the status is ENOMEM
EXPECT_EQ(status, CELIX_ENOMEM);
- celix_autoptr(celix_array_list_t) defaultList = celix_arrayList_create();
+ celix_autoptr(celix_array_list_t) defaultList = celix_arrayList_createLongArray();
//Given an error injection for celix_arrayList_copy
celix_ei_expect_celix_arrayList_copy((void*)celix_utils_convertStringToLongArrayList, 1, nullptr);
diff --git a/libs/utils/gtest/src/ConvertUtilsTestSuite.cc b/libs/utils/gtest/src/ConvertUtilsTestSuite.cc
index 95a683c64..a73f4013f 100644
--- a/libs/utils/gtest/src/ConvertUtilsTestSuite.cc
+++ b/libs/utils/gtest/src/ConvertUtilsTestSuite.cc
@@ -326,7 +326,7 @@ TEST_F(ConvertUtilsTestSuite, ConvertToLongArrayTest) {
EXPECT_EQ(CELIX_ILLEGAL_ARGUMENT, convertState);
EXPECT_TRUE(result == nullptr);
- celix_autoptr(celix_array_list_t) defaultList = celix_arrayList_create();
+ celix_autoptr(celix_array_list_t) defaultList = celix_arrayList_createLongArray();
celix_arrayList_addLong(defaultList, 42L);
convertState = celix_utils_convertStringToLongArrayList("1,2,3,invalid", defaultList, &result);
EXPECT_EQ(CELIX_ILLEGAL_ARGUMENT, convertState);
@@ -570,8 +570,6 @@ TEST_F(ConvertUtilsTestSuite, VersionArrayToStringTest) {
TEST_F(ConvertUtilsTestSuite, InvalidArgumentsForArrayToStringTest) {
EXPECT_EQ(nullptr, celix_utils_arrayListToString(nullptr));
- celix_autoptr(celix_array_list_t) list1 = celix_arrayList_create(); //unsupported undefined type
- EXPECT_EQ(nullptr, celix_utils_arrayListToString(list1));
celix_autoptr(celix_array_list_t) list2 = celix_arrayList_createPointerArray(); //unsupported pointer type
EXPECT_EQ(nullptr, celix_utils_arrayListToString(list2));
}
diff --git a/libs/utils/gtest/src/PropertiesTestSuite.cc b/libs/utils/gtest/src/PropertiesTestSuite.cc
index bfb908783..be2f6d584 100644
--- a/libs/utils/gtest/src/PropertiesTestSuite.cc
+++ b/libs/utils/gtest/src/PropertiesTestSuite.cc
@@ -674,7 +674,7 @@ TEST_F(PropertiesTestSuite, InvalidArgumentsTest) {
EXPECT_EQ(CELIX_ILLEGAL_ARGUMENT, celix_properties_assignString(props, nullptr, strdup("value")));
- celix_autoptr(celix_array_list_t) list1 = celix_arrayList_create();
+ celix_autoptr(celix_array_list_t) list1 = celix_arrayList_createPointerArray();
celix_autoptr(celix_array_list_t) list2 = celix_arrayList_createStringArray();
celix_autoptr(celix_array_list_t) list3 = celix_arrayList_createPointerArray();
diff --git a/libs/utils/include/celix_array_list.h b/libs/utils/include/celix_array_list.h
index 8393bc238..d1390c759 100644
--- a/libs/utils/include/celix_array_list.h
+++ b/libs/utils/include/celix_array_list.h
@@ -17,7 +17,8 @@
* under the License.
*/
-#include <stdbool.h>
+#ifndef CELIX_ARRAY_LIST_H_
+#define CELIX_ARRAY_LIST_H_
#include "celix_array_list_type.h"
#include "celix_utils_export.h"
@@ -25,9 +26,6 @@
#include "celix_errno.h"
#include "celix_version_type.h"
-#ifndef CELIX_ARRAY_LIST_H_
-#define CELIX_ARRAY_LIST_H_
-
/**
* Init macro so that the opts are correctly initialized for C++ compilers
*/
@@ -52,13 +50,12 @@ extern "C" {
* @brief An enumeration of the types of elements that can be stored in a Celix array list.
*/
typedef enum celix_array_list_element_type {
- CELIX_ARRAY_LIST_ELEMENT_TYPE_UNDEFINED = 0, /**< Represents an undefined element type. */
- CELIX_ARRAY_LIST_ELEMENT_TYPE_POINTER = 1, /**< Represents a pointer element type. */
- CELIX_ARRAY_LIST_ELEMENT_TYPE_STRING = 2, /**< Represents a string element type where the array list is the owner */
- CELIX_ARRAY_LIST_ELEMENT_TYPE_LONG = 3, /**< Represents a long integer element type. */
- CELIX_ARRAY_LIST_ELEMENT_TYPE_DOUBLE = 4, /**< Represents a double element type. */
- CELIX_ARRAY_LIST_ELEMENT_TYPE_BOOL = 5, /**< Represents a boolean element type. */
- CELIX_ARRAY_LIST_ELEMENT_TYPE_VERSION = 6, /**< Represents a celix_version_t* element type. */
+ CELIX_ARRAY_LIST_ELEMENT_TYPE_POINTER = 0, /**< Represents a pointer element type. */
+ CELIX_ARRAY_LIST_ELEMENT_TYPE_STRING = 1, /**< Represents a string element type where the array list is the owner */
+ CELIX_ARRAY_LIST_ELEMENT_TYPE_LONG = 2, /**< Represents a long integer element type. */
+ CELIX_ARRAY_LIST_ELEMENT_TYPE_DOUBLE = 3, /**< Represents a double element type. */
+ CELIX_ARRAY_LIST_ELEMENT_TYPE_BOOL = 4, /**< Represents a boolean element type. */
+ CELIX_ARRAY_LIST_ELEMENT_TYPE_VERSION = 5, /**< Represents a celix_version_t* element type. */
} celix_array_list_element_type_t;
/**
@@ -68,19 +65,16 @@ typedef enum celix_array_list_element_type {
* This union can hold different types of values, including pointers, strings, integers, long integers,
* unsigned integers, unsigned long integers, doubles, floats, booleans, and size_t values.
*/
-typedef union celix_array_list_entry {
- void* voidPtrVal; /**< A pointer value when the element type is CELIX_ARRAY_LIST_ELEMENT_TYPE_PTR or
- CELIX_ARRAY_LIST_ELEMENT_TYPE_UNDEFINED. */
- const char* stringVal; /**< A string value when the element type is CELIX_ARRAY_LIST_ELEMENT_TYPE_STRING,
- CELIX_ARRAY_LIST_ELEMENT_TYPE_STRING_REF or CELIX_ARRAY_LIST_ELEMENT_TYPE_UNDEFINED. */
- long int longVal; /**< A long integer value when the element type is CELIX_ARRAY_LIST_ELEMENT_TYPE_LONG or
- CELIX_ARRAY_LIST_ELEMENT_TYPE_UNDEFINED. */
- double doubleVal; /**< A double value when the element type is CELIX_ARRAY_LIST_ELEMENT_TYPE_DOUBLE or
- CELIX_ARRAY_LIST_ELEMENT_TYPE_UNDEFINED. */
- bool boolVal; /**< A boolean value when the element type is CELIX_ARRAY_LIST_ELEMENT_TYPE_BOOL or
- CELIX_ARRAY_LIST_ELEMENT_TYPE_UNDEFINED. */
- const celix_version_t* versionVal; /**< A celix_version_t* value when the element type is
- CELIX_ARRAY_LIST_ELEMENT_TYPE_VERSION or CELIX_ARRAY_LIST_ELEMENT_TYPE_UNDEFINED. */
+typedef union celix_array_list_entry
+{
+ void* voidPtrVal; /**< A pointer value when the element type is CELIX_ARRAY_LIST_ELEMENT_TYPE_PTR. */
+ const char* stringVal;
+ /**< A string value when the element type is CELIX_ARRAY_LIST_ELEMENT_TYPE_STRING or CELIX_ARRAY_LIST_ELEMENT_TYPE_STRING_REF. */
+ long int longVal; /**< A long integer value when the element type is CELIX_ARRAY_LIST_ELEMENT_TYPE_LONG. */
+ double doubleVal; /**< A double value when the element type is CELIX_ARRAY_LIST_ELEMENT_TYPE_DOUBLE. */
+ bool boolVal; /**< A boolean value when the element type is CELIX_ARRAY_LIST_ELEMENT_TYPE_BOOL. */
+ const celix_version_t* versionVal;
+ /**< A celix_version_t* value when the element type is CELIX_ARRAY_LIST_ELEMENT_TYPE_VERSION. */
} celix_array_list_entry_t;
/**
@@ -99,18 +93,6 @@ typedef int (*celix_array_list_compare_entries_fp)(celix_array_list_entry_t a, c
*/
typedef celix_status_t (*celix_array_list_copy_entry_fp)(celix_array_list_entry_t src, celix_array_list_entry_t* dst);
-/**
- * @brief Creates a new empty array list with an undefined element type.
- * @deprecated Use celix_arrayList_createWithOptions or celix_arrayList_create<Type>Array instead.
- *
- * The remove, equals and compare callback will be NULL.
- *
- * @return A new empty array list or NULL if the array list could not be created. If NULL is returned an error message
- * is logged to celix_err.
- */
-CELIX_UTILS_DEPRECATED_EXPORT
-celix_array_list_t* celix_arrayList_create();
-
/**
* @brief Creates a new empty array list with a pointer element type where the array list is not the owner of the
* pointers.
@@ -252,7 +234,7 @@ typedef struct celix_array_list_create_options {
*/
#define CELIX_EMPTY_ARRAY_LIST_CREATE_OPTIONS \
{ \
- .elementType = CELIX_ARRAY_LIST_ELEMENT_TYPE_UNDEFINED, .simpleRemovedCallback = NULL, \
+ .elementType = CELIX_ARRAY_LIST_ELEMENT_TYPE_POINTER, .simpleRemovedCallback = NULL, \
.removedCallbackData = NULL, .removedCallback = NULL, .equalsCallback = NULL, \
.compareCallback = NULL, .copyCallback = NULL, \
}
diff --git a/libs/utils/src/array_list.c b/libs/utils/src/array_list.c
index 361525f2e..6ffb27dc5 100644
--- a/libs/utils/src/array_list.c
+++ b/libs/utils/src/array_list.c
@@ -17,12 +17,13 @@
* under the License.
*/
-#include <assert.h>
+#include "celix_array_list_type.h"
+#include "celix_array_list.h"
+#include <assert.h>
#include <stdlib.h>
#include <string.h>
-#include "celix_array_list.h"
#include "celix_err.h"
#include "celix_stdlib_cleanup.h"
#include "celix_utils.h"
@@ -49,10 +50,6 @@ struct celix_array_list {
void (*removedCallback)(void* data, celix_array_list_entry_t entry);
};
-static bool celix_arrayList_undefinedEquals(celix_array_list_entry_t a, celix_array_list_entry_t b) {
- return memcmp(&a.voidPtrVal, &b.voidPtrVal, sizeof(a)) == 0;
-}
-
static int celix_arrayList_comparePtrEntries(celix_array_list_entry_t a, celix_array_list_entry_t b) {
return a.voidPtrVal > b.voidPtrVal ? 1 : (a.voidPtrVal < b.voidPtrVal ? -1 : 0);
}
@@ -101,7 +98,7 @@ static bool celix_arrayList_versionEquals(celix_array_list_entry_t a, celix_arra
return celix_arrayList_compareVersionEntries(a, b) == 0;
}
-inline static bool celix_arrayList_equalsForElement(celix_array_list_t *list, celix_array_list_entry_t a, celix_array_list_entry_t b) {
+static bool celix_arrayList_equalsForElement(const celix_array_list_t* list, celix_array_list_entry_t a, celix_array_list_entry_t b) {
// by class invariant, equalsCallback is never NULL
return list->equalsCallback(a, b);
}
@@ -129,7 +126,7 @@ static void celix_arrayList_destroyVersion(void* v) {
celix_version_destroy(version);
}
-static void celix_arrayList_callRemovedCallback(celix_array_list_t *list, int index) {
+static void celix_arrayList_callRemovedCallback(celix_array_list_t* list, int index) {
celix_array_list_entry_t entry = list->elementData[index];
if (list->simpleRemovedCallback != NULL) {
list->simpleRemovedCallback(entry.voidPtrVal);
@@ -184,10 +181,6 @@ static void celix_arrayList_setTypeSpecificCallbacks(celix_array_list_t* list) {
list->compareCallback = celix_arrayList_compareVersionEntries;
list->copyCallback = celix_arrayList_copyVersionEntry;
break;
- default:
- assert(list->elementType == CELIX_ARRAY_LIST_ELEMENT_TYPE_UNDEFINED);
- list->equalsCallback = celix_arrayList_undefinedEquals;
- break;
}
}
@@ -234,10 +227,6 @@ static celix_array_list_t* celix_arrayList_createTypedArray(celix_array_list_ele
return celix_arrayList_createWithOptions(&opts);
}
-celix_array_list_t* celix_arrayList_create() {
- return celix_arrayList_createTypedArray(CELIX_ARRAY_LIST_ELEMENT_TYPE_UNDEFINED);
-}
-
celix_array_list_t* celix_arrayList_createPointerArray() {
return celix_arrayList_createTypedArray(CELIX_ARRAY_LIST_ELEMENT_TYPE_POINTER);
}
@@ -292,32 +281,27 @@ celix_array_list_entry_t celix_arrayList_getEntry(const celix_array_list_t *list
}
void* celix_arrayList_get(const celix_array_list_t* list, int index) {
- assert(list->elementType == CELIX_ARRAY_LIST_ELEMENT_TYPE_POINTER ||
- list->elementType == CELIX_ARRAY_LIST_ELEMENT_TYPE_UNDEFINED);
+ assert(list->elementType == CELIX_ARRAY_LIST_ELEMENT_TYPE_POINTER);
return arrayList_getEntry(list, index).voidPtrVal;
}
const char* celix_arrayList_getString(const celix_array_list_t* list, int index) {
- assert(list->elementType == CELIX_ARRAY_LIST_ELEMENT_TYPE_STRING ||
- list->elementType == CELIX_ARRAY_LIST_ELEMENT_TYPE_UNDEFINED);
+ assert(list->elementType == CELIX_ARRAY_LIST_ELEMENT_TYPE_STRING);
return arrayList_getEntry(list, index).stringVal;
}
long int celix_arrayList_getLong(const celix_array_list_t* list, int index) {
- assert(list->elementType == CELIX_ARRAY_LIST_ELEMENT_TYPE_LONG ||
- list->elementType == CELIX_ARRAY_LIST_ELEMENT_TYPE_UNDEFINED);
+ assert(list->elementType == CELIX_ARRAY_LIST_ELEMENT_TYPE_LONG);
return arrayList_getEntry(list, index).longVal;
}
double celix_arrayList_getDouble(const celix_array_list_t* list, int index) {
- assert(list->elementType == CELIX_ARRAY_LIST_ELEMENT_TYPE_DOUBLE ||
- list->elementType == CELIX_ARRAY_LIST_ELEMENT_TYPE_UNDEFINED);
+ assert(list->elementType == CELIX_ARRAY_LIST_ELEMENT_TYPE_DOUBLE);
return arrayList_getEntry(list, index).doubleVal;
}
bool celix_arrayList_getBool(const celix_array_list_t* list, int index) {
- assert(list->elementType == CELIX_ARRAY_LIST_ELEMENT_TYPE_BOOL ||
- list->elementType == CELIX_ARRAY_LIST_ELEMENT_TYPE_UNDEFINED);
+ assert(list->elementType == CELIX_ARRAY_LIST_ELEMENT_TYPE_BOOL);
return arrayList_getEntry(list, index).boolVal;
}
@@ -342,27 +326,19 @@ static celix_status_t celix_arrayList_addEntry(celix_array_list_t* list, celix_a
celix_status_t celix_arrayList_add(celix_array_list_t* list, void* element) {
assert(element);
- assert(list->elementType == CELIX_ARRAY_LIST_ELEMENT_TYPE_POINTER ||
- list->elementType == CELIX_ARRAY_LIST_ELEMENT_TYPE_UNDEFINED);
- celix_array_list_entry_t entry;
- memset(&entry, 0, sizeof(entry));
+ assert(list->elementType == CELIX_ARRAY_LIST_ELEMENT_TYPE_POINTER);
+ celix_array_list_entry_t entry = {0};
entry.voidPtrVal = element;
return celix_arrayList_addEntry(list, entry);
}
celix_status_t celix_arrayList_addString(celix_array_list_t* list, const char* val) {
assert(val);
- assert(list->elementType == CELIX_ARRAY_LIST_ELEMENT_TYPE_STRING ||
- list->elementType == CELIX_ARRAY_LIST_ELEMENT_TYPE_UNDEFINED);
- celix_array_list_entry_t entry;
- memset(&entry, 0, sizeof(entry));
- if (list->elementType == CELIX_ARRAY_LIST_ELEMENT_TYPE_STRING) {
- entry.stringVal = celix_utils_strdup(val);
- if (entry.stringVal == NULL) {
- return ENOMEM;
- }
- } else {
- entry.stringVal = val;
+ assert(list->elementType == CELIX_ARRAY_LIST_ELEMENT_TYPE_STRING);
+ celix_array_list_entry_t entry = {0};
+ entry.stringVal = celix_utils_strdup(val);
+ if (entry.stringVal == NULL) {
+ return ENOMEM;
}
return celix_arrayList_addEntry(list, entry);
}
@@ -370,52 +346,39 @@ celix_status_t celix_arrayList_addString(celix_array_list_t* list, const char* v
celix_status_t celix_arrayList_assignString(celix_array_list_t* list, char* value) {
assert(value);
assert(list->elementType == CELIX_ARRAY_LIST_ELEMENT_TYPE_STRING);
- celix_array_list_entry_t entry;
- memset(&entry, 0, sizeof(entry));
+ celix_array_list_entry_t entry = {0};
entry.stringVal = value;
return celix_arrayList_addEntry(list, entry);
}
celix_status_t celix_arrayList_addLong(celix_array_list_t* list, long val) {
- assert(list->elementType == CELIX_ARRAY_LIST_ELEMENT_TYPE_LONG ||
- list->elementType == CELIX_ARRAY_LIST_ELEMENT_TYPE_UNDEFINED);
- celix_array_list_entry_t entry;
- memset(&entry, 0, sizeof(entry));
+ assert(list->elementType == CELIX_ARRAY_LIST_ELEMENT_TYPE_LONG);
+ celix_array_list_entry_t entry = {0};
entry.longVal = val;
return celix_arrayList_addEntry(list, entry);
}
celix_status_t celix_arrayList_addDouble(celix_array_list_t* list, double val) {
- assert(list->elementType == CELIX_ARRAY_LIST_ELEMENT_TYPE_DOUBLE ||
- list->elementType == CELIX_ARRAY_LIST_ELEMENT_TYPE_UNDEFINED);
- celix_array_list_entry_t entry;
- memset(&entry, 0, sizeof(entry));
+ assert(list->elementType == CELIX_ARRAY_LIST_ELEMENT_TYPE_DOUBLE);
+ celix_array_list_entry_t entry = {0};
entry.doubleVal = val;
return celix_arrayList_addEntry(list, entry);
}
celix_status_t celix_arrayList_addBool(celix_array_list_t* list, bool val) {
- assert(list->elementType == CELIX_ARRAY_LIST_ELEMENT_TYPE_BOOL ||
- list->elementType == CELIX_ARRAY_LIST_ELEMENT_TYPE_UNDEFINED);
- celix_array_list_entry_t entry;
- memset(&entry, 0, sizeof(entry));
+ assert(list->elementType == CELIX_ARRAY_LIST_ELEMENT_TYPE_BOOL);
+ celix_array_list_entry_t entry = {0};
entry.boolVal = val;
return celix_arrayList_addEntry(list, entry);
}
celix_status_t celix_arrayList_addVersion(celix_array_list_t* list, const celix_version_t* value) {
assert(value);
- assert(list->elementType == CELIX_ARRAY_LIST_ELEMENT_TYPE_VERSION ||
- list->elementType == CELIX_ARRAY_LIST_ELEMENT_TYPE_UNDEFINED);
- celix_array_list_entry_t entry;
- memset(&entry, 0, sizeof(entry));
- if (list->elementType == CELIX_ARRAY_LIST_ELEMENT_TYPE_VERSION) {
- entry.versionVal = celix_version_copy(value);
- if (entry.versionVal == NULL) {
- return ENOMEM;
- }
- } else {
- entry.versionVal = value;
+ assert(list->elementType == CELIX_ARRAY_LIST_ELEMENT_TYPE_VERSION);
+ celix_array_list_entry_t entry = {0};
+ entry.versionVal = celix_version_copy(value);
+ if (entry.versionVal == NULL) {
+ return ENOMEM;
}
return celix_arrayList_addEntry(list, entry);
}
@@ -423,17 +386,15 @@ celix_status_t celix_arrayList_addVersion(celix_array_list_t* list, const celix_
celix_status_t celix_arrayList_assignVersion(celix_array_list_t* list, celix_version_t* value) {
assert(value);
assert(list->elementType == CELIX_ARRAY_LIST_ELEMENT_TYPE_VERSION);
- celix_array_list_entry_t entry;
- memset(&entry, 0, sizeof(entry));
+ celix_array_list_entry_t entry = {0};
entry.versionVal = value;
return celix_arrayList_addEntry(list, entry);
}
int celix_arrayList_indexOf(celix_array_list_t *list, celix_array_list_entry_t entry) {
- size_t size = celix_arrayList_size(list);
- int i;
+ const size_t size = celix_arrayList_size(list);
int index = -1;
- for (i = 0 ; i < size ; ++i) {
+ for (int i = 0 ; i < size ; ++i) {
bool eq = celix_arrayList_equalsForElement(list, entry, list->elementData[i]);
if (eq) {
index = i;
@@ -457,55 +418,43 @@ void celix_arrayList_removeEntry(celix_array_list_t *list, celix_array_list_entr
}
void celix_arrayList_remove(celix_array_list_t* list, void* ptr) {
- assert(list->elementType == CELIX_ARRAY_LIST_ELEMENT_TYPE_POINTER ||
- list->elementType == CELIX_ARRAY_LIST_ELEMENT_TYPE_UNDEFINED);
- celix_array_list_entry_t entry;
- memset(&entry, 0, sizeof(entry));
+ assert(list->elementType == CELIX_ARRAY_LIST_ELEMENT_TYPE_POINTER);
+ celix_array_list_entry_t entry = {0};
entry.voidPtrVal = ptr;
celix_arrayList_removeEntry(list, entry);
}
void celix_arrayList_removeString(celix_array_list_t* list, const char* val) {
- assert(list->elementType == CELIX_ARRAY_LIST_ELEMENT_TYPE_STRING ||
- list->elementType == CELIX_ARRAY_LIST_ELEMENT_TYPE_UNDEFINED);
- celix_array_list_entry_t entry;
- memset(&entry, 0, sizeof(entry));
+ assert(list->elementType == CELIX_ARRAY_LIST_ELEMENT_TYPE_STRING);
+ celix_array_list_entry_t entry = {0};
entry.stringVal = val;
celix_arrayList_removeEntry(list, entry);
}
void celix_arrayList_removeLong(celix_array_list_t* list, long val) {
- assert(list->elementType == CELIX_ARRAY_LIST_ELEMENT_TYPE_LONG ||
- list->elementType == CELIX_ARRAY_LIST_ELEMENT_TYPE_UNDEFINED);
- celix_array_list_entry_t entry;
- memset(&entry, 0, sizeof(entry));
+ assert(list->elementType == CELIX_ARRAY_LIST_ELEMENT_TYPE_LONG);
+ celix_array_list_entry_t entry = {0};
entry.longVal = val;
celix_arrayList_removeEntry(list, entry);
}
void celix_arrayList_removeDouble(celix_array_list_t* list, double val) {
- assert(list->elementType == CELIX_ARRAY_LIST_ELEMENT_TYPE_DOUBLE ||
- list->elementType == CELIX_ARRAY_LIST_ELEMENT_TYPE_UNDEFINED);
- celix_array_list_entry_t entry;
- memset(&entry, 0, sizeof(entry));
+ assert(list->elementType == CELIX_ARRAY_LIST_ELEMENT_TYPE_DOUBLE);
+ celix_array_list_entry_t entry = {0};
entry.doubleVal = val;
celix_arrayList_removeEntry(list, entry);
}
void celix_arrayList_removeBool(celix_array_list_t* list, bool val) {
- assert(list->elementType == CELIX_ARRAY_LIST_ELEMENT_TYPE_BOOL ||
- list->elementType == CELIX_ARRAY_LIST_ELEMENT_TYPE_UNDEFINED);
- celix_array_list_entry_t entry;
- memset(&entry, 0, sizeof(entry));
+ assert(list->elementType == CELIX_ARRAY_LIST_ELEMENT_TYPE_BOOL);
+ celix_array_list_entry_t entry = {0};
entry.boolVal = val;
celix_arrayList_removeEntry(list, entry);
}
void celix_arrayList_removeVersion(celix_array_list_t* list, const celix_version_t* val) {
- assert(list->elementType == CELIX_ARRAY_LIST_ELEMENT_TYPE_VERSION ||
- list->elementType == CELIX_ARRAY_LIST_ELEMENT_TYPE_UNDEFINED);
- celix_array_list_entry_t entry;
- memset(&entry, 0, sizeof(entry));
+ assert(list->elementType == CELIX_ARRAY_LIST_ELEMENT_TYPE_VERSION);
+ celix_array_list_entry_t entry = {0};
entry.versionVal = val;
celix_arrayList_removeEntry(list, entry);
}
@@ -612,8 +561,6 @@ void celix_arrayList_sortEntries(celix_array_list_t *list, celix_array_list_comp
const char* celix_arrayList_elementTypeToString(celix_array_list_element_type_t type) {
switch (type) {
- case CELIX_ARRAY_LIST_ELEMENT_TYPE_UNDEFINED:
- return STRING_VALUE_UNDEFINED_EL_TYPE;
case CELIX_ARRAY_LIST_ELEMENT_TYPE_POINTER:
return STRING_VALUE_POINTER_EL_TYPE;
case CELIX_ARRAY_LIST_ELEMENT_TYPE_STRING:
diff --git a/libs/utils/src/properties.c b/libs/utils/src/properties.c
index f48c1eb31..3e75a42ac 100644
--- a/libs/utils/src/properties.c
+++ b/libs/utils/src/properties.c
@@ -656,8 +656,7 @@ celix_properties_assignVersion(celix_properties_t* properties, const char* key,
celix_status_t
celix_properties_setArrayList(celix_properties_t* properties, const char* key, const celix_array_list_t* values) {
- if (!key || !values || celix_arrayList_getElementType(values) == CELIX_ARRAY_LIST_ELEMENT_TYPE_UNDEFINED ||
- celix_arrayList_getElementType(values) == CELIX_ARRAY_LIST_ELEMENT_TYPE_POINTER) {
+ if (!key || !values || celix_arrayList_getElementType(values) == CELIX_ARRAY_LIST_ELEMENT_TYPE_POINTER) {
return CELIX_ILLEGAL_ARGUMENT;
}
celix_array_list_t* copy = celix_arrayList_copy(values);
@@ -672,8 +671,7 @@ celix_properties_setArrayList(celix_properties_t* properties, const char* key, c
celix_status_t
celix_properties_assignArrayList(celix_properties_t* properties, const char* key, celix_array_list_t* values) {
- if (!key || !values || celix_arrayList_getElementType(values) == CELIX_ARRAY_LIST_ELEMENT_TYPE_UNDEFINED ||
- celix_arrayList_getElementType(values) == CELIX_ARRAY_LIST_ELEMENT_TYPE_POINTER) {
+ if (!key || !values || celix_arrayList_getElementType(values) == CELIX_ARRAY_LIST_ELEMENT_TYPE_POINTER) {
celix_arrayList_destroy(values);
return CELIX_ILLEGAL_ARGUMENT;
}