#include <stdio.h>
#include "utype.h"
#include "list.h"
#include "hash.h"
#include "allocate.h"

/* Append data to a list */
void AppendToList(LIST **list, void *data)
{
  LIST **pos = list;
  while (*pos)
    pos = (LIST **)*pos;

  (*pos) = (LIST *) AllocateMemory(sizeof(LIST));
  (*pos)->data = data;
  (*pos)->link = 0;
}
/*
 * Unlink an element from a file list
 */
void *UnlinkFromList(LIST **list, LIST *loc)
{
  LIST **pos = list;
  void *rv;
  while (*pos && (*pos != loc))
    pos = (LIST **) *pos;
  
  rv = 0;
  if (*pos) {
    LIST *temp = *pos;
    *pos = (*pos)->link;
    rv = temp->data;
    DeallocateMemory(temp);
  }
  return(rv);
} 