- int n_groups;
- int n_group_slots;
- struct group_info *gi;
- GETGROUPS_T *group;
-
- /* getgroups () returns the number of elements that it was able to
- place into the array. We simply continue to call getgroups ()
- until the number of elements placed into the array is smaller than
- the physical size of the array. */
-
- group = NULL;
- n_groups = 0;
- n_group_slots = 0;
- while (n_groups == n_group_slots)
- {
- n_group_slots += 64;
- group = (GETGROUPS_T *) xrealloc (group,
- n_group_slots * sizeof (GETGROUPS_T));
- n_groups = getgroups (n_group_slots, group);
- }
+ int n_groups = getgroups (GROUPBUF_SIZE, gi->groupbuf);
+ gi->group = gi->groupbuf;