> But I don't get the purpose of that function-pointer match.
Well the whole idea with having a bunch of function pointers in the List structure is to allow the generic list to implement any kind of functionality which involves traversing the list.
Essentially, every list API function (foo) is going to do your basic list traversal, and call some specific function.
Code:
// data is some data pointer
void foo ( List *list, void *data ) {
ListElmt *n = list->head;
while ( n != NULL ) {
// call the user's foo function, passing in the current list user data, and
// the supplied data pointer.
list->foo(n->data,data);
n = n->next;
}
}
> int (*match) (const void *key1, const void *key2);
So I'd guess that match gets passed key1 = the current node data, and key2 = whatever is trying to be found.
Who knows what the int means
- success / fail
- a count of total matches
- an index to the first match