OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkWriter32.h" | 8 #include "SkWriter32.h" |
9 | 9 |
10 SkWriter32::SkWriter32(size_t minSize, void* storage, size_t storageSize) { | 10 SkWriter32::SkWriter32(size_t minSize, void* storage, size_t storageSize) { |
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
241 #include "SkString.h" | 241 #include "SkString.h" |
242 | 242 |
243 /* | 243 /* |
244 * Strings are stored as: length[4-bytes] + string_data + '\0' + pad_to_mul_4 | 244 * Strings are stored as: length[4-bytes] + string_data + '\0' + pad_to_mul_4 |
245 */ | 245 */ |
246 | 246 |
247 const char* SkReader32::readString(size_t* outLen) { | 247 const char* SkReader32::readString(size_t* outLen) { |
248 size_t len = this->readInt(); | 248 size_t len = this->readInt(); |
249 const void* ptr = this->peek(); | 249 const void* ptr = this->peek(); |
250 | 250 |
251 // skip over teh string + '\0' and then pad to a multiple of 4 | 251 // skip over the string + '\0' and then pad to a multiple of 4 |
sugoi1
2013/08/29 18:55:53
Just fixing the typo
| |
252 size_t alignedSize = SkAlign4(len + 1); | 252 size_t alignedSize = SkAlign4(len + 1); |
253 this->skip(alignedSize); | 253 this->skip(alignedSize); |
254 | 254 |
255 if (outLen) { | 255 if (outLen) { |
256 *outLen = len; | 256 *outLen = len; |
257 } | 257 } |
258 return (const char*)ptr; | 258 return (const char*)ptr; |
259 } | 259 } |
260 | 260 |
261 size_t SkReader32::readIntoString(SkString* copy) { | 261 size_t SkReader32::readIntoString(SkString* copy) { |
(...skipping 28 matching lines...) Expand all Loading... | |
290 | 290 |
291 size_t SkWriter32::WriteStringSize(const char* str, size_t len) { | 291 size_t SkWriter32::WriteStringSize(const char* str, size_t len) { |
292 if ((long)len < 0) { | 292 if ((long)len < 0) { |
293 SkASSERT(str); | 293 SkASSERT(str); |
294 len = strlen(str); | 294 len = strlen(str); |
295 } | 295 } |
296 const size_t lenBytes = 4; // we use 4 bytes to record the length | 296 const size_t lenBytes = 4; // we use 4 bytes to record the length |
297 // add 1 since we also write a terminating 0 | 297 // add 1 since we also write a terminating 0 |
298 return SkAlign4(lenBytes + len + 1); | 298 return SkAlign4(lenBytes + len + 1); |
299 } | 299 } |
OLD | NEW |