aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/lib/transport
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2016-12-09 09:40:11 -0800
committerGravatar Craig Tiller <ctiller@google.com>2016-12-09 09:40:11 -0800
commitb4aa70ea94687f41c731e57f9782c51c5dacf779 (patch)
tree618a24561fe188b69d36619c43e14f1831bc9014 /src/core/lib/transport
parent75f8013ba65f5008660c8483800f325d0c1b80a9 (diff)
Offer grpc_slice_to_c_string to simplify some code
Diffstat (limited to 'src/core/lib/transport')
-rw-r--r--src/core/lib/transport/metadata.c28
-rw-r--r--src/core/lib/transport/metadata_batch.c4
-rw-r--r--src/core/lib/transport/service_config.c2
-rw-r--r--src/core/lib/transport/transport.c4
4 files changed, 19 insertions, 19 deletions
diff --git a/src/core/lib/transport/metadata.c b/src/core/lib/transport/metadata.c
index 06e703c9d9..489c20cbc8 100644
--- a/src/core/lib/transport/metadata.c
+++ b/src/core/lib/transport/metadata.c
@@ -161,8 +161,8 @@ static int is_mdelem_static(grpc_mdelem e) {
static void ref_md_locked(mdtab_shard *shard,
interned_metadata *md DEBUG_ARGS) {
#ifdef GRPC_METADATA_REFCOUNT_DEBUG
- char *key_str = grpc_dump_slice(md->key, GPR_DUMP_ASCII);
- char *value_str = grpc_dump_slice(md->value, GPR_DUMP_ASCII);
+ char *key_str = grpc_slice_to_c_string(md->key);
+ char *value_str = grpc_slice_to_c_string(md->value);
gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
"ELM REF:%p:%zu->%zu: '%s' = '%s'", (void *)md,
gpr_atm_no_barrier_load(&md->refcnt),
@@ -261,8 +261,8 @@ grpc_mdelem grpc_mdelem_create(
allocated->value = grpc_slice_ref_internal(value);
gpr_atm_rel_store(&allocated->refcnt, 1);
#ifdef GRPC_METADATA_REFCOUNT_DEBUG
- char *key_str = grpc_dump_slice(allocated->key, GPR_DUMP_ASCII);
- char *value_str = grpc_dump_slice(allocated->value, GPR_DUMP_ASCII);
+ char *key_str = grpc_slice_to_c_string(allocated->key);
+ char *value_str = grpc_slice_to_c_string(allocated->value);
gpr_log(GPR_DEBUG, "ELM ALLOC:%p:%zu: '%s' = '%s'", (void *)allocated,
gpr_atm_no_barrier_load(&allocated->refcnt), key_str, value_str);
gpr_free(key_str);
@@ -312,8 +312,8 @@ grpc_mdelem grpc_mdelem_create(
shard->elems[idx] = md;
gpr_mu_init(&md->mu_user_data);
#ifdef GRPC_METADATA_REFCOUNT_DEBUG
- char *key_str = grpc_dump_slice(md->key, GPR_DUMP_ASCII);
- char *value_str = grpc_dump_slice(md->value, GPR_DUMP_ASCII);
+ char *key_str = grpc_slice_to_c_string(md->key);
+ char *value_str = grpc_slice_to_c_string(md->value);
gpr_log(GPR_DEBUG, "ELM NEW:%p:%zu: '%s' = '%s'", (void *)md,
gpr_atm_no_barrier_load(&md->refcnt), key_str, value_str);
gpr_free(key_str);
@@ -374,8 +374,8 @@ grpc_mdelem grpc_mdelem_ref(grpc_mdelem gmd DEBUG_ARGS) {
case GRPC_MDELEM_STORAGE_INTERNED: {
interned_metadata *md = (interned_metadata *)GRPC_MDELEM_DATA(gmd);
#ifdef GRPC_METADATA_REFCOUNT_DEBUG
- char *key_str = grpc_dump_slice(md->key, GPR_DUMP_ASCII);
- char *value_str = grpc_dump_slice(md->value, GPR_DUMP_ASCII);
+ char *key_str = grpc_slice_to_c_string(md->key);
+ char *value_str = grpc_slice_to_c_string(md->value);
gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
"ELM REF:%p:%zu->%zu: '%s' = '%s'", (void *)md,
gpr_atm_no_barrier_load(&md->refcnt),
@@ -394,8 +394,8 @@ grpc_mdelem grpc_mdelem_ref(grpc_mdelem gmd DEBUG_ARGS) {
case GRPC_MDELEM_STORAGE_ALLOCATED: {
allocated_metadata *md = (allocated_metadata *)GRPC_MDELEM_DATA(gmd);
#ifdef GRPC_METADATA_REFCOUNT_DEBUG
- char *key_str = grpc_dump_slice(md->key, GPR_DUMP_ASCII);
- char *value_str = grpc_dump_slice(md->value, GPR_DUMP_ASCII);
+ char *key_str = grpc_slice_to_c_string(md->key);
+ char *value_str = grpc_slice_to_c_string(md->value);
gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
"ELM REF:%p:%zu->%zu: '%s' = '%s'", (void *)md,
gpr_atm_no_barrier_load(&md->refcnt),
@@ -422,8 +422,8 @@ void grpc_mdelem_unref(grpc_exec_ctx *exec_ctx, grpc_mdelem gmd DEBUG_ARGS) {
case GRPC_MDELEM_STORAGE_INTERNED: {
interned_metadata *md = (interned_metadata *)GRPC_MDELEM_DATA(gmd);
#ifdef GRPC_METADATA_REFCOUNT_DEBUG
- char *key_str = grpc_dump_slice(md->key, GPR_DUMP_ASCII);
- char *value_str = grpc_dump_slice(md->value, GPR_DUMP_ASCII);
+ char *key_str = grpc_slice_to_c_string(md->key);
+ char *value_str = grpc_slice_to_c_string(md->value);
gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
"ELM UNREF:%p:%zu->%zu: '%s' = '%s'", (void *)md,
gpr_atm_no_barrier_load(&md->refcnt),
@@ -446,8 +446,8 @@ void grpc_mdelem_unref(grpc_exec_ctx *exec_ctx, grpc_mdelem gmd DEBUG_ARGS) {
case GRPC_MDELEM_STORAGE_ALLOCATED: {
allocated_metadata *md = (allocated_metadata *)GRPC_MDELEM_DATA(gmd);
#ifdef GRPC_METADATA_REFCOUNT_DEBUG
- char *key_str = grpc_dump_slice(md->key, GPR_DUMP_ASCII);
- char *value_str = grpc_dump_slice(md->value, GPR_DUMP_ASCII);
+ char *key_str = grpc_slice_to_c_string(md->key);
+ char *value_str = grpc_slice_to_c_string(md->value);
gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG,
"ELM UNREF:%p:%zu->%zu: '%s' = '%s'", (void *)md,
gpr_atm_no_barrier_load(&md->refcnt),
diff --git a/src/core/lib/transport/metadata_batch.c b/src/core/lib/transport/metadata_batch.c
index 07b0dd3725..18b0f161ab 100644
--- a/src/core/lib/transport/metadata_batch.c
+++ b/src/core/lib/transport/metadata_batch.c
@@ -99,8 +99,8 @@ void grpc_metadata_batch_destroy(grpc_exec_ctx *exec_ctx,
}
grpc_error *grpc_attach_md_to_error(grpc_error *src, grpc_mdelem md) {
- char *k = grpc_dump_slice(GRPC_MDKEY(md), GPR_DUMP_ASCII);
- char *v = grpc_dump_slice(GRPC_MDVALUE(md), GPR_DUMP_ASCII);
+ char *k = grpc_slice_to_c_string(GRPC_MDKEY(md));
+ char *v = grpc_slice_to_c_string(GRPC_MDVALUE(md));
grpc_error *out = grpc_error_set_str(
grpc_error_set_str(src, GRPC_ERROR_STR_KEY, k), GRPC_ERROR_STR_VALUE, v);
gpr_free(k);
diff --git a/src/core/lib/transport/service_config.c b/src/core/lib/transport/service_config.c
index 8073a46105..12da2a88fe 100644
--- a/src/core/lib/transport/service_config.c
+++ b/src/core/lib/transport/service_config.c
@@ -237,7 +237,7 @@ void* grpc_method_config_table_get(grpc_exec_ctx* exec_ctx,
// If we didn't find a match for the path, try looking for a wildcard
// entry (i.e., change "/service/method" to "/service/*").
if (value == NULL) {
- char* path_str = grpc_dump_slice(path, GPR_DUMP_ASCII);
+ char* path_str = grpc_slice_to_c_string(path);
const char* sep = strrchr(path_str, '/') + 1;
const size_t len = (size_t)(sep - path_str);
char* buf = gpr_malloc(len + 2); // '*' and NUL
diff --git a/src/core/lib/transport/transport.c b/src/core/lib/transport/transport.c
index 9bc278c133..9ccd7daf45 100644
--- a/src/core/lib/transport/transport.c
+++ b/src/core/lib/transport/transport.c
@@ -224,7 +224,7 @@ void grpc_transport_stream_op_add_cancellation_with_message(
}
grpc_error *error;
if (optional_message != NULL) {
- char *msg = grpc_dump_slice(*optional_message, GPR_DUMP_ASCII);
+ char *msg = grpc_slice_to_c_string(*optional_message);
error = grpc_error_set_str(GRPC_ERROR_CREATE(msg),
GRPC_ERROR_STR_GRPC_MESSAGE, msg);
gpr_free(msg);
@@ -250,7 +250,7 @@ void grpc_transport_stream_op_add_close(grpc_exec_ctx *exec_ctx,
}
grpc_error *error;
if (optional_message != NULL) {
- char *msg = grpc_dump_slice(*optional_message, GPR_DUMP_ASCII);
+ char *msg = grpc_slice_to_c_string(*optional_message);
error = grpc_error_set_str(GRPC_ERROR_CREATE(msg),
GRPC_ERROR_STR_GRPC_MESSAGE, msg);
gpr_free(msg);