#include <stdlib.h>
#include <stdio.h>
#include <string.h>

struct linked_node
{
    void* data;
    struct linked_node* next;
};

struct data_x { int i; char c; };
struct data_y { char* s; };

void add_node(struct linked_node** a_head, void* a_data)
{
    struct linked_node* new_node = malloc(sizeof(*new_node));
    new_node->data = a_data;
    new_node->next = 0;
    if (!*a_head)
    {
        *a_head = new_node;
    }
    else
    {
        /* ... */
    }
}

int main(void)
{
    struct linked_node* list_x = 0;
    struct data_x* dx = malloc(sizeof(*dx));
    dx->i = 4;
    dx->c = 'a';

    add_node(&list_x, dx);

    if (list_x)
    {
        struct data_x* x = list_x->data;
        printf("x.i=%d x.c=%c\n", x->i, x->c);
    }

    struct linked_node* list_y = 0;
    struct data_y* dy = malloc(sizeof(*dy));
    dy->s = "hello";

    add_node(&list_y, dy);

    if (list_y)
    {
        struct data_y* y = list_y->data;
        printf("y.s=%s\n", y->s);
    }

    return 0;
}
