wineps.drv: Slightly simplify a PPD parser code snippet.
[wine] / dlls / msvcp71 / 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 "msvcp.h"
25
26 #include "windef.h"
27 #include "winbase.h"
28
29 /* ?deallocate@?$allocator@D@std@@QAEXPADI@Z */
30 /* ?deallocate@?$allocator@D@std@@QEAAXPEAD_K@Z */
31 void MSVCP_allocator_char_deallocate(void *this, char *ptr, MSVCP_size_t size)
32 {
33     MSVCRT_operator_delete(ptr);
34 }
35
36 /* ?allocate@?$allocator@D@std@@QAEPADI@Z */
37 /* ?allocate@?$allocator@D@std@@QEAAPEAD_K@Z */
38 char* MSVCP_allocator_char_allocate(void *this, MSVCP_size_t count)
39 {
40     return MSVCRT_operator_new(count);
41 }
42
43 /* ?max_size@?$allocator@D@std@@QBEIXZ */
44 /* ?max_size@?$allocator@D@std@@QEBA_KXZ */
45 MSVCP_size_t MSVCP_allocator_char_max_size(void *this)
46 {
47     return UINT_MAX/sizeof(char);
48 }
49
50
51 /* allocator<wchar_t> */
52 /* ?deallocate@?$allocator@_W@std@@QAEXPA_WI@Z */
53 /* ?deallocate@?$allocator@_W@std@@QEAAXPEA_W_K@Z */
54 void MSVCP_allocator_wchar_deallocate(void *this,
55         wchar_t *ptr, MSVCP_size_t size)
56 {
57     MSVCRT_operator_delete(ptr);
58 }
59
60 /* ?allocate@?$allocator@_W@std@@QAEPA_WI@Z */
61 /* ?allocate@?$allocator@_W@std@@QEAAPEA_W_K@Z */
62 wchar_t* MSVCP_allocator_wchar_allocate(void *this, MSVCP_size_t count)
63 {
64     if(UINT_MAX/count < sizeof(wchar_t)) {
65         throw_exception(EXCEPTION_BAD_ALLOC, NULL);
66         return NULL;
67     }
68
69     return MSVCRT_operator_new(count * sizeof(wchar_t));
70 }
71
72 /* ?max_size@?$allocator@_W@std@@QBEIXZ */
73 /* ?max_size@?$allocator@_W@std@@QEBA_KXZ */
74 MSVCP_size_t MSVCP_allocator_wchar_max_size(void *this)
75 {
76     return UINT_MAX/sizeof(wchar_t);
77 }
78
79 /* allocator<void> */
80 /* ??0?$allocator@X@std@@QAE@XZ */
81 /* ??0?$allocator@X@std@@QEAA@XZ */
82 DEFINE_THISCALL_WRAPPER(MSVCP_allocator_void_ctor, 4)
83 void* __thiscall MSVCP_allocator_void_ctor(void *this)
84 {
85     return this;
86 }
87
88 /* ??0?$allocator@X@std@@QAE@ABV01@@Z */
89 /* ??0?$allocator@X@std@@QEAA@AEBV01@@Z */
90 DEFINE_THISCALL_WRAPPER(MSVCP_allocator_void_copy_ctor, 8)
91 void* __thiscall MSVCP_allocator_void_copy_ctor(void *this, void *copy)
92 {
93     return this;
94 }
95
96 /* ??4?$allocator@X@std@@QAEAAV01@ABV01@@Z */
97 /* ??4?$allocator@X@std@@QEAAAEAV01@AEBV01@@Z */
98 DEFINE_THISCALL_WRAPPER(MSVCP_allocator_void_assign, 8)
99 void* __thiscall MSVCP_allocator_void_assign(void *this, void *assign)
100 {
101     return this;
102 }