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

Side by Side Diff: third_party/tcmalloc/chromium/src/raw_printer.cc

Issue 7050034: Merge google-perftools r109 (the current contents of third_party/tcmalloc/vendor) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 6 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) 2008, Google Inc. 1 // Copyright (c) 2008, Google Inc.
2 // All rights reserved. 2 // All rights reserved.
3 // 3 //
4 // Redistribution and use in source and binary forms, with or without 4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are 5 // modification, are permitted provided that the following conditions are
6 // met: 6 // met:
7 // 7 //
8 // * Redistributions of source code must retain the above copyright 8 // * Redistributions of source code must retain the above copyright
9 // notice, this list of conditions and the following disclaimer. 9 // notice, this list of conditions and the following disclaimer.
10 // * Redistributions in binary form must reproduce the above 10 // * Redistributions in binary form must reproduce the above
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
47 *limit_ = '\0'; 47 *limit_ = '\0';
48 } 48 }
49 49
50 void RawPrinter::Printf(const char* format, ...) { 50 void RawPrinter::Printf(const char* format, ...) {
51 if (limit_ > ptr_) { 51 if (limit_ > ptr_) {
52 va_list ap; 52 va_list ap;
53 va_start(ap, format); 53 va_start(ap, format);
54 int avail = limit_ - ptr_; 54 int avail = limit_ - ptr_;
55 // We pass avail+1 to vsnprintf() since that routine needs room 55 // We pass avail+1 to vsnprintf() since that routine needs room
56 // to store the trailing \0. 56 // to store the trailing \0.
57 const int r = vsnprintf(ptr_, avail+1, format, ap); 57 const int r = perftools_vsnprintf(ptr_, avail+1, format, ap);
58 va_end(ap); 58 va_end(ap);
59 if (r < 0) { 59 if (r < 0) {
60 // Perhaps an old glibc that returns -1 on truncation? 60 // Perhaps an old glibc that returns -1 on truncation?
61 ptr_ = limit_; 61 ptr_ = limit_;
62 } else if (r > avail) { 62 } else if (r > avail) {
63 // Truncation 63 // Truncation
64 ptr_ = limit_; 64 ptr_ = limit_;
65 } else { 65 } else {
66 ptr_ += r; 66 ptr_ += r;
67 } 67 }
68 } 68 }
69 } 69 }
70 70
71 } 71 }
OLDNEW
« no previous file with comments | « third_party/tcmalloc/chromium/src/profiler.cc ('k') | third_party/tcmalloc/chromium/src/sampler.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698