aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/support/slice.c
diff options
context:
space:
mode:
authorGravatar Hongwei Wang <hongweiw@google.com>2015-07-17 17:38:34 -0700
committerGravatar Hongwei Wang <hongweiw@google.com>2015-07-17 17:38:34 -0700
commitb307ae280b974a927cd1319ffd974c1dd90ec95d (patch)
treee38b428e51ec491cc7aac5a78925540092079131 /src/core/support/slice.c
parenteec3b9103baa784bbcd6be10d101ab53b1f169de (diff)
parentefccb3f5ce7cae89739d3a0474fcc0d6e2a5b12c (diff)
Merge branch 'master' into zookeeper
Diffstat (limited to 'src/core/support/slice.c')
-rw-r--r--src/core/support/slice.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/core/support/slice.c b/src/core/support/slice.c
index a2d62fc1e5..e4196a48c6 100644
--- a/src/core/support/slice.c
+++ b/src/core/support/slice.c
@@ -325,3 +325,10 @@ int gpr_slice_str_cmp(gpr_slice a, const char *b) {
if (d != 0) return d;
return memcmp(GPR_SLICE_START_PTR(a), b, b_length);
}
+
+char *gpr_slice_to_cstring(gpr_slice slice) {
+ char *result = gpr_malloc(GPR_SLICE_LENGTH(slice) + 1);
+ memcpy(result, GPR_SLICE_START_PTR(slice), GPR_SLICE_LENGTH(slice));
+ result[GPR_SLICE_LENGTH(slice)] = '\0';
+ return result;
+}