Blame malloc/tst-mxfast.c
|
Packit Service |
f6b4a2 |
/* Test that glibc.malloc.mxfast tunable works.
|
|
Packit Service |
ffbb63 |
Copyright (C) 2019 Free Software Foundation, Inc.
|
|
Packit Service |
f6b4a2 |
This file is part of the GNU C Library.
|
|
Packit Service |
f6b4a2 |
|
|
Packit Service |
f6b4a2 |
The GNU C Library is free software; you can redistribute it and/or
|
|
Packit Service |
f6b4a2 |
modify it under the terms of the GNU Lesser General Public
|
|
Packit Service |
f6b4a2 |
License as published by the Free Software Foundation; either
|
|
Packit Service |
f6b4a2 |
version 2.1 of the License, or (at your option) any later version.
|
|
Packit Service |
f6b4a2 |
|
|
Packit Service |
f6b4a2 |
The GNU C Library is distributed in the hope that it will be useful,
|
|
Packit Service |
f6b4a2 |
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
Packit Service |
f6b4a2 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
Packit Service |
f6b4a2 |
Lesser General Public License for more details.
|
|
Packit Service |
f6b4a2 |
|
|
Packit Service |
f6b4a2 |
You should have received a copy of the GNU Lesser General Public
|
|
Packit Service |
f6b4a2 |
License along with the GNU C Library; if not, see
|
|
Packit Service |
f6b4a2 |
<http://www.gnu.org/licenses/>. */
|
|
Packit Service |
f6b4a2 |
|
|
Packit Service |
f6b4a2 |
/* This test verifies that setting the glibc.malloc.mxfast tunable to
|
|
Packit Service |
f6b4a2 |
zero results in free'd blocks being returned to the small bins, not
|
|
Packit Service |
f6b4a2 |
the fast bins. */
|
|
Packit Service |
f6b4a2 |
|
|
Packit Service |
f6b4a2 |
#include <malloc.h>
|
|
Packit Service |
ffbb63 |
#include <support/check.h>
|
|
Packit Service |
f6b4a2 |
|
|
Packit Service |
f6b4a2 |
int
|
|
Packit Service |
ffbb63 |
do_test (void)
|
|
Packit Service |
f6b4a2 |
{
|
|
Packit Service |
f6b4a2 |
struct mallinfo m;
|
|
Packit Service |
ffbb63 |
char *volatile p1;
|
|
Packit Service |
ffbb63 |
char *volatile p2;
|
|
Packit Service |
f6b4a2 |
|
|
Packit Service |
f6b4a2 |
/* Arbitrary value; must be in default fastbin range. */
|
|
Packit Service |
f6b4a2 |
p1 = malloc (3);
|
|
Packit Service |
f6b4a2 |
/* Something large so that p1 isn't a "top block" */
|
|
Packit Service |
f6b4a2 |
p2 = malloc (512);
|
|
Packit Service |
f6b4a2 |
free (p1);
|
|
Packit Service |
f6b4a2 |
|
|
Packit Service |
ffbb63 |
m = mallinfo ();
|
|
Packit Service |
f6b4a2 |
|
|
Packit Service |
f6b4a2 |
/* This will fail if there are any blocks in the fastbins. */
|
|
Packit Service |
ffbb63 |
TEST_COMPARE (m.smblks, 0);
|
|
Packit Service |
f6b4a2 |
|
|
Packit Service |
f6b4a2 |
/* To keep gcc happy. */
|
|
Packit Service |
f6b4a2 |
free (p2);
|
|
Packit Service |
f6b4a2 |
|
|
Packit Service |
f6b4a2 |
return 0;
|
|
Packit Service |
f6b4a2 |
}
|
|
Packit Service |
f6b4a2 |
|
|
Packit Service |
f6b4a2 |
#include <support/test-driver.c>
|