aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/cpp/util
diff options
context:
space:
mode:
Diffstat (limited to 'src/cpp/util')
-rw-r--r--src/cpp/util/byte_buffer.cc6
-rw-r--r--src/cpp/util/string_ref.cc25
-rw-r--r--src/cpp/util/time.cc8
3 files changed, 17 insertions, 22 deletions
diff --git a/src/cpp/util/byte_buffer.cc b/src/cpp/util/byte_buffer.cc
index e46e656beb..755234d7e8 100644
--- a/src/cpp/util/byte_buffer.cc
+++ b/src/cpp/util/byte_buffer.cc
@@ -45,6 +45,12 @@ ByteBuffer::ByteBuffer(const Slice* slices, size_t nslices) {
buffer_ = grpc_raw_byte_buffer_create(c_slices.data(), nslices);
}
+ByteBuffer::~ByteBuffer() {
+ if (buffer_) {
+ grpc_byte_buffer_destroy(buffer_);
+ }
+}
+
void ByteBuffer::Clear() {
if (buffer_) {
grpc_byte_buffer_destroy(buffer_);
diff --git a/src/cpp/util/string_ref.cc b/src/cpp/util/string_ref.cc
index d12701f2c9..66c79a1818 100644
--- a/src/cpp/util/string_ref.cc
+++ b/src/cpp/util/string_ref.cc
@@ -36,6 +36,7 @@
#include <string.h>
#include <algorithm>
+#include <iostream>
namespace grpc {
@@ -84,29 +85,17 @@ size_t string_ref::find(char c) const {
return it == cend() ? npos : std::distance(cbegin(), it);
}
-bool operator==(string_ref x, string_ref y) {
- return x.compare(y) == 0;
-}
+bool operator==(string_ref x, string_ref y) { return x.compare(y) == 0; }
-bool operator!=(string_ref x, string_ref y) {
- return x.compare(y) != 0;
-}
+bool operator!=(string_ref x, string_ref y) { return x.compare(y) != 0; }
-bool operator<(string_ref x, string_ref y) {
- return x.compare(y) < 0;
-}
+bool operator<(string_ref x, string_ref y) { return x.compare(y) < 0; }
-bool operator<=(string_ref x, string_ref y) {
- return x.compare(y) <= 0;
-}
+bool operator<=(string_ref x, string_ref y) { return x.compare(y) <= 0; }
-bool operator>(string_ref x, string_ref y) {
- return x.compare(y) > 0;
-}
+bool operator>(string_ref x, string_ref y) { return x.compare(y) > 0; }
-bool operator>=(string_ref x, string_ref y) {
- return x.compare(y) >= 0;
-}
+bool operator>=(string_ref x, string_ref y) { return x.compare(y) >= 0; }
std::ostream& operator<<(std::ostream& out, const string_ref& string) {
return out << grpc::string(string.begin(), string.end());
diff --git a/src/cpp/util/time.cc b/src/cpp/util/time.cc
index b3401eb26b..6157a37745 100644
--- a/src/cpp/util/time.cc
+++ b/src/cpp/util/time.cc
@@ -57,8 +57,8 @@ void Timepoint2Timespec(const system_clock::time_point& from,
return;
}
nanoseconds nsecs = duration_cast<nanoseconds>(deadline - secs);
- to->tv_sec = secs.count();
- to->tv_nsec = nsecs.count();
+ to->tv_sec = (time_t)secs.count();
+ to->tv_nsec = (int)nsecs.count();
to->clock_type = GPR_CLOCK_REALTIME;
}
@@ -73,8 +73,8 @@ void TimepointHR2Timespec(const high_resolution_clock::time_point& from,
return;
}
nanoseconds nsecs = duration_cast<nanoseconds>(deadline - secs);
- to->tv_sec = secs.count();
- to->tv_nsec = nsecs.count();
+ to->tv_sec = (time_t)secs.count();
+ to->tv_nsec = (int)nsecs.count();
to->clock_type = GPR_CLOCK_REALTIME;
}