hjl / source-git / glibc

Forked from source-git/glibc 3 years ago
Clone

Blame malloc/tst-mxfast.c

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