Skip to content
Permalink
Browse files
Merge branch 'apache:master' into fix_configurable_listening_ip
  • Loading branch information
xuzhenbao committed Mar 26, 2022
2 parents 0f5581a + 9cf8bc3 commit 16c60b9bcff1ab7f644f0f02ae68ce4cb6182d6e
Showing 2 changed files with 46 additions and 44 deletions.
@@ -101,6 +101,9 @@ void celix_arrayList_removeDouble(celix_array_list_t *list, double val);
void celix_arrayList_removeBool(celix_array_list_t *list, bool val);
void celix_arrayList_removeSize(celix_array_list_t *list, size_t val);

/**
* @warning Never use this function with array of doubles, since on some 32-bit platform (sizeof(double)==8 && sizeof(void*)==4)
*/
void celix_arrayList_sort(celix_array_list_t *list, celix_arrayList_sort_fp sortFp);

#ifdef __cplusplus
@@ -61,8 +61,8 @@ static celix_status_t arrayList_elementEquals(const void *a, const void *b, bool
}

static bool celix_arrayList_defaultEquals(celix_array_list_entry_t a, celix_array_list_entry_t b) {
CELIX_BUILD_ASSERT(sizeof(a.voidPtrVal) == sizeof(a));
return a.voidPtrVal== b.voidPtrVal;
CELIX_BUILD_ASSERT(sizeof(a.voidPtrVal) == sizeof(a) || sizeof(a.doubleVal) == sizeof(a));
return __builtin_choose_expr(sizeof(a.voidPtrVal) >= sizeof(a.doubleVal), a.voidPtrVal== b.voidPtrVal, a.doubleVal == a.doubleVal);
}

static bool celix_arrayList_equalsForElement(celix_array_list_t *list, celix_array_list_entry_t a, celix_array_list_entry_t b) {
@@ -197,7 +197,7 @@ int arrayList_addIndex(array_list_pt list, unsigned int index, void * element) {
}
arrayList_ensureCapacity(list, (int)list->size+1);
numMoved = list->size - index;
memmove(list->elementData+(index+1), list->elementData+index, sizeof(void *) * numMoved);
memmove(list->elementData+(index+1), list->elementData+index, sizeof(celix_array_list_entry_t) * numMoved);

list->elementData[index].voidPtrVal = element;
list->size++;
@@ -214,7 +214,7 @@ void * arrayList_remove(array_list_pt list, unsigned int index) {
list->modCount++;
oldElement = list->elementData[index].voidPtrVal;
numMoved = list->size - index - 1;
memmove(list->elementData+index, list->elementData+index+1, sizeof(void *) * numMoved);
memmove(list->elementData+index, list->elementData+index+1, sizeof(celix_array_list_entry_t) * numMoved);
memset(&list->elementData[--list->size], 0, sizeof(celix_array_list_entry_t));

return oldElement;
@@ -225,7 +225,7 @@ void arrayList_fastRemove(array_list_pt list, unsigned int index) {
list->modCount++;

numMoved = list->size - index - 1;
memmove(list->elementData+index, list->elementData+index+1, sizeof(void *) * numMoved);
memmove(list->elementData+index, list->elementData+index+1, sizeof(celix_array_list_entry_t) * numMoved);
memset(&list->elementData[--list->size], 0, sizeof(celix_array_list_entry_t));
}

@@ -409,61 +409,62 @@ size_t celix_arrayList_getSize(const celix_array_list_t *list, int index) { retu

static void arrayList_addEntry(celix_array_list_t *list, celix_array_list_entry_t entry) {
arrayList_ensureCapacity(list, (int)list->size + 1);
memset(&list->elementData[list->size], 0, sizeof(entry));
list->elementData[list->size++] = entry;
}

void celix_arrayList_add(celix_array_list_t *list, void * element) {
celix_array_list_entry_t entry = { .voidPtrVal = element };
celix_array_list_entry_t entry;
memset(&entry, 0, sizeof(entry));
entry.voidPtrVal = element;
arrayList_addEntry(list, entry);
}

void celix_arrayList_addInt(celix_array_list_t *list, int val) {
celix_array_list_entry_t entry;
memset(&entry, 0, sizeof(entry));
entry.intVal = val;
celix_array_list_entry_t entry;
memset(&entry, 0, sizeof(entry));
entry.intVal = val;
arrayList_addEntry(list, entry);
}
void celix_arrayList_addLong(celix_array_list_t *list, long val) {
celix_array_list_entry_t entry;
memset(&entry, 0, sizeof(entry));
entry.longVal = val;
celix_array_list_entry_t entry;
memset(&entry, 0, sizeof(entry));
entry.longVal = val;
arrayList_addEntry(list, entry);
}
void celix_arrayList_addUInt(celix_array_list_t *list, unsigned int val) {
celix_array_list_entry_t entry;
memset(&entry, 0, sizeof(entry));
entry.uintVal = val;
celix_array_list_entry_t entry;
memset(&entry, 0, sizeof(entry));
entry.uintVal = val;
arrayList_addEntry(list, entry);
}
void celix_arrayList_addULong(celix_array_list_t *list, unsigned long val) {
celix_array_list_entry_t entry;
memset(&entry, 0, sizeof(entry));
entry.ulongVal = val;
celix_array_list_entry_t entry;
memset(&entry, 0, sizeof(entry));
entry.ulongVal = val;
arrayList_addEntry(list, entry);
}
void celix_arrayList_addDouble(celix_array_list_t *list, double val) {
celix_array_list_entry_t entry;
memset(&entry, 0, sizeof(entry));
entry.doubleVal = val;
celix_array_list_entry_t entry;
memset(&entry, 0, sizeof(entry));
entry.doubleVal = val;
arrayList_addEntry(list, entry);
}
void celix_arrayList_addFloat(celix_array_list_t *list, float val) {
celix_array_list_entry_t entry;
memset(&entry, 0, sizeof(entry));
entry.floatVal = val;
celix_array_list_entry_t entry;
memset(&entry, 0, sizeof(entry));
entry.floatVal = val;
arrayList_addEntry(list, entry);
}
void celix_arrayList_addBool(celix_array_list_t *list, bool val) {
celix_array_list_entry_t entry;
memset(&entry, 0, sizeof(entry));
entry.boolVal = val;
celix_array_list_entry_t entry;
memset(&entry, 0, sizeof(entry));
entry.boolVal = val;
arrayList_addEntry(list, entry);
}
void celix_arrayList_addSize(celix_array_list_t *list, size_t val) {
celix_array_list_entry_t entry;
memset(&entry, 0, sizeof(entry));
entry.sizeVal = val;
celix_array_list_entry_t entry;
memset(&entry, 0, sizeof(entry));
entry.sizeVal = val;
arrayList_addEntry(list, entry);
}

@@ -484,7 +485,7 @@ void celix_arrayList_removeAt(celix_array_list_t *list, int index) {
if (index >= 0 && index < list->size) {
list->modCount++;
size_t numMoved = list->size - index - 1;
memmove(list->elementData+index, list->elementData+index+1, sizeof(void *) * numMoved);
memmove(list->elementData+index, list->elementData+index+1, sizeof(celix_array_list_entry_t) * numMoved);
memset(&list->elementData[--list->size], 0, sizeof(celix_array_list_entry_t));
}
}
@@ -504,67 +505,65 @@ void celix_arrayList_remove(celix_array_list_t *list, void *ptr) {

void celix_arrayList_removeInt(celix_array_list_t *list, int val) {
celix_array_list_entry_t entry;
memset(&entry, 0, sizeof(entry));
memset(&entry, 0, sizeof(entry));
entry.intVal = val;
celix_arrayList_removeEntry(list, entry);
}

void celix_arrayList_removeLong(celix_array_list_t *list, long val) {
celix_array_list_entry_t entry;
memset(&entry, 0, sizeof(entry));
memset(&entry, 0, sizeof(entry));
entry.longVal = val;
celix_arrayList_removeEntry(list, entry);
}

void celix_arrayList_removeUInt(celix_array_list_t *list, unsigned int val) {
celix_array_list_entry_t entry;
memset(&entry, 0, sizeof(entry));
memset(&entry, 0, sizeof(entry));
entry.uintVal = val;
celix_arrayList_removeEntry(list, entry);
}

void celix_arrayList_removeULong(celix_array_list_t *list, unsigned long val) {
celix_array_list_entry_t entry;
memset(&entry, 0, sizeof(entry));
memset(&entry, 0, sizeof(entry));
entry.ulongVal = val;
celix_arrayList_removeEntry(list, entry);
}

void celix_arrayList_removeFloat(celix_array_list_t *list, float val) {
celix_array_list_entry_t entry;
memset(&entry, 0, sizeof(entry));
memset(&entry, 0, sizeof(entry));
entry.floatVal = val;
celix_arrayList_removeEntry(list, entry);
}

void celix_arrayList_removeDouble(celix_array_list_t *list, double val) {
celix_array_list_entry_t entry;
memset(&entry, 0, sizeof(entry));
memset(&entry, 0, sizeof(entry));
entry.doubleVal = val;
celix_arrayList_removeEntry(list, entry);
}

void celix_arrayList_removeBool(celix_array_list_t *list, bool val) {
celix_array_list_entry_t entry;
memset(&entry, 0, sizeof(entry));
memset(&entry, 0, sizeof(entry));
entry.boolVal = val;
celix_arrayList_removeEntry(list, entry);
}

void celix_arrayList_removeSize(celix_array_list_t *list, size_t val) {
celix_array_list_entry_t entry;
memset(&entry, 0, sizeof(entry));
memset(&entry, 0, sizeof(entry));
entry.sizeVal = val;
celix_arrayList_removeEntry(list, entry);
}

void celix_arrayList_clear(celix_array_list_t *list) {
unsigned int i;
list->modCount++;

for (i = 0; i < list->size; i++) {
// free(list->elementData[i]);
memset(&list->elementData[i], 0, sizeof(celix_array_list_entry_t));
if(list->size > 0) {
memset(&list->elementData[0], 0, sizeof(celix_array_list_entry_t)*list->size);
}
list->size = 0;
}

0 comments on commit 16c60b9

Please sign in to comment.