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

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

Issue 247753003: fix size_t/int warnings (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: revert name-change in swap32 Created 6 years, 8 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 | « src/core/SkValidatingReadBuffer.cpp ('k') | src/sfnt/SkOTUtils.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 "SkReader32.h" 8 #include "SkReader32.h"
9 #include "SkString.h" 9 #include "SkString.h"
10 #include "SkWriter32.h" 10 #include "SkWriter32.h"
(...skipping 29 matching lines...) Expand all
40 if (NULL == str) { 40 if (NULL == str) {
41 str = ""; 41 str = "";
42 len = 0; 42 len = 0;
43 } 43 }
44 if ((long)len < 0) { 44 if ((long)len < 0) {
45 len = strlen(str); 45 len = strlen(str);
46 } 46 }
47 47
48 // [ 4 byte len ] [ str ... ] [1 - 4 \0s] 48 // [ 4 byte len ] [ str ... ] [1 - 4 \0s]
49 uint32_t* ptr = this->reservePad(sizeof(uint32_t) + len + 1); 49 uint32_t* ptr = this->reservePad(sizeof(uint32_t) + len + 1);
50 *ptr = len; 50 *ptr = SkToU32(len);
51 char* chars = (char*)(ptr + 1); 51 char* chars = (char*)(ptr + 1);
52 memcpy(chars, str, len); 52 memcpy(chars, str, len);
53 chars[len] = '\0'; 53 chars[len] = '\0';
54 } 54 }
55 55
56 size_t SkWriter32::WriteStringSize(const char* str, size_t len) { 56 size_t SkWriter32::WriteStringSize(const char* str, size_t len) {
57 if ((long)len < 0) { 57 if ((long)len < 0) {
58 SkASSERT(str); 58 SkASSERT(str);
59 len = strlen(str); 59 len = strlen(str);
60 } 60 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 // prepare us to do copy on write, by pretending the data buffer 96 // prepare us to do copy on write, by pretending the data buffer
97 // is external and size limited 97 // is external and size limited
98 mutable_this.fData = buffer; 98 mutable_this.fData = buffer;
99 mutable_this.fCapacity = fUsed; 99 mutable_this.fCapacity = fUsed;
100 mutable_this.fExternal = buffer; 100 mutable_this.fExternal = buffer;
101 } 101 }
102 mutable_this.fSnapshot.reset(SkData::NewFromMalloc(buffer, fUsed)); 102 mutable_this.fSnapshot.reset(SkData::NewFromMalloc(buffer, fUsed));
103 } 103 }
104 return SkRef(fSnapshot.get()); // Take an extra ref for the caller. 104 return SkRef(fSnapshot.get()); // Take an extra ref for the caller.
105 } 105 }
OLDNEW
« no previous file with comments | « src/core/SkValidatingReadBuffer.cpp ('k') | src/sfnt/SkOTUtils.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698