Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(107)

Side by Side Diff: src/core/SkWriter32.cpp

Issue 23646007: Fix bug in SkWriter32. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: tweak Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | tests/Writer32Test.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 SkASSERT(SkAlign4(size) == size); 54 SkASSERT(SkAlign4(size) == size);
55 55
56 Block* block = fTail; 56 Block* block = fTail;
57 SkASSERT(NULL == block || block->available() < size); 57 SkASSERT(NULL == block || block->available() < size);
58 58
59 if (NULL == block) { 59 if (NULL == block) {
60 SkASSERT(NULL == fHead); 60 SkASSERT(NULL == fHead);
61 fHead = fTail = block = Block::Create(SkMax32(size, fMinSize)); 61 fHead = fTail = block = Block::Create(SkMax32(size, fMinSize));
62 SkASSERT(0 == fWrittenBeforeLastBlock); 62 SkASSERT(0 == fWrittenBeforeLastBlock);
63 } else { 63 } else {
64 SkASSERT(fSize > 0);
65 fWrittenBeforeLastBlock = fSize; 64 fWrittenBeforeLastBlock = fSize;
66 65
67 fTail = Block::Create(SkMax32(size, fMinSize)); 66 fTail = Block::Create(SkMax32(size, fMinSize));
68 block->fNext = fTail; 67 block->fNext = fTail;
69 block = fTail; 68 block = fTail;
70 } 69 }
71 return block; 70 return block;
72 } 71 }
73 72
74 uint32_t* SkWriter32::peek32(size_t offset) { 73 uint32_t* SkWriter32::peek32(size_t offset) {
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after
290 289
291 size_t SkWriter32::WriteStringSize(const char* str, size_t len) { 290 size_t SkWriter32::WriteStringSize(const char* str, size_t len) {
292 if ((long)len < 0) { 291 if ((long)len < 0) {
293 SkASSERT(str); 292 SkASSERT(str);
294 len = strlen(str); 293 len = strlen(str);
295 } 294 }
296 const size_t lenBytes = 4; // we use 4 bytes to record the length 295 const size_t lenBytes = 4; // we use 4 bytes to record the length
297 // add 1 since we also write a terminating 0 296 // add 1 since we also write a terminating 0
298 return SkAlign4(lenBytes + len + 1); 297 return SkAlign4(lenBytes + len + 1);
299 } 298 }
OLDNEW
« no previous file with comments | « no previous file | tests/Writer32Test.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698