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

Side by Side Diff: base/pickle.cc

Issue 8368009: Replace most LOG statements with DLOG statements in base. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 9 years, 2 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <algorithm> // for max() 9 #include <algorithm> // for max()
10 10
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
394 void Pickle::EndWrite(char* dest, int length) { 394 void Pickle::EndWrite(char* dest, int length) {
395 // Zero-pad to keep tools like valgrind from complaining about uninitialized 395 // Zero-pad to keep tools like valgrind from complaining about uninitialized
396 // memory. 396 // memory.
397 if (length % sizeof(uint32)) 397 if (length % sizeof(uint32))
398 memset(dest + length, 0, sizeof(uint32) - (length % sizeof(uint32))); 398 memset(dest + length, 0, sizeof(uint32) - (length % sizeof(uint32)));
399 } 399 }
400 400
401 bool Pickle::Resize(size_t new_capacity) { 401 bool Pickle::Resize(size_t new_capacity) {
402 new_capacity = AlignInt(new_capacity, kPayloadUnit); 402 new_capacity = AlignInt(new_capacity, kPayloadUnit);
403 403
404 CHECK_NE(capacity_, kCapacityReadOnly); 404 DCHECK_NE(capacity_, kCapacityReadOnly);
jar (doing other things) 2011/10/23 00:36:28 I've had a lot of trouble with this class and memo
405 void* p = realloc(header_, new_capacity); 405 void* p = realloc(header_, new_capacity);
406 if (!p) 406 if (!p)
407 return false; 407 return false;
408 408
409 header_ = reinterpret_cast<Header*>(p); 409 header_ = reinterpret_cast<Header*>(p);
410 capacity_ = new_capacity; 410 capacity_ = new_capacity;
411 return true; 411 return true;
412 } 412 }
413 413
414 // static 414 // static
415 const char* Pickle::FindNext(size_t header_size, 415 const char* Pickle::FindNext(size_t header_size,
416 const char* start, 416 const char* start,
417 const char* end) { 417 const char* end) {
418 DCHECK_EQ(header_size, AlignInt(header_size, sizeof(uint32))); 418 DCHECK_EQ(header_size, AlignInt(header_size, sizeof(uint32)));
419 DCHECK_LE(header_size, static_cast<size_t>(kPayloadUnit)); 419 DCHECK_LE(header_size, static_cast<size_t>(kPayloadUnit));
420 420
421 if (static_cast<size_t>(end - start) < sizeof(Header)) 421 if (static_cast<size_t>(end - start) < sizeof(Header))
422 return NULL; 422 return NULL;
423 423
424 const Header* hdr = reinterpret_cast<const Header*>(start); 424 const Header* hdr = reinterpret_cast<const Header*>(start);
425 const char* payload_base = start + header_size; 425 const char* payload_base = start + header_size;
426 const char* payload_end = payload_base + hdr->payload_size; 426 const char* payload_end = payload_base + hdr->payload_size;
427 if (payload_end < payload_base) 427 if (payload_end < payload_base)
428 return NULL; 428 return NULL;
429 429
430 return (payload_end > end) ? NULL : payload_end; 430 return (payload_end > end) ? NULL : payload_end;
431 } 431 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698