[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
- [PATCH 01/13] walloc: new module, Paul Eggert, 2017/06/05
- [PATCH 08/13] getgroups: use walloc, Paul Eggert, 2017/06/05
- [PATCH 06/13] acl-permissions: use walloc, Paul Eggert, 2017/06/05
- [PATCH 09/13] group-member: use walloc,
Paul Eggert <=
- [PATCH 10/13] propername: use xwalloc rather than xalloc, Paul Eggert, 2017/06/05
- [PATCH 07/13] exclude: use xwalloc instead of xalloc, Paul Eggert, 2017/06/05
- [PATCH 13/13] xstriconv: use xwalloc rather than xalloc, Paul Eggert, 2017/06/05
- [PATCH 02/13] xwalloc, xwalloc-die, xwallocator: new modules, Paul Eggert, 2017/06/05
- [PATCH 11/13] quotearg: use xwalloc rather than xalloc, Paul Eggert, 2017/06/05
- [PATCH 04/13] careadlinkat: use walloc, Paul Eggert, 2017/06/05
- [PATCH 05/13] dfa: use xwalloc instead of xalloc, Paul Eggert, 2017/06/05
- [PATCH 03/13] allocator: allow reasons other than size overflow, Paul Eggert, 2017/06/05
- [PATCH 12/13] trim: use xwalloc rather than xalloc, Paul Eggert, 2017/06/05