Blame malloc/tst-mxfast.c

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