/*----------------------Stack routines------------------*/ /* Pushes cell p on top of stack t, and returns new top. */ tStack Push( tStack t, tStack p ) { p->next = t; return p; } /* Pops off top elment of stack p, frees up the cell, and returns new top. */ tStack Pop( tStack p ) { tStack top; top = p->next; free( (void *) p ); return top; } /* Prints the stack, both point index and point coordinates. */ void PrintStack( tStack t ) { if (t) { /* printf("i=%d:", t->i);*/ PrintPoint( P[t->i] ); putchar('\n'); PrintStack( t->next ); } } /* GetCell returns a pointer to a newly allocated piece of storage of type tCell, or exits if no space is available. */ tStack GetCell( void ) { tStack p; p = (tStack) malloc( sizeof( struct tCell ) ); if (p == NULL) { printf("Error in GetCell: Out of memory!\n"); exit(1); } else return p; }