Chromium Code Reviews| 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 void SkOrderedReadBuffer::readString(SkString& string) { | |
| 92 size_t len; | |
| 93 string.set(fReader.readString(&len), len); | |
|
reed1
2013/05/20 13:42:47
Parameter evaluation order is undefined, so it is
djsollen
2013/05/21 12:17:17
Done.
| |
| 94 } | |
| 95 | |
| 91 char* SkOrderedReadBuffer::readString() { | 96 char* SkOrderedReadBuffer::readString() { |
|
reed1
2013/05/20 13:42:47
Suggestion: rename this to something other than St
djsollen
2013/05/21 12:17:17
removed and updated the one caller to use the new
| |
| 92 const char* string = fReader.readString(); | 97 size_t length; |
| 93 const size_t length = strlen(string); | 98 const char* string = fReader.readString(&length); |
| 94 char* value = (char*)sk_malloc_throw(length + 1); | 99 char* value = (char*)sk_malloc_throw(length + 1); |
| 95 strcpy(value, string); | 100 strcpy(value, string); |
| 96 return value; | 101 return value; |
| 97 } | 102 } |
| 98 | 103 |
| 99 void* SkOrderedReadBuffer::readEncodedString(size_t* length, SkPaint::TextEncodi ng encoding) { | 104 void* SkOrderedReadBuffer::readEncodedString(size_t* length, SkPaint::TextEncodi ng encoding) { |
| 100 SkDEBUGCODE(int32_t encodingType = ) fReader.readInt(); | 105 SkDEBUGCODE(int32_t encodingType = ) fReader.readInt(); |
| 101 SkASSERT(encodingType == encoding); | 106 SkASSERT(encodingType == encoding); |
| 102 *length = fReader.readInt(); | 107 *length = fReader.readInt(); |
| 103 void* data = sk_malloc_throw(*length); | 108 void* data = sk_malloc_throw(*length); |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 267 if (sizeRecorded != sizeRead) { | 272 if (sizeRecorded != sizeRead) { |
| 268 // we could try to fix up the offset... | 273 // we could try to fix up the offset... |
| 269 sk_throw(); | 274 sk_throw(); |
| 270 } | 275 } |
| 271 } else { | 276 } else { |
| 272 // we must skip the remaining data | 277 // we must skip the remaining data |
| 273 fReader.skip(sizeRecorded); | 278 fReader.skip(sizeRecorded); |
| 274 } | 279 } |
| 275 return obj; | 280 return obj; |
| 276 } | 281 } |
| OLD | NEW |