Lines Matching defs:gidc

57 struct gidc {
61 struct gidc *next; /* for collisions */
65 static struct gidc **gidtoname; /* gid to group name cache */
67 static struct gidc **nametogid; /* group name to gid cache */
142 gidc_insert(struct gidc **tbl, struct gidc *gidc, uint32_t key)
145 gidc->next = tbl[key];
146 tbl[key] = gidc;
200 struct gidc *gidc, *gidc2;
205 gidc = gidtoname[key];
206 while (gidc != NULL) {
207 if (gidc->gid == gid)
209 gidc = gidc->next;
212 if (gidc == NULL) {
214 gidc = xmalloc(sizeof(struct gidc));
215 gidc->gid = gid;
219 gidc->name = xstrdup(gr->gr_name);
220 gidc->valid = 1;
222 gidc2 = xmalloc(sizeof(struct gidc));
224 gidc2->name = gidc->name; /* We reuse the pointer. */
226 key2 = hash(gidc->name) % NAMETOGID_SZ;
230 gidc->name = NULL;
231 gidc->valid = 0;
233 gidc_insert(gidtoname, gidc, key);
238 return (gidc->name);
296 struct gidc *gidc, *gidc2;
301 gidc = nametogid[key];
302 while (gidc != NULL) {
303 if (strcmp(gidc->name, name) == 0)
305 gidc = gidc->next;
308 if (gidc == NULL) {
309 gidc = xmalloc(sizeof(struct gidc));
310 gidc->name = xstrdup(name);
314 gidc->gid = gr->gr_gid;
315 gidc->valid = 1;
317 gidc2 = xmalloc(sizeof(struct gidc));
318 gidc2->name = gidc->name; /* We reuse the pointer. */
319 gidc2->gid = gidc->gid;
325 gidc->gid = (gid_t)-1; /* Should not be accessed. */
326 gidc->valid = 0;
328 gidc_insert(nametogid, gidc, key);
333 if (!gidc->valid)
335 *gid = gidc->gid;
347 gidtoname = xmalloc(GIDTONAME_SZ * sizeof(struct gidc *));
349 nametogid = xmalloc(NAMETOGID_SZ * sizeof(struct gidc *));
351 memset(gidtoname, 0, GIDTONAME_SZ * sizeof(struct gidc *));
353 memset(nametogid, 0, NAMETOGID_SZ * sizeof(struct gidc *));
361 struct gidc *gidc, *gidc2;
394 gidc = gidtoname[i];
395 while (gidc != NULL) {
396 if (gidc->name != NULL) {
397 assert(gidc->valid);
398 free(gidc->name);
400 gidc2 = gidc->next;
401 free(gidc);
402 gidc = gidc2;
407 gidc = nametogid[i];
408 while (gidc != NULL) {
409 assert(gidc->name != NULL);
411 if (!gidc->valid)
412 free(gidc->name);
413 gidc2 = gidc->next;
414 free(gidc);
415 gidc = gidc2;