1 mike 1.1 //BEGIN_LICENSE
2 //
3 // Copyright (c) 2000 The Open Group, BMC Software, Tivoli Systems, IBM
4 //
5 // Permission is hereby granted, free of charge, to any person obtaining a
6 // copy of this software and associated documentation files (the "Software"),
7 // to deal in the Software without restriction, including without limitation
8 // the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 // and/or sell copies of the Software, and to permit persons to whom the
10 // Software is furnished to do so, subject to the following conditions:
11 //
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
13 // IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
14 // FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
15 // THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
16 // LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
17 // FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
18 // DEALINGS IN THE SOFTWARE.
19 //
20 //END_LICENSE
21 //BEGIN_HISTORY
22 mike 1.1 //
23 // Author:
24 //
|
54 mike 1.1 #include <Pegasus/Common/Char16.h>
55
56 PEGASUS_NAMESPACE_BEGIN
57
58 template<class T>
59 inline void Zeros(T* items, Uint32 size)
60 {
61 memset(items, 0, sizeof(T) * size);
62 }
63
64 template<class T>
65 inline void Destroy(T* items, Uint32 size)
66 {
67 while (size--)
68 items++->~T();
69 }
70
71 inline void Destroy(Boolean* items, Uint32 size) { }
72 inline void Destroy(Uint8* items, Uint32 size) { }
73 inline void Destroy(Sint8* items, Uint32 size) { }
74 inline void Destroy(Uint16* items, Uint32 size) { }
75 mike 1.1 inline void Destroy(Sint16* items, Uint32 size) { }
76 inline void Destroy(Uint32* items, Uint32 size) { }
77 inline void Destroy(Sint32* items, Uint32 size) { }
78 inline void Destroy(Uint64* items, Uint32 size) { }
79 inline void Destroy(Sint64* items, Uint32 size) { }
80 inline void Destroy(Real32* items, Uint32 size) { }
81 inline void Destroy(Real64* items, Uint32 size) { }
82 inline void Destroy(Char16* items, Uint32 size) { }
83
84 template<class T, class U>
85 inline void CopyToRaw(T* to, const U* from, Uint32 size)
86 {
87 while (size--)
88 new(to++) T(*from++);
89 }
90
91 inline void CopyToRaw(Boolean* to, const Boolean* from, Uint32 size)
92 {
93 memcpy(to, from, sizeof(Boolean) * size);
94 }
95
96 mike 1.1 inline void CopyToRaw(Uint8* to, const Uint8* from, Uint32 size)
97 {
98 memcpy(to, from, sizeof(Uint8) * size);
99 }
100
101 inline void CopyToRaw(Sint8* to, const Sint8* from, Uint32 size)
102 {
103 memcpy(to, from, sizeof(Sint8) * size);
104 }
105
106 inline void CopyToRaw(Uint16* to, const Uint16* from, Uint32 size)
107 {
108 memcpy(to, from, sizeof(Uint16) * size);
109 }
110
111 inline void CopyToRaw(Sint16* to, const Sint16* from, Uint32 size)
112 {
113 memcpy(to, from, sizeof(Sint16) * size);
114 }
115
116 inline void CopyToRaw(Uint32* to, const Uint32* from, Uint32 size)
117 mike 1.1 {
118 memcpy(to, from, sizeof(Uint32) * size);
119 }
120
121 inline void CopyToRaw(Sint32* to, const Sint32* from, Uint32 size)
122 {
123 memcpy(to, from, sizeof(Sint32) * size);
124 }
125
126 inline void CopyToRaw(Uint64* to, const Uint64* from, Uint32 size)
127 {
128 memcpy(to, from, sizeof(Uint64) * size);
129 }
130
131 inline void CopyToRaw(Sint64* to, const Sint64* from, Uint32 size)
132 {
133 memcpy(to, from, sizeof(Sint64) * size);
134 }
135
136 inline void CopyToRaw(Real32* to, const Real32* from, Uint32 size)
137 {
138 mike 1.1 memcpy(to, from, sizeof(Real32) * size);
139 }
140
141 inline void CopyToRaw(Real64* to, const Real64* from, Uint32 size)
142 {
143 memcpy(to, from, sizeof(Real64) * size);
144 }
145
146 inline void CopyToRaw(Char16* to, const Char16* from, Uint32 size)
147 {
148 memcpy(to, from, sizeof(Char16) * size);
149 }
150
151 template<class T>
152 inline void InitializeRaw(T* items, Uint32 size)
153 {
154 while (size--)
155 items++->~T();
156 }
157
158 inline void InitializeRaw(Boolean* items, Uint32 size) { Zeros(items, size); }
159 mike 1.1 inline void InitializeRaw(Uint8* items, Uint32 size) { Zeros(items, size); }
160 inline void InitializeRaw(Sint8* items, Uint32 size) { Zeros(items, size); }
161 inline void InitializeRaw(Uint16* items, Uint32 size) { Zeros(items, size); }
162 inline void InitializeRaw(Sint16* items, Uint32 size) { Zeros(items, size); }
163 inline void InitializeRaw(Uint32* items, Uint32 size) { Zeros(items, size); }
164 inline void InitializeRaw(Sint32* items, Uint32 size) { Zeros(items, size); }
165 inline void InitializeRaw(Uint64* items, Uint32 size) { Zeros(items, size); }
166 inline void InitializeRaw(Sint64* items, Uint32 size) { Zeros(items, size); }
167 inline void InitializeRaw(Real32* items, Uint32 size) { Zeros(items, size); }
168 inline void InitializeRaw(Real64* items, Uint32 size) { Zeros(items, size); }
169 inline void InitializeRaw(Char16* items, Uint32 size) { Zeros(items, size); }
170
171 PEGASUS_NAMESPACE_END
172
173 #endif /* Pegasus_Memory_h */
|