U_CAPI void U_EXPORT2 ulist_addItemEndList(UList *list, const void *data, UBool forceDelete, UErrorCode *status) { UListNode *newItem = NULL; if (U_FAILURE(*status) || list == NULL || data == NULL) { if (forceDelete) { uprv_free((void *)data); } return; } newItem = (UListNode *)uprv_malloc(sizeof(UListNode)); if (newItem == NULL) { if (forceDelete) { uprv_free((void *)data); } *status = U_MEMORY_ALLOCATION_ERROR; return; } newItem->data = (void *)(data); newItem->forceDelete = forceDelete; if (list->size == 0) { ulist_addFirstItem(list, newItem); } else { newItem->next = NULL; newItem->previous = list->tail; list->tail->next = newItem; list->tail = newItem; } list->size++; }
U_CAPI void U_EXPORT2 ulist_addItemBeginList(UList * list, const void * data, UBool forceDelete, UErrorCode * status) { UListNode * newItem = NULL; if (U_FAILURE(*status) || list == NULL || data == NULL) { return; } newItem = (UListNode *)uprv_malloc(sizeof(UListNode)); if (newItem == NULL) { *status = U_MEMORY_ALLOCATION_ERROR; return; } newItem->data = (void *)(data); newItem->forceDelete = forceDelete; if (list->size == 0) { ulist_addFirstItem(list, newItem); } else { newItem->previous = NULL; newItem->next = list->head; list->head->previous = newItem; list->head = newItem; list->currentIndex++; } list->size++; }