blob: 103f2af9d2085aa9cf625f424ac860eae9d7a353 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
/***
*msize.c - calculate the size of a memory block in the heap
*
* Copyright (c) 1989-1991, Microsoft Corporation. All rights reserved.
*
*Purpose:
* Defines the following function:
* _msize() - calculate the size of a block in the heap
*
*Revision History:
* 07-18-89 GJF Module created
* 11-13-89 GJF Added MTHREAD support. Also fixed copyright and got
* rid of DEBUG286 stuff.
* 12-18-89 GJF Changed name of header file to heap.h, also added
* explicit _cdecl to function definitions.
* 03-11-90 GJF Replaced _cdecl with _CALLTYPE1 and added #include
* <cruntime.h>
* 07-30-90 SBM Added return statement to MTHREAD _msize function
* 09-28-90 GJF New-style function declarators.
* 04-08-91 GJF Temporary hack for Win32/DOS folks - special version
* of _msize that calls HeapSize. Change conditioned on
* _WIN32DOS_.
*
*******************************************************************************/
#ifndef _WIN32DOS_
#include <cruntime.h>
#include <heap.h>
#include <malloc.h>
#include <os2dll.h>
#include <stdlib.h>
/***
*size_t _msize(pblck) - calculate the size of specified block in the heap
*
*Purpose:
* Calculates the size of memory block (in the heap) pointed to by
* pblck.
*
*Entry:
* void *pblck - pointer to a memory block in the heap
*
*Return:
* size of the block
*
*******************************************************************************/
#ifdef MTHREAD
size_t _CALLTYPE1 _msize (
void *pblck
)
{
size_t retval;
/* lock the heap
*/
_mlock(_HEAP_LOCK);
retval = _msize_lk(pblck);
/* release the heap lock
*/
_munlock(_HEAP_LOCK);
return retval;
}
size_t _CALLTYPE1 _msize_lk (
#else /* ndef MTHREAD */
size_t _CALLTYPE1 _msize (
#endif /* MTHREAD */
void *pblck
)
{
#ifdef DEBUG
if (!_CHECK_BACKPTR(pblck))
_heap_abort();
#endif
return( (size_t) ((char *)_ADDRESS(_BACKPTR(pblck)->pnextdesc) -
(char *)pblck) );
}
#else /* _WIN32DOS_ */
/*
* TEMPORARY HACK! THE CODE BELOW IS INTENDED TO ALLOW LIMITED USE OF THE
* C RUNTIME ON WIN32/DOS. IT WILL BE DELETED AS SOON AS THEY IMPLEMENT
* VirtualAlloc()!
*/
#include <cruntime.h>
#include <oscalls.h>
#include <malloc.h>
extern HANDLE _HeapHandle;
size_t _CALLTYPE1 _msize (
void *pblck
)
{
return( (size_t)HeapSize(_HeapHandle, pblck) );
}
#endif /* _WIN32DOS_ */
|