Hi folks,
I have been writing a linked list today just for a bit of learning, all was going well and the list is fine, I can add and remove nodes and everything, I didnt start to have any problems until I wanted to do a simple node by node search for a key, I think the problem is being caused by the way I am casting a void pointer.

Code:
typedef struct _llnode LLNODE;
struct _llnode {
    LLNODE *next;
    LLNODE *prev;
    int x;
};

typedef struct _llist LLIST;
struct _llist   {
    LLNODE *head;
    LLNODE *tail;
    unsigned char cnt;
};


/*
 Usage: Traverse forward or backwards through a list.
 */
void    *llist_travrse(void *node, TRAV_DIRECTION dir)   {

    if(dir == TRAVERSE_FORWARD)
        return (void *)(((LLNODE*)node)->next);
    else
        return (void *)((LLNODE*)node)->prev;
}


/*
 Usage: Look through a list for a specific value.
 */
void *llist_search(LLIST *list, int key)  {
    void *temp = &((LLIST*)list)->head;
    //Search the entire list for the value specified.

    while(temp != NULL) {
        //We have found the key.       
        if(((LLNODE *)temp)->x == key)  {
            return (void *)temp;
        }
        else {
            temp = llist_travrse(&temp, TRAVERSE_FORWARD);
        }
    }
    return NULL;
}
When I call the llist_travrse I was expecting the value to be returned to be equal to the next node in the list whereas what seems to happen is that the value being returned is actually equal to the value of the current node, I fear I am overlooking something simple here!?

I have just changed to the new MPLab X IDE as well which I think could be adding to my confusion!

Cheers for any help!

Pheetuz.