I'm writing a generic list adt and this is what I have in the header so far. From what I know this is usually how it's done.
typedef struct _node {
void *data;
struct _node *next;
} Node;
typedef struct {
Node *dummy;
int (*comparePtr) (void *d1, void *d2);
void (*destroyPtr) (void *data);
} List;
List *ListCreate (int (*comparePtr) (void *d1, void *d2), void (*destroyPtr) (void *data));
void ListDestroy (List *node);
void ListAddToTail (List *list, void *data);
int ListContains (List *list, void *data);
void *ListGetFromIndex (List *list, int index);
It works fine on the implementation side. What I noticed is that in order to use this adt to store integers I have to make calls in this fashion
int a = 5;
ListAddToTail (list, &a);
whereas in a perfect world I'd be able to do this
ListAddToTail (list, 55);
So the question is is it possible to modify this to allow me to pass in any type of data, pointer or non-pointer, non-pointer being mainly primitive types like integers and characters?