I'm reading a book on algorithms and the author defines doubly linked list with this code:
void dlist_init(DList *list, void (*destroy)(void *data));
What is the use of function pointer to destroy function here? Can't we just later call the destroy() function on any list? Why pass pointer to it during initialization?
destroyfunctions, so you bundle the one to use with the list, I suspect.