Repository: celix Updated Branches: refs/heads/develop d7546831a -> 3ba41cad6
CELIX-446: Change a struct initialization for gcc 4 Project: http://git-wip-us.apache.org/repos/asf/celix/repo Commit: http://git-wip-us.apache.org/repos/asf/celix/commit/3ba41cad Tree: http://git-wip-us.apache.org/repos/asf/celix/tree/3ba41cad Diff: http://git-wip-us.apache.org/repos/asf/celix/diff/3ba41cad Branch: refs/heads/develop Commit: 3ba41cad6bab608d13e8a66d3865cab8cb578350 Parents: d754683 Author: Pepijn Noltes <[email protected]> Authored: Sat May 12 17:35:37 2018 +0200 Committer: Pepijn Noltes <[email protected]> Committed: Sat May 12 17:35:37 2018 +0200 ---------------------------------------------------------------------- framework/tst/bundle_context_services_test.cpp | 10 ++++++---- utils/include/array_list.h | 5 +++++ utils/src/array_list.c | 10 +++++++--- 3 files changed, 18 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/celix/blob/3ba41cad/framework/tst/bundle_context_services_test.cpp ---------------------------------------------------------------------- diff --git a/framework/tst/bundle_context_services_test.cpp b/framework/tst/bundle_context_services_test.cpp index 6fa1204..ec7b92d 100644 --- a/framework/tst/bundle_context_services_test.cpp +++ b/framework/tst/bundle_context_services_test.cpp @@ -21,9 +21,6 @@ #include <iostream> #include <mutex> #include <condition_variable> - -#include <CppUTest/TestHarness.h> -#include <CppUTest/CommandLineTestRunner.h> #include <zconf.h> #include <string.h> #include <map> @@ -35,6 +32,11 @@ #include "celix_service_factory.h" +#include <CppUTest/TestHarness.h> +#include <CppUTest/CommandLineTestRunner.h> + + + TEST_GROUP(CelixBundleContextServicesTests) { framework_t* fw = NULL; bundle_context_t *ctx = NULL; @@ -601,7 +603,7 @@ TEST(CelixBundleContextServicesTests, serviceFactoryTest) { fac.getService = [](void *handle, const celix_bundle_t *, const celix_properties_t *) -> void* { auto *c = (int *)handle; *c += 1; - static struct calc svc{}; //normally a service per bundle + static struct calc svc; //normally a service per bundle svc.calc = [](int arg) { return arg * 42; }; return &svc; }; http://git-wip-us.apache.org/repos/asf/celix/blob/3ba41cad/utils/include/array_list.h ---------------------------------------------------------------------- diff --git a/utils/include/array_list.h b/utils/include/array_list.h index fa8602b..7003501 100644 --- a/utils/include/array_list.h +++ b/utils/include/array_list.h @@ -155,6 +155,11 @@ void celix_arrayList_addSize(celix_array_list_t *list, size_t val); int celix_arrayList_indexOf(celix_array_list_t *list, celix_array_list_entry_t entry); void celix_arrayList_remove(celix_array_list_t *list, int index); + +/** + * Remove entry from array list. To use this first memset the entry to null to ensure it completely initialized or + * ensure that the array list is created with a custom equals which matches the used entry. + */ void celix_arrayList_removeEntry(celix_array_list_t *list, celix_array_list_entry_t entry); #ifdef __cplusplus http://git-wip-us.apache.org/repos/asf/celix/blob/3ba41cad/utils/src/array_list.c ---------------------------------------------------------------------- diff --git a/utils/src/array_list.c b/utils/src/array_list.c index ca12798..6a48c7a 100644 --- a/utils/src/array_list.c +++ b/utils/src/array_list.c @@ -122,7 +122,9 @@ int arrayList_indexOf(array_list_pt list, void * element) { } else { unsigned int i = 0; for (i = 0; i < list->size; i++) { - celix_array_list_entry_t entry = { .voidPtrVal = element }; + celix_array_list_entry_t entry; + memset(&entry, 0, sizeof(entry)); + entry.voidPtrVal = element; bool equals = celix_arrayList_equalsForElement(list, entry, list->elementData[i]); if (equals) { return i; @@ -145,8 +147,9 @@ int arrayList_lastIndexOf(array_list_pt list, void * element) { int i = 0; int size = (int)list->size; for (i = size - 1; i >= 0; i--) { - celix_array_list_entry_t entry = { .voidPtrVal = element }; - + celix_array_list_entry_t entry; + memset(&entry, 0, sizeof(entry)); + entry.voidPtrVal = element; bool equals = celix_arrayList_equalsForElement(list, entry, list->elementData[i]); if (equals) { return (int)i; @@ -235,6 +238,7 @@ bool arrayList_removeElement(array_list_pt list, void * element) { unsigned int i = 0; for (i = 0; i < list->size; i++) { celix_array_list_entry_t entry; + memset(&entry, 0, sizeof(entry)); entry.voidPtrVal = element; bool equals = celix_arrayList_equalsForElement(list, entry, list->elementData[i]); if (equals) {
