OLD | NEW |
1 | 1 |
2 /* | 2 /* |
3 * Copyright 2012 Google Inc. | 3 * Copyright 2012 Google Inc. |
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 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkErrorInternals.h" | 10 #include "SkErrorInternals.h" |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
81 } | 81 } |
82 | 82 |
83 uint32_t SkOrderedReadBuffer::readUInt() { | 83 uint32_t SkOrderedReadBuffer::readUInt() { |
84 return fReader.readU32(); | 84 return fReader.readU32(); |
85 } | 85 } |
86 | 86 |
87 int32_t SkOrderedReadBuffer::read32() { | 87 int32_t SkOrderedReadBuffer::read32() { |
88 return fReader.readInt(); | 88 return fReader.readInt(); |
89 } | 89 } |
90 | 90 |
91 char* SkOrderedReadBuffer::readString() { | 91 void SkOrderedReadBuffer::readString(SkString* string) { |
92 const char* string = fReader.readString(); | 92 size_t len; |
93 const size_t length = strlen(string); | 93 const char* strContents = fReader.readString(&len); |
94 char* value = (char*)sk_malloc_throw(length + 1); | 94 string->set(strContents, len); |
95 strcpy(value, string); | |
96 return value; | |
97 } | 95 } |
98 | 96 |
99 void* SkOrderedReadBuffer::readEncodedString(size_t* length, SkPaint::TextEncodi
ng encoding) { | 97 void* SkOrderedReadBuffer::readEncodedString(size_t* length, SkPaint::TextEncodi
ng encoding) { |
100 SkDEBUGCODE(int32_t encodingType = ) fReader.readInt(); | 98 SkDEBUGCODE(int32_t encodingType = ) fReader.readInt(); |
101 SkASSERT(encodingType == encoding); | 99 SkASSERT(encodingType == encoding); |
102 *length = fReader.readInt(); | 100 *length = fReader.readInt(); |
103 void* data = sk_malloc_throw(*length); | 101 void* data = sk_malloc_throw(*length); |
104 memcpy(data, fReader.skip(SkAlign4(*length)), *length); | 102 memcpy(data, fReader.skip(SkAlign4(*length)), *length); |
105 return data; | 103 return data; |
106 } | 104 } |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
282 if (sizeRecorded != sizeRead) { | 280 if (sizeRecorded != sizeRead) { |
283 // we could try to fix up the offset... | 281 // we could try to fix up the offset... |
284 sk_throw(); | 282 sk_throw(); |
285 } | 283 } |
286 } else { | 284 } else { |
287 // we must skip the remaining data | 285 // we must skip the remaining data |
288 fReader.skip(sizeRecorded); | 286 fReader.skip(sizeRecorded); |
289 } | 287 } |
290 return obj; | 288 return obj; |
291 } | 289 } |
OLD | NEW |