home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / jove-4.16-src.tgz / tar.out / bsd / jove / list.c < prev    next >
C/C++ Source or Header  |  1996-09-28  |  1KB  |  51 lines

  1. /************************************************************************
  2.  * This program is Copyright (C) 1986-1996 by Jonathan Payne.  JOVE is  *
  3.  * provided to you without charge, and with no warranty.  You may give  *
  4.  * away copies of JOVE, including sources, provided that this notice is *
  5.  * included in all the files.                                           *
  6.  ************************************************************************/
  7.  
  8. #include "jove.h"
  9. #include "list.h"
  10.  
  11. private List *
  12. list_new()
  13. {
  14.     List    *new;
  15.  
  16.     new = (List *) emalloc(sizeof (List));
  17.     new->car = NULL;
  18.     return new;
  19. }
  20.  
  21. /* push an object to the beginning of list */
  22.  
  23. UnivPtr
  24. list_push(list, element)
  25. register List    **list;
  26. UnivPtr element;
  27. {
  28.     List    *new;
  29.  
  30.     new = list_new();
  31.     new->cdr = *list;
  32.     new->car = element;
  33.     *list = new;
  34.     return element;
  35. }
  36.  
  37. UnivPtr
  38. list_pop(list)
  39. List    **list;
  40. {
  41.     List    *cell = *list;
  42.     UnivPtr    element;
  43.  
  44.     if (cell == NULL)
  45.         return NULL;
  46.     element = cell->car;
  47.     *list = cell->cdr;
  48.     free((UnivPtr) cell);
  49.     return element;
  50. }
  51.