aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/lib/slice
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2016-11-16 15:54:03 -0800
committerGravatar Craig Tiller <ctiller@google.com>2016-11-16 15:54:03 -0800
commit1094c32f358cef7df323952c117a6773809019c0 (patch)
tree5923eced0f83d9f5df5a04c77b919b22bc2d9dae /src/core/lib/slice
parentdf5b62755155883a888a783b783319e8a2f1110e (diff)
parentf2752ebb3b81cbad4e3b9ac0df5d7021c4659243 (diff)
Merge branch 'slice_with_exec_ctx' into slice_interning
Diffstat (limited to 'src/core/lib/slice')
-rw-r--r--src/core/lib/slice/slice.c8
-rw-r--r--src/core/lib/slice/slice_buffer.c5
-rw-r--r--src/core/lib/slice/slice_internal.h6
3 files changed, 12 insertions, 7 deletions
diff --git a/src/core/lib/slice/slice.c b/src/core/lib/slice/slice.c
index 6da0952e27..a85a52b2c6 100644
--- a/src/core/lib/slice/slice.c
+++ b/src/core/lib/slice/slice.c
@@ -368,3 +368,11 @@ int grpc_slice_str_cmp(grpc_slice a, const char *b) {
if (d != 0) return d;
return memcmp(GRPC_SLICE_START_PTR(a), b, b_length);
}
+
+int grpc_slice_is_equivalent(grpc_slice a, grpc_slice b) {
+ if (a.refcount == NULL || b.refcount == NULL) {
+ return grpc_slice_cmp(a, b) == 0;
+ }
+ return a.data.refcounted.length == b.data.refcounted.length &&
+ a.data.refcounted.bytes == b.data.refcounted.bytes;
+}
diff --git a/src/core/lib/slice/slice_buffer.c b/src/core/lib/slice/slice_buffer.c
index 872bd10a09..08eaf4963a 100644
--- a/src/core/lib/slice/slice_buffer.c
+++ b/src/core/lib/slice/slice_buffer.c
@@ -75,10 +75,7 @@ void grpc_slice_buffer_destroy_internal(grpc_exec_ctx *exec_ctx,
void grpc_slice_buffer_destroy(grpc_slice_buffer *sb) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
- grpc_slice_buffer_reset_and_unref_internal(&exec_ctx, sb);
- if (sb->slices != sb->inlined) {
- gpr_free(sb->slices);
- }
+ grpc_slice_buffer_destroy_internal(&exec_ctx, sb);
grpc_exec_ctx_finish(&exec_ctx);
}
diff --git a/src/core/lib/slice/slice_internal.h b/src/core/lib/slice/slice_internal.h
index a027a3979b..8bfe066fdb 100644
--- a/src/core/lib/slice/slice_internal.h
+++ b/src/core/lib/slice/slice_internal.h
@@ -31,8 +31,8 @@
*
*/
-#ifndef GRPC_CORE_LIB_SUPPORT_SLICE_INTERNAL_H
-#define GRPC_CORE_LIB_SUPPORT_SLICE_INTERNAL_H
+#ifndef GRPC_CORE_LIB_SLICE_SLICE_INTERNAL_H
+#define GRPC_CORE_LIB_SLICE_SLICE_INTERNAL_H
#include <grpc/slice.h>
#include <grpc/slice_buffer.h>
@@ -50,4 +50,4 @@ void grpc_slice_intern_init(void);
void grpc_slice_intern_shutdown(void);
void grpc_test_only_set_slice_interning_hash_seed(uint32_t key);
-#endif
+#endif /* GRPC_CORE_LIB_SLICE_SLICE_INTERNAL_H */