aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/support/slice_buffer.c
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2015-06-30 16:38:39 -0700
committerGravatar Craig Tiller <ctiller@google.com>2015-06-30 16:38:39 -0700
commit49dc1146ec6d9c23e6bf9f45e582565ff09d401f (patch)
tree89ade9cb8d34f86b69522ca5b4e4ff0902713ccd /src/core/support/slice_buffer.c
parentee98d84a02266acd7da5ed769a7eb3f18599d914 (diff)
parent3e57357aff574e54aaeeaae98c3e5aac41b50e63 (diff)
Merge github.com:grpc/grpc into forever-is-a-long-time
Diffstat (limited to 'src/core/support/slice_buffer.c')
-rw-r--r--src/core/support/slice_buffer.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/core/support/slice_buffer.c b/src/core/support/slice_buffer.c
index 7e25d99774..6e6c72a2bf 100644
--- a/src/core/support/slice_buffer.c
+++ b/src/core/support/slice_buffer.c
@@ -190,3 +190,19 @@ void gpr_slice_buffer_swap(gpr_slice_buffer *a, gpr_slice_buffer *b) {
GPR_SWAP(gpr_slice *, a->slices, b->slices);
}
}
+
+void gpr_slice_buffer_move_into(gpr_slice_buffer *src, gpr_slice_buffer *dst) {
+ /* anything to move? */
+ if (src->count == 0) {
+ return;
+ }
+ /* anything in dst? */
+ if (dst->count == 0) {
+ gpr_slice_buffer_swap(src, dst);
+ return;
+ }
+ /* both buffers have data - copy, and reset src */
+ gpr_slice_buffer_addn(dst, src->slices, src->count);
+ src->count = 0;
+ src->length = 0;
+}