aboutsummaryrefslogtreecommitdiffhomepage
path: root/include/grpc++/support
diff options
context:
space:
mode:
authorGravatar Vijay Pai <vpai@google.com>2017-08-03 13:05:42 -0700
committerGravatar Vijay Pai <vpai@google.com>2017-08-04 07:48:48 -0700
commitce58cf8c44c9d41b50f85a9b87337f0736022e7a (patch)
treea29cd0a135489af9cbb944bf35bd967b774c8a4b /include/grpc++/support
parent3e6df473bfc7cd8c37c88e46298ee9ed40634cfd (diff)
Add Slice constructors to match all grpc_slice cases
Diffstat (limited to 'include/grpc++/support')
-rw-r--r--include/grpc++/support/slice.h14
1 files changed, 14 insertions, 0 deletions
diff --git a/include/grpc++/support/slice.h b/include/grpc++/support/slice.h
index 0b4ba7cecb..bbf97f280e 100644
--- a/include/grpc++/support/slice.h
+++ b/include/grpc++/support/slice.h
@@ -67,6 +67,20 @@ class Slice final {
return *this;
}
+ /// Create a slice pointing at some data. Calls malloc to allocate a refcount
+ /// for the object, and arranges that destroy will be called with the
+ /// user data pointer passed in at destruction. Can be the same as buf or
+ /// different (e.g., if data is part of a larger structure that must be
+ /// destroyed when the data is no longer needed)
+ Slice(void* buf, size_t len, void (*destroy)(void*), void* user_data);
+
+ /// Specialization of above for common case where buf == user_data
+ Slice(void* buf, size_t len, void (*destroy)(void*))
+ : Slice(buf, len, destroy, buf) {}
+
+ /// Similar to the above but has a destroy that also takes slice length
+ Slice(void* buf, size_t len, void (*destroy)(void*, size_t));
+
/// Byte size.
size_t size() const { return GRPC_SLICE_LENGTH(slice_); }