home *** CD-ROM | disk | FTP | other *** search
/ Boston 2 / boston-2.iso / DOS / PROGRAM / C / JAZLIB / JZPUSH.C < prev    next >
Text File  |  1993-12-01  |  1KB  |  43 lines

  1. #include <jaz.h>
  2.  
  3. /*
  4. ┌────────────────────────────────────────────────────────────────────────────┐
  5. │jzpush.c                                     │
  6. │Push Data onto the stack                             │
  7. │Synopsis                                     │
  8. │  TSTKHEAD whead;                                 │
  9. │  jzintstk(&whead);   ( initialize the stack header record )             │
  10. │  jzpush(&whead,wstr,sizeof(TDATA));                         │
  11. │                                         │
  12. └────────────────────────────────────────────────────────────────────────────┘
  13. */
  14.  
  15. jzpush(fhead,fdata,fsize)
  16. TSTKHEAD *fhead;        /* head of stack structure */
  17. char *fdata;            /* pointer to data to save */
  18. unsigned int fsize;        /* number of bytes to put on stack */
  19. {
  20.   TSTACK *wtemp;
  21.  
  22.   wtemp = (TSTACK *)  malloc(sizeof(TSTACK));    /* get pointer to struct */
  23.   wtemp->pointer = (char *) malloc(fsize);    /* get pointer to data */
  24.  
  25.   /* copy the data onto the stack */
  26.   memcpy(wtemp->pointer,fdata,fsize);
  27.   wtemp->wint = fsize;        /* save size of data */
  28.  
  29.   if (fhead->last == 0) {    /* empty stack */
  30.     wtemp->prev  = 0;
  31.     fhead->last  =  wtemp;    /* set last item (top of stack) */
  32.     fhead->first =  wtemp;    /* set first item */
  33.     fhead->numitems = 1;    /* set number of items */
  34.   }
  35.   else {
  36.     wtemp->prev = fhead->last;    /* set link to stack top */
  37.     fhead->last = wtemp;    /* set new top of stack */
  38.     fhead->numitems++;        /* increment stack pointer */
  39.   }
  40. }
  41.  
  42.  
  43.