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

Side by Side Diff: third_party/protobuf/src/google/protobuf/io/coded_stream_inl.h

Issue 21208003: Update protobuf to r428, part 1. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 7 years, 4 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 // Protocol Buffers - Google's data interchange format 1 // Protocol Buffers - Google's data interchange format
2 // Copyright 2008 Google Inc. All rights reserved. 2 // Copyright 2008 Google Inc. All rights reserved.
3 // http://code.google.com/p/protobuf/ 3 // http://code.google.com/p/protobuf/
4 // 4 //
5 // Redistribution and use in source and binary forms, with or without 5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are 6 // modification, are permitted provided that the following conditions are
7 // met: 7 // met:
8 // 8 //
9 // * Redistributions of source code must retain the above copyright 9 // * Redistributions of source code must retain the above copyright
10 // notice, this list of conditions and the following disclaimer. 10 // notice, this list of conditions and the following disclaimer.
(...skipping 20 matching lines...) Expand all
31 // Author: jasonh@google.com (Jason Hsueh) 31 // Author: jasonh@google.com (Jason Hsueh)
32 // 32 //
33 // Implements methods of coded_stream.h that need to be inlined for performance 33 // Implements methods of coded_stream.h that need to be inlined for performance
34 // reasons, but should not be defined in a public header. 34 // reasons, but should not be defined in a public header.
35 35
36 #ifndef GOOGLE_PROTOBUF_IO_CODED_STREAM_INL_H__ 36 #ifndef GOOGLE_PROTOBUF_IO_CODED_STREAM_INL_H__
37 #define GOOGLE_PROTOBUF_IO_CODED_STREAM_INL_H__ 37 #define GOOGLE_PROTOBUF_IO_CODED_STREAM_INL_H__
38 38
39 #include <google/protobuf/io/coded_stream.h> 39 #include <google/protobuf/io/coded_stream.h>
40 #include <string> 40 #include <string>
41 #include <google/protobuf/stubs/stl_util-inl.h> 41 #include <google/protobuf/stubs/stl_util.h>
42 42
43 namespace google { 43 namespace google {
44 namespace protobuf { 44 namespace protobuf {
45 namespace io { 45 namespace io {
46 46
47 inline bool CodedInputStream::InternalReadStringInline(string* buffer, 47 inline bool CodedInputStream::InternalReadStringInline(string* buffer,
48 int size) { 48 int size) {
49 if (size < 0) return false; // security: size is often user-supplied 49 if (size < 0) return false; // security: size is often user-supplied
50 50
51 if (BufferSize() >= size) { 51 if (BufferSize() >= size) {
52 STLStringResizeUninitialized(buffer, size); 52 STLStringResizeUninitialized(buffer, size);
53 // When buffer is empty, string_as_array(buffer) will return NULL but memcpy 53 // When buffer is empty, string_as_array(buffer) will return NULL but memcpy
54 // requires non-NULL pointers even when size is 0. Hench this check. 54 // requires non-NULL pointers even when size is 0. Hench this check.
55 if (size > 0) { 55 if (size > 0) {
56 memcpy(string_as_array(buffer), buffer_, size); 56 memcpy(string_as_array(buffer), buffer_, size);
57 Advance(size); 57 Advance(size);
58 } 58 }
59 return true; 59 return true;
60 } 60 }
61 61
62 return ReadStringFallback(buffer, size); 62 return ReadStringFallback(buffer, size);
63 } 63 }
64 64
65 } // namespace io 65 } // namespace io
66 } // namespace protobuf 66 } // namespace protobuf
67 } // namespace google 67 } // namespace google
68 #endif // GOOGLE_PROTOBUF_IO_CODED_STREAM_INL_H__ 68 #endif // GOOGLE_PROTOBUF_IO_CODED_STREAM_INL_H__
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698