summaryrefslogtreecommitdiffstats
path: root/private/crt32/heap/heapprm.c
diff options
context:
space:
mode:
authorAdam <you@example.com>2020-05-17 05:51:50 +0200
committerAdam <you@example.com>2020-05-17 05:51:50 +0200
commite611b132f9b8abe35b362e5870b74bce94a1e58e (patch)
treea5781d2ec0e085eeca33cf350cf878f2efea6fe5 /private/crt32/heap/heapprm.c
downloadNT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.gz
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.bz2
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.lz
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.xz
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.tar.zst
NT4.0-e611b132f9b8abe35b362e5870b74bce94a1e58e.zip
Diffstat (limited to 'private/crt32/heap/heapprm.c')
-rw-r--r--private/crt32/heap/heapprm.c87
1 files changed, 87 insertions, 0 deletions
diff --git a/private/crt32/heap/heapprm.c b/private/crt32/heap/heapprm.c
new file mode 100644
index 000000000..c0d810ecc
--- /dev/null
+++ b/private/crt32/heap/heapprm.c
@@ -0,0 +1,87 @@
+/***
+*heapprm.c - Set/report heap parameters
+*
+* Copyright (c) 1991, Microsoft Corporation. All rights reserved.
+*
+*Purpose:
+* Set or report the values of certain parameters in the heap.
+*
+*Revision History:
+* 03-04-91 GJF Module created.
+*
+*******************************************************************************/
+
+#include <cruntime.h>
+#include <heap.h>
+#include <malloc.h>
+#include <os2dll.h>
+
+/***
+*_heap_param(int flag, int param_id, void *pparam) - set or report the values
+* of the specified heap parameter.
+*
+*Purpose:
+* Get or set certain parameters which affect the behavior of the heap.
+* The supported parameters vary implementation to implementation and
+* version to version. See description of entry conditions for the
+* currently supported parameters.
+*
+*Entry:
+* int flag - _HP_GETPARAM, to get a parameter value, or _HP_SETPARAM,
+* to set a parameter value
+*
+* int param_id - identifier for the heap parameter. values supported in
+* this release are:
+*
+* _HP_AMBLKSIZ - _amblksiz (aka _heap_growsize) parameter
+* _HP_GROWSIZE - same as _HP_AMBLKSIZ
+* _HP_RESETSIZE - _heap_resetsize parameter
+*
+* void *pparam - pointer to variable of appropriate type for the heap
+* parameter to be fetched/set
+*
+*Exit:
+* 0 = no error has occurred
+* -1 = an error has occurred (errno is set)
+*
+*Exceptions:
+*
+*******************************************************************************/
+
+int _CALLTYPE1 _heap_param (
+ int flag,
+ int param_id,
+ void *pparam
+ )
+{
+
+ switch ( param_id ) {
+
+ case _HP_RESETSIZE:
+ if ( flag == _HP_SETPARAM ) {
+ _mlock(_HEAP_LOCK);
+ _heap_resetsize = *(unsigned *)pparam;
+ _munlock(_HEAP_LOCK);
+ }
+ else
+ *(unsigned *)pparam = _heap_resetsize;
+ break;
+
+ case _HP_AMBLKSIZ:
+ if ( flag == _HP_SETPARAM )
+ /*
+ * the only references to _amblksiz (aka
+ * _heap_growsize) are atomic. therefore, the
+ * heap does not need to be locked.
+ */
+ _amblksiz = *(unsigned *)pparam;
+ else
+ *(unsigned *)pparam = _amblksiz;
+ break;
+
+ default:
+ return -1;
+ }
+
+ return 0;
+}