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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
/****************************************************************************
*
* Open Watcom Project
*
* Portions Copyright (c) 1983-2002 Sybase, Inc. All Rights Reserved.
*
* ========================================================================
*
* This file contains Original Code and/or Modifications of Original
* Code as defined in and that are subject to the Sybase Open Watcom
* Public License version 1.0 (the 'License'). You may not use this file
* except in compliance with the License. BY USING THIS FILE YOU AGREE TO
* ALL TERMS AND CONDITIONS OF THE LICENSE. A copy of the License is
* provided with the Original Code and Modifications, and is also
* available at www.sybase.com/developer/opensource.
*
* The Original Code and all software distributed under the License are
* distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
* EXPRESS OR IMPLIED, AND SYBASE AND ALL CONTRIBUTORS HEREBY DISCLAIM
* ALL SUCH WARRANTIES, INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR
* NON-INFRINGEMENT. Please see the License for the specific language
* governing rights and limitations under the License.
*
* ========================================================================
*
* Description: Interface to the trmem memory allocation tracker and
* validator. This isn't used normally and will work for
* Open Watcom only.
****************************************************************************/
typedef struct _trmem_internal *_trmem_hdl;
typedef void ; /* generic pointer to code */
/* generic pointer to code with realloc signature */
typedef void *;
/*
These are some special conditions that trmem can detect. OR together
the ones you're interested in and pass them to _trmem_open in the __flags
parameter.
*/
;
/*
_trmem_open:
__alloc must be supplied and behave like malloc() when passed a size of 0.
__free must be supplied and behave like free() when passed a NULL ptr.
__realloc may be omitted (use _TRMEM_NO_REALLOC). __realloc must behave
like realloc() when passed a NULL pointer or a size of 0.
__expand may be omitted (use _TRMEM_NO_REALLOC). __expand must behave
like _expand() when passed a NULL pointer or a size of 0.
__prt_parm is passed to __prt_line only.
__prt_line must be supplied. It is called to output any messages trmem
needs to communicate. __buf is a null-terminated string of length
__len (including a trailing '\n').
__flags see enum above for more information.
trmem uses __alloc and __free for its own internal structures. None of
the internal structures will appear in the memory statistics given by
_trmem_prt_usage or _trmem_prt_list.
The handle returned uniquely identifies the tracker. Multiple trackers
may be used simultaneously.
A NULL return indicates failure, for one of any reason.
_trmem_open can/will use any of __alloc, __free, or __prt_line; so be
sure they are initialized before calling _trmem_open.
*/
_trmem_hdl ;
/*
If ( __flags & _TRMEM_CLOSE_CHECK_FREE ) then _trmem_close checks if all
allocated chunks were freed before closing the handle.
Returns number of unfreed chunks.
*/
unsigned ;
/*
Replace calls such as
ptr = malloc( size );
with
ptr = _trmem_alloc( size, _trmem_guess_who(), hdl );
*/
void *;
void ;
void *;
void *;
char *;
size_t ;
/*
_trmem_prt_usage prints the current memory usage, and peak usage.
_trmem_prt_list prints a list of all currently allocated chunks.
*/
void ;
unsigned ;
/*
_trmem_get_current_usage retrieves the current memory usage.
_trmem_get_peak_usage retrieves the peak memory usage.
*/
unsigned long ;
unsigned long ;
_trmem_who ;