diff options
author | Yang Gao <yangg@google.com> | 2015-06-22 16:31:11 -0700 |
---|---|---|
committer | Yang Gao <yangg@google.com> | 2015-06-22 16:31:11 -0700 |
commit | 89c5a5623377e7d4d253c7a304bc726357c6ef0e (patch) | |
tree | 483c48d1531d0a8fe3ba91b6dbf3887b56d8a51b /src | |
parent | 04b0383d23e65482ba98b190fb802d237a5fe32a (diff) |
Add const to ByteBuffer methods and add tests
Diffstat (limited to 'src')
-rw-r--r-- | src/cpp/util/byte_buffer.cc | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/cpp/util/byte_buffer.cc b/src/cpp/util/byte_buffer.cc index a78e4226d2..a66c92c3e1 100644 --- a/src/cpp/util/byte_buffer.cc +++ b/src/cpp/util/byte_buffer.cc @@ -36,7 +36,7 @@ namespace grpc { -ByteBuffer::ByteBuffer(Slice* slices, size_t nslices) { +ByteBuffer::ByteBuffer(const Slice* slices, size_t nslices) { // TODO(yangg) maybe expose some core API to simplify this std::vector<gpr_slice> c_slices(nslices); for (size_t i = 0; i < nslices; i++) { @@ -52,20 +52,20 @@ void ByteBuffer::Clear() { } } -void ByteBuffer::Dump(std::vector<Slice>* slices) { +void ByteBuffer::Dump(std::vector<Slice>* slices) const { slices->clear(); if (!buffer_) { return; } grpc_byte_buffer_reader reader; - grpc_byte_buffer_reader_init(&reader,buffer_); + grpc_byte_buffer_reader_init(&reader, buffer_); gpr_slice s; while (grpc_byte_buffer_reader_next(&reader, &s)) { slices->push_back(Slice(s, Slice::STEAL_REF)); } } -size_t ByteBuffer::Length() { +size_t ByteBuffer::Length() const { if (buffer_) { return grpc_byte_buffer_length(buffer_); } else { |