I have the following code:
typedef struct ll_node linked_list_node;
struct ll_node {
int value;
linked_list_node* next;
};
typedef struct ll linked_list;
struct ll {
size_t size;
linked_list_node* head;
linked_list_node* tail;
};
void for_each(linked_list* list, void (*function)(linked_list_node*, ...)) {
if (list == NULL || list->head == NULL) {
return;
}
for (linked_list_node* node = list->head; node != NULL; node = node->next) {
function(node, function->__va_arg_pack());
}
}
What I mainly want to achieve is for_each
to receive a function that is executed to every single linked list node, but I'm not sure if that can be achieved with functions that receive multiple parameters... Please help!