llwfp

Documentation
Login

Documentation

/*
   Compile:
   make readme-ex05-one-single-object
*/

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

/* ---------------- */
/* Type definitions */
/* ---------------- */
typedef struct node_t
{
  struct node_t *next;
  void *data; /* GENERIC */
} node_t;

/* Delete all nodes */
void node_cleanup(node_t **head)
{
  node_t *current = *head, *next = NULL;
  while (current)
  {
    next = current->next;
    free(current);
    current = next;
  }
   /* Set variable to NULL *before* free(). */
   /* Valgrind doesn't like it the other way around! */
  *head = NULL;
  free(*head);
}

int
main(int argc, char *argv[])
{
  (void)argc; (void)argv;
  printf("\nREADME EX05\n");
  printf("----------------------------------------\n");

  printf("----------------------------------------\n");

  return 0;
}