Chromium Code Reviews

Side by Side Diff: base/pickle.cc

Issue 16479: Bring up chrome/common/render_mesages.cc on POSIX. (Closed)
Patch Set: also bring up message_router.cc. Created 11 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
« no previous file with comments | « base/pickle.h ('k') | chrome/chrome.xcodeproj/project.pbxproj » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "base/pickle.h" 5 #include "base/pickle.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 8
9 #include <limits> 9 #include <limits>
10 #include <string> 10 #include <string>
(...skipping 126 matching lines...)
137 137
138 // TODO(jar) bug 1129285: Pickle should be cleaned up, and not dependent on 138 // TODO(jar) bug 1129285: Pickle should be cleaned up, and not dependent on
139 // alignment. 139 // alignment.
140 // Next line is otherwise the same as: memcpy(result, *iter, sizeof(*result)); 140 // Next line is otherwise the same as: memcpy(result, *iter, sizeof(*result));
141 *result = *reinterpret_cast<size_t*>(*iter); 141 *result = *reinterpret_cast<size_t*>(*iter);
142 142
143 UpdateIter(iter, sizeof(*result)); 143 UpdateIter(iter, sizeof(*result));
144 return true; 144 return true;
145 } 145 }
146 146
147 bool Pickle::ReadUInt32(void** iter, uint32* result) const {
Amanda Walker 2008/12/26 22:06:37 we're ending up with a lot of copies of this funct
148 DCHECK(iter);
149 if (!*iter)
150 *iter = const_cast<char*>(payload());
151
152 if (!IteratorHasRoomFor(*iter, sizeof(*result)))
153 return false;
154
155 memcpy(result, *iter, sizeof(*result));
156
157 UpdateIter(iter, sizeof(*result));
158 return true;
159 }
160
147 bool Pickle::ReadInt64(void** iter, int64* result) const { 161 bool Pickle::ReadInt64(void** iter, int64* result) const {
148 DCHECK(iter); 162 DCHECK(iter);
149 if (!*iter) 163 if (!*iter)
150 *iter = const_cast<char*>(payload()); 164 *iter = const_cast<char*>(payload());
151 165
152 if (!IteratorHasRoomFor(*iter, sizeof(*result))) 166 if (!IteratorHasRoomFor(*iter, sizeof(*result)))
153 return false; 167 return false;
154 168
155 memcpy(result, *iter, sizeof(*result)); 169 memcpy(result, *iter, sizeof(*result));
156 170
(...skipping 184 matching lines...)
341 355
342 const Header* hdr = reinterpret_cast<const Header*>(start); 356 const Header* hdr = reinterpret_cast<const Header*>(start);
343 const char* payload_base = start + header_size; 357 const char* payload_base = start + header_size;
344 const char* payload_end = payload_base + hdr->payload_size; 358 const char* payload_end = payload_base + hdr->payload_size;
345 if (payload_end < payload_base) 359 if (payload_end < payload_base)
346 return NULL; 360 return NULL;
347 361
348 return (payload_end > end) ? NULL : payload_end; 362 return (payload_end > end) ? NULL : payload_end;
349 } 363 }
350 364
OLDNEW
« no previous file with comments | « base/pickle.h ('k') | chrome/chrome.xcodeproj/project.pbxproj » ('j') | no next file with comments »

Powered by Google App Engine