+2003-07-22 Paul Eggert <eggert@twinsun.com>
+
+ * modules/xalloc (Depends-on): Add exitfail.
+ * modules/xmemcoll: Likewise.
+
2003-07-20 Jim Meyering <jim@meyering.net>
* modules/closeout (Depends-on): Add exitfail.
+2003-07-22 Paul Eggert <eggert@twinsun.com>
+
+ * xalloc.h (XCALLOC, XREALLOC, CCLONE): Fix under- and
+ over-parenthesization in macros.
+
+ Sync with coreutils.
+
+ * xalloc.h (XMALLOC, XCALLOC, XREALLOC): Remove casts not
+ required by C99.
+
+ Use `exit_failure' for xalloc and xmemcoll instead of their own
+ private exit-failure variables.
+ * xalloc.h (xalloc_exit_failure): Remove.
+ * xmalloc.c: Likewise. Include exitfail.h.
+ (xalloc_die): Use exit_failure instead of xalloc_exit_failure.
+ * xmemcoll.h (xmemcoll_exit_failure): Remove.
+ * xmemcoll.c: Likewise. Include exitfail.h.
+ (xmemcoll): Use exit_failure instead of xalloc_exit_failure.
+
2003-07-18 Paul Eggert <eggert@twinsun.com>
* closeout.h (close_stdout_set_status, close_stdout_status): Remove.
# define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
# endif
-/* Exit value when the requested amount of memory is not available.
- It is initialized to EXIT_FAILURE, but the caller may set it to
- some other value. */
-extern int xalloc_exit_failure;
-
/* If this pointer is non-zero, run the specified function upon each
allocation failure. It is initialized to zero. */
extern void (*xalloc_fail_func) (void);
extern char const xalloc_msg_memory_exhausted[];
/* This function is always triggered when memory is exhausted. It is
- in charge of honoring the three previous items. This is the
+ in charge of honoring the two previous items. It exits with status
+ exit_failure (defined in exitfail.h). This is the
function to call when one wants the program to die because of a
memory allocation failure. */
extern void xalloc_die (void) ATTRIBUTE_NORETURN;
void *xrealloc (void *p, size_t n);
char *xstrdup (const char *str);
-# define XMALLOC(Type, N_items) ((Type *) xmalloc (sizeof (Type) * (N_items)))
-# define XCALLOC(Type, N_items) ((Type *) xcalloc (sizeof (Type), (N_items)))
-# define XREALLOC(Ptr, Type, N_items) \
- ((Type *) xrealloc ((void *) (Ptr), sizeof (Type) * (N_items)))
+# define XMALLOC(Type, N_items) xmalloc (sizeof (Type) * (N_items))
+# define XCALLOC(Type, N_items) xcalloc (sizeof (Type), N_items)
+# define XREALLOC(Ptr, Type, N_items) xrealloc (Ptr, sizeof (Type) * (N_items))
/* Declare and alloc memory for VAR of type TYPE. */
# define NEW(Type, Var) Type *(Var) = XMALLOC (Type, 1)
/* Return a pointer to a malloc'ed copy of the array SRC of NUM elements. */
# define CCLONE(Src, Num) \
- (memcpy (xmalloc (sizeof (*Src) * (Num)), (Src), sizeof (*Src) * (Num)))
+ (memcpy (xmalloc (sizeof *(Src) * (Num)), Src, sizeof *(Src) * (Num)))
/* Return a malloc'ed copy of SRC. */
# define CLONE(Src) CCLONE (Src, 1)
#define N_(msgid) msgid
#include "error.h"
+#include "exitfail.h"
#include "xalloc.h"
#ifndef EXIT_FAILURE
"you must run the autoconf test for a GNU libc compatible realloc"
#endif
-/* Exit value when the requested amount of memory is not available.
- The caller may set it to some other value. */
-int xalloc_exit_failure = EXIT_FAILURE;
-
/* If non NULL, call this function when memory is exhausted. */
void (*xalloc_fail_func) (void) = 0;
{
if (xalloc_fail_func)
(*xalloc_fail_func) ();
- error (xalloc_exit_failure, 0, "%s", _(xalloc_msg_memory_exhausted));
+ error (exit_failure, 0, "%s", _(xalloc_msg_memory_exhausted));
/* The `noreturn' cannot be given to error, since it may return if
its first argument is 0. To help compilers understand the
xalloc_die does terminate, call exit. */
/* Locale-specific memory comparison.
- Copyright (C) 2002 Free Software Foundation, Inc.
+ Copyright (C) 2002, 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
#define _(msgid) gettext (msgid)
#include "error.h"
+#include "exitfail.h"
#include "memcoll.h"
#include "quotearg.h"
#include "xmemcoll.h"
-/* Exit value when xmemcoll fails.
- The caller may set it to some other value. */
-int xmemcoll_exit_failure = EXIT_FAILURE;
-
/* Compare S1 (with length S1LEN) and S2 (with length S2LEN) according
to the LC_COLLATE locale. S1 and S2 do not overlap, and are not
adjacent. Temporarily modify the bytes after S1 and S2, but
{
error (0, collation_errno, _("string comparison failed"));
error (0, 0, _("Set LC_ALL='C' to work around the problem."));
- error (xmemcoll_exit_failure, 0,
+ error (exit_failure, 0,
_("The strings compared were %s and %s."),
quotearg_n_style_mem (0, locale_quoting_style, s1, s1len),
quotearg_n_style_mem (1, locale_quoting_style, s2, s2len));
#include <stddef.h>
-extern int xmemcoll_exit_failure;
int xmemcoll (char *, size_t, char *, size_t);
realloc
error
gettext
+exitfail
configure.ac:
gl_XALLOC
gettext
error
quotearg
+exitfail
configure.ac: