netstat: Initial implementation.
[wine] / dlls / msvcp90 / memory.c
1 /*
2  * Copyright 2010 Piotr Caban for CodeWeavers
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18
19 #include "config.h"
20
21 #include <stdarg.h>
22 #include <limits.h>
23
24 #include "msvcp90.h"
25
26 #include "windef.h"
27 #include "winbase.h"
28
29
30 /* ?address@?$allocator@D@std@@QBEPADAAD@Z */
31 /* ?address@?$allocator@D@std@@QEBAPEADAEAD@Z */
32 DEFINE_THISCALL_WRAPPER(MSVCP_allocator_char_address, 8)
33 char* __thiscall MSVCP_allocator_char_address(void *this, char *ptr)
34 {
35     return ptr;
36 }
37
38 /* ?address@?$allocator@D@std@@QBEPBDABD@Z */
39 /* ?address@?$allocator@D@std@@QEBAPEBDAEBD@Z */
40 DEFINE_THISCALL_WRAPPER(MSVCP_allocator_char_const_address, 8)
41 const char* __thiscall MSVCP_allocator_char_const_address(void *this, const char *ptr)
42 {
43     return ptr;
44 }
45
46 /* ??0?$allocator@D@std@@QAE@XZ */
47 /* ??0?$allocator@D@std@@QEAA@XZ */
48 DEFINE_THISCALL_WRAPPER(MSVCP_allocator_char_ctor, 4)
49 void* __thiscall MSVCP_allocator_char_ctor(void *this)
50 {
51     return this;
52 }
53
54 /* ??0?$allocator@D@std@@QAE@ABV01@@Z */
55 /* ??0?$allocator@D@std@@QEAA@AEBV01@@Z */
56 DEFINE_THISCALL_WRAPPER(MSVCP_allocator_char_copy_ctor, 8)
57 void* __thiscall MSVCP_allocator_char_copy_ctor(void *this, const void *copy)
58 {
59     return this;
60 }
61
62 /* ??4?$allocator@D@std@@QAEAAV01@ABV01@@Z */
63 /* ??4?$allocator@D@std@@QEAAAEAV01@AEBV01@@Z */
64 DEFINE_THISCALL_WRAPPER(MSVCP_allocator_char_assign, 8)
65 void* __thiscall MSVCP_allocator_char_assign(void *this, const void *assign)
66 {
67     return this;
68 }
69
70 /* ?deallocate@?$allocator@D@std@@QAEXPADI@Z */
71 /* ?deallocate@?$allocator@D@std@@QEAAXPEAD_K@Z */
72 DEFINE_THISCALL_WRAPPER(MSVCP_allocator_char_deallocate, 12)
73 void __thiscall MSVCP_allocator_char_deallocate(void *this, char *ptr, MSVCP_size_t size)
74 {
75     MSVCRT_operator_delete(ptr);
76 }
77
78 /* ?allocate@?$allocator@D@std@@QAEPADI@Z */
79 /* ?allocate@?$allocator@D@std@@QEAAPEAD_K@Z */
80 DEFINE_THISCALL_WRAPPER(MSVCP_allocator_char_allocate, 8)
81 char* __thiscall MSVCP_allocator_char_allocate(void *this, MSVCP_size_t count)
82 {
83     return MSVCRT_operator_new(count);
84 }
85
86 /* ?allocate@?$allocator@D@std@@QAEPADIPBX@Z */
87 /* ?allocate@?$allocator@D@std@@QEAAPEAD_KPEBX@Z */
88 DEFINE_THISCALL_WRAPPER(MSVCP_allocator_char_allocate_hint, 12)
89 char* __thiscall MSVCP_allocator_char_allocate_hint(void *this,
90         MSVCP_size_t count, const void *hint)
91 {
92     /* Native ignores hint */
93     return MSVCP_allocator_char_allocate(this, count);
94 }
95
96 /* ?construct@?$allocator@D@std@@QAEXPADABD@Z */
97 /* ?construct@?$allocator@D@std@@QEAAXPEADAEBD@Z */
98 DEFINE_THISCALL_WRAPPER(MSVCP_allocator_char_construct, 12)
99 void __thiscall MSVCP_allocator_char_construct(void *this, char *ptr, const char *val)
100 {
101     *ptr = *val;
102 }
103
104 /* ?destroy@?$allocator@D@std@@QAEXPAD@Z */
105 /* ?destroy@?$allocator@D@std@@QEAAXPEAD@Z */
106 DEFINE_THISCALL_WRAPPER(MSVCP_allocator_char_destroy, 8)
107 void __thiscall MSVCP_allocator_char_destroy(void *this, char *ptr)
108 {
109 }
110
111 /* ?max_size@?$allocator@D@std@@QBEIXZ */
112 /* ?max_size@?$allocator@D@std@@QEBA_KXZ */
113 DEFINE_THISCALL_WRAPPER(MSVCP_allocator_char_max_size, 4)
114 MSVCP_size_t __thiscall MSVCP_allocator_char_max_size(void *this)
115 {
116     return UINT_MAX/sizeof(char);
117 }
118
119
120 /* allocator<wchar_t> */
121 /* ?address@?$allocator@_W@std@@QBEPA_WAA_W@Z */
122 /* ?address@?$allocator@_W@std@@QEBAPEA_WAEA_W@Z */
123 DEFINE_THISCALL_WRAPPER(MSVCP_allocator_wchar_address, 8)
124 wchar_t* __thiscall MSVCP_allocator_wchar_address(void *this, wchar_t *ptr)
125 {
126     return ptr;
127 }
128
129 /* ?address@?$allocator@_W@std@@QBEPB_WAB_W@Z */
130 /* ?address@?$allocator@_W@std@@QEBAPEB_WAEB_W@Z */
131 DEFINE_THISCALL_WRAPPER(MSVCP_allocator_wchar_const_address, 8)
132 const wchar_t* __thiscall MSVCP_allocator_wchar_const_address(void *this, const wchar_t *ptr)
133 {
134     return ptr;
135 }
136
137 /* ??0?$allocator@_W@std@@QAE@XZ */
138 /* ??0?$allocator@_W@std@@QEAA@XZ */
139 DEFINE_THISCALL_WRAPPER(MSVCP_allocator_wchar_ctor, 4)
140 void* __thiscall MSVCP_allocator_wchar_ctor(void *this)
141 {
142     return this;
143 }
144
145 /* ??0?$allocator@_W@std@@QAE@ABV01@@Z */
146 /* ??0?$allocator@_W@std@@QEAA@AEBV01@@Z */
147 DEFINE_THISCALL_WRAPPER(MSVCP_allocator_wchar_copy_ctor, 8)
148 void* __thiscall MSVCP_allocator_wchar_copy_ctor(void *this, void *copy)
149 {
150     return this;
151 }
152
153 /* ??4?$allocator@_W@std@@QAEAAV01@ABV01@@Z */
154 /* ??4?$allocator@_W@std@@QEAAAEAV01@AEBV01@@Z */
155 DEFINE_THISCALL_WRAPPER(MSVCP_allocator_wchar_assign, 8)
156 void* __thiscall MSVCP_allocator_wchar_assign(void *this, void *assign)
157 {
158     return this;
159 }
160
161 /* ?deallocate@?$allocator@_W@std@@QAEXPA_WI@Z */
162 /* ?deallocate@?$allocator@_W@std@@QEAAXPEA_W_K@Z */
163 DEFINE_THISCALL_WRAPPER(MSVCP_allocator_wchar_deallocate, 12)
164 void __thiscall MSVCP_allocator_wchar_deallocate(void *this,
165         wchar_t *ptr, MSVCP_size_t size)
166 {
167     MSVCRT_operator_delete(ptr);
168 }
169
170 /* ?allocate@?$allocator@_W@std@@QAEPA_WI@Z */
171 /* ?allocate@?$allocator@_W@std@@QEAAPEA_W_K@Z */
172 DEFINE_THISCALL_WRAPPER(MSVCP_allocator_wchar_allocate, 8)
173 wchar_t* __thiscall MSVCP_allocator_wchar_allocate(void *this, MSVCP_size_t count)
174 {
175     if(UINT_MAX/count < sizeof(wchar_t)) {
176         throw_exception(EXCEPTION_BAD_ALLOC, NULL);
177         return NULL;
178     }
179
180     return MSVCRT_operator_new(count * sizeof(wchar_t));
181 }
182
183 /* ?allocate@?$allocator@_W@std@@QAEPA_WIPBX@Z */
184 /* ?allocate@?$allocator@_W@std@@QEAAPEA_W_KPEBX@Z */
185 DEFINE_THISCALL_WRAPPER(MSVCP_allocator_wchar_allocate_hint, 12)
186 wchar_t* __thiscall MSVCP_allocator_wchar_allocate_hint(void *this,
187         MSVCP_size_t count, const void *hint)
188 {
189     return MSVCP_allocator_wchar_allocate(this, count);
190 }
191
192 /* ?construct@?$allocator@_W@std@@QAEXPA_WAB_W@Z */
193 /* ?construct@?$allocator@_W@std@@QEAAXPEA_WAEB_W@Z */
194 DEFINE_THISCALL_WRAPPER(MSVCP_allocator_wchar_construct, 12)
195 void __thiscall MSVCP_allocator_wchar_construct(void *this,
196         wchar_t *ptr, const wchar_t *val)
197 {
198     *ptr = *val;
199 }
200
201 /* ?destroy@?$allocator@_W@std@@QAEXPA_W@Z */
202 /* ?destroy@?$allocator@_W@std@@QEAAXPEA_W@Z */
203 DEFINE_THISCALL_WRAPPER(MSVCP_allocator_wchar_destroy, 8)
204 void __thiscall MSVCP_allocator_wchar_destroy(void *this, char *ptr)
205 {
206 }
207
208 /* ?max_size@?$allocator@_W@std@@QBEIXZ */
209 /* ?max_size@?$allocator@_W@std@@QEBA_KXZ */
210 DEFINE_THISCALL_WRAPPER(MSVCP_allocator_wchar_max_size, 4)
211 MSVCP_size_t __thiscall MSVCP_allocator_wchar_max_size(void *this)
212 {
213     return UINT_MAX/sizeof(wchar_t);
214 }
215
216 /* allocator<unsigned short> */
217 /* ?address@?$allocator@G@std@@QBEPAGAAG@Z */
218 /* ?address@?$allocator@G@std@@QEBAPEAGAEAG@Z */
219 DEFINE_THISCALL_WRAPPER(MSVCP_allocator_short_address, 8)
220 unsigned short* __thiscall MSVCP_allocator_short_address(
221         void *this, unsigned short *ptr)
222 {
223     return ptr;
224 }
225
226 /* ?address@?$allocator@G@std@@QBEPBGABG@Z */
227 /* ?address@?$allocator@G@std@@QEBAPEBGAEBG@Z */
228 DEFINE_THISCALL_WRAPPER(MSVCP_allocator_short_const_address, 8)
229 const unsigned short* __thiscall MSVCP_allocator_short_const_address(
230         void *this, const unsigned short *ptr)
231 {
232     return ptr;
233 }
234
235 /* ??0?$allocator@G@std@@QAE@XZ */
236 /* ??0?$allocator@G@std@@QEAA@XZ */
237 DEFINE_THISCALL_WRAPPER(MSVCP_allocator_short_ctor, 4)
238 void* __thiscall MSVCP_allocator_short_ctor(void *this)
239 {
240     return this;
241 }
242
243 /* ??0?$allocator@G@std@@QAE@ABV01@@Z */
244 /* ??0?$allocator@G@std@@QEAA@AEBV01@@Z */
245 DEFINE_THISCALL_WRAPPER(MSVCP_allocator_short_copy_ctor, 8)
246 void* __thiscall MSVCP_allocator_short_copy_ctor(void *this, void *copy)
247 {
248     return this;
249 }
250
251 /* ??4?$allocator@G@std@@QAEAAV01@ABV01@@Z */
252 /* ??4?$allocator@G@std@@QEAAAEAV01@AEBV01@@Z */
253 DEFINE_THISCALL_WRAPPER(MSVCP_allocator_short_assign, 8)
254 void* __thiscall MSVCP_allocator_short_assign(void *this, void *assign)
255 {
256     return this;
257 }
258
259 /* ?deallocate@?$allocator@G@std@@QAEXPAGI@Z */
260 /* ?deallocate@?$allocator@G@std@@QEAAXPEAG_K@Z */
261 DEFINE_THISCALL_WRAPPER(MSVCP_allocator_short_deallocate, 12)
262 void __thiscall MSVCP_allocator_short_deallocate(void *this,
263         unsigned short *ptr, MSVCP_size_t size)
264 {
265     MSVCRT_operator_delete(ptr);
266 }
267
268 /* ?allocate@?$allocator@G@std@@QAEPAGI@Z */
269 /* ?allocate@?$allocator@G@std@@QEAAPEAG_K@Z */
270 DEFINE_THISCALL_WRAPPER(MSVCP_allocator_short_allocate, 8)
271 unsigned short* __thiscall MSVCP_allocator_short_allocate(
272         void *this, MSVCP_size_t count)
273 {
274     if(UINT_MAX/count < sizeof(unsigned short)) {
275         throw_exception(EXCEPTION_BAD_ALLOC, NULL);
276         return NULL;
277     }
278
279     return MSVCRT_operator_new(count * sizeof(unsigned short));
280 }
281
282 /* ?allocate@?$allocator@G@std@@QAEPAGIPBX@Z */
283 /* ?allocate@?$allocator@G@std@@QEAAPEAG_KPEBX@Z */
284 DEFINE_THISCALL_WRAPPER(MSVCP_allocator_short_allocate_hint, 12)
285 unsigned short* __thiscall MSVCP_allocator_short_allocate_hint(
286         void *this, MSVCP_size_t count, const void *hint)
287 {
288     return MSVCP_allocator_short_allocate(this, count);
289 }
290
291 /* ?construct@?$allocator@G@std@@QAEXPAGABG@Z */
292 /* ?construct@?$allocator@G@std@@QEAAXPEAGAEBG@Z */
293 DEFINE_THISCALL_WRAPPER(MSVCP_allocator_short_construct, 12)
294 void __thiscall MSVCP_allocator_short_construct(void *this,
295         unsigned short *ptr, unsigned short *val)
296 {
297     *ptr = *val;
298 }
299
300 /* ?destroy@?$allocator@G@std@@QAEXPAG@Z */
301 /* ?destroy@?$allocator@G@std@@QEAAXPEAG@Z */
302 DEFINE_THISCALL_WRAPPER(MSVCP_allocator_short_destroy, 8)
303 void __thiscall MSVCP_allocator_short_destroy(void *this, MSVCP_size_t *ptr)
304 {
305 }
306
307 /* ?max_size@?$allocator@G@std@@QBEIXZ */
308 /* ?max_size@?$allocator@G@std@@QEBA_KXZ */
309 DEFINE_THISCALL_WRAPPER(MSVCP_allocator_short_max_size, 4)
310 MSVCP_size_t __thiscall MSVCP_allocator_short_max_size(void *this)
311 {
312     return UINT_MAX/sizeof(unsigned short);
313 }
314
315 /* allocator<void> */
316 /* ??0?$allocator@X@std@@QAE@XZ */
317 /* ??0?$allocator@X@std@@QEAA@XZ */
318 DEFINE_THISCALL_WRAPPER(MSVCP_allocator_void_ctor, 4)
319 void* __thiscall MSVCP_allocator_void_ctor(void *this)
320 {
321     return this;
322 }
323
324 /* ??0?$allocator@X@std@@QAE@ABV01@@Z */
325 /* ??0?$allocator@X@std@@QEAA@AEBV01@@Z */
326 DEFINE_THISCALL_WRAPPER(MSVCP_allocator_void_copy_ctor, 8)
327 void* __thiscall MSVCP_allocator_void_copy_ctor(void *this, void *copy)
328 {
329     return this;
330 }
331
332 /* ??4?$allocator@X@std@@QAEAAV01@ABV01@@Z */
333 /* ??4?$allocator@X@std@@QEAAAEAV01@AEBV01@@Z */
334 DEFINE_THISCALL_WRAPPER(MSVCP_allocator_void_assign, 8)
335 void* __thiscall MSVCP_allocator_void_assign(void *this, void *assign)
336 {
337     return this;
338 }