Beispiel #1
0
DListRet dlist_delete(DList* thiz, size_t index)
{
	DListNode* cursor = dlist_get_node(thiz, index, 0);

	if(cursor != NULL)
	{
		if(cursor == thiz->first)
		{
			thiz->first = cursor->next;
		}

		if(cursor->next != NULL)
		{
			cursor->next->prev = cursor->prev;
		}

		if(cursor->prev != NULL)
		{
			cursor->prev->next = cursor->next;
		}

		dlist_node_destroy(cursor);
	}

	return DLIST_RET_OK;
}
Beispiel #2
0
int dlist_delete(DList* thiz, int index)
{
	DListNode* cursor = dlist_get_node(thiz, index, 0);

	if(cursor != NULL) {
		if(cursor == thiz->first)	thiz->first = cursor->next;
		if(cursor->next != NULL)	cursor->next->prev = cursor->prev;
		if(cursor->prev != NULL)	cursor->prev->next = cursor->next;

		dlist_node_destroy(cursor);
	}

	return 0;
}
Beispiel #3
0
void dlist_destroy(DList* thiz)
{
	DListNode* iter = thiz->first;
	DListNode* next = NULL;

	while(iter != NULL) {
		next = iter->next;
		dlist_node_destroy(iter);
		iter = next;
	}

	thiz->first = NULL;
	free(thiz);

	return;
}