예제 #1
0
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++;
}
예제 #2
0
파일: ulist.c 프로젝트: Botyto/Core
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++;
}