| OLD | NEW |
| 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 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 if (!dest) { | 87 if (!dest) { |
| 88 return false; | 88 return false; |
| 89 } | 89 } |
| 90 | 90 |
| 91 memcpy(dest, data, data_len); | 91 memcpy(dest, data, data_len); |
| 92 | 92 |
| 93 length_ += data_len; | 93 length_ += data_len; |
| 94 return true; | 94 return true; |
| 95 } | 95 } |
| 96 | 96 |
| 97 void QuicDataWriter::WriteUint8ToBuffer(uint8 value, char* buffer) { |
| 98 memcpy(buffer, &value, sizeof(value)); |
| 99 } |
| 100 |
| 101 void QuicDataWriter::WriteUint16ToBuffer(uint16 value, char* buffer) { |
| 102 memcpy(buffer, &value, sizeof(value)); |
| 103 } |
| 104 |
| 105 void QuicDataWriter::WriteUint32ToBuffer(uint32 value, char* buffer) { |
| 106 memcpy(buffer, &value, sizeof(value)); |
| 107 } |
| 108 |
| 109 void QuicDataWriter::WriteUint48ToBuffer(uint64 value, char* buffer) { |
| 110 uint16 hi = value >> 32; |
| 111 uint32 lo = value & 0x00000000FFFFFFFF; |
| 112 WriteUint32ToBuffer(lo, buffer); |
| 113 WriteUint16ToBuffer(hi, buffer + sizeof(lo)); |
| 114 } |
| 115 |
| 97 void QuicDataWriter::WriteUint64ToBuffer(uint64 value, char* buffer) { | 116 void QuicDataWriter::WriteUint64ToBuffer(uint64 value, char* buffer) { |
| 98 memcpy(buffer, &value, sizeof(value)); | 117 memcpy(buffer, &value, sizeof(value)); |
| 99 } | 118 } |
| 100 | 119 |
| 101 void QuicDataWriter::WriteUint128ToBuffer(uint128 value, char* buffer) { | 120 void QuicDataWriter::WriteUint128ToBuffer(uint128 value, char* buffer) { |
| 102 WriteUint64ToBuffer(value.lo, buffer); | 121 WriteUint64ToBuffer(value.lo, buffer); |
| 103 WriteUint64ToBuffer(value.hi, buffer + sizeof(value.lo)); | 122 WriteUint64ToBuffer(value.hi, buffer + sizeof(value.lo)); |
| 104 } | 123 } |
| 105 | 124 |
| 106 } // namespace net | 125 } // namespace net |
| OLD | NEW |