static int copy_group_ifcont(const char *groupname,
                             const gid_t *groups, int ngroups,
                             gid_t *new_groups, int *new_ngroups, int new_sz) {
	if (*new_ngroups >= new_sz) {
		errno = ERANGE;
		goto out;
	}

	gid_t g = get_group_id(groupname);
	if (g && find_group(g, groups, ngroups) >= 0) {
		new_groups[*new_ngroups] = g;
		(*new_ngroups)++;
	}

out:
	return *new_ngroups;
}
static int copy_group_ifcont(const char *groupname,
                             const gid_t *groups, int ngroups,
                             gid_t *new_groups, int *new_ngroups, int new_sz) {
	if (*new_ngroups >= new_sz) {
		errno = ERANGE;
		goto out;
	}

	gid_t g = get_group_id(groupname);
	if (g && find_group(g, groups, ngroups) >= 0) {
		new_groups[*new_ngroups] = g;
		(*new_ngroups)++;
	}

out:
	return *new_ngroups;
}