summaryrefslogtreecommitdiff
path: root/tests/xalloc.h
diff options
context:
space:
mode:
Diffstat (limited to 'tests/xalloc.h')
-rw-r--r--tests/xalloc.h59
1 files changed, 30 insertions, 29 deletions
diff --git a/tests/xalloc.h b/tests/xalloc.h
index 57a13e0..6122cc5 100644
--- a/tests/xalloc.h
+++ b/tests/xalloc.h
@@ -1,7 +1,8 @@
/* xalloc.h -- malloc with out-of-memory checking
- Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
- 1999, 2000, 2003, 2004, 2006, 2007, 2008 Free Software Foundation, Inc.
+ Copyright (C) 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+ 2000, 2003, 2004, 2006, 2007, 2008, 2009, 2010 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
@@ -105,10 +106,10 @@ char *xstrdup (char const *str) ATTRIBUTE_MALLOC;
# if HAVE_INLINE
# define static_inline static inline
# else
- void *xnmalloc (size_t n, size_t s) ATTRIBUTE_MALLOC;
- void *xnrealloc (void *p, size_t n, size_t s);
- void *x2nrealloc (void *p, size_t *pn, size_t s);
- char *xcharalloc (size_t n) ATTRIBUTE_MALLOC;
+void *xnmalloc (size_t n, size_t s) ATTRIBUTE_MALLOC;
+void *xnrealloc (void *p, size_t n, size_t s);
+void *x2nrealloc (void *p, size_t *pn, size_t s);
+char *xcharalloc (size_t n) ATTRIBUTE_MALLOC;
# endif
# ifdef static_inline
@@ -161,9 +162,9 @@ xnrealloc (void *p, size_t n, size_t s)
void
append_int (int value)
{
- if (used == allocated)
- p = x2nrealloc (p, &allocated, sizeof *p);
- p[used++] = value;
+ if (used == allocated)
+ p = x2nrealloc (p, &allocated, sizeof *p);
+ p[used++] = value;
}
This causes x2nrealloc to allocate a block of some nonzero size the
@@ -181,12 +182,12 @@ xnrealloc (void *p, size_t n, size_t s)
void
append_int (int value)
{
- if (used == allocated)
- {
- p = x2nrealloc (p, &allocated1, sizeof *p);
- allocated = allocated1;
- }
- p[used++] = value;
+ if (used == allocated)
+ {
+ p = x2nrealloc (p, &allocated1, sizeof *p);
+ allocated = allocated1;
+ }
+ p[used++] = value;
}
*/
@@ -199,25 +200,25 @@ x2nrealloc (void *p, size_t *pn, size_t s)
if (! p)
{
if (! n)
- {
- /* The approximate size to use for initial small allocation
- requests, when the invoking code specifies an old size of
- zero. 64 bytes is the largest "small" request for the
- GNU C library malloc. */
- enum { DEFAULT_MXFAST = 64 };
-
- n = DEFAULT_MXFAST / s;
- n += !n;
- }
+ {
+ /* The approximate size to use for initial small allocation
+ requests, when the invoking code specifies an old size of
+ zero. 64 bytes is the largest "small" request for the
+ GNU C library malloc. */
+ enum { DEFAULT_MXFAST = 64 };
+
+ n = DEFAULT_MXFAST / s;
+ n += !n;
+ }
}
else
{
/* Set N = ceil (1.5 * N) so that progress is made if N == 1.
- Check for overflow, so that N * S stays in size_t range.
- The check is slightly conservative, but an exact check isn't
- worth the trouble. */
+ Check for overflow, so that N * S stays in size_t range.
+ The check is slightly conservative, but an exact check isn't
+ worth the trouble. */
if ((size_t) -1 / 3 * 2 / s <= n)
- xalloc_die ();
+ xalloc_die ();
n += (n + 1) / 2;
}