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

typedef struct node_s {
    int value;
    struct node_s *next;
} node;

void node_add(node **p, int value)
{
    node *tmp;
    tmp = malloc(sizeof(node));
    tmp->value = value;
    tmp->next = *p;
    *p = tmp;
}

void node_print(const node *p)
{
    for (; p; p = p->next)
        printf("%d ", p->value);
    printf("\n");
}

void node_clean(node *p)
{
    node *tmp;
    for (; p; p = tmp) {
        tmp = p->next;
        free(p);
    }
}

int main()
{
    node *p = NULL;

    node_add(&p, 1);
    node_add(&p, 2);

    node_print(p);
    node_clean(p);
    return 0;
}
