int
__libc_mallopt (int param_number, int value)
{
  mstate av = &main_arena;
  int res = 1;

  if (__malloc_initialized < 0)
    ptmalloc_init ();
  __libc_lock_lock (av->mutex);

  LIBC_PROBE (memory_mallopt, 2, param_number, value);

  /* We must consolidate main arena before changing max_fast
     (see definition of set_max_fast).  */
  malloc_consolidate (av);

  switch (param_number)
    {
    case M_MXFAST:
      if (value >= 0 && value <= MAX_FAST_SIZE)
        {
          LIBC_PROBE (memory_mallopt_mxfast, 2, value, get_max_fast ());
          set_max_fast (value);
        }
      else
        res = 0;
      break;

    case M_TRIM_THRESHOLD:
      do_set_trim_threshold (value);
      break;

    case M_TOP_PAD:
      do_set_top_pad (value);
      break;

    case M_MMAP_THRESHOLD:
      res = do_set_mmap_threshold (value);
      break;

    case M_MMAP_MAX:
      do_set_mmaps_max (value);
      break;

    case M_CHECK_ACTION:
      do_set_mallopt_check (value);
      break;

    case M_PERTURB:
      do_set_perturb_byte (value);
      break;

    case M_ARENA_TEST:
      if (value > 0)
	do_set_arena_test (value);
      break;

    case M_ARENA_MAX:
      if (value > 0)
	do_set_arena_max (value);
      break;
    }
  __libc_lock_unlock (av->mutex);
  return res;
int
__libc_mallopt (int param_number, int value)
{
  mstate av = &main_arena;
  int res = 1;

  if (__malloc_initialized < 0)
    ptmalloc_init ();
  __libc_lock_lock (av->mutex);

  LIBC_PROBE (memory_mallopt, 2, param_number, value);

   
  malloc_consolidate (av);

  switch (param_number)
    {
    case M_MXFAST:
      if (value >= 0 && value <= MAX_FAST_SIZE)
        {
          LIBC_PROBE (memory_mallopt_mxfast, 2, value, get_max_fast ());
          set_max_fast (value);
        }
      else
        res = 0;
      break;

    case M_TRIM_THRESHOLD:
      do_set_trim_threshold (value);
      break;

    case M_TOP_PAD:
      do_set_top_pad (value);
      break;

    case M_MMAP_THRESHOLD:
      res = do_set_mmap_threshold (value);
      break;

    case M_MMAP_MAX:
      do_set_mmaps_max (value);
      break;

    case M_CHECK_ACTION:
      do_set_mallopt_check (value);
      break;

    case M_PERTURB:
      do_set_perturb_byte (value);
      break;

    case M_ARENA_TEST:
      if (value > 0)
	do_set_arena_test (value);
      break;

    case M_ARENA_MAX:
      if (value > 0)
	do_set_arena_max (value);
      break;
    }
  __libc_lock_unlock (av->mutex);
  return res;