aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/lib/slice
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2016-11-16 16:05:01 -0800
committerGravatar Craig Tiller <ctiller@google.com>2016-11-16 16:05:01 -0800
commit66b14c125ef7a792ce277021619e8a14a2619dda (patch)
tree53aa69cb045258a49bb4b974742030e900d5f9f5 /src/core/lib/slice
parent8cfe059dbc82bcfbd35647654a869369978b052e (diff)
parent1094c32f358cef7df323952c117a6773809019c0 (diff)
Merge branch 'slice_interning' into eliminate_mdstr
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 d1f045bd6f..dc3e6fd93d 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 */