summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/ChangeLog8
-rw-r--r--lib/Makefile.am1
-rw-r--r--lib/userspec.c2
-rw-r--r--lib/xalloc.h15
-rw-r--r--lib/xmalloc.c12
-rw-r--r--lib/xstrdup.c33
-rw-r--r--m4/ChangeLog3
-rw-r--r--m4/xalloc.m48
8 files changed, 25 insertions, 57 deletions
diff --git a/lib/ChangeLog b/lib/ChangeLog
index 7cb4619f6..9bfb3b279 100644
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -1,6 +1,14 @@
2004-10-04 Paul Eggert <eggert@cs.ucla.edu>
Sync from gnulib.
+
+ * xalloc.h (xmemdup): Renamed from xclone.
+ * xmalloc.c (xmemdup): Likewise.
+ * xalloc.h (CCLONE, CLONE, NEW, XCALLOC, XMALLOC, XREALLOC,
+ XFREE): Remove these long-obsolescent macros.
+ * xmalloc.c (xstrdup): Implementation moved here from xstrdup.c
+ * xstrdup.c: Remove.
+
* argmatch.c, closeout.c, error.c, exclude.c, getdate.y,
getndelim2.c, getpass.c, getusershell.c, linebuffer.c,
md5.c, mountlist.c, posixtm.c, readtokens.c, readutmp.c,
diff --git a/lib/Makefile.am b/lib/Makefile.am
index e5a776b72..131b18e3c 100644
--- a/lib/Makefile.am
+++ b/lib/Makefile.am
@@ -130,7 +130,6 @@ libfetish_a_SOURCES = \
xmemcoll.c xmemcoll.h \
xnanosleep.c xnanosleep.h \
xreadlink.c xreadlink.h \
- xstrdup.c \
xstrndup.c xstrndup.h \
xstrtod.c xstrtod.h \
xstrtoimax.c \
diff --git a/lib/userspec.c b/lib/userspec.c
index ba66fac8b..037961d47 100644
--- a/lib/userspec.c
+++ b/lib/userspec.c
@@ -154,7 +154,7 @@ parse_with_separator (char const *spec, char const *separator,
size_t ulen = separator - spec;
if (ulen != 0)
{
- u = xclone (spec, ulen + 1);
+ u = xmemdup (spec, ulen + 1);
u[ulen] = '\0';
}
}
diff --git a/lib/xalloc.h b/lib/xalloc.h
index d81f2a676..8d0fcf0fa 100644
--- a/lib/xalloc.h
+++ b/lib/xalloc.h
@@ -53,8 +53,8 @@ void *xrealloc (void *p, size_t s);
void *xnrealloc (void *p, size_t n, size_t s);
void *x2realloc (void *p, size_t *pn);
void *x2nrealloc (void *p, size_t *pn, size_t s);
-void *xclone (void const *p, size_t s);
-char *xstrdup (const char *str);
+void *xmemdup (void const *p, size_t s);
+char *xstrdup (char const *str);
/* Return 1 if an array of N objects, each of size S, cannot exist due
to size arithmetic overflow. S must be positive and N must be
@@ -71,17 +71,6 @@ char *xstrdup (const char *str);
# define xalloc_oversized(n, s) \
((size_t) (sizeof (ptrdiff_t) <= sizeof (size_t) ? -1 : -2) / (s) < (n))
-/* These macros are deprecated; they will go away soon, and are retained
- temporarily only to ease conversion to the functions described above. */
-# define CCLONE(p, n) xclone (p, (n) * sizeof *(p))
-# define CLONE(p) xclone (p, sizeof *(p))
-# define NEW(type, var) type *var = xmalloc (sizeof (type))
-# define XCALLOC(type, n) xcalloc (n, sizeof (type))
-# define XMALLOC(type, n) xnmalloc (n, sizeof (type))
-# define XREALLOC(p, type, n) xnrealloc (p, n, sizeof (type))
-# define XFREE(p) free (p)
-
-
# ifdef __cplusplus
}
# endif
diff --git a/lib/xmalloc.c b/lib/xmalloc.c
index 9b7a948c2..13c249026 100644
--- a/lib/xmalloc.c
+++ b/lib/xmalloc.c
@@ -211,11 +211,19 @@ xcalloc (size_t n, size_t s)
}
/* Clone an object P of size S, with error checking. There's no need
- for xnclone (P, N, S), since xclone (P, N * S) works without any
+ for xnmemdup (P, N, S), since xmemdup (P, N * S) works without any
need for an arithmetic overflow check. */
void *
-xclone (void const *p, size_t s)
+xmemdup (void const *p, size_t s)
{
return memcpy (xmalloc (s), p, s);
}
+
+/* Clone STRING. */
+
+char *
+xstrdup (char const *string)
+{
+ return xmemdup (string, strlen (string) + 1);
+}
diff --git a/lib/xstrdup.c b/lib/xstrdup.c
deleted file mode 100644
index 58f18beb6..000000000
--- a/lib/xstrdup.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/* xstrdup.c -- copy a string with out of memory checking
- Copyright (C) 1990, 1996, 1998, 2001, 2003 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 2, 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, write to the Free Software Foundation,
- Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */
-
-#if HAVE_CONFIG_H
-# include <config.h>
-#endif
-
-/* Specification. */
-#include "xalloc.h"
-
-#include <string.h>
-
-/* Return a newly allocated copy of STRING. */
-
-char *
-xstrdup (const char *string)
-{
- return xclone (string, strlen (string) + 1);
-}
diff --git a/m4/ChangeLog b/m4/ChangeLog
index 450fd1e7c..da71b55de 100644
--- a/m4/ChangeLog
+++ b/m4/ChangeLog
@@ -1,6 +1,9 @@
2004-10-04 Paul Eggert <eggert@cs.ucla.edu>
Sync from gnulib.
+
+ * xalloc.m4 (gl_PREREQ_XSTRDUP): Remove. All uses removed.
+
* unlocked-io.m4: Add copyright notice.
(gl_FUNC_GLIBC_UNLOCKED_IO): Define USE_UNLOCKED_IO.
diff --git a/m4/xalloc.m4 b/m4/xalloc.m4
index 4d9383509..96797e9f5 100644
--- a/m4/xalloc.m4
+++ b/m4/xalloc.m4
@@ -1,4 +1,4 @@
-# xalloc.m4 serial 9
+# xalloc.m4 serial 10
dnl Copyright (C) 2002-2004 Free Software Foundation, Inc.
dnl This file is free software, distributed under the terms of the GNU
dnl General Public License. As a special exception to the GNU General
@@ -10,7 +10,6 @@ AC_DEFUN([gl_XALLOC],
[
gl_PREREQ_XALLOC
gl_PREREQ_XMALLOC
- gl_PREREQ_XSTRDUP
])
# Prerequisites of lib/xalloc.h.
@@ -23,8 +22,3 @@ AC_DEFUN([gl_PREREQ_XMALLOC], [
AC_REQUIRE([AC_C_INLINE])
:
])
-
-# Prerequisites of lib/xstrdup.c.
-AC_DEFUN([gl_PREREQ_XSTRDUP], [
- :
-])