home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c222 / 1.ddi / SOURCE / CLIB / UT_STACK.C < prev    next >
Encoding:
C/C++ Source or Header  |  1990-07-10  |  858 b   |  48 lines

  1. /*********************
  2.  *
  3.  *  ut_stack.c - local stack implementaion.
  4.  *
  5.  *  Purpose: This file contains the push and pop functions to implement
  6.  *           a local stack.
  7.  *
  8.  *  Blackstar C Function Library
  9.  *  (c) Copyright 1985,1989 Sterling Castle Software
  10.  *
  11.  *******/
  12.  
  13. #include "blackstr.h"
  14. #include "ut_head.h"
  15.  
  16. int lstack_[BLIB_CSTACK];           /* local stack         */
  17. int *lstkptr_ = &lstack_[0];        /* local stack pointer */
  18. int *lstkend_ = &lstack_[BLIB_CSTACK-1];   /* end of stack */
  19.  
  20.  
  21. /********
  22.  *
  23.  *   ut_push(val) - push a value onto the stack
  24.  *
  25.  **/
  26.  
  27. int ut_push(int val)
  28. {
  29.     *lstkptr_++ = val;
  30.     if(lstkptr_ > lstkend_)
  31.     return(ERROR);
  32.     else
  33.     return NUL;
  34. }
  35.  
  36.  
  37. /********
  38.  *
  39.  *   ut_pop() - get a value off the local stack
  40.  *
  41.  **/
  42.  
  43. int ut_pop(void)
  44. {
  45.     return(*--lstkptr_);
  46. }
  47.  
  48.