diff options
author | 2015-07-17 17:38:34 -0700 | |
---|---|---|
committer | 2015-07-17 17:38:34 -0700 | |
commit | b307ae280b974a927cd1319ffd974c1dd90ec95d (patch) | |
tree | e38b428e51ec491cc7aac5a78925540092079131 /src/core/support/slice.c | |
parent | eec3b9103baa784bbcd6be10d101ab53b1f169de (diff) | |
parent | efccb3f5ce7cae89739d3a0474fcc0d6e2a5b12c (diff) |
Merge branch 'master' into zookeeper
Diffstat (limited to 'src/core/support/slice.c')
-rw-r--r-- | src/core/support/slice.c | 7 |
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; +} |