aboutsummaryrefslogtreecommitdiff
path: root/malloc/tst-mallocstate.c
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2002-01-29 07:54:51 +0000
committerUlrich Drepper <drepper@redhat.com>2002-01-29 07:54:51 +0000
commitfa8d436c87f156d18208df3819fecee9fc1dbd9e (patch)
treee22f5754d69c0144f0945a26727c3984008f9d37 /malloc/tst-mallocstate.c
parentdb2ebcef2428cb568315895f8fe3ef19d41735bc (diff)
downloadglibc-fa8d436c87f156d18208df3819fecee9fc1dbd9e.tar
glibc-fa8d436c87f156d18208df3819fecee9fc1dbd9e.tar.gz
glibc-fa8d436c87f156d18208df3819fecee9fc1dbd9e.tar.bz2
glibc-fa8d436c87f156d18208df3819fecee9fc1dbd9e.zip
Update.
2002-01-18 Wolfram Gloger <wg@malloc.de> * malloc/malloc.c: Rewrite, adapted from Doug Lea's malloc-2.7.0.c. * malloc/malloc.h: Likewise. * malloc/arena.c: New file. * malloc/hooks.c: New file. * malloc/tst-mallocstate.c: New file. * malloc/Makefile: Add new testcase tst-mallocstate. Add arena.c and hooks.c to distribute. Fix commented CPPFLAGS. 2002-01-28 Ulrich Drepper <drepper@redhat.com> * stdlib/msort.c: Remove last patch. The optimization violates the same rule which qsort.c had problems with. 2002-01-27 Paul Eggert <eggert@twinsun.com> * stdlib/qsort.c (_quicksort): Do not apply the comparison function to a pivot element that lies outside the array to be sorted, as ISO C99 requires that the comparison function be called only with addresses of array elements [PR libc/2880].
Diffstat (limited to 'malloc/tst-mallocstate.c')
-rw-r--r--malloc/tst-mallocstate.c82
1 files changed, 82 insertions, 0 deletions
diff --git a/malloc/tst-mallocstate.c b/malloc/tst-mallocstate.c
new file mode 100644
index 0000000000..97a10586d3
--- /dev/null
+++ b/malloc/tst-mallocstate.c
@@ -0,0 +1,82 @@
+/* Copyright (C) 2001 Free Software Foundation, Inc.
+ This file is part of the GNU C Library.
+ Contributed by Wolfram Gloger <wg@malloc.de>, 2001.
+
+ The GNU C Library is free software; you can redistribute it and/or
+ modify it under the terms of the GNU Lesser General Public
+ License as published by the Free Software Foundation; either
+ version 2.1 of the License, or (at your option) any later version.
+
+ The GNU C Library 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
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with the GNU C Library; if not, write to the Free
+ Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+ 02111-1307 USA. */
+
+#include <errno.h>
+#include <stdio.h>
+#include "malloc.h"
+
+static int errors = 0;
+
+static void
+merror (const char *msg)
+{
+ ++errors;
+ printf ("Error: %s\n", msg);
+}
+
+int
+main (void)
+{
+ void *p1, *p2;
+ void *save_state;
+ long i;
+
+ errno = 0;
+
+ p1 = malloc (10);
+ if (p1 == NULL)
+ merror ("malloc (10) failed.");
+
+ p2 = malloc (20);
+ if (p2 == NULL)
+ merror ("malloc (20) failed.");
+
+ free (malloc (10));
+
+ for (i=0; i<100; ++i)
+ {
+ save_state = malloc_get_state ();
+ if (save_state == NULL)
+ {
+ merror ("malloc_get_state () failed.");
+ break;
+ }
+ /*free (malloc (10)); This could change the top chunk! */
+ malloc_set_state (save_state);
+ p1 = realloc (p1, i*4 + 4);
+ if (p1 == NULL)
+ merror ("realloc (i*4) failed.");
+ free (save_state);
+ }
+
+ p1 = realloc (p1, 40);
+ free (p2);
+ p2 = malloc (10);
+ if (p2 == NULL)
+ merror ("malloc (10) failed.");
+ free (p1);
+
+ return errors != 0;
+}
+
+/*
+ * Local variables:
+ * c-basic-offset: 2
+ * End:
+ */