OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2008 The Android Open Source Project | 3 * Copyright 2008 The Android Open Source Project |
4 * | 4 * |
5 * Use of this source code is governed by a BSD-style license that can be | 5 * Use of this source code is governed by a BSD-style license that can be |
6 * found in the LICENSE file. | 6 * found in the LICENSE file. |
7 */ | 7 */ |
8 | 8 |
9 | 9 |
10 #ifndef SkWriter32_DEFINED | 10 #ifndef SkWriter32_DEFINED |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 void writeMul4(const void* values, size_t size) { | 158 void writeMul4(const void* values, size_t size) { |
159 this->write(values, size); | 159 this->write(values, size); |
160 } | 160 } |
161 | 161 |
162 /** | 162 /** |
163 * Write size bytes from values. size must be a multiple of 4, though | 163 * Write size bytes from values. size must be a multiple of 4, though |
164 * values need not be 4-byte aligned. | 164 * values need not be 4-byte aligned. |
165 */ | 165 */ |
166 void write(const void* values, size_t size) { | 166 void write(const void* values, size_t size) { |
167 SkASSERT(SkAlign4(size) == size); | 167 SkASSERT(SkAlign4(size) == size); |
168 memcpy(this->reserve(size), values, size); | 168 sk_careful_memcpy(this->reserve(size), values, size); |
169 } | 169 } |
170 | 170 |
171 /** | 171 /** |
172 * Reserve size bytes. Does not need to be 4 byte aligned. The remaining sp
ace (if any) will be | 172 * Reserve size bytes. Does not need to be 4 byte aligned. The remaining sp
ace (if any) will be |
173 * filled in with zeroes. | 173 * filled in with zeroes. |
174 */ | 174 */ |
175 uint32_t* reservePad(size_t size) { | 175 uint32_t* reservePad(size_t size) { |
176 size_t alignedSize = SkAlign4(size); | 176 size_t alignedSize = SkAlign4(size); |
177 uint32_t* p = this->reserve(alignedSize); | 177 uint32_t* p = this->reserve(alignedSize); |
178 if (alignedSize != size) { | 178 if (alignedSize != size) { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 union { | 261 union { |
262 void* fPtrAlignment; | 262 void* fPtrAlignment; |
263 double fDoubleAlignment; | 263 double fDoubleAlignment; |
264 char fStorage[SIZE]; | 264 char fStorage[SIZE]; |
265 } fData; | 265 } fData; |
266 | 266 |
267 typedef SkWriter32 INHERITED; | 267 typedef SkWriter32 INHERITED; |
268 }; | 268 }; |
269 | 269 |
270 #endif | 270 #endif |
OLD | NEW |