2011-04-28 Eric Blake <eblake@redhat.com>
+ hash, mgetgroups: drop xalloc dependency
+ * lib/hash.c (includes): Adjust includes.
+ * lib/mgetgroups.c (includes): Likewise.
+ (xgetgroups): Move...
+ * lib/xgetgroups.c: ...to new file.
+ * lib/mgetgroups.h (xgetgroups): Make declaration conditional.
+ * modules/xgetgroups: New file, split from...
+ * modules/mgetgroups: ...here.
+ (Depends-on): Add xalloc-oversized.
+ * modules/hash (Depends-on): Likewise.
+ * modules/hash-tests (Depends-on): Drop xalloc.
+ (test_hash_LDADD): Drop unused library.
+ * tests/test-hash.c (main): Break xalloc dependency.
+ (includes): Drop unused include.
+
xalloc-oversized: new module
* modules/xalloc-oversized: New module.
* modules/xalloc (Depends-on): Add it.
Date Modules Changes
+2011-04-27 mgetgroups The 'xgetgroups' function has been split into
+ a new 'xgetgroups' module.
+
2011-04-27 save-cwd This module pulls in fewer dependencies by
default; to retain robust handling of directories
with an absolute name longer than PATH_MAX, you
#include "hash.h"
#include "bitrotate.h"
-#include "xalloc.h"
+#include "xalloc-oversized.h"
#include <stdint.h>
#include <stdio.h>
#endif
#include "getugroups.h"
-#include "xalloc.h"
+#include "xalloc-oversized.h"
static gid_t *
realloc_groupbuf (gid_t *g, size_t num)
return ng;
}
-
-/* Like mgetgroups, but call xalloc_die on allocation failure. */
-
-int
-xgetgroups (char const *username, gid_t gid, gid_t **groups)
-{
- int result = mgetgroups (username, gid, groups);
- if (result == -1 && errno == ENOMEM)
- xalloc_die ();
- return result;
-}
#include <sys/types.h>
int mgetgroups (const char *username, gid_t gid, gid_t **groups);
+#if GNULIB_XGETGROUPS
int xgetgroups (const char *username, gid_t gid, gid_t **groups);
+#endif
--- /dev/null
+/* xgetgroups.c -- return a list of the groups a user or current process is in
+
+ Copyright (C) 2007-2011 Free Software Foundation, Inc.
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>. */
+
+/* Extracted from coreutils' src/id.c. */
+
+#include <config.h>
+
+#include "mgetgroups.h"
+
+#include <errno.h>
+
+#include "xalloc.h"
+
+/* Like mgetgroups, but call xalloc_die on allocation failure. */
+
+int
+xgetgroups (char const *username, gid_t gid, gid_t **groups)
+{
+ int result = mgetgroups (username, gid, groups);
+ if (result == -1 && errno == ENOMEM)
+ xalloc_die ();
+ return result;
+}
Description:
-Parametrizable hash table.
+Parameterizable hash table.
Files:
lib/hash.c
bitrotate
stdbool
stdint
-xalloc
+xalloc-oversized
configure.ac:
gl_HASH
inttostr
progname
stdbool
-xalloc
configure.ac:
Makefile.am:
TESTS += test-hash
check_PROGRAMS += test-hash
-test_hash_LDADD = $(LDADD) @LIBINTL@
getgroups
getugroups
realloc-gnu
-xalloc
+xalloc-oversized
configure.ac:
gl_MGETGROUPS
--- /dev/null
+Description:
+Return the group IDs of a user or current process in malloc'd storage, with
+out-of-memory checking.
+
+Files:
+lib/xgetgroups.c
+
+Depends-on:
+mgetgroups
+xalloc
+
+configure.ac:
+gl_MODULE_INDICATOR([xgetgroups])
+
+Makefile.am:
+lib_SOURCES += xgetgroups.c
+
+Include:
+"mgetgroups.h"
+
+License:
+GPL
+
+Maintainer:
+Jim Meyering, Eric Blake
#include "hash.h"
#include "hash-pjw.h"
#include "inttostr.h"
-#include "xalloc.h"
#include <stdio.h>
#include <stdlib.h>
ASSERT (ht);
insert_new (ht, "a");
{
- char *str1 = xstrdup ("a");
- char *str2 = hash_insert (ht, str1);
+ char *str1 = strdup ("a");
+ char *str2;
+ ASSERT (str1);
+ str2 = hash_insert (ht, str1);
ASSERT (str1 != str2);
ASSERT (STREQ (str1, str2));
free (str1);
ht = hash_initialize (sz, NULL, NULL, NULL, NULL);
ASSERT (ht);
{
- char *str = xstrdup ("a");
+ char *str = strdup ("a");
+ ASSERT (str);
insert_new (ht, "a");
insert_new (ht, str);
ASSERT (hash_lookup (ht, str) == str);
{
char buf[50];
char const *p = uinttostr (i, buf);
- insert_new (ht, xstrdup (p));
+ char *dup = strdup (p);
+ ASSERT (dup);
+ insert_new (ht, dup);
}
break;