User defined destroy (free) function
This is my first question here. I'm unable to understand a couple line of
codes in this program.
The custom destroy function pointer is what I'm unable to understand.
I've commented with "need help #1 and need help #2" where I need help with
the codes.
Any help would be greatly appreciated and I will be really grateful to
anyone who could help me understand these codes.
#ifndef LIST_H
#define LIST_H
#include <stdio.h>
typedef struct _ListElmt
{
void *data;
struct ListElmt *next;
} ListElmt;
typedef struct _List
{
int size;
int (*match)(const void *key1, const void *key2);
void (*destroy)(void *data);
ListElmt *head;
ListElmt *tail;
} List;
void list_init(List *list, void (*destroy)(void *data));
void list_destroy(List *list);
int list_ins_next(List *list, ListElmt *element, const void *data);
int list_rem_next(List *list, ListElmt *element, void **data);
int list_size(const List *list);
ListElmt *list_head(const List *list);
ListElmt *list_tail(const List *list);
int list_is_head(const ListElmt *element);
int list_is_tail(const ListElmt *element);
void *list_data(const ListElmt *element);
ListElmt *list_next(const ListElmt *element);
No comments:
Post a Comment