Lines Matching full:cp

53 	char		*cp;  in HASH()  local
56 for (cp = (char *)datap; cp != ((char *)datap + datalen); hv += *cp++) in HASH()
63 Cache **cp, in init_cache() argument
74 if ((*cp = (Cache *) Malloc(sizeof (**cp))) == NULL) { in init_cache()
75 (void) fprintf(stderr, "Malloc(Cache **cp)"); in init_cache()
78 (*cp)->bp = (Bucket *) Malloc(sizeof (*(*cp)->bp) * hsz); in init_cache()
79 if ((*cp)->bp == NULL) { in init_cache()
80 (void) fprintf(stderr, "Malloc(Bucket cp->bp)"); in init_cache()
83 (*cp)->hsz = hsz; in init_cache()
84 (*cp)->bsz = bsz; in init_cache()
85 for (i = 0; i < (*cp)->hsz; i++) { in init_cache()
86 (*cp)->bp[i].nent = 0; in init_cache()
87 (*cp)->bp[i].nalloc = 0; in init_cache()
88 (*cp)->bp[i].itempp = NULL; in init_cache()
92 (*cp)->hfunc = hfunc; in init_cache()
94 (*cp)->hfunc = HASH; in init_cache()
98 (*cp)->cfunc = cfunc; in init_cache()
100 (*cp)->cfunc = BCMP; in init_cache()
104 (*cp)->kffunc = kffunc; in init_cache()
106 (*cp)->kffunc = Free; in init_cache()
110 (*cp)->dffunc = dffunc; in init_cache()
112 (*cp)->dffunc = Free; in init_cache()
118 add_cache(Cache *cp, Item *itemp) in add_cache() argument
123 if (cp == NULL) { in add_cache()
129 bp = &cp->bp[(*cp->hfunc)(itemp->key, itemp->keyl, cp->hsz)]; in add_cache()
133 (Item **) Malloc(sizeof (*bp->itempp) * cp->bsz); in add_cache()
137 "realloc(%d) bucket=%d\n", bp->nalloc + cp->bsz, in add_cache()
138 (*cp->hfunc)(itemp->key, itemp->keyl, cp->hsz)); in add_cache()
142 (bp->nalloc + cp->bsz)); in add_cache()
162 bp->nalloc += cp->bsz; in add_cache()
170 lookup_cache(Cache *cp, void *datap, int datalen) in lookup_cache() argument
175 if (cp == NULL) { in lookup_cache()
181 bp = &cp->bp[(*cp->hfunc)(datap, datalen, cp->hsz)]; in lookup_cache()
183 if (!(*cp->cfunc)((void *)bp->itempp[i]->key, datap, datalen)) in lookup_cache()
189 first_item(Cache *cp, int *bidx, int *iidx) in first_item() argument
193 if (cp == NULL) { in first_item()
199 for (*bidx = 0; *bidx < cp->hsz && (cp->bp[*bidx].nalloc == 0 || in first_item()
200 cp->bp[*bidx].nent == 0); (*bidx)++) in first_item()
203 if (*bidx < cp->hsz && cp->bp[*bidx].nent > 0) { in first_item()
204 itemp = cp->bp[*bidx].itempp[0]; in first_item()
214 next_item(Cache *cp, int *bidx, int *iidx) in next_item() argument
218 if (cp == NULL) { in next_item()
224 if (*bidx < cp->hsz && *bidx >= 0) { in next_item()
225 if ((*iidx + 1) < cp->bp[*bidx].nent) { in next_item()
226 itemp = cp->bp[*bidx].itempp[++(*iidx)]; in next_item()
229 *bidx < cp->hsz && (cp->bp[*bidx].nalloc == 0 || in next_item()
230 cp->bp[*bidx].nent == 0); in next_item()
233 if (*bidx < cp->hsz && cp->bp[*bidx].nent > 0) { in next_item()
235 itemp = cp->bp[*bidx].itempp[(*iidx)++]; in next_item()
251 Cache *cp = *cpp; in des_cache() local
257 if (cp == NULL) { in des_cache()
263 for (i = 0; i < cp->hsz; i++) { in des_cache()
264 bp = &cp->bp[i]; in des_cache()
269 (void) (*cp->kffunc)(itemp->key); in des_cache()
271 (void) (*cp->dffunc)(itemp->data); in des_cache()
276 (void) Free(cp->bp); in des_cache()
277 (void) Free(cp); in des_cache()
282 del_cache(Cache *cp, Item *itemp) in del_cache() argument
293 if (cp == NULL) { in del_cache()
299 bidx = (*cp->hfunc)(datap, datalen, cp->hsz); in del_cache()
300 bp = &cp->bp[bidx]; in del_cache()
303 if (!(*cp->cfunc)((void *)bp->itempp[iidx]->key, datap, in del_cache()
310 (void) (*cp->kffunc)(titemp->key); in del_cache()
312 (void) (*cp->dffunc)(titemp->data); in del_cache()
336 cache_stat(Cache *cp, char *tag) in cache_stat() argument
341 if (cp == NULL) { in cache_stat()
350 for (bidx = 0; bidx < cp->hsz; bidx++) { in cache_stat()
351 bp = &cp->bp[bidx]; in cache_stat()
357 (bp->nalloc / cp->hsz)); in cache_stat()
369 pr_cache(Cache *cp, char *tag, void (*pfunc)(void *, int, void *, int)) in pr_cache() argument
376 if (cp == NULL) { in pr_cache()
385 for (bidx = 0; bidx < cp->hsz; bidx++) { in pr_cache()
386 bp = &cp->bp[bidx]; in pr_cache()