Beispiel #1
0
void listCheck(Connection * previous, Connection * current)
{
    DEBUGOUT("in listCheck");
    if(current && !(current->status.is_alive))
    {
        previous->next = current->next;
        delConnection(current);
        listCheck(previous, previous->next);
    }
    return;
}
Beispiel #2
0
void listFree(list *lst)
{
	assert(listCheck(lst));
	if(lst->current) {
		listnode *start = lst->current;
		do {
			listnode *next = lst->current->next;
			free(lst->current);
			lst->current = next;
		} while(lst->current != start);
	}
	free(lst);
}
Beispiel #3
0
void listDeleteCurrent(list *lst)
{
	assert(lst && lst->current && listCheck(lst));
	listnode *next = lst->current->next,
		*prev = lst->current->prev;
	free(lst->current);
	lst->size--;
	if(lst->size == 0) {
		lst->current = NULL;
	}
	else {
		lst->current = next;
		next->prev = prev;
		prev->next = next;
	}
}
Beispiel #4
0
void reapConnections(Server * srv)
{
    void listCheck(Connection * previous, Connection * current);
    DEBUGOUT("in reapConnections\n");
    if(srv->conList && srv->conList->next)
    {
        listCheck(srv->conList, srv->conList->next);
    }
    else if(srv->conList && !(srv->conList->next) && !(srv->conList->status.is_alive))
    {
        delConnection(srv->conList);
        srv->conList = NULL;
    }
    else DEBUGOUT("NOTHING\n");
    DEBUGOUT("reapConnections returning\n");
    return;
}
Beispiel #5
0
void listInsert(list *lst, void *data)
{
	assert(lst && listCheck(lst));
	listnode *node = malloc(sizeof(listnode));
	if(lst->current) {
		node->next = lst->current;
		node->prev = lst->current->prev;
		node->prev->next = node;
		node->next->prev = node;
		if(lst->current->next == lst->current) {
			lst->current->next = node;
		}
	}
	else {
		node->next = node;
		node->prev = node;
	}
	lst->current = node;
	node->data = data;
	lst->size++;
}
Beispiel #6
0
void listMoveBack(list *lst)
{
	assert(lst && listCheck(lst));
	if(lst->current)
		lst->current = lst->current->prev;
}
Beispiel #7
0
int listSize(list *lst)
{
	assert(lst && listCheck(lst));
	return lst->size;
}
Beispiel #8
0
void *listGetCurrent(list *lst)
{
	assert(lst && lst->current && listCheck(lst));
	return lst->current->data;
}
Beispiel #9
0
void listMoveForward(list *lst)
{
	assert(lst && listCheck(lst));
	if(lst->current)
		lst->current = lst->current->next;
}