Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 lines
2.2 KiB

  1. /***
  2. *heapprm.c - Set/report heap parameters
  3. *
  4. * Copyright (c) 1991-2001, Microsoft Corporation. All rights reserved.
  5. *
  6. *Purpose:
  7. * Set or report the values of certain parameters in the heap.
  8. *
  9. *Revision History:
  10. * 03-04-91 GJF Module created.
  11. * 04-06-93 SKS Replace _CRTAPI* with __cdecl
  12. * 04-30-95 GJF Made conditional on WINHEAP.
  13. *
  14. *******************************************************************************/
  15. #ifndef WINHEAP
  16. #include <cruntime.h>
  17. #include <heap.h>
  18. #include <malloc.h>
  19. #include <mtdll.h>
  20. /***
  21. *_heap_param(int flag, int param_id, void *pparam) - set or report the values
  22. * of the specified heap parameter.
  23. *
  24. *Purpose:
  25. * Get or set certain parameters which affect the behavior of the heap.
  26. * The supported parameters vary implementation to implementation and
  27. * version to version. See description of entry conditions for the
  28. * currently supported parameters.
  29. *
  30. *Entry:
  31. * int flag - _HP_GETPARAM, to get a parameter value, or _HP_SETPARAM,
  32. * to set a parameter value
  33. *
  34. * int param_id - identifier for the heap parameter. values supported in
  35. * this release are:
  36. *
  37. * _HP_AMBLKSIZ - _amblksiz (aka _heap_growsize) parameter
  38. * _HP_GROWSIZE - same as _HP_AMBLKSIZ
  39. * _HP_RESETSIZE - _heap_resetsize parameter
  40. *
  41. * void *pparam - pointer to variable of appropriate type for the heap
  42. * parameter to be fetched/set
  43. *
  44. *Exit:
  45. * 0 = no error has occurred
  46. * -1 = an error has occurred (errno is set)
  47. *
  48. *Exceptions:
  49. *
  50. *******************************************************************************/
  51. int __cdecl _heap_param (
  52. int flag,
  53. int param_id,
  54. void *pparam
  55. )
  56. {
  57. switch ( param_id ) {
  58. case _HP_RESETSIZE:
  59. if ( flag == _HP_SETPARAM ) {
  60. _mlock(_HEAP_LOCK);
  61. _heap_resetsize = *(unsigned *)pparam;
  62. _munlock(_HEAP_LOCK);
  63. }
  64. else
  65. *(unsigned *)pparam = _heap_resetsize;
  66. break;
  67. case _HP_AMBLKSIZ:
  68. if ( flag == _HP_SETPARAM )
  69. /*
  70. * the only references to _amblksiz (aka
  71. * _heap_growsize) are atomic. therefore, the
  72. * heap does not need to be locked.
  73. */
  74. _amblksiz = *(unsigned *)pparam;
  75. else
  76. *(unsigned *)pparam = _amblksiz;
  77. break;
  78. default:
  79. return -1;
  80. }
  81. return 0;
  82. }
  83. #endif /* WINHEAP */