URI:
       ttb.c - plan9port - [fork] Plan 9 from user space
  HTML git clone git://src.adamsgaard.dk/plan9port
   DIR Log
   DIR Files
   DIR Refs
   DIR README
   DIR LICENSE
       ---
       ttb.c (1725B)
       ---
            1 /* tb.c: check which entries exist, also storage allocation */
            2 # include "t.h"
            3 
            4 void
            5 checkuse(void)
            6 {
            7         int        i, c, k;
            8 
            9         for (c = 0; c < ncol; c++) {
           10                 used[c] = lused[c] = rused[c] = 0;
           11                 for (i = 0; i < nlin; i++) {
           12                         if (instead[i] || fullbot[i])
           13                                 continue;
           14                         k = ctype(i, c);
           15                         if (k == '-' || k == '=')
           16                                 continue;
           17                         if ((k == 'n' || k == 'a')) {
           18                                 rused[c] |= real(table[i][c].rcol);
           19                                 if ( !real(table[i][c].rcol))
           20                                         used[c] |= real(table[i][c].col);
           21                                 if (table[i][c].rcol)
           22                                         lused[c] |= real(table[i][c].col);
           23                         } else
           24                                 used[c] |= real(table[i][c].col);
           25                 }
           26         }
           27 }
           28 
           29 
           30 int
           31 real(char *s)
           32 {
           33         if (s == 0)
           34                 return(0);
           35         if (!point(s))
           36                 return(1);
           37         if (*s == 0)
           38                 return(0);
           39         return(1);
           40 }
           41 
           42 
           43 int        spcount = 0;
           44 # define MAXVEC 20
           45 char        *spvecs[MAXVEC];
           46 
           47 char        *
           48 chspace(void)
           49 {
           50         char        *pp;
           51 
           52         if (spvecs[spcount])
           53                 return(spvecs[spcount++]);
           54         if (spcount >= MAXVEC)
           55                 error("Too many characters in table");
           56         spvecs[spcount++] = pp = calloc(MAXCHS + MAXLINLEN, 1);
           57         if (pp == (char *) - 1 || pp == (char *)0)
           58                 error("no space for characters");
           59         return(pp);
           60 }
           61 
           62 
           63 # define MAXPC 50
           64 char        *thisvec;
           65 int        tpcount = -1;
           66 char        *tpvecs[MAXPC];
           67 
           68 int        *
           69 alocv(int n)
           70 {
           71         int        *tp, *q;
           72 
           73         if (tpcount < 0 || thisvec + n > tpvecs[tpcount] + MAXCHS) {
           74                 tpcount++;
           75                 if (tpvecs[tpcount] == 0) {
           76                         tpvecs[tpcount] = calloc(MAXCHS, 1);
           77                 }
           78                 thisvec = tpvecs[tpcount];
           79                 if (thisvec == (char *)0)
           80                         error("no space for vectors");
           81         }
           82         tp = (int *)thisvec;
           83         thisvec += n;
           84         for (q = tp; q < (int *)thisvec; q++)
           85                 *q = 0;
           86         return(tp);
           87 }
           88 
           89 
           90 void
           91 release(void)
           92 {
           93                         /* give back unwanted space in some vectors */
           94                         /* this should call free; it does not because
           95                                 alloc() is so buggy */
           96         spcount = 0;
           97         tpcount = -1;
           98         exstore = 0;
           99 }