* Add a new member name to a struct group. */
| 474 | * Add a new member name to a struct group. |
| 475 | */ |
| 476 | struct group * |
| 477 | gr_add(const struct group *gr, const char *newmember) |
| 478 | { |
| 479 | char *mem; |
| 480 | size_t len; |
| 481 | int num_mem; |
| 482 | |
| 483 | num_mem = 0; |
| 484 | len = grmemlen(gr, newmember, &num_mem); |
| 485 | /* Create new group and copy old group into it. */ |
| 486 | if ((mem = malloc(len)) == NULL) |
| 487 | return (NULL); |
| 488 | return (grcopy(gr, mem, newmember, num_mem)); |
| 489 | } |
| 490 | |
| 491 | /* It is safer to walk the pointers given at gr_mem since there is no |
| 492 | * guarantee the gr_mem + strings are contiguous in the given struct group |