예제 #1
0
파일: xlist.c 프로젝트: kfihihc/xmms2-devel
x_list_t*
x_list_insert (x_list_t *list, void *data, int position)
{
	x_list_t *new_list;
	x_list_t *tmp_list;

	if (position < 0) {
		return x_list_append (list, data);
	} else if (position == 0) {
		return x_list_prepend (list, data);
	}

	tmp_list = x_list_nth (list, position);
	if (!tmp_list)
		return x_list_append (list, data);

	new_list = _x_list_alloc ();
	new_list->data = data;

	if (tmp_list->prev) {
		tmp_list->prev->next = new_list;
		new_list->prev = tmp_list->prev;
	}
	new_list->next = tmp_list;
	tmp_list->prev = new_list;

	if (tmp_list == list) {
		return new_list;
	} else {
		return list;
	}
}
예제 #2
0
void
xmmsc_ipc_result_register (xmmsc_ipc_t *ipc, xmmsc_result_t *res)
{
	x_return_if_fail (ipc);
	x_return_if_fail (res);

	xmmsc_ipc_lock (ipc);
	ipc->results_list = x_list_prepend (ipc->results_list, res);
	xmmsc_ipc_unlock (ipc);
}
예제 #3
0
void
x_queue_push_head (x_queue_t *queue, void *data)
{
	x_return_if_fail (queue);

	queue->head = x_list_prepend (queue->head, data);

	if (!queue->tail)
		queue->tail = queue->head;

	queue->length++;
}