diff options
author | Sree Kuchibhotla <sreek@google.com> | 2015-12-08 12:58:02 -0800 |
---|---|---|
committer | Sree Kuchibhotla <sreek@google.com> | 2015-12-08 13:02:57 -0800 |
commit | 38d39f4622bf3714aa58e386be9d489190fe8bda (patch) | |
tree | fccc99414e7a3e177460bebe100013ba0721dbd0 | |
parent | b6fd9bcbb699ebeed0d674e78bfd764efebbc1dd (diff) |
expose gpr_slice_to_cstring()
-rw-r--r-- | include/grpc/support/slice.h | 4 | ||||
-rw-r--r-- | test/core/support/slice_test.c | 1 |
2 files changed, 5 insertions, 0 deletions
diff --git a/include/grpc/support/slice.h b/include/grpc/support/slice.h index 507cb19f64..37ba591047 100644 --- a/include/grpc/support/slice.h +++ b/include/grpc/support/slice.h @@ -175,6 +175,10 @@ gpr_slice gpr_empty_slice(void); int gpr_slice_cmp(gpr_slice a, gpr_slice b); int gpr_slice_str_cmp(gpr_slice a, const char *b); +/* Returns a c-string representation of a slice. Useful for logging or debugging + purposes only. The string representation can change in future */ +char *gpr_slice_to_cstring(gpr_slice slice); + #ifdef __cplusplus } #endif diff --git a/test/core/support/slice_test.c b/test/core/support/slice_test.c index 9e0e22c24b..96070d5bc8 100644 --- a/test/core/support/slice_test.c +++ b/test/core/support/slice_test.c @@ -221,6 +221,7 @@ static void test_slice_from_copied_string_works(void) { LOG_TEST_NAME("test_slice_from_copied_string_works"); slice = gpr_slice_from_copied_string(text); + gpr_log(GPR_INFO, "slice: %s", gpr_slice_to_cstring(slice)); GPR_ASSERT(strlen(text) == GPR_SLICE_LENGTH(slice)); GPR_ASSERT(0 == memcmp(text, GPR_SLICE_START_PTR(slice), GPR_SLICE_LENGTH(slice))); |