home *** CD-ROM | disk | FTP | other *** search
/ gondwana.ecr.mu.oz.au/pub/ / Graphics.tar / Graphics / voglw.zip / newtoken.c < prev    next >
C/C++ Source or Header  |  1997-02-13  |  863b  |  45 lines

  1. #include <stdio.h>
  2. #include "vogl.h"
  3.  
  4. static TokList        *current;
  5.  
  6. /*
  7.  * newtokens
  8.  *
  9.  *    returns the space for num tokens
  10.  */
  11. Token *
  12. newtokens(num)
  13.     int    num;
  14. {
  15.     TokList    *tl;
  16.     Token    *addr;
  17.     int    size;
  18.  
  19.     if (vdevice.tokens == (TokList *)NULL || num >= MAXTOKS - current->count) {
  20.         if ((tl = (TokList *)malloc(sizeof(TokList))) == (TokList *)NULL)
  21.             verror("newtokens: malloc returns NULL");
  22.  
  23.         if (vdevice.tokens != (TokList *)NULL)
  24.             current->next = tl;
  25.         else 
  26.             vdevice.tokens = tl;
  27.  
  28.         tl->count = 0;
  29.         tl->next = (TokList *)NULL;
  30.         if (num > MAXTOKS)
  31.             size = num;
  32.         else
  33.             size = MAXTOKS;
  34.         if ((tl->toks = (Token *)malloc(size * sizeof(Token))) == (Token *)NULL)
  35.             verror("newtokens: malloc returns NULL");
  36.  
  37.         current = tl;
  38.     }
  39.  
  40.     addr = ¤t->toks[current->count];
  41.     current->count += num;
  42.  
  43.     return(addr);
  44. }
  45.