Lines Matching refs:tp
43 ktinit(struct table *tp, Area *ap, int tsize) in ktinit() argument
45 tp->areap = ap; in ktinit()
46 tp->tbls = NULL; in ktinit()
47 tp->size = tp->nfree = 0; in ktinit()
49 texpand(tp, tsize); in ktinit()
53 texpand(struct table *tp, int nsize) in texpand() argument
57 struct tbl **ntblp, **otblp = tp->tbls; in texpand()
58 int osize = tp->size; in texpand()
60 ntblp = areallocarray(NULL, nsize, sizeof(struct tbl *), tp->areap); in texpand()
63 tp->size = nsize; in texpand()
64 tp->nfree = 7*nsize/10; /* table can get 70% full */ in texpand()
65 tp->tbls = ntblp; in texpand()
72 (tp->size-1)]; *p != NULL; p--) in texpand()
74 p += tp->size; in texpand()
76 tp->nfree--; in texpand()
78 afree(tblp, tp->areap); in texpand()
81 afree(otblp, tp->areap); in texpand()
88 ktsearch(struct table *tp, const char *n, unsigned int h) in ktsearch() argument
92 if (tp->size == 0) in ktsearch()
96 for (pp = &tp->tbls[h & (tp->size-1)]; (p = *pp) != NULL; pp--) { in ktsearch()
100 if (pp == tp->tbls) /* wrap */ in ktsearch()
101 pp += tp->size; in ktsearch()
111 ktenter(struct table *tp, const char *n, unsigned int h) in ktenter() argument
116 if (tp->size == 0) in ktenter()
117 texpand(tp, INIT_TBLS); in ktenter()
120 for (pp = &tp->tbls[h & (tp->size-1)]; (p = *pp) != NULL; pp--) { in ktenter()
123 if (pp == tp->tbls) /* wrap */ in ktenter()
124 pp += tp->size; in ktenter()
127 if (tp->nfree <= 0) { /* too full */ in ktenter()
128 if (tp->size <= INT_MAX/2) in ktenter()
129 texpand(tp, 2*tp->size); in ktenter()
138 tp->areap); in ktenter()
141 p->areap = tp->areap; in ktenter()
147 tp->nfree--; in ktenter()
159 ktwalk(struct tstate *ts, struct table *tp) in ktwalk() argument
161 ts->left = tp->size; in ktwalk()
162 ts->next = tp->tbls; in ktwalk()
185 ktsort(struct table *tp) in ktsort() argument
190 p = areallocarray(NULL, tp->size + 1, in ktsort()
192 sp = tp->tbls; /* source */ in ktsort()
194 for (i = 0; i < tp->size; i++) in ktsort()
206 void tprintinfo(struct table *tp);
209 tprintinfo(struct table *tp) in tprintinfo() argument
219 shellf("table size %d, nfree %d\n", tp->size, tp->nfree); in tprintinfo()
221 ktwalk(&ts, tp); in tprintinfo()
229 for (pp = &tp->tbls[h & (tp->size-1)]; (p = *pp); pp--) { in tprintinfo()
234 if (pp == tp->tbls) /* wrap */ in tprintinfo()
235 pp += tp->size; in tprintinfo()