mallopt.c 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /*
  2. This is a version (aka dlmalloc) of malloc/free/realloc written by
  3. Doug Lea and released to the public domain. Use, modify, and
  4. redistribute this code without permission or acknowledgement in any
  5. way you wish. Send questions, comments, complaints, performance
  6. data, etc to dl@cs.oswego.edu
  7. VERSION 2.7.2 Sat Aug 17 09:07:30 2002 Doug Lea (dl at gee)
  8. Note: There may be an updated version of this malloc obtainable at
  9. ftp://gee.cs.oswego.edu/pub/misc/malloc.c
  10. Check before installing!
  11. Hacked up for uClibc by Erik Andersen <andersen@codepoet.org>
  12. */
  13. #include "malloc.h"
  14. /* ------------------------------ mallopt ------------------------------ */
  15. int mallopt(int param_number, int value)
  16. {
  17. int ret;
  18. mstate av;
  19. ret = 0;
  20. __MALLOC_LOCK;
  21. av = get_malloc_state();
  22. /* Ensure initialization/consolidation */
  23. __malloc_consolidate(av);
  24. switch(param_number) {
  25. case M_MXFAST:
  26. if (value >= 0 && value <= MAX_FAST_SIZE) {
  27. set_max_fast(av, value);
  28. ret = 1;
  29. }
  30. break;
  31. case M_TRIM_THRESHOLD:
  32. av->trim_threshold = value;
  33. ret = 1;
  34. break;
  35. case M_TOP_PAD:
  36. av->top_pad = value;
  37. ret = 1;
  38. break;
  39. case M_MMAP_THRESHOLD:
  40. av->mmap_threshold = value;
  41. ret = 1;
  42. break;
  43. case M_MMAP_MAX:
  44. av->n_mmaps_max = value;
  45. ret = 1;
  46. break;
  47. }
  48. __MALLOC_UNLOCK;
  49. return ret;
  50. }