SPModel: libDelaunay/src/stack.c Source File
VPAC - Computational Software Development
Main | SPModel | StGermain FrameWork |
Main Page | Alphabetical List | Class List | Directories | File List | Class Members | File Members

stack.c

Go to the documentation of this file.
00001 #include <stdlib.h>
00002 
00003 struct node
00004 { int key; struct node *next; };
00005 
00006 static struct node *head, *z, *t;
00007 
00008 void stackinit_() 
00009 {
00010     head = (struct node *) malloc(sizeof *head);
00011     z = (struct node *) malloc(sizeof *z);
00012     head->next = z; head->key=0;
00013     z->next = z;
00014     z->key = 0;
00015 }
00016 
00017 void push_(p)
00018 int *p;
00019 {
00020     int v;
00021     v = *p;
00022     t = (struct node *) malloc(sizeof *t);  
00023     t->key = v; t->next = head->next;   
00024     head->next =t;  
00025 }
00026 
00027 void pop_(x)
00028 int *x;
00029 {
00030     t = head->next; head->next = t->next;
00031     *x = t->key;
00032     free(t);
00033 }
00034 
00035 void stackempty_(i)
00036 int *i;
00037 { 
00038     *i = 0;
00039     if(head->next == z) *i = 1;
00040 }
00041 
00042 void stackflush_()
00043 {
00044     free(head);
00045     free(z);
00046 }
00047