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

Side by Side Diff: net/quic/quic_data_writer.cc

Issue 612323013: QUIC - (no behavior change) s/NULL/nullptr/g in .../quic/... (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 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
« no previous file with comments | « net/quic/quic_data_writer.h ('k') | net/quic/quic_dispatcher.cc » ('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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "net/quic/quic_data_writer.h" 5 #include "net/quic/quic_data_writer.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <limits> 8 #include <limits>
9 #include <string> 9 #include <string>
10 10
(...skipping 10 matching lines...) Expand all
21 capacity_(size), 21 capacity_(size),
22 length_(0) { 22 length_(0) {
23 } 23 }
24 24
25 QuicDataWriter::~QuicDataWriter() { 25 QuicDataWriter::~QuicDataWriter() {
26 delete[] buffer_; 26 delete[] buffer_;
27 } 27 }
28 28
29 char* QuicDataWriter::take() { 29 char* QuicDataWriter::take() {
30 char* rv = buffer_; 30 char* rv = buffer_;
31 buffer_ = NULL; 31 buffer_ = nullptr;
32 capacity_ = 0; 32 capacity_ = 0;
33 length_ = 0; 33 length_ = 0;
34 return rv; 34 return rv;
35 } 35 }
36 36
37 bool QuicDataWriter::WriteUInt8(uint8 value) { 37 bool QuicDataWriter::WriteUInt8(uint8 value) {
38 return WriteBytes(&value, sizeof(value)); 38 return WriteBytes(&value, sizeof(value));
39 } 39 }
40 40
41 bool QuicDataWriter::WriteUInt16(uint16 value) { 41 bool QuicDataWriter::WriteUInt16(uint16 value) {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 } 112 }
113 for (size_t i = 0; i < data.Size(); ++i) { 113 for (size_t i = 0; i < data.Size(); ++i) {
114 WriteBytes(data.iovec()[i].iov_base, data.iovec()[i].iov_len); 114 WriteBytes(data.iovec()[i].iov_base, data.iovec()[i].iov_len);
115 } 115 }
116 116
117 return true; 117 return true;
118 } 118 }
119 119
120 char* QuicDataWriter::BeginWrite(size_t length) { 120 char* QuicDataWriter::BeginWrite(size_t length) {
121 if (length_ > capacity_) { 121 if (length_ > capacity_) {
122 return NULL; 122 return nullptr;
123 } 123 }
124 124
125 if (capacity_ - length_ < length) { 125 if (capacity_ - length_ < length) {
126 return NULL; 126 return nullptr;
127 } 127 }
128 128
129 #ifdef ARCH_CPU_64_BITS 129 #ifdef ARCH_CPU_64_BITS
130 DCHECK_LE(length, numeric_limits<uint32>::max()); 130 DCHECK_LE(length, numeric_limits<uint32>::max());
131 #endif 131 #endif
132 132
133 return buffer_ + length_; 133 return buffer_ + length_;
134 } 134 }
135 135
136 bool QuicDataWriter::WriteBytes(const void* data, size_t data_len) { 136 bool QuicDataWriter::WriteBytes(const void* data, size_t data_len) {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 DCHECK_LT(offset, capacity_); 193 DCHECK_LT(offset, capacity_);
194 size_t latched_length = length_; 194 size_t latched_length = length_;
195 length_ = offset; 195 length_ = offset;
196 bool success = WriteUInt48(value); 196 bool success = WriteUInt48(value);
197 DCHECK_LE(length_, latched_length); 197 DCHECK_LE(length_, latched_length);
198 length_ = latched_length; 198 length_ = latched_length;
199 return success; 199 return success;
200 } 200 }
201 201
202 } // namespace net 202 } // namespace net
OLDNEW
« no previous file with comments | « net/quic/quic_data_writer.h ('k') | net/quic/quic_dispatcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698