bug-gnulib
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH 09/13] group-member: use walloc


From: Paul Eggert
Subject: [PATCH 09/13] group-member: use walloc
Date: Sun, 4 Jun 2017 23:45:59 -0700

* lib/group-member.c: Include walloc.h instead of
xalloc-oversized.
(get_group_info): Use walloc.h function instead of checking for
overflow by hand.
* modules/group-member: Remove xalloc-oversized.
Add walloc.
---
 ChangeLog            | 6 ++++++
 lib/group-member.c   | 7 +++----
 modules/group-member | 2 +-
 3 files changed, 10 insertions(+), 5 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index 4ced38a..db3adba 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 2017-06-04  Paul Eggert  <address@hidden>
 
+       group-member: use walloc
+       * lib/group-member.c: Include walloc.h instead of
+       xalloc-oversized.
+       (get_group_info): Use walloc.h function instead of checking for
+       overflow by hand.
+
        getgroups: use walloc
        * lib/getgroups.c: Include minmax.h, walloc.h, limits.h.
        (rpl_getgroups): Use walloc.h functions instead of checking for
diff --git a/lib/group-member.c b/lib/group-member.c
index 20f8ee8..6fe6bd5 100644
--- a/lib/group-member.c
+++ b/lib/group-member.c
@@ -25,7 +25,7 @@
 #include <sys/types.h>
 #include <stdlib.h>
 
-#include "xalloc-oversized.h"
+#include "walloc.h"
 
 /* Most processes have no more than this many groups, and for these
    processes we can avoid using malloc.  */
@@ -53,10 +53,9 @@ get_group_info (struct group_info *gi)
   if (n_groups < 0)
     {
       int n_group_slots = getgroups (0, NULL);
-      if (0 <= n_group_slots
-          && ! xalloc_oversized (n_group_slots, sizeof *gi->group))
+      if (0 <= n_group_slots)
         {
-          gi->group = malloc (n_group_slots * sizeof *gi->group);
+          gi->group = wreallocarray (NULL, n_group_slots, sizeof *gi->group);
           if (gi->group)
             n_groups = getgroups (n_group_slots, gi->group);
         }
diff --git a/modules/group-member b/modules/group-member
index 9baf8e9..d8f19b2 100644
--- a/modules/group-member
+++ b/modules/group-member
@@ -9,7 +9,7 @@ Depends-on:
 unistd
 extensions
 getgroups        [test $HAVE_GROUP_MEMBER = 0]
-xalloc-oversized [test $HAVE_GROUP_MEMBER = 0]
+walloc           [test $HAVE_GROUP_MEMBER = 0]
 
 configure.ac:
 gl_FUNC_GROUP_MEMBER
-- 
2.9.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]