MCPcopy Create free account
hub / github.com/F-Stack/f-stack / gr_add

Function gr_add

tools/libutil/gr_util.c:476–489  ·  view source on GitHub ↗

* Add a new member name to a struct group. */

Source from the content-addressed store, hash-verified

474 * Add a new member name to a struct group.
475 */
476struct group *
477gr_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

Callers 1

gr_dupFunction · 0.85

Calls 3

grmemlenFunction · 0.85
mallocFunction · 0.85
grcopyFunction · 0.85

Tested by

no test coverage detected