Memory aside, some thoughts on making link lists faster.
I think there is a bit of confusion in your code. It has a very basic linked list:
typdef struct _node { ... struct _node *next; } NODE;
Most implementations have void * to hang the payload. This is not particularly important now.
List insertions should include pointers. To simply add a node (and ignore the addition of a payload), there is 1 purpose if node goes at the beginning or end of the list, and 2 in the middle. This is not enough that can be done to get around this.
Sometimes simple lists use only node structures, so traversal is required to insert a tail. It is expensive. Having a special header structure with knowledge of the first and last node removes this cost.
Traverses can be done faster by implementing this as a skip list ( http://en.wikipedia.org/wiki/Skip_list ). Although the optimization process is necessary in the node process (although you get more pointers during insertion).
Jon l
source share