s/GPR_SLICE/GRPC_SLICE/g

reviewable/pr8532/r1
Craig Tiller 8 years ago
parent 2d75209fa8
commit 618e67d655
  1. 20
      include/grpc++/impl/codegen/proto_utils.h
  2. 2
      include/grpc++/impl/codegen/thrift_serializer.h
  3. 6
      include/grpc++/support/slice.h
  4. 16
      include/grpc/impl/codegen/slice.h
  5. 2
      src/core/ext/census/grpc_filter.c
  6. 4
      src/core/ext/client_channel/http_connect_handshaker.c
  7. 10
      src/core/ext/lb_policy/grpclb/load_balancer_api.c
  8. 6
      src/core/ext/transport/chttp2/client/insecure/channel_create.c
  9. 6
      src/core/ext/transport/chttp2/client/secure/secure_channel_create.c
  10. 30
      src/core/ext/transport/chttp2/transport/bin_decoder.c
  11. 30
      src/core/ext/transport/chttp2/transport/bin_encoder.c
  12. 22
      src/core/ext/transport/chttp2/transport/chttp2_transport.c
  13. 6
      src/core/ext/transport/chttp2/transport/frame_data.c
  14. 12
      src/core/ext/transport/chttp2/transport/frame_goaway.c
  15. 6
      src/core/ext/transport/chttp2/transport/frame_ping.c
  16. 6
      src/core/ext/transport/chttp2/transport/frame_rst_stream.c
  17. 10
      src/core/ext/transport/chttp2/transport/frame_settings.c
  18. 6
      src/core/ext/transport/chttp2/transport/frame_window_update.c
  19. 28
      src/core/ext/transport/chttp2/transport/hpack_encoder.c
  20. 8
      src/core/ext/transport/chttp2/transport/hpack_parser.c
  21. 8
      src/core/ext/transport/chttp2/transport/hpack_table.c
  22. 4
      src/core/ext/transport/chttp2/transport/parsing.c
  23. 6
      src/core/ext/transport/cronet/transport/cronet_transport.c
  24. 6
      src/core/lib/channel/http_client_filter.c
  25. 18
      src/core/lib/compression/message_compress.c
  26. 2
      src/core/lib/http/httpcli.c
  27. 4
      src/core/lib/http/parser.c
  28. 10
      src/core/lib/iomgr/tcp_posix.c
  29. 30
      src/core/lib/iomgr/tcp_uv.c
  30. 8
      src/core/lib/iomgr/tcp_windows.c
  31. 2
      src/core/lib/security/credentials/google_default/google_default_credentials.c
  32. 22
      src/core/lib/security/credentials/jwt/jwt_verifier.c
  33. 6
      src/core/lib/security/transport/handshake.c
  34. 32
      src/core/lib/security/transport/secure_endpoint.c
  35. 8
      src/core/lib/security/transport/security_connector.c
  36. 14
      src/core/lib/security/transport/server_auth_filter.c
  37. 4
      src/core/lib/security/util/b64.c
  38. 28
      src/core/lib/slice/percent_encoding.c
  39. 14
      src/core/lib/slice/slice.c
  40. 22
      src/core/lib/slice/slice_buffer.c
  41. 8
      src/core/lib/slice/slice_string_helpers.c
  42. 6
      src/core/lib/surface/byte_buffer_reader.c
  43. 12
      src/core/lib/surface/call.c
  44. 2
      src/core/lib/surface/server.c
  45. 28
      src/core/lib/transport/metadata.c
  46. 2
      src/core/lib/transport/metadata.h
  47. 6
      src/csharp/ext/grpc_csharp_ext.c
  48. 6
      src/node/ext/byte_buffer.cc
  49. 4
      src/objective-c/GRPCClient/private/NSData+GRPC.m
  50. 4
      src/php/ext/grpc/byte_buffer.c
  51. 4
      src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi
  52. 4
      src/ruby/ext/grpc/rb_byte_buffer.c
  53. 2
      test/core/bad_client/tests/large_metadata.c
  54. 4
      test/core/bad_ssl/servers/cert.c
  55. 12
      test/core/compression/message_compress_test.c
  56. 14
      test/core/end2end/cq_verifier.c
  57. 16
      test/core/end2end/fixtures/http_proxy.c
  58. 2
      test/core/end2end/fuzzers/api_fuzzer.c
  59. 2
      test/core/end2end/tests/invoke_large_request.c
  60. 6
      test/core/handshake/client_ssl.c
  61. 6
      test/core/handshake/server_ssl.c
  62. 12
      test/core/iomgr/endpoint_tests.c
  63. 20
      test/core/iomgr/load_file_test.c
  64. 12
      test/core/iomgr/tcp_posix_test.c
  65. 28
      test/core/security/b64_test.c
  66. 2
      test/core/security/create_jwt.c
  67. 2
      test/core/security/fetch_oauth2.c
  68. 18
      test/core/security/json_token_test.c
  69. 14
      test/core/security/jwt_verifier_test.c
  70. 8
      test/core/security/oauth2_utils.c
  71. 4
      test/core/security/secure_endpoint_test.c
  72. 2
      test/core/security/security_connector_test.c
  73. 38
      test/core/slice/slice_test.c
  74. 42
      test/core/surface/byte_buffer_reader_test.c
  75. 4
      test/core/transport/chttp2/hpack_parser_test.c
  76. 2
      test/core/transport/chttp2/varint_test.c
  77. 2
      test/core/transport/metadata_test.c
  78. 2
      test/core/util/one_corpus_entry_fuzzer.c
  79. 2
      test/core/util/parse_hexstring.c
  80. 24
      test/core/util/slice_splitter.c
  81. 4
      test/cpp/grpclb/grpclb_api_test.cc
  82. 4
      test/cpp/grpclb/grpclb_test.cc
  83. 4
      test/cpp/util/byte_buffer_test.cc
  84. 4
      test/cpp/util/slice_test.cc

@ -74,10 +74,10 @@ class GrpcBufferWriter GRPC_FINAL
} else {
slice_ = g_core_codegen_interface->grpc_slice_malloc(block_size_);
}
*data = GPR_SLICE_START_PTR(slice_);
*data = GRPC_SLICE_START_PTR(slice_);
// On win x64, int is only 32bit
GPR_CODEGEN_ASSERT(GPR_SLICE_LENGTH(slice_) <= INT_MAX);
byte_count_ += * size = (int)GPR_SLICE_LENGTH(slice_);
GPR_CODEGEN_ASSERT(GRPC_SLICE_LENGTH(slice_) <= INT_MAX);
byte_count_ += * size = (int)GRPC_SLICE_LENGTH(slice_);
g_core_codegen_interface->grpc_slice_buffer_add(slice_buffer_, slice_);
return true;
}
@ -88,7 +88,7 @@ class GrpcBufferWriter GRPC_FINAL
backup_slice_ = slice_;
} else {
backup_slice_ = g_core_codegen_interface->grpc_slice_split_tail(
&slice_, GPR_SLICE_LENGTH(slice_) - count);
&slice_, GRPC_SLICE_LENGTH(slice_) - count);
g_core_codegen_interface->grpc_slice_buffer_add(slice_buffer_, slice_);
}
have_backup_ = true;
@ -126,7 +126,7 @@ class GrpcBufferReader GRPC_FINAL
return false;
}
if (backup_count_ > 0) {
*data = GPR_SLICE_START_PTR(slice_) + GPR_SLICE_LENGTH(slice_) -
*data = GRPC_SLICE_START_PTR(slice_) + GRPC_SLICE_LENGTH(slice_) -
backup_count_;
GPR_CODEGEN_ASSERT(backup_count_ <= INT_MAX);
*size = (int)backup_count_;
@ -138,10 +138,10 @@ class GrpcBufferReader GRPC_FINAL
return false;
}
g_core_codegen_interface->grpc_slice_unref(slice_);
*data = GPR_SLICE_START_PTR(slice_);
*data = GRPC_SLICE_START_PTR(slice_);
// On win x64, int is only 32bit
GPR_CODEGEN_ASSERT(GPR_SLICE_LENGTH(slice_) <= INT_MAX);
byte_count_ += * size = (int)GPR_SLICE_LENGTH(slice_);
GPR_CODEGEN_ASSERT(GRPC_SLICE_LENGTH(slice_) <= INT_MAX);
byte_count_ += * size = (int)GRPC_SLICE_LENGTH(slice_);
return true;
}
@ -188,8 +188,8 @@ class SerializationTraits<T, typename std::enable_if<std::is_base_of<
if (byte_size <= internal::kGrpcBufferWriterMaxBufferLength) {
grpc_slice slice = g_core_codegen_interface->grpc_slice_malloc(byte_size);
GPR_CODEGEN_ASSERT(
GPR_SLICE_END_PTR(slice) ==
msg.SerializeWithCachedSizesToArray(GPR_SLICE_START_PTR(slice)));
GRPC_SLICE_END_PTR(slice) ==
msg.SerializeWithCachedSizesToArray(GRPC_SLICE_START_PTR(slice)));
*bp = g_core_codegen_interface->grpc_raw_byte_buffer_create(&slice, 1);
g_core_codegen_interface->grpc_slice_unref(slice);
return g_core_codegen_interface->ok();

@ -159,7 +159,7 @@ class ThriftSerializer {
grpc_slice slice = grpc_byte_buffer_reader_readall(&reader);
uint32_t len =
Deserialize(GPR_SLICE_START_PTR(slice), GPR_SLICE_LENGTH(slice), msg);
Deserialize(GRPC_SLICE_START_PTR(slice), GRPC_SLICE_LENGTH(slice), msg);
grpc_slice_unref(slice);

@ -69,13 +69,13 @@ class Slice GRPC_FINAL {
}
/// Byte size.
size_t size() const { return GPR_SLICE_LENGTH(slice_); }
size_t size() const { return GRPC_SLICE_LENGTH(slice_); }
/// Raw pointer to the beginning (first element) of the slice.
const uint8_t* begin() const { return GPR_SLICE_START_PTR(slice_); }
const uint8_t* begin() const { return GRPC_SLICE_START_PTR(slice_); }
/// Raw pointer to the end (one byte \em past the last element) of the slice.
const uint8_t* end() const { return GPR_SLICE_END_PTR(slice_); }
const uint8_t* end() const { return GRPC_SLICE_END_PTR(slice_); }
/// Raw C slice. Caller needs to call grpc_slice_unref when done.
grpc_slice c_slice() const { return grpc_slice_ref(slice_); }

@ -60,7 +60,7 @@ typedef struct grpc_slice_refcount {
void (*unref)(void *);
} grpc_slice_refcount;
#define GPR_SLICE_INLINED_SIZE (sizeof(size_t) + sizeof(uint8_t *) - 1)
#define GRPC_SLICE_INLINED_SIZE (sizeof(size_t) + sizeof(uint8_t *) - 1)
/* A grpc_slice s, if initialized, represents the byte range
s.bytes[0..s.length-1].
@ -80,7 +80,7 @@ typedef struct grpc_slice {
} refcounted;
struct {
uint8_t length;
uint8_t bytes[GPR_SLICE_INLINED_SIZE];
uint8_t bytes[GRPC_SLICE_INLINED_SIZE];
} inlined;
} data;
} grpc_slice;
@ -102,17 +102,17 @@ typedef struct {
grpc_slice inlined[GRPC_SLICE_BUFFER_INLINE_ELEMENTS];
} grpc_slice_buffer;
#define GPR_SLICE_START_PTR(slice) \
#define GRPC_SLICE_START_PTR(slice) \
((slice).refcount ? (slice).data.refcounted.bytes \
: (slice).data.inlined.bytes)
#define GPR_SLICE_LENGTH(slice) \
#define GRPC_SLICE_LENGTH(slice) \
((slice).refcount ? (slice).data.refcounted.length \
: (slice).data.inlined.length)
#define GPR_SLICE_SET_LENGTH(slice, newlen) \
#define GRPC_SLICE_SET_LENGTH(slice, newlen) \
((slice).refcount ? ((slice).data.refcounted.length = (size_t)(newlen)) \
: ((slice).data.inlined.length = (uint8_t)(newlen)))
#define GPR_SLICE_END_PTR(slice) \
GPR_SLICE_START_PTR(slice) + GPR_SLICE_LENGTH(slice)
#define GPR_SLICE_IS_EMPTY(slice) (GPR_SLICE_LENGTH(slice) == 0)
#define GRPC_SLICE_END_PTR(slice) \
GRPC_SLICE_START_PTR(slice) + GRPC_SLICE_LENGTH(slice)
#define GRPC_SLICE_IS_EMPTY(slice) (GRPC_SLICE_LENGTH(slice) == 0)
#endif /* GRPC_IMPL_CODEGEN_SLICE_H */

@ -69,7 +69,7 @@ static void extract_and_annotate_method_tag(grpc_metadata_batch *md,
for (m = md->list.head; m != NULL; m = m->next) {
if (m->md->key == GRPC_MDSTR_PATH) {
gpr_log(GPR_DEBUG, "%s",
(const char *)GPR_SLICE_START_PTR(m->md->value->slice));
(const char *)GRPC_SLICE_START_PTR(m->md->value->slice));
/* Add method tag here */
}
}

@ -118,7 +118,7 @@ static void on_read_done(grpc_exec_ctx* exec_ctx, void* arg,
}
// Add buffer to parser.
for (size_t i = 0; i < handshaker->read_buffer->count; ++i) {
if (GPR_SLICE_LENGTH(handshaker->read_buffer->slices[i]) > 0) {
if (GRPC_SLICE_LENGTH(handshaker->read_buffer->slices[i]) > 0) {
size_t body_start_offset = 0;
error = grpc_http_parser_parse(&handshaker->http_parser,
handshaker->read_buffer->slices[i],
@ -132,7 +132,7 @@ static void on_read_done(grpc_exec_ctx* exec_ctx, void* arg,
grpc_slice_buffer tmp_buffer;
grpc_slice_buffer_init(&tmp_buffer);
if (body_start_offset <
GPR_SLICE_LENGTH(handshaker->read_buffer->slices[i])) {
GRPC_SLICE_LENGTH(handshaker->read_buffer->slices[i])) {
grpc_slice_buffer_add(
&tmp_buffer,
grpc_slice_split_tail(&handshaker->read_buffer->slices[i],

@ -101,7 +101,7 @@ grpc_slice grpc_grpclb_request_encode(const grpc_grpclb_request *request) {
slice = grpc_slice_malloc(encoded_length);
outputstream =
pb_ostream_from_buffer(GPR_SLICE_START_PTR(slice), encoded_length);
pb_ostream_from_buffer(GRPC_SLICE_START_PTR(slice), encoded_length);
GPR_ASSERT(pb_encode(&outputstream, grpc_lb_v1_LoadBalanceRequest_fields,
request) != 0);
return slice;
@ -115,8 +115,8 @@ typedef grpc_lb_v1_LoadBalanceResponse grpc_grpclb_response;
grpc_grpclb_initial_response *grpc_grpclb_initial_response_parse(
grpc_slice encoded_grpc_grpclb_response) {
pb_istream_t stream =
pb_istream_from_buffer(GPR_SLICE_START_PTR(encoded_grpc_grpclb_response),
GPR_SLICE_LENGTH(encoded_grpc_grpclb_response));
pb_istream_from_buffer(GRPC_SLICE_START_PTR(encoded_grpc_grpclb_response),
GRPC_SLICE_LENGTH(encoded_grpc_grpclb_response));
grpc_grpclb_response res;
memset(&res, 0, sizeof(grpc_grpclb_response));
if (!pb_decode(&stream, grpc_lb_v1_LoadBalanceResponse_fields, &res)) {
@ -136,8 +136,8 @@ grpc_grpclb_serverlist *grpc_grpclb_response_parse_serverlist(
bool status;
decode_serverlist_arg arg;
pb_istream_t stream =
pb_istream_from_buffer(GPR_SLICE_START_PTR(encoded_grpc_grpclb_response),
GPR_SLICE_LENGTH(encoded_grpc_grpclb_response));
pb_istream_from_buffer(GRPC_SLICE_START_PTR(encoded_grpc_grpclb_response),
GRPC_SLICE_LENGTH(encoded_grpc_grpclb_response));
pb_istream_t stream_at_start = stream;
grpc_grpclb_response res;
memset(&res, 0, sizeof(grpc_grpclb_response));

@ -36,9 +36,9 @@
#include <stdlib.h>
#include <string.h>
#include <grpc/support/alloc.h>
#include <grpc/slice.h>
#include <grpc/slice_buffer.h>
#include <grpc/support/alloc.h>
#include "src/core/ext/client_channel/client_channel.h"
#include "src/core/ext/client_channel/http_connect_handshaker.h"
@ -117,12 +117,12 @@ static void connected(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
connector *c = arg;
grpc_endpoint *tcp = c->tcp;
if (tcp != NULL) {
if (!GPR_SLICE_IS_EMPTY(c->args.initial_connect_string)) {
if (!GRPC_SLICE_IS_EMPTY(c->args.initial_connect_string)) {
grpc_closure_init(&c->initial_string_sent, on_initial_connect_string_sent,
c);
grpc_slice_buffer_init(&c->initial_string_buffer);
grpc_slice_buffer_add(&c->initial_string_buffer,
c->args.initial_connect_string);
c->args.initial_connect_string);
connector_ref(arg);
grpc_endpoint_write(exec_ctx, tcp, &c->initial_string_buffer,
&c->initial_string_sent);

@ -36,9 +36,9 @@
#include <stdlib.h>
#include <string.h>
#include <grpc/support/alloc.h>
#include <grpc/slice.h>
#include <grpc/slice_buffer.h>
#include <grpc/support/alloc.h>
#include "src/core/ext/client_channel/client_channel.h"
#include "src/core/ext/client_channel/http_connect_handshaker.h"
@ -166,12 +166,12 @@ static void connected(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
GPR_ASSERT(c->connecting_endpoint == NULL);
c->connecting_endpoint = tcp;
gpr_mu_unlock(&c->mu);
if (!GPR_SLICE_IS_EMPTY(c->args.initial_connect_string)) {
if (!GRPC_SLICE_IS_EMPTY(c->args.initial_connect_string)) {
grpc_closure_init(&c->initial_string_sent, on_initial_connect_string_sent,
c);
grpc_slice_buffer_init(&c->initial_string_buffer);
grpc_slice_buffer_add(&c->initial_string_buffer,
c->args.initial_connect_string);
c->args.initial_connect_string);
grpc_endpoint_write(exec_ctx, tcp, &c->initial_string_buffer,
&c->initial_string_sent);
} else {

@ -144,7 +144,7 @@ bool grpc_base64_decode_partial(struct grpc_base64_decode_context *ctx) {
}
grpc_slice grpc_chttp2_base64_decode(grpc_slice input) {
size_t input_length = GPR_SLICE_LENGTH(input);
size_t input_length = GRPC_SLICE_LENGTH(input);
size_t output_length = input_length / 4 * 3;
struct grpc_base64_decode_context ctx;
grpc_slice output;
@ -159,7 +159,7 @@ grpc_slice grpc_chttp2_base64_decode(grpc_slice input) {
}
if (input_length > 0) {
uint8_t *input_end = GPR_SLICE_END_PTR(input);
uint8_t *input_end = GRPC_SLICE_END_PTR(input);
if (*(--input_end) == '=') {
output_length--;
if (*(--input_end) == '=') {
@ -169,10 +169,10 @@ grpc_slice grpc_chttp2_base64_decode(grpc_slice input) {
}
output = grpc_slice_malloc(output_length);
ctx.input_cur = GPR_SLICE_START_PTR(input);
ctx.input_end = GPR_SLICE_END_PTR(input);
ctx.output_cur = GPR_SLICE_START_PTR(output);
ctx.output_end = GPR_SLICE_END_PTR(output);
ctx.input_cur = GRPC_SLICE_START_PTR(input);
ctx.input_end = GRPC_SLICE_END_PTR(input);
ctx.output_cur = GRPC_SLICE_START_PTR(output);
ctx.output_end = GRPC_SLICE_END_PTR(output);
ctx.contains_tail = false;
if (!grpc_base64_decode_partial(&ctx)) {
@ -182,14 +182,14 @@ grpc_slice grpc_chttp2_base64_decode(grpc_slice input) {
grpc_slice_unref(output);
return gpr_empty_slice();
}
GPR_ASSERT(ctx.output_cur == GPR_SLICE_END_PTR(output));
GPR_ASSERT(ctx.input_cur == GPR_SLICE_END_PTR(input));
GPR_ASSERT(ctx.output_cur == GRPC_SLICE_END_PTR(output));
GPR_ASSERT(ctx.input_cur == GRPC_SLICE_END_PTR(input));
return output;
}
grpc_slice grpc_chttp2_base64_decode_with_length(grpc_slice input,
size_t output_length) {
size_t input_length = GPR_SLICE_LENGTH(input);
size_t input_length = GRPC_SLICE_LENGTH(input);
grpc_slice output = grpc_slice_malloc(output_length);
struct grpc_base64_decode_context ctx;
@ -214,10 +214,10 @@ grpc_slice grpc_chttp2_base64_decode_with_length(grpc_slice input,
return gpr_empty_slice();
}
ctx.input_cur = GPR_SLICE_START_PTR(input);
ctx.input_end = GPR_SLICE_END_PTR(input);
ctx.output_cur = GPR_SLICE_START_PTR(output);
ctx.output_end = GPR_SLICE_END_PTR(output);
ctx.input_cur = GRPC_SLICE_START_PTR(input);
ctx.input_end = GRPC_SLICE_END_PTR(input);
ctx.output_cur = GRPC_SLICE_START_PTR(output);
ctx.output_end = GRPC_SLICE_END_PTR(output);
ctx.contains_tail = true;
if (!grpc_base64_decode_partial(&ctx)) {
@ -227,7 +227,7 @@ grpc_slice grpc_chttp2_base64_decode_with_length(grpc_slice input,
grpc_slice_unref(output);
return gpr_empty_slice();
}
GPR_ASSERT(ctx.output_cur == GPR_SLICE_END_PTR(output));
GPR_ASSERT(ctx.input_cur <= GPR_SLICE_END_PTR(input));
GPR_ASSERT(ctx.output_cur == GRPC_SLICE_END_PTR(output));
GPR_ASSERT(ctx.input_cur <= GRPC_SLICE_END_PTR(input));
return output;
}

@ -62,13 +62,13 @@ static const b64_huff_sym huff_alphabet[64] = {
static const uint8_t tail_xtra[3] = {0, 2, 3};
grpc_slice grpc_chttp2_base64_encode(grpc_slice input) {
size_t input_length = GPR_SLICE_LENGTH(input);
size_t input_length = GRPC_SLICE_LENGTH(input);
size_t input_triplets = input_length / 3;
size_t tail_case = input_length % 3;
size_t output_length = input_triplets * 4 + tail_xtra[tail_case];
grpc_slice output = grpc_slice_malloc(output_length);
uint8_t *in = GPR_SLICE_START_PTR(input);
char *out = (char *)GPR_SLICE_START_PTR(output);
uint8_t *in = GRPC_SLICE_START_PTR(input);
char *out = (char *)GRPC_SLICE_START_PTR(output);
size_t i;
/* encode full triplets */
@ -100,8 +100,8 @@ grpc_slice grpc_chttp2_base64_encode(grpc_slice input) {
break;
}
GPR_ASSERT(out == (char *)GPR_SLICE_END_PTR(output));
GPR_ASSERT(in == GPR_SLICE_END_PTR(input));
GPR_ASSERT(out == (char *)GRPC_SLICE_END_PTR(output));
GPR_ASSERT(in == GRPC_SLICE_END_PTR(input));
return output;
}
@ -114,13 +114,13 @@ grpc_slice grpc_chttp2_huffman_compress(grpc_slice input) {
uint32_t temp_length = 0;
nbits = 0;
for (in = GPR_SLICE_START_PTR(input); in != GPR_SLICE_END_PTR(input); ++in) {
for (in = GRPC_SLICE_START_PTR(input); in != GRPC_SLICE_END_PTR(input); ++in) {
nbits += grpc_chttp2_huffsyms[*in].length;
}
output = grpc_slice_malloc(nbits / 8 + (nbits % 8 != 0));
out = GPR_SLICE_START_PTR(output);
for (in = GPR_SLICE_START_PTR(input); in != GPR_SLICE_END_PTR(input); ++in) {
out = GRPC_SLICE_START_PTR(output);
for (in = GRPC_SLICE_START_PTR(input); in != GRPC_SLICE_END_PTR(input); ++in) {
int sym = *in;
temp <<= grpc_chttp2_huffsyms[sym].length;
temp |= grpc_chttp2_huffsyms[sym].bits;
@ -141,7 +141,7 @@ grpc_slice grpc_chttp2_huffman_compress(grpc_slice input) {
(uint8_t)(0xffu >> temp_length));
}
GPR_ASSERT(out == GPR_SLICE_END_PTR(output));
GPR_ASSERT(out == GRPC_SLICE_END_PTR(output));
return output;
}
@ -176,15 +176,15 @@ static void enc_add1(huff_out *out, uint8_t a) {
}
grpc_slice grpc_chttp2_base64_encode_and_huffman_compress_impl(grpc_slice input) {
size_t input_length = GPR_SLICE_LENGTH(input);
size_t input_length = GRPC_SLICE_LENGTH(input);
size_t input_triplets = input_length / 3;
size_t tail_case = input_length % 3;
size_t output_syms = input_triplets * 4 + tail_xtra[tail_case];
size_t max_output_bits = 11 * output_syms;
size_t max_output_length = max_output_bits / 8 + (max_output_bits % 8 != 0);
grpc_slice output = grpc_slice_malloc(max_output_length);
uint8_t *in = GPR_SLICE_START_PTR(input);
uint8_t *start_out = GPR_SLICE_START_PTR(output);
uint8_t *in = GRPC_SLICE_START_PTR(input);
uint8_t *start_out = GRPC_SLICE_START_PTR(output);
huff_out out;
size_t i;
@ -231,9 +231,9 @@ grpc_slice grpc_chttp2_base64_encode_and_huffman_compress_impl(grpc_slice input)
(uint8_t)(0xffu >> out.temp_length));
}
GPR_ASSERT(out.out <= GPR_SLICE_END_PTR(output));
GPR_SLICE_SET_LENGTH(output, out.out - start_out);
GPR_ASSERT(out.out <= GRPC_SLICE_END_PTR(output));
GRPC_SLICE_SET_LENGTH(output, out.out - start_out);
GPR_ASSERT(in == GPR_SLICE_END_PTR(input));
GPR_ASSERT(in == GRPC_SLICE_END_PTR(input));
return output;
}

@ -885,7 +885,7 @@ static void add_fetched_slice_locked(grpc_exec_ctx *exec_ctx,
grpc_chttp2_transport *t,
grpc_chttp2_stream *s) {
s->fetched_send_message_length +=
(uint32_t)GPR_SLICE_LENGTH(s->fetching_slice);
(uint32_t)GRPC_SLICE_LENGTH(s->fetching_slice);
grpc_slice_buffer_add(&s->flow_controlled_buffer, s->fetching_slice);
if (s->id != 0) {
grpc_chttp2_become_writable(exec_ctx, t, s, true, "op.send_message");
@ -1602,7 +1602,7 @@ static void close_from_api(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
compression
and just write the uncompressed bytes onto the wire. */
status_hdr = grpc_slice_malloc(15 + (grpc_status >= 10));
p = GPR_SLICE_START_PTR(status_hdr);
p = GRPC_SLICE_START_PTR(status_hdr);
*p++ = 0x40; /* literal header */
*p++ = 11; /* len(grpc-status) */
*p++ = 'g';
@ -1624,8 +1624,8 @@ static void close_from_api(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
*p++ = (uint8_t)('0' + (grpc_status / 10));
*p++ = (uint8_t)('0' + (grpc_status % 10));
}
GPR_ASSERT(p == GPR_SLICE_END_PTR(status_hdr));
len += (uint32_t)GPR_SLICE_LENGTH(status_hdr);
GPR_ASSERT(p == GRPC_SLICE_END_PTR(status_hdr));
len += (uint32_t)GRPC_SLICE_LENGTH(status_hdr);
const char *optional_message =
grpc_error_get_str(error, GRPC_ERROR_STR_GRPC_MESSAGE);
@ -1634,7 +1634,7 @@ static void close_from_api(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
size_t msg_len = strlen(optional_message);
GPR_ASSERT(msg_len < 127);
message_pfx = grpc_slice_malloc(15);
p = GPR_SLICE_START_PTR(message_pfx);
p = GRPC_SLICE_START_PTR(message_pfx);
*p++ = 0x40;
*p++ = 12; /* len(grpc-message) */
*p++ = 'g';
@ -1650,13 +1650,13 @@ static void close_from_api(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
*p++ = 'g';
*p++ = 'e';
*p++ = (uint8_t)msg_len;
GPR_ASSERT(p == GPR_SLICE_END_PTR(message_pfx));
len += (uint32_t)GPR_SLICE_LENGTH(message_pfx);
GPR_ASSERT(p == GRPC_SLICE_END_PTR(message_pfx));
len += (uint32_t)GRPC_SLICE_LENGTH(message_pfx);
len += (uint32_t)msg_len;
}
hdr = grpc_slice_malloc(9);
p = GPR_SLICE_START_PTR(hdr);
p = GRPC_SLICE_START_PTR(hdr);
*p++ = (uint8_t)(len >> 16);
*p++ = (uint8_t)(len >> 8);
*p++ = (uint8_t)(len);
@ -1666,7 +1666,7 @@ static void close_from_api(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
*p++ = (uint8_t)(s->id >> 16);
*p++ = (uint8_t)(s->id >> 8);
*p++ = (uint8_t)(s->id);
GPR_ASSERT(p == GPR_SLICE_END_PTR(hdr));
GPR_ASSERT(p == GRPC_SLICE_END_PTR(hdr));
grpc_slice_buffer_add(&t->qbuf, hdr);
grpc_slice_buffer_add(&t->qbuf, status_hdr);
@ -2043,11 +2043,11 @@ void grpc_chttp2_incoming_byte_stream_push(grpc_exec_ctx *exec_ctx,
grpc_chttp2_incoming_byte_stream *bs,
grpc_slice slice) {
gpr_mu_lock(&bs->slice_mu);
if (bs->remaining_bytes < GPR_SLICE_LENGTH(slice)) {
if (bs->remaining_bytes < GRPC_SLICE_LENGTH(slice)) {
incoming_byte_stream_publish_error(
exec_ctx, bs, GRPC_ERROR_CREATE("Too many bytes in stream"));
} else {
bs->remaining_bytes -= (uint32_t)GPR_SLICE_LENGTH(slice);
bs->remaining_bytes -= (uint32_t)GRPC_SLICE_LENGTH(slice);
if (bs->on_next != NULL) {
*bs->next = slice;
grpc_exec_ctx_sched(exec_ctx, bs->on_next, GRPC_ERROR_NONE, NULL);

@ -122,7 +122,7 @@ void grpc_chttp2_encode_data(uint32_t id, grpc_slice_buffer *inbuf,
static const size_t header_size = 9;
hdr = grpc_slice_malloc(header_size);
p = GPR_SLICE_START_PTR(hdr);
p = GRPC_SLICE_START_PTR(hdr);
GPR_ASSERT(write_bytes < (1 << 24));
*p++ = (uint8_t)(write_bytes >> 16);
*p++ = (uint8_t)(write_bytes >> 8);
@ -145,8 +145,8 @@ static grpc_error *parse_inner(grpc_exec_ctx *exec_ctx,
grpc_chttp2_data_parser *p,
grpc_chttp2_transport *t, grpc_chttp2_stream *s,
grpc_slice slice) {
uint8_t *const beg = GPR_SLICE_START_PTR(slice);
uint8_t *const end = GPR_SLICE_END_PTR(slice);
uint8_t *const beg = GRPC_SLICE_START_PTR(slice);
uint8_t *const end = GRPC_SLICE_END_PTR(slice);
uint8_t *cur = beg;
uint32_t message_flags;
grpc_chttp2_incoming_byte_stream *incoming_byte_stream;

@ -72,8 +72,8 @@ grpc_error *grpc_chttp2_goaway_parser_parse(grpc_exec_ctx *exec_ctx,
grpc_chttp2_transport *t,
grpc_chttp2_stream *s,
grpc_slice slice, int is_last) {
uint8_t *const beg = GPR_SLICE_START_PTR(slice);
uint8_t *const end = GPR_SLICE_END_PTR(slice);
uint8_t *const beg = GRPC_SLICE_START_PTR(slice);
uint8_t *const end = GRPC_SLICE_END_PTR(slice);
uint8_t *cur = beg;
grpc_chttp2_goaway_parser *p = parser;
@ -163,10 +163,10 @@ void grpc_chttp2_goaway_append(uint32_t last_stream_id, uint32_t error_code,
grpc_slice debug_data,
grpc_slice_buffer *slice_buffer) {
grpc_slice header = grpc_slice_malloc(9 + 4 + 4);
uint8_t *p = GPR_SLICE_START_PTR(header);
uint8_t *p = GRPC_SLICE_START_PTR(header);
uint32_t frame_length;
GPR_ASSERT(GPR_SLICE_LENGTH(debug_data) < UINT32_MAX - 4 - 4);
frame_length = 4 + 4 + (uint32_t)GPR_SLICE_LENGTH(debug_data);
GPR_ASSERT(GRPC_SLICE_LENGTH(debug_data) < UINT32_MAX - 4 - 4);
frame_length = 4 + 4 + (uint32_t)GRPC_SLICE_LENGTH(debug_data);
/* frame header: length */
*p++ = (uint8_t)(frame_length >> 16);
@ -191,7 +191,7 @@ void grpc_chttp2_goaway_append(uint32_t last_stream_id, uint32_t error_code,
*p++ = (uint8_t)(error_code >> 16);
*p++ = (uint8_t)(error_code >> 8);
*p++ = (uint8_t)(error_code);
GPR_ASSERT(p == GPR_SLICE_END_PTR(header));
GPR_ASSERT(p == GRPC_SLICE_END_PTR(header));
grpc_slice_buffer_add(slice_buffer, header);
grpc_slice_buffer_add(slice_buffer, debug_data);
}

@ -42,7 +42,7 @@
grpc_slice grpc_chttp2_ping_create(uint8_t ack, uint8_t *opaque_8bytes) {
grpc_slice slice = grpc_slice_malloc(9 + 8);
uint8_t *p = GPR_SLICE_START_PTR(slice);
uint8_t *p = GRPC_SLICE_START_PTR(slice);
*p++ = 0;
*p++ = 0;
@ -77,8 +77,8 @@ grpc_error *grpc_chttp2_ping_parser_parse(grpc_exec_ctx *exec_ctx, void *parser,
grpc_chttp2_transport *t,
grpc_chttp2_stream *s,
grpc_slice slice, int is_last) {
uint8_t *const beg = GPR_SLICE_START_PTR(slice);
uint8_t *const end = GPR_SLICE_END_PTR(slice);
uint8_t *const beg = GRPC_SLICE_START_PTR(slice);
uint8_t *const end = GRPC_SLICE_END_PTR(slice);
uint8_t *cur = beg;
grpc_chttp2_ping_parser *p = parser;

@ -47,7 +47,7 @@ grpc_slice grpc_chttp2_rst_stream_create(uint32_t id, uint32_t code,
static const size_t frame_size = 13;
grpc_slice slice = grpc_slice_malloc(frame_size);
stats->framing_bytes += frame_size;
uint8_t *p = GPR_SLICE_START_PTR(slice);
uint8_t *p = GRPC_SLICE_START_PTR(slice);
// Frame size.
*p++ = 0;
@ -90,8 +90,8 @@ grpc_error *grpc_chttp2_rst_stream_parser_parse(grpc_exec_ctx *exec_ctx,
grpc_chttp2_transport *t,
grpc_chttp2_stream *s,
grpc_slice slice, int is_last) {
uint8_t *const beg = GPR_SLICE_START_PTR(slice);
uint8_t *const end = GPR_SLICE_END_PTR(slice);
uint8_t *const beg = GRPC_SLICE_START_PTR(slice);
uint8_t *const end = GRPC_SLICE_END_PTR(slice);
uint8_t *cur = beg;
grpc_chttp2_rst_stream_parser *p = parser;

@ -94,7 +94,7 @@ grpc_slice grpc_chttp2_settings_create(uint32_t *old, const uint32_t *new,
}
output = grpc_slice_malloc(9 + 6 * n);
p = fill_header(GPR_SLICE_START_PTR(output), 6 * n, 0);
p = fill_header(GRPC_SLICE_START_PTR(output), 6 * n, 0);
for (i = 0; i < count; i++) {
if (new[i] != old[i] || (force_mask & (1u << i)) != 0) {
@ -109,14 +109,14 @@ grpc_slice grpc_chttp2_settings_create(uint32_t *old, const uint32_t *new,
}
}
GPR_ASSERT(p == GPR_SLICE_END_PTR(output));
GPR_ASSERT(p == GRPC_SLICE_END_PTR(output));
return output;
}
grpc_slice grpc_chttp2_settings_ack_create(void) {
grpc_slice output = grpc_slice_malloc(9);
fill_header(GPR_SLICE_START_PTR(output), 0, GRPC_CHTTP2_FLAG_ACK);
fill_header(GRPC_SLICE_START_PTR(output), 0, GRPC_CHTTP2_FLAG_ACK);
return output;
}
@ -148,8 +148,8 @@ grpc_error *grpc_chttp2_settings_parser_parse(grpc_exec_ctx *exec_ctx, void *p,
grpc_chttp2_stream *s,
grpc_slice slice, int is_last) {
grpc_chttp2_settings_parser *parser = p;
const uint8_t *cur = GPR_SLICE_START_PTR(slice);
const uint8_t *end = GPR_SLICE_END_PTR(slice);
const uint8_t *cur = GRPC_SLICE_START_PTR(slice);
const uint8_t *end = GRPC_SLICE_END_PTR(slice);
char *msg;
if (parser->is_ack) {

@ -43,7 +43,7 @@ grpc_slice grpc_chttp2_window_update_create(
static const size_t frame_size = 13;
grpc_slice slice = grpc_slice_malloc(frame_size);
stats->header_bytes += frame_size;
uint8_t *p = GPR_SLICE_START_PTR(slice);
uint8_t *p = GRPC_SLICE_START_PTR(slice);
GPR_ASSERT(window_update);
@ -82,8 +82,8 @@ grpc_error *grpc_chttp2_window_update_parser_begin_frame(
grpc_error *grpc_chttp2_window_update_parser_parse(
grpc_exec_ctx *exec_ctx, void *parser, grpc_chttp2_transport *t,
grpc_chttp2_stream *s, grpc_slice slice, int is_last) {
uint8_t *const beg = GPR_SLICE_START_PTR(slice);
uint8_t *const end = GPR_SLICE_END_PTR(slice);
uint8_t *const beg = GRPC_SLICE_START_PTR(slice);
uint8_t *const end = GRPC_SLICE_END_PTR(slice);
uint8_t *cur = beg;
grpc_chttp2_window_update_parser *p = parser;

@ -104,7 +104,7 @@ static void finish_frame(framer_state *st, int is_header_boundary,
type = st->is_first_frame ? GRPC_CHTTP2_FRAME_HEADER
: GRPC_CHTTP2_FRAME_CONTINUATION;
fill_header(
GPR_SLICE_START_PTR(st->output->slices[st->header_idx]), type,
GRPC_SLICE_START_PTR(st->output->slices[st->header_idx]), type,
st->stream_id, st->output->length - st->output_length_at_start_of_frame,
(uint8_t)((is_last_in_stream ? GRPC_CHTTP2_DATA_FLAG_END_STREAM : 0) |
(is_header_boundary ? GRPC_CHTTP2_DATA_FLAG_END_HEADERS : 0)));
@ -148,7 +148,7 @@ static void inc_filter(uint8_t idx, uint32_t *sum, uint8_t *elems) {
}
static void add_header_data(framer_state *st, grpc_slice slice) {
size_t len = GPR_SLICE_LENGTH(slice);
size_t len = GRPC_SLICE_LENGTH(slice);
size_t remaining;
if (len == 0) return;
remaining = st->max_frame_size + st->output_length_at_start_of_frame -
@ -269,8 +269,8 @@ static void emit_indexed(grpc_chttp2_hpack_compressor *c, uint32_t elem_index,
}
static grpc_slice get_wire_value(grpc_mdelem *elem, uint8_t *huffman_prefix) {
if (grpc_is_binary_header((const char *)GPR_SLICE_START_PTR(elem->key->slice),
GPR_SLICE_LENGTH(elem->key->slice))) {
if (grpc_is_binary_header((const char *)GRPC_SLICE_START_PTR(elem->key->slice),
GRPC_SLICE_LENGTH(elem->key->slice))) {
*huffman_prefix = 0x80;
return grpc_mdstr_as_base64_encoded_and_huffman_compressed(elem->value);
}
@ -285,7 +285,7 @@ static void emit_lithdr_incidx(grpc_chttp2_hpack_compressor *c,
uint32_t len_pfx = GRPC_CHTTP2_VARINT_LENGTH(key_index, 2);
uint8_t huffman_prefix;
grpc_slice value_slice = get_wire_value(elem, &huffman_prefix);
size_t len_val = GPR_SLICE_LENGTH(value_slice);
size_t len_val = GRPC_SLICE_LENGTH(value_slice);
uint32_t len_val_len;
GPR_ASSERT(len_val <= UINT32_MAX);
len_val_len = GRPC_CHTTP2_VARINT_LENGTH((uint32_t)len_val, 1);
@ -302,7 +302,7 @@ static void emit_lithdr_noidx(grpc_chttp2_hpack_compressor *c,
uint32_t len_pfx = GRPC_CHTTP2_VARINT_LENGTH(key_index, 4);
uint8_t huffman_prefix;
grpc_slice value_slice = get_wire_value(elem, &huffman_prefix);
size_t len_val = GPR_SLICE_LENGTH(value_slice);
size_t len_val = GRPC_SLICE_LENGTH(value_slice);
uint32_t len_val_len;
GPR_ASSERT(len_val <= UINT32_MAX);
len_val_len = GRPC_CHTTP2_VARINT_LENGTH((uint32_t)len_val, 1);
@ -315,14 +315,14 @@ static void emit_lithdr_noidx(grpc_chttp2_hpack_compressor *c,
static void emit_lithdr_incidx_v(grpc_chttp2_hpack_compressor *c,
grpc_mdelem *elem, framer_state *st) {
uint32_t len_key = (uint32_t)GPR_SLICE_LENGTH(elem->key->slice);
uint32_t len_key = (uint32_t)GRPC_SLICE_LENGTH(elem->key->slice);
uint8_t huffman_prefix;
grpc_slice value_slice = get_wire_value(elem, &huffman_prefix);
uint32_t len_val = (uint32_t)GPR_SLICE_LENGTH(value_slice);
uint32_t len_val = (uint32_t)GRPC_SLICE_LENGTH(value_slice);
uint32_t len_key_len = GRPC_CHTTP2_VARINT_LENGTH(len_key, 1);
uint32_t len_val_len = GRPC_CHTTP2_VARINT_LENGTH(len_val, 1);
GPR_ASSERT(len_key <= UINT32_MAX);
GPR_ASSERT(GPR_SLICE_LENGTH(value_slice) <= UINT32_MAX);
GPR_ASSERT(GRPC_SLICE_LENGTH(value_slice) <= UINT32_MAX);
*add_tiny_header_data(st, 1) = 0x40;
GRPC_CHTTP2_WRITE_VARINT(len_key, 1, 0x00,
add_tiny_header_data(st, len_key_len), len_key_len);
@ -334,14 +334,14 @@ static void emit_lithdr_incidx_v(grpc_chttp2_hpack_compressor *c,
static void emit_lithdr_noidx_v(grpc_chttp2_hpack_compressor *c,
grpc_mdelem *elem, framer_state *st) {
uint32_t len_key = (uint32_t)GPR_SLICE_LENGTH(elem->key->slice);
uint32_t len_key = (uint32_t)GRPC_SLICE_LENGTH(elem->key->slice);
uint8_t huffman_prefix;
grpc_slice value_slice = get_wire_value(elem, &huffman_prefix);
uint32_t len_val = (uint32_t)GPR_SLICE_LENGTH(value_slice);
uint32_t len_val = (uint32_t)GRPC_SLICE_LENGTH(value_slice);
uint32_t len_key_len = GRPC_CHTTP2_VARINT_LENGTH(len_key, 1);
uint32_t len_val_len = GRPC_CHTTP2_VARINT_LENGTH(len_val, 1);
GPR_ASSERT(len_key <= UINT32_MAX);
GPR_ASSERT(GPR_SLICE_LENGTH(value_slice) <= UINT32_MAX);
GPR_ASSERT(GRPC_SLICE_LENGTH(value_slice) <= UINT32_MAX);
*add_tiny_header_data(st, 1) = 0x00;
GRPC_CHTTP2_WRITE_VARINT(len_key, 1, 0x00,
add_tiny_header_data(st, len_key_len), len_key_len);
@ -373,8 +373,8 @@ static void hpack_enc(grpc_chttp2_hpack_compressor *c, grpc_mdelem *elem,
uint32_t indices_key;
int should_add_elem;
GPR_ASSERT(GPR_SLICE_LENGTH(elem->key->slice) > 0);
if (GPR_SLICE_START_PTR(elem->key->slice)[0] != ':') { /* regular header */
GPR_ASSERT(GRPC_SLICE_LENGTH(elem->key->slice) > 0);
if (GRPC_SLICE_START_PTR(elem->key->slice)[0] != ':') { /* regular header */
st->seen_regular_header = 1;
} else {
GPR_ASSERT(

@ -1502,8 +1502,8 @@ static grpc_error *is_binary_indexed_header(grpc_chttp2_hpack_parser *p,
GRPC_ERROR_INT_SIZE, (intptr_t)p->table.num_ents);
}
*is =
grpc_is_binary_header((const char *)GPR_SLICE_START_PTR(elem->key->slice),
GPR_SLICE_LENGTH(elem->key->slice));
grpc_is_binary_header((const char *)GRPC_SLICE_START_PTR(elem->key->slice),
GRPC_SLICE_LENGTH(elem->key->slice));
return GRPC_ERROR_NONE;
}
@ -1586,10 +1586,10 @@ grpc_error *grpc_chttp2_header_parser_parse(grpc_exec_ctx *exec_ctx,
grpc_chttp2_hpack_parser *parser = hpack_parser;
GPR_TIMER_BEGIN("grpc_chttp2_hpack_parser_parse", 0);
if (s != NULL) {
s->stats.incoming.header_bytes += GPR_SLICE_LENGTH(slice);
s->stats.incoming.header_bytes += GRPC_SLICE_LENGTH(slice);
}
grpc_error *error = grpc_chttp2_hpack_parser_parse(
exec_ctx, parser, GPR_SLICE_START_PTR(slice), GPR_SLICE_END_PTR(slice));
exec_ctx, parser, GRPC_SLICE_START_PTR(slice), GRPC_SLICE_END_PTR(slice));
if (error != GRPC_ERROR_NONE) {
GPR_TIMER_END("grpc_chttp2_hpack_parser_parse", 0);
return error;

@ -226,8 +226,8 @@ grpc_mdelem *grpc_chttp2_hptbl_lookup(const grpc_chttp2_hptbl *tbl,
/* Evict one element from the table */
static void evict1(grpc_chttp2_hptbl *tbl) {
grpc_mdelem *first_ent = tbl->ents[tbl->first_ent];
size_t elem_bytes = GPR_SLICE_LENGTH(first_ent->key->slice) +
GPR_SLICE_LENGTH(first_ent->value->slice) +
size_t elem_bytes = GRPC_SLICE_LENGTH(first_ent->key->slice) +
GRPC_SLICE_LENGTH(first_ent->value->slice) +
GRPC_CHTTP2_HPACK_ENTRY_OVERHEAD;
GPR_ASSERT(elem_bytes <= tbl->mem_used);
tbl->mem_used -= (uint32_t)elem_bytes;
@ -298,8 +298,8 @@ grpc_error *grpc_chttp2_hptbl_set_current_table_size(grpc_chttp2_hptbl *tbl,
grpc_error *grpc_chttp2_hptbl_add(grpc_chttp2_hptbl *tbl, grpc_mdelem *md) {
/* determine how many bytes of buffer this entry represents */
size_t elem_bytes = GPR_SLICE_LENGTH(md->key->slice) +
GPR_SLICE_LENGTH(md->value->slice) +
size_t elem_bytes = GRPC_SLICE_LENGTH(md->key->slice) +
GRPC_SLICE_LENGTH(md->value->slice) +
GRPC_CHTTP2_HPACK_ENTRY_OVERHEAD;
if (tbl->current_table_bytes > tbl->max_bytes) {

@ -73,8 +73,8 @@ static grpc_error *parse_frame_slice(grpc_exec_ctx *exec_ctx,
grpc_error *grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx,
grpc_chttp2_transport *t,
grpc_slice slice) {
uint8_t *beg = GPR_SLICE_START_PTR(slice);
uint8_t *end = GPR_SLICE_END_PTR(slice);
uint8_t *beg = GRPC_SLICE_START_PTR(slice);
uint8_t *end = GRPC_SLICE_END_PTR(slice);
uint8_t *cur = beg;
grpc_error *err;

@ -521,7 +521,7 @@ static void create_grpc_frame(grpc_slice_buffer *write_slice_buffer,
char **pp_write_buffer,
size_t *p_write_buffer_size) {
grpc_slice slice = grpc_slice_buffer_take_first(write_slice_buffer);
size_t length = GPR_SLICE_LENGTH(slice);
size_t length = GRPC_SLICE_LENGTH(slice);
*p_write_buffer_size = length + GRPC_HEADER_SIZE_IN_BYTES;
/* This is freed in the on_write_completed callback */
char *write_buffer = gpr_malloc(length + GRPC_HEADER_SIZE_IN_BYTES);
@ -534,7 +534,7 @@ static void create_grpc_frame(grpc_slice_buffer *write_slice_buffer,
*p++ = (uint8_t)(length >> 8);
*p++ = (uint8_t)(length);
/* append actual data */
memcpy(p, GPR_SLICE_START_PTR(slice), length);
memcpy(p, GRPC_SLICE_START_PTR(slice), length);
}
/*
@ -920,7 +920,7 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx,
CRONET_LOG(GPR_DEBUG, "read operation complete");
grpc_slice read_data_slice =
grpc_slice_malloc((uint32_t)stream_state->rs.length_field);
uint8_t *dst_p = GPR_SLICE_START_PTR(read_data_slice);
uint8_t *dst_p = GRPC_SLICE_START_PTR(read_data_slice);
memcpy(dst_p, stream_state->rs.read_buffer,
(size_t)stream_state->rs.length_field);
free_read_buffer(s);

@ -176,9 +176,9 @@ static void continue_send_message(grpc_exec_ctx *exec_ctx,
while (grpc_byte_stream_next(exec_ctx, calld->send_op.send_message,
&calld->incoming_slice, ~(size_t)0,
&calld->got_slice)) {
memcpy(wrptr, GPR_SLICE_START_PTR(calld->incoming_slice),
GPR_SLICE_LENGTH(calld->incoming_slice));
wrptr += GPR_SLICE_LENGTH(calld->incoming_slice);
memcpy(wrptr, GRPC_SLICE_START_PTR(calld->incoming_slice),
GRPC_SLICE_LENGTH(calld->incoming_slice));
wrptr += GRPC_SLICE_LENGTH(calld->incoming_slice);
grpc_slice_buffer_add(&calld->slices, calld->incoming_slice);
if (calld->send_length == calld->slices.length) {
calld->send_message_blocked = false;

@ -51,22 +51,22 @@ static int zlib_body(z_stream* zs, grpc_slice_buffer* input,
grpc_slice outbuf = grpc_slice_malloc(OUTPUT_BLOCK_SIZE);
const uInt uint_max = ~(uInt)0;
GPR_ASSERT(GPR_SLICE_LENGTH(outbuf) <= uint_max);
zs->avail_out = (uInt)GPR_SLICE_LENGTH(outbuf);
zs->next_out = GPR_SLICE_START_PTR(outbuf);
GPR_ASSERT(GRPC_SLICE_LENGTH(outbuf) <= uint_max);
zs->avail_out = (uInt)GRPC_SLICE_LENGTH(outbuf);
zs->next_out = GRPC_SLICE_START_PTR(outbuf);
flush = Z_NO_FLUSH;
for (i = 0; i < input->count; i++) {
if (i == input->count - 1) flush = Z_FINISH;
GPR_ASSERT(GPR_SLICE_LENGTH(input->slices[i]) <= uint_max);
zs->avail_in = (uInt)GPR_SLICE_LENGTH(input->slices[i]);
zs->next_in = GPR_SLICE_START_PTR(input->slices[i]);
GPR_ASSERT(GRPC_SLICE_LENGTH(input->slices[i]) <= uint_max);
zs->avail_in = (uInt)GRPC_SLICE_LENGTH(input->slices[i]);
zs->next_in = GRPC_SLICE_START_PTR(input->slices[i]);
do {
if (zs->avail_out == 0) {
grpc_slice_buffer_add_indexed(output, outbuf);
outbuf = grpc_slice_malloc(OUTPUT_BLOCK_SIZE);
GPR_ASSERT(GPR_SLICE_LENGTH(outbuf) <= uint_max);
zs->avail_out = (uInt)GPR_SLICE_LENGTH(outbuf);
zs->next_out = GPR_SLICE_START_PTR(outbuf);
GPR_ASSERT(GRPC_SLICE_LENGTH(outbuf) <= uint_max);
zs->avail_out = (uInt)GRPC_SLICE_LENGTH(outbuf);
zs->next_out = GRPC_SLICE_START_PTR(outbuf);
}
r = flate(zs, flush);
if (r < 0 && r != Z_BUF_ERROR /* not fatal */) {

@ -144,7 +144,7 @@ static void on_read(grpc_exec_ctx *exec_ctx, void *user_data,
size_t i;
for (i = 0; i < req->incoming.count; i++) {
if (GPR_SLICE_LENGTH(req->incoming.slices[i])) {
if (GRPC_SLICE_LENGTH(req->incoming.slices[i])) {
req->have_read_byte = 1;
grpc_error *err =
grpc_http_parser_parse(&req->parser, req->incoming.slices[i], NULL);

@ -335,10 +335,10 @@ void grpc_http_response_destroy(grpc_http_response *response) {
grpc_error *grpc_http_parser_parse(grpc_http_parser *parser, grpc_slice slice,
size_t *start_of_body) {
for (size_t i = 0; i < GPR_SLICE_LENGTH(slice); i++) {
for (size_t i = 0; i < GRPC_SLICE_LENGTH(slice); i++) {
bool found_body_start = false;
grpc_error *err =
addbyte(parser, GPR_SLICE_START_PTR(slice)[i], &found_body_start);
addbyte(parser, GRPC_SLICE_START_PTR(slice)[i], &found_body_start);
if (err != GRPC_ERROR_NONE) return err;
if (found_body_start && start_of_body != NULL) *start_of_body = i + 1;
}

@ -217,8 +217,8 @@ static void tcp_do_read(grpc_exec_ctx *exec_ctx, grpc_tcp *tcp) {
GPR_TIMER_BEGIN("tcp_continue_read", 0);
for (i = 0; i < tcp->incoming_buffer->count; i++) {
iov[i].iov_base = GPR_SLICE_START_PTR(tcp->incoming_buffer->slices[i]);
iov[i].iov_len = GPR_SLICE_LENGTH(tcp->incoming_buffer->slices[i]);
iov[i].iov_base = GRPC_SLICE_START_PTR(tcp->incoming_buffer->slices[i]);
iov[i].iov_len = GRPC_SLICE_LENGTH(tcp->incoming_buffer->slices[i]);
}
msg.msg_name = NULL;
@ -348,11 +348,11 @@ static bool tcp_flush(grpc_tcp *tcp, grpc_error **error) {
iov_size != MAX_WRITE_IOVEC;
iov_size++) {
iov[iov_size].iov_base =
GPR_SLICE_START_PTR(
GRPC_SLICE_START_PTR(
tcp->outgoing_buffer->slices[tcp->outgoing_slice_idx]) +
tcp->outgoing_byte_idx;
iov[iov_size].iov_len =
GPR_SLICE_LENGTH(
GRPC_SLICE_LENGTH(
tcp->outgoing_buffer->slices[tcp->outgoing_slice_idx]) -
tcp->outgoing_byte_idx;
sending_length += iov[iov_size].iov_len;
@ -393,7 +393,7 @@ static bool tcp_flush(grpc_tcp *tcp, grpc_error **error) {
size_t slice_length;
tcp->outgoing_slice_idx--;
slice_length = GPR_SLICE_LENGTH(
slice_length = GRPC_SLICE_LENGTH(
tcp->outgoing_buffer->slices[tcp->outgoing_slice_idx]);
if (slice_length > trailing) {
tcp->outgoing_byte_idx = slice_length - trailing;

@ -59,9 +59,9 @@ typedef struct {
grpc_closure *read_cb;
grpc_closure *write_cb;
gpr_slice read_slice;
gpr_slice_buffer *read_slices;
gpr_slice_buffer *write_slices;
GRPC_SLICE read_slice;
GRPC_SLICE_buffer *read_slices;
GRPC_SLICE_buffer *write_slices;
uv_buf_t *write_buffers;
bool shutting_down;
@ -108,14 +108,14 @@ static void alloc_uv_buf(uv_handle_t *handle, size_t suggested_size,
uv_buf_t *buf) {
grpc_tcp *tcp = handle->data;
(void)suggested_size;
tcp->read_slice = gpr_slice_malloc(GRPC_TCP_DEFAULT_READ_SLICE_SIZE);
buf->base = (char *)GPR_SLICE_START_PTR(tcp->read_slice);
buf->len = GPR_SLICE_LENGTH(tcp->read_slice);
tcp->read_slice = GRPC_SLICE_malloc(GRPC_TCP_DEFAULT_READ_SLICE_SIZE);
buf->base = (char *)GRPC_SLICE_START_PTR(tcp->read_slice);
buf->len = GRPC_SLICE_LENGTH(tcp->read_slice);
}
static void read_callback(uv_stream_t *stream, ssize_t nread,
const uv_buf_t *buf) {
gpr_slice sub;
GRPC_SLICE sub;
grpc_error *error;
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_tcp *tcp = stream->data;
@ -132,8 +132,8 @@ static void read_callback(uv_stream_t *stream, ssize_t nread,
error = GRPC_ERROR_CREATE("EOF");
} else if (nread > 0) {
// Successful read
sub = gpr_slice_sub_no_ref(tcp->read_slice, 0, (size_t)nread);
gpr_slice_buffer_add(tcp->read_slices, sub);
sub = GRPC_SLICE_sub_no_ref(tcp->read_slice, 0, (size_t)nread);
GRPC_SLICE_buffer_add(tcp->read_slices, sub);
error = GRPC_ERROR_NONE;
if (grpc_tcp_trace) {
size_t i;
@ -157,14 +157,14 @@ static void read_callback(uv_stream_t *stream, ssize_t nread,
}
static void uv_endpoint_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
gpr_slice_buffer *read_slices, grpc_closure *cb) {
GRPC_SLICE_buffer *read_slices, grpc_closure *cb) {
grpc_tcp *tcp = (grpc_tcp *)ep;
int status;
grpc_error *error = GRPC_ERROR_NONE;
GPR_ASSERT(tcp->read_cb == NULL);
tcp->read_cb = cb;
tcp->read_slices = read_slices;
gpr_slice_buffer_reset_and_unref(read_slices);
GRPC_SLICE_buffer_reset_and_unref(read_slices);
TCP_REF(tcp, "read");
// TODO(murgatroid99): figure out what the return value here means
status =
@ -204,13 +204,13 @@ static void write_callback(uv_write_t *req, int status) {
}
static void uv_endpoint_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
gpr_slice_buffer *write_slices,
GRPC_SLICE_buffer *write_slices,
grpc_closure *cb) {
grpc_tcp *tcp = (grpc_tcp *)ep;
uv_buf_t *buffers;
unsigned int buffer_count;
unsigned int i;
gpr_slice *slice;
GRPC_SLICE *slice;
uv_write_t *write_req;
if (grpc_tcp_trace) {
@ -245,8 +245,8 @@ static void uv_endpoint_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
buffers = gpr_malloc(sizeof(uv_buf_t) * buffer_count);
for (i = 0; i < buffer_count; i++) {
slice = &tcp->write_slices->slices[i];
buffers[i].base = (char *)GPR_SLICE_START_PTR(*slice);
buffers[i].len = GPR_SLICE_LENGTH(*slice);
buffers[i].base = (char *)GRPC_SLICE_START_PTR(*slice);
buffers[i].len = GRPC_SLICE_LENGTH(*slice);
}
write_req = gpr_malloc(sizeof(uv_write_t));
write_req->data = tcp;

@ -209,9 +209,9 @@ static void win_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
tcp->read_slice = grpc_slice_malloc(8192);
buffer.len = (ULONG)GPR_SLICE_LENGTH(
buffer.len = (ULONG)GRPC_SLICE_LENGTH(
tcp->read_slice); // we know slice size fits in 32bit.
buffer.buf = (char *)GPR_SLICE_START_PTR(tcp->read_slice);
buffer.buf = (char *)GRPC_SLICE_START_PTR(tcp->read_slice);
TCP_REF(tcp, "read");
@ -300,10 +300,10 @@ static void win_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep,
}
for (i = 0; i < tcp->write_slices->count; i++) {
len = GPR_SLICE_LENGTH(tcp->write_slices->slices[i]);
len = GRPC_SLICE_LENGTH(tcp->write_slices->slices[i]);
GPR_ASSERT(len <= ULONG_MAX);
buffers[i].len = (ULONG)len;
buffers[i].buf = (char *)GPR_SLICE_START_PTR(tcp->write_slices->slices[i]);
buffers[i].buf = (char *)GRPC_SLICE_START_PTR(tcp->write_slices->slices[i]);
}
/* First, let's try a synchronous, non-blocking write. */

@ -186,7 +186,7 @@ static grpc_error *create_default_creds_from_path(
goto end;
}
json = grpc_json_parse_string_with_len(
(char *)GPR_SLICE_START_PTR(creds_data), GPR_SLICE_LENGTH(creds_data));
(char *)GRPC_SLICE_START_PTR(creds_data), GRPC_SLICE_LENGTH(creds_data));
if (json == NULL) {
char *dump = grpc_dump_slice(creds_data, GPR_DUMP_HEX | GPR_DUMP_ASCII);
error = grpc_error_set_str(GRPC_ERROR_CREATE("Failed to parse JSON"),

@ -89,12 +89,12 @@ static grpc_json *parse_json_part_from_jwt(const char *str, size_t len,
grpc_json *json;
*buffer = grpc_base64_decode_with_len(str, len, 1);
if (GPR_SLICE_IS_EMPTY(*buffer)) {
if (GRPC_SLICE_IS_EMPTY(*buffer)) {
gpr_log(GPR_ERROR, "Invalid base64.");
return NULL;
}
json = grpc_json_parse_string_with_len((char *)GPR_SLICE_START_PTR(*buffer),
GPR_SLICE_LENGTH(*buffer));
json = grpc_json_parse_string_with_len((char *)GRPC_SLICE_START_PTR(*buffer),
GRPC_SLICE_LENGTH(*buffer));
if (json == NULL) {
grpc_slice_unref(*buffer);
gpr_log(GPR_ERROR, "JSON parsing error.");
@ -453,12 +453,12 @@ static BIGNUM *bignum_from_base64(const char *b64) {
if (b64 == NULL) return NULL;
bin = grpc_base64_decode(b64, 1);
if (GPR_SLICE_IS_EMPTY(bin)) {
if (GRPC_SLICE_IS_EMPTY(bin)) {
gpr_log(GPR_ERROR, "Invalid base64 for big num.");
return NULL;
}
result = BN_bin2bn(GPR_SLICE_START_PTR(bin),
TSI_SIZE_AS_SIZE(GPR_SLICE_LENGTH(bin)), NULL);
result = BN_bin2bn(GRPC_SLICE_START_PTR(bin),
TSI_SIZE_AS_SIZE(GRPC_SLICE_LENGTH(bin)), NULL);
grpc_slice_unref(bin);
return result;
}
@ -567,13 +567,13 @@ static int verify_jwt_signature(EVP_PKEY *key, const char *alg,
gpr_log(GPR_ERROR, "EVP_DigestVerifyInit failed.");
goto end;
}
if (EVP_DigestVerifyUpdate(md_ctx, GPR_SLICE_START_PTR(signed_data),
GPR_SLICE_LENGTH(signed_data)) != 1) {
if (EVP_DigestVerifyUpdate(md_ctx, GRPC_SLICE_START_PTR(signed_data),
GRPC_SLICE_LENGTH(signed_data)) != 1) {
gpr_log(GPR_ERROR, "EVP_DigestVerifyUpdate failed.");
goto end;
}
if (EVP_DigestVerifyFinal(md_ctx, GPR_SLICE_START_PTR(signature),
GPR_SLICE_LENGTH(signature)) != 1) {
if (EVP_DigestVerifyFinal(md_ctx, GRPC_SLICE_START_PTR(signature),
GRPC_SLICE_LENGTH(signature)) != 1) {
gpr_log(GPR_ERROR, "JWT signature verification failed.");
goto end;
}
@ -824,7 +824,7 @@ void grpc_jwt_verifier_verify(grpc_exec_ctx *exec_ctx,
signed_jwt_len = (size_t)(dot - jwt);
cur = dot + 1;
signature = grpc_base64_decode(cur, 1);
if (GPR_SLICE_IS_EMPTY(signature)) goto error;
if (GRPC_SLICE_IS_EMPTY(signature)) goto error;
retrieve_key_and_verify(
exec_ctx,
verifier_cb_ctx_create(verifier, pollset, header, claims, audience,

@ -239,9 +239,9 @@ static void on_handshake_data_received_from_peer(grpc_exec_ctx *exec_ctx,
}
for (i = 0; i < h->incoming.count; i++) {
consumed_slice_size = GPR_SLICE_LENGTH(h->incoming.slices[i]);
consumed_slice_size = GRPC_SLICE_LENGTH(h->incoming.slices[i]);
result = tsi_handshaker_process_bytes_from_peer(
h->handshaker, GPR_SLICE_START_PTR(h->incoming.slices[i]),
h->handshaker, GRPC_SLICE_START_PTR(h->incoming.slices[i]),
&consumed_slice_size);
if (!tsi_handshaker_is_in_progress(h->handshaker)) break;
}
@ -267,7 +267,7 @@ static void on_handshake_data_received_from_peer(grpc_exec_ctx *exec_ctx,
/* Handshake is done and successful this point. */
has_left_overs_in_current_slice =
(consumed_slice_size < GPR_SLICE_LENGTH(h->incoming.slices[i]));
(consumed_slice_size < GRPC_SLICE_LENGTH(h->incoming.slices[i]));
num_left_overs =
(has_left_overs_in_current_slice ? 1 : 0) + h->incoming.count - i - 1;
if (num_left_overs == 0) {

@ -124,8 +124,8 @@ static void flush_read_staging_buffer(secure_endpoint *ep, uint8_t **cur,
uint8_t **end) {
grpc_slice_buffer_add(ep->read_buffer, ep->read_staging_buffer);
ep->read_staging_buffer = grpc_slice_malloc(STAGING_BUFFER_SIZE);
*cur = GPR_SLICE_START_PTR(ep->read_staging_buffer);
*end = GPR_SLICE_END_PTR(ep->read_staging_buffer);
*cur = GRPC_SLICE_START_PTR(ep->read_staging_buffer);
*end = GRPC_SLICE_END_PTR(ep->read_staging_buffer);
}
static void call_read_cb(grpc_exec_ctx *exec_ctx, secure_endpoint *ep,
@ -150,8 +150,8 @@ static void on_read(grpc_exec_ctx *exec_ctx, void *user_data,
uint8_t keep_looping = 0;
tsi_result result = TSI_OK;
secure_endpoint *ep = (secure_endpoint *)user_data;
uint8_t *cur = GPR_SLICE_START_PTR(ep->read_staging_buffer);
uint8_t *end = GPR_SLICE_END_PTR(ep->read_staging_buffer);
uint8_t *cur = GRPC_SLICE_START_PTR(ep->read_staging_buffer);
uint8_t *end = GRPC_SLICE_END_PTR(ep->read_staging_buffer);
if (error != GRPC_ERROR_NONE) {
grpc_slice_buffer_reset_and_unref(ep->read_buffer);
@ -163,8 +163,8 @@ static void on_read(grpc_exec_ctx *exec_ctx, void *user_data,
/* TODO(yangg) check error, maybe bail out early */
for (i = 0; i < ep->source_buffer.count; i++) {
grpc_slice encrypted = ep->source_buffer.slices[i];
uint8_t *message_bytes = GPR_SLICE_START_PTR(encrypted);
size_t message_size = GPR_SLICE_LENGTH(encrypted);
uint8_t *message_bytes = GRPC_SLICE_START_PTR(encrypted);
size_t message_size = GRPC_SLICE_LENGTH(encrypted);
while (message_size > 0 || keep_looping) {
size_t unprotected_buffer_size_written = (size_t)(end - cur);
@ -199,12 +199,12 @@ static void on_read(grpc_exec_ctx *exec_ctx, void *user_data,
if (result != TSI_OK) break;
}
if (cur != GPR_SLICE_START_PTR(ep->read_staging_buffer)) {
if (cur != GRPC_SLICE_START_PTR(ep->read_staging_buffer)) {
grpc_slice_buffer_add(
ep->read_buffer,
grpc_slice_split_head(
&ep->read_staging_buffer,
(size_t)(cur - GPR_SLICE_START_PTR(ep->read_staging_buffer))));
(size_t)(cur - GRPC_SLICE_START_PTR(ep->read_staging_buffer))));
}
/* TODO(yangg) experiment with moving this block after read_cb to see if it
@ -244,8 +244,8 @@ static void flush_write_staging_buffer(secure_endpoint *ep, uint8_t **cur,
uint8_t **end) {
grpc_slice_buffer_add(&ep->output_buffer, ep->write_staging_buffer);
ep->write_staging_buffer = grpc_slice_malloc(STAGING_BUFFER_SIZE);
*cur = GPR_SLICE_START_PTR(ep->write_staging_buffer);
*end = GPR_SLICE_END_PTR(ep->write_staging_buffer);
*cur = GRPC_SLICE_START_PTR(ep->write_staging_buffer);
*end = GRPC_SLICE_END_PTR(ep->write_staging_buffer);
}
static void endpoint_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *secure_ep,
@ -255,8 +255,8 @@ static void endpoint_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *secure_ep,
unsigned i;
tsi_result result = TSI_OK;
secure_endpoint *ep = (secure_endpoint *)secure_ep;
uint8_t *cur = GPR_SLICE_START_PTR(ep->write_staging_buffer);
uint8_t *end = GPR_SLICE_END_PTR(ep->write_staging_buffer);
uint8_t *cur = GRPC_SLICE_START_PTR(ep->write_staging_buffer);
uint8_t *end = GRPC_SLICE_END_PTR(ep->write_staging_buffer);
grpc_slice_buffer_reset_and_unref(&ep->output_buffer);
@ -271,8 +271,8 @@ static void endpoint_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *secure_ep,
for (i = 0; i < slices->count; i++) {
grpc_slice plain = slices->slices[i];
uint8_t *message_bytes = GPR_SLICE_START_PTR(plain);
size_t message_size = GPR_SLICE_LENGTH(plain);
uint8_t *message_bytes = GRPC_SLICE_START_PTR(plain);
size_t message_size = GRPC_SLICE_LENGTH(plain);
while (message_size > 0) {
size_t protected_buffer_size_to_send = (size_t)(end - cur);
size_t processed_message_size = message_size;
@ -311,12 +311,12 @@ static void endpoint_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *secure_ep,
flush_write_staging_buffer(ep, &cur, &end);
}
} while (still_pending_size > 0);
if (cur != GPR_SLICE_START_PTR(ep->write_staging_buffer)) {
if (cur != GRPC_SLICE_START_PTR(ep->write_staging_buffer)) {
grpc_slice_buffer_add(
&ep->output_buffer,
grpc_slice_split_head(
&ep->write_staging_buffer,
(size_t)(cur - GPR_SLICE_START_PTR(ep->write_staging_buffer))));
(size_t)(cur - GRPC_SLICE_START_PTR(ep->write_staging_buffer))));
}
}

@ -656,7 +656,7 @@ static grpc_slice compute_default_pem_root_certs_once(void) {
/* Try overridden roots if needed. */
grpc_ssl_roots_override_result ovrd_res = GRPC_SSL_ROOTS_OVERRIDE_FAIL;
if (GPR_SLICE_IS_EMPTY(result) && ssl_roots_override_cb != NULL) {
if (GRPC_SLICE_IS_EMPTY(result) && ssl_roots_override_cb != NULL) {
char *pem_root_certs = NULL;
ovrd_res = ssl_roots_override_cb(&pem_root_certs);
if (ovrd_res == GRPC_SSL_ROOTS_OVERRIDE_OK) {
@ -666,7 +666,7 @@ static grpc_slice compute_default_pem_root_certs_once(void) {
}
/* Fall back to installed certs if needed. */
if (GPR_SLICE_IS_EMPTY(result) &&
if (GRPC_SLICE_IS_EMPTY(result) &&
ovrd_res != GRPC_SSL_ROOTS_OVERRIDE_FAIL_PERMANENTLY) {
GRPC_LOG_IF_ERROR("load_file",
grpc_load_file(installed_roots_path, 0, &result));
@ -714,8 +714,8 @@ size_t grpc_get_default_ssl_roots(const unsigned char **pem_root_certs) {
loading all the roots once for the lifetime of the process. */
static gpr_once once = GPR_ONCE_INIT;
gpr_once_init(&once, init_default_pem_root_certs);
*pem_root_certs = GPR_SLICE_START_PTR(default_pem_root_certs);
return GPR_SLICE_LENGTH(default_pem_root_certs);
*pem_root_certs = GRPC_SLICE_START_PTR(default_pem_root_certs);
return GRPC_SLICE_LENGTH(default_pem_root_certs);
}
grpc_security_status grpc_ssl_channel_security_connector_create(

@ -78,7 +78,7 @@ static grpc_metadata_array metadata_batch_to_md_array(
usr_md = &result.metadata[result.count++];
usr_md->key = grpc_mdstr_as_c_string(key);
usr_md->value = grpc_mdstr_as_c_string(value);
usr_md->value_length = GPR_SLICE_LENGTH(value->slice);
usr_md->value_length = GRPC_SLICE_LENGTH(value->slice);
}
return result;
}
@ -92,14 +92,14 @@ static grpc_mdelem *remove_consumed_md(void *user_data, grpc_mdelem *md) {
/* Maybe we could do a pointer comparison but we do not have any guarantee
that the metadata processor used the same pointers for consumed_md in the
callback. */
if (GPR_SLICE_LENGTH(md->key->slice) != strlen(consumed_md->key) ||
GPR_SLICE_LENGTH(md->value->slice) != consumed_md->value_length) {
if (GRPC_SLICE_LENGTH(md->key->slice) != strlen(consumed_md->key) ||
GRPC_SLICE_LENGTH(md->value->slice) != consumed_md->value_length) {
continue;
}
if (memcmp(GPR_SLICE_START_PTR(md->key->slice), consumed_md->key,
GPR_SLICE_LENGTH(md->key->slice)) == 0 &&
memcmp(GPR_SLICE_START_PTR(md->value->slice), consumed_md->value,
GPR_SLICE_LENGTH(md->value->slice)) == 0) {
if (memcmp(GRPC_SLICE_START_PTR(md->key->slice), consumed_md->key,
GRPC_SLICE_LENGTH(md->key->slice)) == 0 &&
memcmp(GRPC_SLICE_START_PTR(md->value->slice), consumed_md->value,
GRPC_SLICE_LENGTH(md->value->slice)) == 0) {
return NULL; /* Delete. */
}
}

@ -185,7 +185,7 @@ static int decode_group(const unsigned char *codes, size_t num_codes,
grpc_slice grpc_base64_decode_with_len(const char *b64, size_t b64_len,
int url_safe) {
grpc_slice result = grpc_slice_malloc(b64_len);
unsigned char *current = GPR_SLICE_START_PTR(result);
unsigned char *current = GRPC_SLICE_START_PTR(result);
size_t result_size = 0;
unsigned char codes[4];
size_t num_codes = 0;
@ -224,7 +224,7 @@ grpc_slice grpc_base64_decode_with_len(const char *b64, size_t b64_len,
!decode_group(codes, num_codes, current, &result_size)) {
goto fail;
}
GPR_SLICE_SET_LENGTH(result, result_size);
GRPC_SLICE_SET_LENGTH(result, result_size);
return result;
fail:

@ -55,8 +55,8 @@ grpc_slice grpc_percent_encode_slice(grpc_slice slice,
// first pass: count the number of bytes needed to output this string
size_t output_length = 0;
const uint8_t *slice_start = GPR_SLICE_START_PTR(slice);
const uint8_t *slice_end = GPR_SLICE_END_PTR(slice);
const uint8_t *slice_start = GRPC_SLICE_START_PTR(slice);
const uint8_t *slice_end = GRPC_SLICE_END_PTR(slice);
const uint8_t *p;
bool any_reserved_bytes = false;
for (p = slice_start; p < slice_end; p++) {
@ -70,7 +70,7 @@ grpc_slice grpc_percent_encode_slice(grpc_slice slice,
}
// second pass: actually encode
grpc_slice out = grpc_slice_malloc(output_length);
uint8_t *q = GPR_SLICE_START_PTR(out);
uint8_t *q = GRPC_SLICE_START_PTR(out);
for (p = slice_start; p < slice_end; p++) {
if (is_unreserved_character(*p, unreserved_bytes)) {
*q++ = *p;
@ -80,7 +80,7 @@ grpc_slice grpc_percent_encode_slice(grpc_slice slice,
*q++ = hex[*p & 15];
}
}
GPR_ASSERT(q == GPR_SLICE_END_PTR(out));
GPR_ASSERT(q == GRPC_SLICE_END_PTR(out));
return out;
}
@ -100,8 +100,8 @@ static uint8_t dehex(uint8_t c) {
bool grpc_strict_percent_decode_slice(grpc_slice slice_in,
const uint8_t *unreserved_bytes,
grpc_slice *slice_out) {
const uint8_t *p = GPR_SLICE_START_PTR(slice_in);
const uint8_t *in_end = GPR_SLICE_END_PTR(slice_in);
const uint8_t *p = GRPC_SLICE_START_PTR(slice_in);
const uint8_t *in_end = GRPC_SLICE_END_PTR(slice_in);
size_t out_length = 0;
bool any_percent_encoded_stuff = false;
while (p != in_end) {
@ -122,9 +122,9 @@ bool grpc_strict_percent_decode_slice(grpc_slice slice_in,
*slice_out = grpc_slice_ref(slice_in);
return true;
}
p = GPR_SLICE_START_PTR(slice_in);
p = GRPC_SLICE_START_PTR(slice_in);
*slice_out = grpc_slice_malloc(out_length);
uint8_t *q = GPR_SLICE_START_PTR(*slice_out);
uint8_t *q = GRPC_SLICE_START_PTR(*slice_out);
while (p != in_end) {
if (*p == '%') {
*q++ = (uint8_t)(dehex(p[1]) << 4) | (dehex(p[2]));
@ -133,13 +133,13 @@ bool grpc_strict_percent_decode_slice(grpc_slice slice_in,
*q++ = *p++;
}
}
GPR_ASSERT(q == GPR_SLICE_END_PTR(*slice_out));
GPR_ASSERT(q == GRPC_SLICE_END_PTR(*slice_out));
return true;
}
grpc_slice grpc_permissive_percent_decode_slice(grpc_slice slice_in) {
const uint8_t *p = GPR_SLICE_START_PTR(slice_in);
const uint8_t *in_end = GPR_SLICE_END_PTR(slice_in);
const uint8_t *p = GRPC_SLICE_START_PTR(slice_in);
const uint8_t *in_end = GRPC_SLICE_END_PTR(slice_in);
size_t out_length = 0;
bool any_percent_encoded_stuff = false;
while (p != in_end) {
@ -160,9 +160,9 @@ grpc_slice grpc_permissive_percent_decode_slice(grpc_slice slice_in) {
if (!any_percent_encoded_stuff) {
return grpc_slice_ref(slice_in);
}
p = GPR_SLICE_START_PTR(slice_in);
p = GRPC_SLICE_START_PTR(slice_in);
grpc_slice out = grpc_slice_malloc(out_length);
uint8_t *q = GPR_SLICE_START_PTR(out);
uint8_t *q = GRPC_SLICE_START_PTR(out);
while (p != in_end) {
if (*p == '%') {
if (!valid_hex(p + 1, in_end) || !valid_hex(p + 2, in_end)) {
@ -175,6 +175,6 @@ grpc_slice grpc_permissive_percent_decode_slice(grpc_slice slice_in) {
*q++ = *p++;
}
}
GPR_ASSERT(q == GPR_SLICE_END_PTR(out));
GPR_ASSERT(q == GRPC_SLICE_END_PTR(out));
return out;
}

@ -159,7 +159,7 @@ grpc_slice grpc_slice_new_with_len(void *p, size_t len,
grpc_slice grpc_slice_from_copied_buffer(const char *source, size_t length) {
grpc_slice slice = grpc_slice_malloc(length);
memcpy(GPR_SLICE_START_PTR(slice), source, length);
memcpy(GRPC_SLICE_START_PTR(slice), source, length);
return slice;
}
@ -252,7 +252,7 @@ grpc_slice grpc_slice_sub(grpc_slice source, size_t begin, size_t end) {
if (end - begin <= sizeof(subset.data.inlined.bytes)) {
subset.refcount = NULL;
subset.data.inlined.length = (uint8_t)(end - begin);
memcpy(subset.data.inlined.bytes, GPR_SLICE_START_PTR(source) + begin,
memcpy(subset.data.inlined.bytes, GRPC_SLICE_START_PTR(source) + begin,
end - begin);
} else {
subset = grpc_slice_sub_no_ref(source, begin, end);
@ -336,15 +336,15 @@ grpc_slice grpc_slice_split_head(grpc_slice *source, size_t split) {
}
int grpc_slice_cmp(grpc_slice a, grpc_slice b) {
int d = (int)(GPR_SLICE_LENGTH(a) - GPR_SLICE_LENGTH(b));
int d = (int)(GRPC_SLICE_LENGTH(a) - GRPC_SLICE_LENGTH(b));
if (d != 0) return d;
return memcmp(GPR_SLICE_START_PTR(a), GPR_SLICE_START_PTR(b),
GPR_SLICE_LENGTH(a));
return memcmp(GRPC_SLICE_START_PTR(a), GRPC_SLICE_START_PTR(b),
GRPC_SLICE_LENGTH(a));
}
int grpc_slice_str_cmp(grpc_slice a, const char *b) {
size_t b_length = strlen(b);
int d = (int)(GPR_SLICE_LENGTH(a) - b_length);
int d = (int)(GRPC_SLICE_LENGTH(a) - b_length);
if (d != 0) return d;
return memcmp(GPR_SLICE_START_PTR(a), b, b_length);
return memcmp(GRPC_SLICE_START_PTR(a), b, b_length);
}

@ -98,7 +98,7 @@ size_t grpc_slice_buffer_add_indexed(grpc_slice_buffer *sb, grpc_slice s) {
size_t out = sb->count;
maybe_embiggen(sb);
sb->slices[out] = s;
sb->length += GPR_SLICE_LENGTH(s);
sb->length += GRPC_SLICE_LENGTH(s);
sb->count = out + 1;
return out;
}
@ -112,18 +112,18 @@ void grpc_slice_buffer_add(grpc_slice_buffer *sb, grpc_slice s) {
writes */
if (!s.refcount && n) {
grpc_slice *back = &sb->slices[n - 1];
if (!back->refcount && back->data.inlined.length < GPR_SLICE_INLINED_SIZE) {
if (!back->refcount && back->data.inlined.length < GRPC_SLICE_INLINED_SIZE) {
if (s.data.inlined.length + back->data.inlined.length <=
GPR_SLICE_INLINED_SIZE) {
GRPC_SLICE_INLINED_SIZE) {
memcpy(back->data.inlined.bytes + back->data.inlined.length,
s.data.inlined.bytes, s.data.inlined.length);
back->data.inlined.length =
(uint8_t)(back->data.inlined.length + s.data.inlined.length);
} else {
size_t cp1 = GPR_SLICE_INLINED_SIZE - back->data.inlined.length;
size_t cp1 = GRPC_SLICE_INLINED_SIZE - back->data.inlined.length;
memcpy(back->data.inlined.bytes + back->data.inlined.length,
s.data.inlined.bytes, cp1);
back->data.inlined.length = GPR_SLICE_INLINED_SIZE;
back->data.inlined.length = GRPC_SLICE_INLINED_SIZE;
maybe_embiggen(sb);
back = &sb->slices[n];
sb->count = n + 1;
@ -149,7 +149,7 @@ void grpc_slice_buffer_addn(grpc_slice_buffer *sb, grpc_slice *s, size_t n) {
void grpc_slice_buffer_pop(grpc_slice_buffer *sb) {
if (sb->count != 0) {
size_t count = --sb->count;
sb->length -= GPR_SLICE_LENGTH(sb->slices[count]);
sb->length -= GRPC_SLICE_LENGTH(sb->slices[count]);
}
}
@ -222,7 +222,7 @@ void grpc_slice_buffer_move_first(grpc_slice_buffer *src, size_t n,
src_idx = 0;
while (src_idx < src->capacity) {
grpc_slice slice = src->slices[src_idx];
size_t slice_len = GPR_SLICE_LENGTH(slice);
size_t slice_len = GRPC_SLICE_LENGTH(slice);
if (n > slice_len) {
grpc_slice_buffer_add(dst, slice);
n -= slice_len;
@ -233,8 +233,8 @@ void grpc_slice_buffer_move_first(grpc_slice_buffer *src, size_t n,
break;
} else { /* n < slice_len */
src->slices[src_idx] = grpc_slice_split_tail(&slice, n);
GPR_ASSERT(GPR_SLICE_LENGTH(slice) == n);
GPR_ASSERT(GPR_SLICE_LENGTH(src->slices[src_idx]) == slice_len - n);
GPR_ASSERT(GRPC_SLICE_LENGTH(slice) == n);
GPR_ASSERT(GRPC_SLICE_LENGTH(src->slices[src_idx]) == slice_len - n);
grpc_slice_buffer_add(dst, slice);
break;
}
@ -254,7 +254,7 @@ void grpc_slice_buffer_trim_end(grpc_slice_buffer *sb, size_t n,
for (;;) {
size_t idx = sb->count - 1;
grpc_slice slice = sb->slices[idx];
size_t slice_len = GPR_SLICE_LENGTH(slice);
size_t slice_len = GRPC_SLICE_LENGTH(slice);
if (slice_len > n) {
sb->slices[idx] = grpc_slice_split_head(&slice, slice_len - n);
grpc_slice_buffer_add_indexed(garbage, slice);
@ -277,6 +277,6 @@ grpc_slice grpc_slice_buffer_take_first(grpc_slice_buffer *sb) {
slice = sb->slices[0];
memmove(&sb->slices[0], &sb->slices[1], (sb->count - 1) * sizeof(grpc_slice));
sb->count--;
sb->length -= GPR_SLICE_LENGTH(slice);
sb->length -= GRPC_SLICE_LENGTH(slice);
return slice;
}

@ -40,7 +40,7 @@
#include "src/core/lib/support/string.h"
char *grpc_dump_slice(grpc_slice s, uint32_t flags) {
return gpr_dump((const char *)GPR_SLICE_START_PTR(s), GPR_SLICE_LENGTH(s),
return gpr_dump((const char *)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s),
flags);
}
@ -53,8 +53,8 @@ static int slice_find_separator_offset(const grpc_slice str, const char *sep,
const size_t read_offset, size_t *begin,
size_t *end) {
size_t i;
const uint8_t *str_ptr = GPR_SLICE_START_PTR(str) + read_offset;
const size_t str_len = GPR_SLICE_LENGTH(str) - read_offset;
const uint8_t *str_ptr = GRPC_SLICE_START_PTR(str) + read_offset;
const size_t str_len = GRPC_SLICE_LENGTH(str) - read_offset;
const size_t sep_len = strlen(sep);
if (str_len < sep_len) {
return 0;
@ -82,7 +82,7 @@ void grpc_slice_split(grpc_slice str, const char *sep, grpc_slice_buffer *dst) {
} while (slice_find_separator_offset(str, sep, end + sep_len, &begin,
&end) != 0);
grpc_slice_buffer_add_indexed(
dst, grpc_slice_sub(str, end + sep_len, GPR_SLICE_LENGTH(str)));
dst, grpc_slice_sub(str, end + sep_len, GRPC_SLICE_LENGTH(str)));
} else { /* no sep found, add whole input */
grpc_slice_buffer_add_indexed(dst, grpc_slice_ref(str));
}

@ -119,11 +119,11 @@ grpc_slice grpc_byte_buffer_reader_readall(grpc_byte_buffer_reader *reader) {
size_t bytes_read = 0;
const size_t input_size = grpc_byte_buffer_length(reader->buffer_out);
grpc_slice out_slice = grpc_slice_malloc(input_size);
uint8_t *const outbuf = GPR_SLICE_START_PTR(out_slice); /* just an alias */
uint8_t *const outbuf = GRPC_SLICE_START_PTR(out_slice); /* just an alias */
while (grpc_byte_buffer_reader_next(reader, &in_slice) != 0) {
const size_t slice_length = GPR_SLICE_LENGTH(in_slice);
memcpy(&(outbuf[bytes_read]), GPR_SLICE_START_PTR(in_slice), slice_length);
const size_t slice_length = GRPC_SLICE_LENGTH(in_slice);
memcpy(&(outbuf[bytes_read]), GRPC_SLICE_START_PTR(in_slice), slice_length);
bytes_read += slice_length;
grpc_slice_unref(in_slice);
GPR_ASSERT(bytes_read <= input_size);

@ -518,8 +518,8 @@ static void set_encodings_accepted_by_peer(grpc_call *call, grpc_mdelem *mdel) {
const grpc_slice *accept_encoding_entry_slice =
&accept_encoding_parts.slices[i];
if (grpc_compression_algorithm_parse(
(const char *)GPR_SLICE_START_PTR(*accept_encoding_entry_slice),
GPR_SLICE_LENGTH(*accept_encoding_entry_slice), &algorithm)) {
(const char *)GRPC_SLICE_START_PTR(*accept_encoding_entry_slice),
GRPC_SLICE_LENGTH(*accept_encoding_entry_slice), &algorithm)) {
GPR_BITSET(&call->encodings_accepted_by_peer, algorithm);
} else {
char *accept_encoding_entry_str =
@ -553,13 +553,13 @@ static void get_final_details(grpc_call *call, char **out_details,
if (call->status[i].is_set) {
if (call->status[i].details) {
grpc_slice details = call->status[i].details->slice;
size_t len = GPR_SLICE_LENGTH(details);
size_t len = GRPC_SLICE_LENGTH(details);
if (len + 1 > *out_details_capacity) {
*out_details_capacity =
GPR_MAX(len + 1, *out_details_capacity * 3 / 2);
*out_details = gpr_realloc(*out_details, *out_details_capacity);
}
memcpy(*out_details, GPR_SLICE_START_PTR(details), len);
memcpy(*out_details, GRPC_SLICE_START_PTR(details), len);
(*out_details)[len] = 0;
} else {
goto no_details;
@ -901,7 +901,7 @@ static uint32_t decode_status(grpc_mdelem *md) {
status = ((uint32_t)(intptr_t)user_data) - STATUS_OFFSET;
} else {
if (!gpr_parse_bytes_to_uint32(grpc_mdstr_as_c_string(md->value),
GPR_SLICE_LENGTH(md->value->slice),
GRPC_SLICE_LENGTH(md->value->slice),
&status)) {
status = GRPC_STATUS_UNKNOWN; /* could not parse status code */
}
@ -954,7 +954,7 @@ static grpc_mdelem *publish_app_metadata(grpc_call *call, grpc_mdelem *elem,
mdusr = &dest->metadata[dest->count++];
mdusr->key = grpc_mdstr_as_c_string(elem->key);
mdusr->value = grpc_mdstr_as_c_string(elem->value);
mdusr->value_length = GPR_SLICE_LENGTH(elem->value->slice);
mdusr->value_length = GRPC_SLICE_LENGTH(elem->value->slice);
GPR_TIMER_END("publish_app_metadata", 0);
return elem;
}

@ -460,7 +460,7 @@ static void destroy_channel(grpc_exec_ctx *exec_ctx, channel_data *chand,
static void cpstr(char **dest, size_t *capacity, grpc_mdstr *value) {
grpc_slice slice = value->slice;
size_t len = GPR_SLICE_LENGTH(slice);
size_t len = GRPC_SLICE_LENGTH(slice);
if (len + 1 > *capacity) {
*capacity = GPR_MAX(len + 1, *capacity * 2);

@ -351,8 +351,8 @@ grpc_mdstr *grpc_mdstr_from_string(const char *str) {
}
grpc_mdstr *grpc_mdstr_from_slice(grpc_slice slice) {
grpc_mdstr *result = grpc_mdstr_from_buffer(GPR_SLICE_START_PTR(slice),
GPR_SLICE_LENGTH(slice));
grpc_mdstr *result = grpc_mdstr_from_buffer(GRPC_SLICE_START_PTR(slice),
GRPC_SLICE_LENGTH(slice));
grpc_slice_unref(slice);
return result;
}
@ -373,9 +373,9 @@ grpc_mdstr *grpc_mdstr_from_buffer(const uint8_t *buf, size_t length) {
idx = (hash + i) % GPR_ARRAY_SIZE(g_static_strtab);
ss = g_static_strtab[idx];
if (ss == NULL) break;
if (ss->hash == hash && GPR_SLICE_LENGTH(ss->slice) == length &&
if (ss->hash == hash && GRPC_SLICE_LENGTH(ss->slice) == length &&
(length == 0 ||
0 == memcmp(buf, GPR_SLICE_START_PTR(ss->slice), length))) {
0 == memcmp(buf, GRPC_SLICE_START_PTR(ss->slice), length))) {
GPR_TIMER_END("grpc_mdstr_from_buffer", 0);
return ss;
}
@ -386,8 +386,8 @@ grpc_mdstr *grpc_mdstr_from_buffer(const uint8_t *buf, size_t length) {
/* search for an existing string */
idx = TABLE_IDX(hash, LOG2_STRTAB_SHARD_COUNT, shard->capacity);
for (s = shard->strs[idx]; s; s = s->bucket_next) {
if (s->hash == hash && GPR_SLICE_LENGTH(s->slice) == length &&
0 == memcmp(buf, GPR_SLICE_START_PTR(s->slice), length)) {
if (s->hash == hash && GRPC_SLICE_LENGTH(s->slice) == length &&
0 == memcmp(buf, GRPC_SLICE_START_PTR(s->slice), length)) {
if (gpr_atm_full_fetch_add(&s->refcnt, 1) == 0) {
/* If we get here, we've added a ref to something that was about to
* die - drop it immediately.
@ -404,7 +404,7 @@ grpc_mdstr *grpc_mdstr_from_buffer(const uint8_t *buf, size_t length) {
}
/* not found: create a new string */
if (length + 1 < GPR_SLICE_INLINED_SIZE) {
if (length + 1 < GRPC_SLICE_INLINED_SIZE) {
/* string data goes directly into the slice */
s = gpr_malloc(sizeof(internal_string));
gpr_atm_rel_store(&s->refcnt, 1);
@ -607,12 +607,12 @@ static size_t get_base64_encoded_size(size_t raw_length) {
}
size_t grpc_mdelem_get_size_in_hpack_table(grpc_mdelem *elem) {
size_t overhead_and_key = 32 + GPR_SLICE_LENGTH(elem->key->slice);
size_t value_len = GPR_SLICE_LENGTH(elem->value->slice);
size_t overhead_and_key = 32 + GRPC_SLICE_LENGTH(elem->key->slice);
size_t value_len = GRPC_SLICE_LENGTH(elem->value->slice);
if (is_mdstr_static(elem->value)) {
if (grpc_is_binary_header(
(const char *)GPR_SLICE_START_PTR(elem->key->slice),
GPR_SLICE_LENGTH(elem->key->slice))) {
(const char *)GRPC_SLICE_START_PTR(elem->key->slice),
GRPC_SLICE_LENGTH(elem->key->slice))) {
return overhead_and_key + get_base64_encoded_size(value_len);
} else {
return overhead_and_key + value_len;
@ -622,8 +622,8 @@ size_t grpc_mdelem_get_size_in_hpack_table(grpc_mdelem *elem) {
gpr_atm current_size = gpr_atm_acq_load(&is->size_in_decoder_table);
if (current_size == SIZE_IN_DECODER_TABLE_NOT_SET) {
if (grpc_is_binary_header(
(const char *)GPR_SLICE_START_PTR(elem->key->slice),
GPR_SLICE_LENGTH(elem->key->slice))) {
(const char *)GRPC_SLICE_START_PTR(elem->key->slice),
GRPC_SLICE_LENGTH(elem->key->slice))) {
current_size = (gpr_atm)get_base64_encoded_size(value_len);
} else {
current_size = (gpr_atm)value_len;
@ -679,7 +679,7 @@ void grpc_mdelem_unref(grpc_mdelem *gmd DEBUG_ARGS) {
}
const char *grpc_mdstr_as_c_string(const grpc_mdstr *s) {
return (const char *)GPR_SLICE_START_PTR(s->slice);
return (const char *)GRPC_SLICE_START_PTR(s->slice);
}
size_t grpc_mdstr_length(const grpc_mdstr *s) { return GRPC_MDSTR_LENGTH(s); }

@ -149,7 +149,7 @@ void grpc_mdelem_unref(grpc_mdelem *md);
Does not promise that the returned string has no embedded nulls however. */
const char *grpc_mdstr_as_c_string(const grpc_mdstr *s);
#define GRPC_MDSTR_LENGTH(s) (GPR_SLICE_LENGTH(s->slice))
#define GRPC_MDSTR_LENGTH(s) (GRPC_SLICE_LENGTH(s->slice))
/* We add 32 bytes of padding as per RFC-7540 section 6.5.2. */
#define GRPC_MDELEM_LENGTH(e) \

@ -288,10 +288,10 @@ GPR_EXPORT void GPR_CALLTYPE grpcsharp_batch_context_recv_message_to_buffer(
GPR_ASSERT(grpc_byte_buffer_reader_init(&reader, ctx->recv_message));
while (grpc_byte_buffer_reader_next(&reader, &slice)) {
size_t len = GPR_SLICE_LENGTH(slice);
size_t len = GRPC_SLICE_LENGTH(slice);
GPR_ASSERT(offset + len <= buffer_len);
memcpy(buffer + offset, GPR_SLICE_START_PTR(slice),
GPR_SLICE_LENGTH(slice));
memcpy(buffer + offset, GRPC_SLICE_START_PTR(slice),
GRPC_SLICE_LENGTH(slice));
offset += len;
grpc_slice_unref(slice);
}

@ -57,7 +57,7 @@ grpc_byte_buffer *BufferToByteBuffer(Local<Value> buffer) {
int length = ::node::Buffer::Length(buffer);
char *data = ::node::Buffer::Data(buffer);
grpc_slice slice = grpc_slice_malloc(length);
memcpy(GPR_SLICE_START_PTR(slice), data, length);
memcpy(GRPC_SLICE_START_PTR(slice), data, length);
grpc_byte_buffer *byte_buffer(grpc_raw_byte_buffer_create(&slice, 1));
grpc_slice_unref(slice);
return byte_buffer;
@ -78,9 +78,9 @@ Local<Value> ByteBufferToBuffer(grpc_byte_buffer *buffer) {
return scope.Escape(Nan::Undefined());
}
grpc_slice slice = grpc_byte_buffer_reader_readall(&reader);
size_t length = GPR_SLICE_LENGTH(slice);
size_t length = GRPC_SLICE_LENGTH(slice);
char *result = new char[length];
memcpy(result, GPR_SLICE_START_PTR(slice), length);
memcpy(result, GRPC_SLICE_START_PTR(slice), length);
grpc_slice_unref(slice);
return scope.Escape(MakeFastBuffer(
Nan::NewBuffer(result, length, delete_buffer, NULL).ToLocalChecked()));

@ -54,10 +54,10 @@ static void MallocAndCopyByteBufferToCharArray(grpc_byte_buffer *buffer,
// The slice contains uncompressed data even if compressed data was received
// because the reader takes care of automatically decompressing it
grpc_slice slice = grpc_byte_buffer_reader_readall(&reader);
size_t uncompressed_length = GPR_SLICE_LENGTH(slice);
size_t uncompressed_length = GRPC_SLICE_LENGTH(slice);
char *result = malloc(uncompressed_length);
if (result) {
memcpy(result, GPR_SLICE_START_PTR(slice), uncompressed_length);
memcpy(result, GRPC_SLICE_START_PTR(slice), uncompressed_length);
}
grpc_slice_unref(slice);
*array = result;

@ -67,9 +67,9 @@ void byte_buffer_to_string(grpc_byte_buffer *buffer, char **out_string,
}
grpc_slice slice = grpc_byte_buffer_reader_readall(&reader);
size_t length = GPR_SLICE_LENGTH(slice);
size_t length = GRPC_SLICE_LENGTH(slice);
char *string = ecalloc(length + 1, sizeof(char));
memcpy(string, GPR_SLICE_START_PTR(slice), length);
memcpy(string, GRPC_SLICE_START_PTR(slice), length);
grpc_slice_unref(slice);
*out_string = string;

@ -68,8 +68,8 @@ cdef extern from "grpc/grpc.h":
grpc_slice grpc_slice_from_copied_buffer(const char *source, size_t len) nogil
# Declare functions for function-like macros (because Cython)...
void *grpc_slice_start_ptr "GPR_SLICE_START_PTR" (grpc_slice s) nogil
size_t grpc_slice_length "GPR_SLICE_LENGTH" (grpc_slice s) nogil
void *grpc_slice_start_ptr "GRPC_SLICE_START_PTR" (grpc_slice s) nogil
size_t grpc_slice_length "GRPC_SLICE_LENGTH" (grpc_slice s) nogil
ctypedef enum gpr_clock_type:
GPR_CLOCK_MONOTONIC

@ -61,8 +61,8 @@ VALUE grpc_rb_byte_buffer_to_s(grpc_byte_buffer *buffer) {
return Qnil;
}
while (grpc_byte_buffer_reader_next(&reader, &next) != 0) {
rb_str_cat(rb_string, (const char *) GPR_SLICE_START_PTR(next),
GPR_SLICE_LENGTH(next));
rb_str_cat(rb_string, (const char *) GRPC_SLICE_START_PTR(next),
GRPC_SLICE_LENGTH(next));
grpc_slice_unref(next);
}
return rb_string;

@ -192,7 +192,7 @@ static void client_validator(grpc_slice_buffer *incoming) {
grpc_slice last_frame = last_frame_buffer.slices[0];
// Construct expected frame.
grpc_slice expected = grpc_slice_malloc(13);
uint8_t *p = GPR_SLICE_START_PTR(expected);
uint8_t *p = GRPC_SLICE_START_PTR(expected);
// Length.
*p++ = 0;
*p++ = 0;

@ -61,8 +61,8 @@ int main(int argc, char **argv) {
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"load_file", grpc_load_file("src/core/lib/tsi/test_creds/badserver.key",
1, &key_slice)));
pem_key_cert_pair.private_key = (const char *)GPR_SLICE_START_PTR(key_slice);
pem_key_cert_pair.cert_chain = (const char *)GPR_SLICE_START_PTR(cert_slice);
pem_key_cert_pair.private_key = (const char *)GRPC_SLICE_START_PTR(key_slice);
pem_key_cert_pair.cert_chain = (const char *)GRPC_SLICE_START_PTR(cert_slice);
ssl_creds =
grpc_ssl_server_credentials_create(NULL, &pem_key_cert_pair, 1, 0, NULL);

@ -70,8 +70,8 @@ static void assert_passthrough(grpc_slice value,
GPR_INFO, "assert_passthrough: value_length=%" PRIuPTR
" value_hash=0x%08x "
"algorithm='%s' uncompressed_split='%s' compressed_split='%s'",
GPR_SLICE_LENGTH(value),
gpr_murmur_hash3(GPR_SLICE_START_PTR(value), GPR_SLICE_LENGTH(value), 0),
GRPC_SLICE_LENGTH(value),
gpr_murmur_hash3(GRPC_SLICE_START_PTR(value), GRPC_SLICE_LENGTH(value), 0),
algorithm_name, grpc_slice_split_mode_name(uncompressed_split_mode),
grpc_slice_split_mode_name(compressed_split_mode));
@ -114,7 +114,7 @@ static void assert_passthrough(grpc_slice value,
static grpc_slice repeated(char c, size_t length) {
grpc_slice out = grpc_slice_malloc(length);
memset(GPR_SLICE_START_PTR(out), c, length);
memset(GRPC_SLICE_START_PTR(out), c, length);
return out;
}
@ -184,9 +184,9 @@ static void test_bad_decompression_data_crc(void) {
grpc_msg_compress(GRPC_COMPRESS_GZIP, &input, &corrupted);
/* corrupt the output by smashing the CRC */
GPR_ASSERT(corrupted.count > 1);
GPR_ASSERT(GPR_SLICE_LENGTH(corrupted.slices[1]) > 8);
idx = GPR_SLICE_LENGTH(corrupted.slices[1]) - 8;
memcpy(GPR_SLICE_START_PTR(corrupted.slices[1]) + idx, &bad, 4);
GPR_ASSERT(GRPC_SLICE_LENGTH(corrupted.slices[1]) > 8);
idx = GRPC_SLICE_LENGTH(corrupted.slices[1]) - 8;
memcpy(GRPC_SLICE_START_PTR(corrupted.slices[1]) + idx, &bad, 4);
/* try (and fail) to decompress the corrupted compresed buffer */
GPR_ASSERT(0 == grpc_msg_decompress(GRPC_COMPRESS_GZIP, &corrupted, &output));

@ -112,15 +112,15 @@ static grpc_slice merge_slices(grpc_slice *slices, size_t nslices) {
grpc_slice out;
for (i = 0; i < nslices; i++) {
len += GPR_SLICE_LENGTH(slices[i]);
len += GRPC_SLICE_LENGTH(slices[i]);
}
out = grpc_slice_malloc(len);
cursor = GPR_SLICE_START_PTR(out);
cursor = GRPC_SLICE_START_PTR(out);
for (i = 0; i < nslices; i++) {
memcpy(cursor, GPR_SLICE_START_PTR(slices[i]), GPR_SLICE_LENGTH(slices[i]));
cursor += GPR_SLICE_LENGTH(slices[i]);
memcpy(cursor, GRPC_SLICE_START_PTR(slices[i]), GRPC_SLICE_LENGTH(slices[i]));
cursor += GRPC_SLICE_LENGTH(slices[i]);
}
return out;
@ -134,9 +134,9 @@ int raw_byte_buffer_eq_slice(grpc_byte_buffer *rbb, grpc_slice b) {
a = merge_slices(rbb->data.raw.slice_buffer.slices,
rbb->data.raw.slice_buffer.count);
ok = GPR_SLICE_LENGTH(a) == GPR_SLICE_LENGTH(b) &&
0 == memcmp(GPR_SLICE_START_PTR(a), GPR_SLICE_START_PTR(b),
GPR_SLICE_LENGTH(a));
ok = GRPC_SLICE_LENGTH(a) == GRPC_SLICE_LENGTH(b) &&
0 == memcmp(GRPC_SLICE_START_PTR(a), GRPC_SLICE_START_PTR(b),
GRPC_SLICE_LENGTH(a));
grpc_slice_unref(a);
grpc_slice_unref(b);
return ok;

@ -37,11 +37,11 @@
#include <string.h>
#include <grpc/slice_buffer.h>
#include <grpc/support/alloc.h>
#include <grpc/support/atm.h>
#include <grpc/support/host_port.h>
#include <grpc/support/log.h>
#include <grpc/slice_buffer.h>
#include <grpc/support/string_util.h>
#include <grpc/support/sync.h>
#include <grpc/support/thd.h>
@ -151,7 +151,7 @@ static void on_client_write_done(grpc_exec_ctx* exec_ctx, void* arg,
// write that data now.
if (conn->client_deferred_write_buffer.length > 0) {
grpc_slice_buffer_move_into(&conn->client_deferred_write_buffer,
&conn->client_write_buffer);
&conn->client_write_buffer);
grpc_endpoint_write(exec_ctx, conn->client_endpoint,
&conn->client_write_buffer,
&conn->on_client_write_done);
@ -176,7 +176,7 @@ static void on_server_write_done(grpc_exec_ctx* exec_ctx, void* arg,
// write that data now.
if (conn->server_deferred_write_buffer.length > 0) {
grpc_slice_buffer_move_into(&conn->server_deferred_write_buffer,
&conn->server_write_buffer);
&conn->server_write_buffer);
grpc_endpoint_write(exec_ctx, conn->server_endpoint,
&conn->server_write_buffer,
&conn->on_server_write_done);
@ -204,10 +204,10 @@ static void on_client_read_done(grpc_exec_ctx* exec_ctx, void* arg,
// Otherwise, move the read data into the write buffer and write it.
if (conn->server_write_buffer.length > 0) {
grpc_slice_buffer_move_into(&conn->client_read_buffer,
&conn->server_deferred_write_buffer);
&conn->server_deferred_write_buffer);
} else {
grpc_slice_buffer_move_into(&conn->client_read_buffer,
&conn->server_write_buffer);
&conn->server_write_buffer);
gpr_ref(&conn->refcount);
grpc_endpoint_write(exec_ctx, conn->server_endpoint,
&conn->server_write_buffer,
@ -236,10 +236,10 @@ static void on_server_read_done(grpc_exec_ctx* exec_ctx, void* arg,
// Otherwise, move the read data into the write buffer and write it.
if (conn->client_write_buffer.length > 0) {
grpc_slice_buffer_move_into(&conn->server_read_buffer,
&conn->client_deferred_write_buffer);
&conn->client_deferred_write_buffer);
} else {
grpc_slice_buffer_move_into(&conn->server_read_buffer,
&conn->client_write_buffer);
&conn->client_write_buffer);
gpr_ref(&conn->refcount);
grpc_endpoint_write(exec_ctx, conn->client_endpoint,
&conn->client_write_buffer,
@ -313,7 +313,7 @@ static void on_read_request_done(grpc_exec_ctx* exec_ctx, void* arg,
}
// Read request and feed it to the parser.
for (size_t i = 0; i < conn->client_read_buffer.count; ++i) {
if (GPR_SLICE_LENGTH(conn->client_read_buffer.slices[i]) > 0) {
if (GRPC_SLICE_LENGTH(conn->client_read_buffer.slices[i]) > 0) {
error = grpc_http_parser_parse(&conn->http_parser,
conn->client_read_buffer.slices[i], NULL);
if (error != GRPC_ERROR_NONE) {

@ -138,7 +138,7 @@ static uint32_t read_uint32(input_stream *inp) {
static grpc_byte_buffer *read_message(input_stream *inp) {
grpc_slice slice = grpc_slice_malloc(read_uint22(inp));
memset(GPR_SLICE_START_PTR(slice), 0, GPR_SLICE_LENGTH(slice));
memset(GRPC_SLICE_START_PTR(slice), 0, GRPC_SLICE_LENGTH(slice));
grpc_byte_buffer *out = grpc_raw_byte_buffer_create(&slice, 1);
grpc_slice_unref(slice);
return out;

@ -96,7 +96,7 @@ static void end_test(grpc_end2end_test_fixture *f) {
static grpc_slice large_slice(void) {
grpc_slice slice = grpc_slice_malloc(1000000);
memset(GPR_SLICE_START_PTR(slice), 'x', GPR_SLICE_LENGTH(slice));
memset(GRPC_SLICE_START_PTR(slice), 'x', GRPC_SLICE_LENGTH(slice));
return slice;
}

@ -238,9 +238,9 @@ static bool client_ssl_test(char *server_alpn_preferred) {
grpc_load_file(SSL_CERT_PATH, 1, &cert_slice)));
GPR_ASSERT(GRPC_LOG_IF_ERROR("load_file",
grpc_load_file(SSL_KEY_PATH, 1, &key_slice)));
const char *ca_cert = (const char *)GPR_SLICE_START_PTR(ca_slice);
pem_key_cert_pair.private_key = (const char *)GPR_SLICE_START_PTR(key_slice);
pem_key_cert_pair.cert_chain = (const char *)GPR_SLICE_START_PTR(cert_slice);
const char *ca_cert = (const char *)GRPC_SLICE_START_PTR(ca_slice);
pem_key_cert_pair.private_key = (const char *)GRPC_SLICE_START_PTR(key_slice);
pem_key_cert_pair.cert_chain = (const char *)GRPC_SLICE_START_PTR(cert_slice);
grpc_channel_credentials *ssl_creds =
grpc_ssl_credentials_create(ca_cert, &pem_key_cert_pair, NULL);

@ -91,9 +91,9 @@ static void server_thread(void *arg) {
grpc_load_file(SSL_CERT_PATH, 1, &cert_slice)));
GPR_ASSERT(GRPC_LOG_IF_ERROR("load_file",
grpc_load_file(SSL_KEY_PATH, 1, &key_slice)));
const char *ca_cert = (const char *)GPR_SLICE_START_PTR(ca_slice);
pem_key_cert_pair.private_key = (const char *)GPR_SLICE_START_PTR(key_slice);
pem_key_cert_pair.cert_chain = (const char *)GPR_SLICE_START_PTR(cert_slice);
const char *ca_cert = (const char *)GRPC_SLICE_START_PTR(ca_slice);
pem_key_cert_pair.private_key = (const char *)GRPC_SLICE_START_PTR(key_slice);
pem_key_cert_pair.cert_chain = (const char *)GRPC_SLICE_START_PTR(cert_slice);
grpc_server_credentials *ssl_creds = grpc_ssl_server_credentials_create(
ca_cert, &pem_key_cert_pair, 1, 0, NULL);

@ -68,12 +68,12 @@ size_t count_slices(grpc_slice *slices, size_t nslices, int *current_data) {
size_t j;
unsigned char *buf;
for (i = 0; i < nslices; ++i) {
buf = GPR_SLICE_START_PTR(slices[i]);
for (j = 0; j < GPR_SLICE_LENGTH(slices[i]); ++j) {
buf = GRPC_SLICE_START_PTR(slices[i]);
for (j = 0; j < GRPC_SLICE_LENGTH(slices[i]); ++j) {
GPR_ASSERT(buf[j] == *current_data);
*current_data = (*current_data + 1) % 256;
}
num_bytes += GPR_SLICE_LENGTH(slices[i]);
num_bytes += GRPC_SLICE_LENGTH(slices[i]);
}
return num_bytes;
}
@ -100,9 +100,9 @@ static grpc_slice *allocate_blocks(size_t num_bytes, size_t slice_size,
for (i = 0; i < nslices; ++i) {
slices[i] = grpc_slice_malloc(slice_size > num_bytes_left ? num_bytes_left
: slice_size);
num_bytes_left -= GPR_SLICE_LENGTH(slices[i]);
buf = GPR_SLICE_START_PTR(slices[i]);
for (j = 0; j < GPR_SLICE_LENGTH(slices[i]); ++j) {
num_bytes_left -= GRPC_SLICE_LENGTH(slices[i]);
buf = GRPC_SLICE_START_PTR(slices[i]);
for (j = 0; j < GRPC_SLICE_LENGTH(slices[i]); ++j) {
buf[j] = *current_data;
(*current_data)++;
}

@ -63,12 +63,12 @@ static void test_load_empty_file(void) {
error = grpc_load_file(tmp_name, 0, &slice);
GPR_ASSERT(error == GRPC_ERROR_NONE);
GPR_ASSERT(GPR_SLICE_LENGTH(slice) == 0);
GPR_ASSERT(GRPC_SLICE_LENGTH(slice) == 0);
error = grpc_load_file(tmp_name, 1, &slice_with_null_term);
GPR_ASSERT(error == GRPC_ERROR_NONE);
GPR_ASSERT(GPR_SLICE_LENGTH(slice_with_null_term) == 1);
GPR_ASSERT(GPR_SLICE_START_PTR(slice_with_null_term)[0] == 0);
GPR_ASSERT(GRPC_SLICE_LENGTH(slice_with_null_term) == 1);
GPR_ASSERT(GRPC_SLICE_START_PTR(slice_with_null_term)[0] == 0);
remove(tmp_name);
gpr_free(tmp_name);
@ -93,7 +93,7 @@ static void test_load_failure(void) {
error = grpc_load_file(tmp_name, 0, &slice);
GPR_ASSERT(error != GRPC_ERROR_NONE);
GRPC_ERROR_UNREF(error);
GPR_ASSERT(GPR_SLICE_LENGTH(slice) == 0);
GPR_ASSERT(GRPC_SLICE_LENGTH(slice) == 0);
gpr_free(tmp_name);
grpc_slice_unref(slice);
}
@ -116,13 +116,13 @@ static void test_load_small_file(void) {
error = grpc_load_file(tmp_name, 0, &slice);
GPR_ASSERT(error == GRPC_ERROR_NONE);
GPR_ASSERT(GPR_SLICE_LENGTH(slice) == strlen(blah));
GPR_ASSERT(!memcmp(GPR_SLICE_START_PTR(slice), blah, strlen(blah)));
GPR_ASSERT(GRPC_SLICE_LENGTH(slice) == strlen(blah));
GPR_ASSERT(!memcmp(GRPC_SLICE_START_PTR(slice), blah, strlen(blah)));
error = grpc_load_file(tmp_name, 1, &slice_with_null_term);
GPR_ASSERT(error == GRPC_ERROR_NONE);
GPR_ASSERT(GPR_SLICE_LENGTH(slice_with_null_term) == (strlen(blah) + 1));
GPR_ASSERT(strcmp((const char *)GPR_SLICE_START_PTR(slice_with_null_term),
GPR_ASSERT(GRPC_SLICE_LENGTH(slice_with_null_term) == (strlen(blah) + 1));
GPR_ASSERT(strcmp((const char *)GRPC_SLICE_START_PTR(slice_with_null_term),
blah) == 0);
remove(tmp_name);
@ -153,8 +153,8 @@ static void test_load_big_file(void) {
error = grpc_load_file(tmp_name, 0, &slice);
GPR_ASSERT(error == GRPC_ERROR_NONE);
GPR_ASSERT(GPR_SLICE_LENGTH(slice) == buffer_size);
current = GPR_SLICE_START_PTR(slice);
GPR_ASSERT(GRPC_SLICE_LENGTH(slice) == buffer_size);
current = GRPC_SLICE_START_PTR(slice);
for (i = 0; i < buffer_size; i++) {
GPR_ASSERT(current[i] == 42);
}

@ -134,12 +134,12 @@ static size_t count_slices(grpc_slice *slices, size_t nslices,
unsigned i, j;
unsigned char *buf;
for (i = 0; i < nslices; ++i) {
buf = GPR_SLICE_START_PTR(slices[i]);
for (j = 0; j < GPR_SLICE_LENGTH(slices[i]); ++j) {
buf = GRPC_SLICE_START_PTR(slices[i]);
for (j = 0; j < GRPC_SLICE_LENGTH(slices[i]); ++j) {
GPR_ASSERT(buf[j] == *current_data);
*current_data = (*current_data + 1) % 256;
}
num_bytes += GPR_SLICE_LENGTH(slices[i]);
num_bytes += GRPC_SLICE_LENGTH(slices[i]);
}
return num_bytes;
}
@ -285,9 +285,9 @@ static grpc_slice *allocate_blocks(size_t num_bytes, size_t slice_size,
for (i = 0; i < nslices; ++i) {
slices[i] = grpc_slice_malloc(slice_size > num_bytes_left ? num_bytes_left
: slice_size);
num_bytes_left -= GPR_SLICE_LENGTH(slices[i]);
buf = GPR_SLICE_START_PTR(slices[i]);
for (j = 0; j < GPR_SLICE_LENGTH(slices[i]); ++j) {
num_bytes_left -= GRPC_SLICE_LENGTH(slices[i]);
buf = GRPC_SLICE_START_PTR(slices[i]);
for (j = 0; j < GRPC_SLICE_LENGTH(slices[i]); ++j) {
buf[j] = *current_data;
(*current_data)++;
}

@ -58,9 +58,9 @@ static void test_simple_encode_decode_b64(int url_safe, int multiline) {
char *hello_b64 =
grpc_base64_encode(hello, strlen(hello), url_safe, multiline);
grpc_slice hello_slice = grpc_base64_decode(hello_b64, url_safe);
GPR_ASSERT(GPR_SLICE_LENGTH(hello_slice) == strlen(hello));
GPR_ASSERT(strncmp((const char *)GPR_SLICE_START_PTR(hello_slice), hello,
GPR_SLICE_LENGTH(hello_slice)) == 0);
GPR_ASSERT(GRPC_SLICE_LENGTH(hello_slice) == strlen(hello));
GPR_ASSERT(strncmp((const char *)GRPC_SLICE_START_PTR(hello_slice), hello,
GRPC_SLICE_LENGTH(hello_slice)) == 0);
grpc_slice_unref(hello_slice);
gpr_free(hello_b64);
@ -77,8 +77,8 @@ static void test_full_range_encode_decode_b64(int url_safe, int multiline) {
for (i = 0; i < 3; i++) {
b64 = grpc_base64_encode(orig, sizeof(orig) - i, url_safe, multiline);
orig_decoded = grpc_base64_decode(b64, url_safe);
GPR_ASSERT(GPR_SLICE_LENGTH(orig_decoded) == (sizeof(orig) - i));
GPR_ASSERT(buffers_are_equal(orig, GPR_SLICE_START_PTR(orig_decoded),
GPR_ASSERT(GRPC_SLICE_LENGTH(orig_decoded) == (sizeof(orig) - i));
GPR_ASSERT(buffers_are_equal(orig, GRPC_SLICE_START_PTR(orig_decoded),
sizeof(orig) - i));
grpc_slice_unref(orig_decoded);
gpr_free(b64);
@ -127,13 +127,13 @@ static void test_url_safe_unsafe_mismtach_failure(void) {
b64 = grpc_base64_encode(orig, sizeof(orig), url_safe, 0);
orig_decoded = grpc_base64_decode(b64, !url_safe);
GPR_ASSERT(GPR_SLICE_IS_EMPTY(orig_decoded));
GPR_ASSERT(GRPC_SLICE_IS_EMPTY(orig_decoded));
gpr_free(b64);
grpc_slice_unref(orig_decoded);
b64 = grpc_base64_encode(orig, sizeof(orig), !url_safe, 0);
orig_decoded = grpc_base64_decode(b64, url_safe);
GPR_ASSERT(GPR_SLICE_IS_EMPTY(orig_decoded));
GPR_ASSERT(GRPC_SLICE_IS_EMPTY(orig_decoded));
gpr_free(b64);
grpc_slice_unref(orig_decoded);
}
@ -174,37 +174,37 @@ static void test_unpadded_decode(void) {
grpc_slice decoded;
decoded = grpc_base64_decode("Zm9vYmFy", 0);
GPR_ASSERT(!GPR_SLICE_IS_EMPTY(decoded));
GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded));
GPR_ASSERT(grpc_slice_str_cmp(decoded, "foobar") == 0);
grpc_slice_unref(decoded);
decoded = grpc_base64_decode("Zm9vYmE", 0);
GPR_ASSERT(!GPR_SLICE_IS_EMPTY(decoded));
GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded));
GPR_ASSERT(grpc_slice_str_cmp(decoded, "fooba") == 0);
grpc_slice_unref(decoded);
decoded = grpc_base64_decode("Zm9vYg", 0);
GPR_ASSERT(!GPR_SLICE_IS_EMPTY(decoded));
GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded));
GPR_ASSERT(grpc_slice_str_cmp(decoded, "foob") == 0);
grpc_slice_unref(decoded);
decoded = grpc_base64_decode("Zm9v", 0);
GPR_ASSERT(!GPR_SLICE_IS_EMPTY(decoded));
GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded));
GPR_ASSERT(grpc_slice_str_cmp(decoded, "foo") == 0);
grpc_slice_unref(decoded);
decoded = grpc_base64_decode("Zm8", 0);
GPR_ASSERT(!GPR_SLICE_IS_EMPTY(decoded));
GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded));
GPR_ASSERT(grpc_slice_str_cmp(decoded, "fo") == 0);
grpc_slice_unref(decoded);
decoded = grpc_base64_decode("Zg", 0);
GPR_ASSERT(!GPR_SLICE_IS_EMPTY(decoded));
GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded));
GPR_ASSERT(grpc_slice_str_cmp(decoded, "f") == 0);
grpc_slice_unref(decoded);
decoded = grpc_base64_decode("", 0);
GPR_ASSERT(GPR_SLICE_IS_EMPTY(decoded));
GPR_ASSERT(GRPC_SLICE_IS_EMPTY(decoded));
}
int main(int argc, char **argv) {

@ -50,7 +50,7 @@ void create_jwt(const char *json_key_file_path, const char *service_url,
GPR_ASSERT(GRPC_LOG_IF_ERROR(
"load_file", grpc_load_file(json_key_file_path, 1, &json_key_data)));
key = grpc_auth_json_key_create_from_string(
(const char *)GPR_SLICE_START_PTR(json_key_data));
(const char *)GRPC_SLICE_START_PTR(json_key_data));
grpc_slice_unref(json_key_data);
if (!grpc_auth_json_key_is_valid(&key)) {
fprintf(stderr, "Could not parse json key.\n");

@ -53,7 +53,7 @@ static grpc_call_credentials *create_refresh_token_creds(
"load_file",
grpc_load_file(json_refresh_token_file_path, 1, &refresh_token)));
return grpc_google_refresh_token_credentials_create(
(const char *)GPR_SLICE_START_PTR(refresh_token), NULL);
(const char *)GRPC_SLICE_START_PTR(refresh_token), NULL);
}
int main(int argc, char **argv) {

@ -228,11 +228,11 @@ static grpc_json *parse_json_part_from_jwt(const char *str, size_t len,
strncpy(b64, str, len);
b64[len] = '\0';
slice = grpc_base64_decode(b64, 1);
GPR_ASSERT(!GPR_SLICE_IS_EMPTY(slice));
decoded = gpr_malloc(GPR_SLICE_LENGTH(slice) + 1);
strncpy(decoded, (const char *)GPR_SLICE_START_PTR(slice),
GPR_SLICE_LENGTH(slice));
decoded[GPR_SLICE_LENGTH(slice)] = '\0';
GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(slice));
decoded = gpr_malloc(GRPC_SLICE_LENGTH(slice) + 1);
strncpy(decoded, (const char *)GRPC_SLICE_START_PTR(slice),
GRPC_SLICE_LENGTH(slice));
decoded[GRPC_SLICE_LENGTH(slice)] = '\0';
json = grpc_json_parse_string(decoded);
gpr_free(b64);
*scratchpad = decoded;
@ -342,8 +342,8 @@ static void check_jwt_signature(const char *b64_signature, RSA *rsa_key,
EVP_PKEY *key = EVP_PKEY_new();
grpc_slice sig = grpc_base64_decode(b64_signature, 1);
GPR_ASSERT(!GPR_SLICE_IS_EMPTY(sig));
GPR_ASSERT(GPR_SLICE_LENGTH(sig) == 128);
GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(sig));
GPR_ASSERT(GRPC_SLICE_LENGTH(sig) == 128);
GPR_ASSERT(md_ctx != NULL);
GPR_ASSERT(key != NULL);
@ -352,8 +352,8 @@ static void check_jwt_signature(const char *b64_signature, RSA *rsa_key,
GPR_ASSERT(EVP_DigestVerifyInit(md_ctx, NULL, EVP_sha256(), NULL, key) == 1);
GPR_ASSERT(EVP_DigestVerifyUpdate(md_ctx, signed_data, signed_data_size) ==
1);
GPR_ASSERT(EVP_DigestVerifyFinal(md_ctx, GPR_SLICE_START_PTR(sig),
GPR_SLICE_LENGTH(sig)) == 1);
GPR_ASSERT(EVP_DigestVerifyFinal(md_ctx, GRPC_SLICE_START_PTR(sig),
GRPC_SLICE_LENGTH(sig)) == 1);
grpc_slice_unref(sig);
if (key != NULL) EVP_PKEY_free(key);

@ -183,7 +183,7 @@ static void test_claims_success(void) {
grpc_jwt_claims *claims;
grpc_slice s = grpc_slice_from_copied_string(claims_without_time_constraint);
grpc_json *json = grpc_json_parse_string_with_len(
(char *)GPR_SLICE_START_PTR(s), GPR_SLICE_LENGTH(s));
(char *)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s));
GPR_ASSERT(json != NULL);
claims = grpc_jwt_claims_from_json(json, s);
GPR_ASSERT(claims != NULL);
@ -201,7 +201,7 @@ static void test_expired_claims_failure(void) {
grpc_jwt_claims *claims;
grpc_slice s = grpc_slice_from_copied_string(expired_claims);
grpc_json *json = grpc_json_parse_string_with_len(
(char *)GPR_SLICE_START_PTR(s), GPR_SLICE_LENGTH(s));
(char *)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s));
gpr_timespec exp_iat = {100, 0, GPR_CLOCK_REALTIME};
gpr_timespec exp_exp = {120, 0, GPR_CLOCK_REALTIME};
gpr_timespec exp_nbf = {60, 0, GPR_CLOCK_REALTIME};
@ -225,7 +225,7 @@ static void test_expired_claims_failure(void) {
static void test_invalid_claims_failure(void) {
grpc_slice s = grpc_slice_from_copied_string(invalid_claims);
grpc_json *json = grpc_json_parse_string_with_len(
(char *)GPR_SLICE_START_PTR(s), GPR_SLICE_LENGTH(s));
(char *)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s));
GPR_ASSERT(grpc_jwt_claims_from_json(json, s) == NULL);
}
@ -233,7 +233,7 @@ static void test_bad_audience_claims_failure(void) {
grpc_jwt_claims *claims;
grpc_slice s = grpc_slice_from_copied_string(claims_without_time_constraint);
grpc_json *json = grpc_json_parse_string_with_len(
(char *)GPR_SLICE_START_PTR(s), GPR_SLICE_LENGTH(s));
(char *)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s));
GPR_ASSERT(json != NULL);
claims = grpc_jwt_claims_from_json(json, s);
GPR_ASSERT(claims != NULL);
@ -484,11 +484,11 @@ static void corrupt_jwt_sig(char *jwt) {
char *last_dot = strrchr(jwt, '.');
GPR_ASSERT(last_dot != NULL);
sig = grpc_base64_decode(last_dot + 1, 1);
GPR_ASSERT(!GPR_SLICE_IS_EMPTY(sig));
sig_bytes = GPR_SLICE_START_PTR(sig);
GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(sig));
sig_bytes = GRPC_SLICE_START_PTR(sig);
(*sig_bytes)++; /* Corrupt first byte. */
bad_b64_sig =
grpc_base64_encode(GPR_SLICE_START_PTR(sig), GPR_SLICE_LENGTH(sig), 1, 0);
grpc_base64_encode(GRPC_SLICE_START_PTR(sig), GRPC_SLICE_LENGTH(sig), 1, 0);
memcpy(last_dot + 1, bad_b64_sig, strlen(bad_b64_sig));
gpr_free(bad_b64_sig);
grpc_slice_unref(sig);

@ -63,10 +63,10 @@ static void on_oauth2_response(grpc_exec_ctx *exec_ctx, void *user_data,
} else {
GPR_ASSERT(num_md == 1);
token_slice = md_elems[0].value;
token = gpr_malloc(GPR_SLICE_LENGTH(token_slice) + 1);
memcpy(token, GPR_SLICE_START_PTR(token_slice),
GPR_SLICE_LENGTH(token_slice));
token[GPR_SLICE_LENGTH(token_slice)] = '\0';
token = gpr_malloc(GRPC_SLICE_LENGTH(token_slice) + 1);
memcpy(token, GRPC_SLICE_START_PTR(token_slice),
GRPC_SLICE_LENGTH(token_slice));
token[GRPC_SLICE_LENGTH(token_slice)] = '\0';
}
gpr_mu_lock(request->mu);
request->is_done = 1;

@ -77,8 +77,8 @@ static grpc_endpoint_test_fixture secure_endpoint_create_fixture_tcp_socketpair(
grpc_slice encrypted_leftover;
for (i = 0; i < leftover_nslices; i++) {
grpc_slice plain = leftover_slices[i];
uint8_t *message_bytes = GPR_SLICE_START_PTR(plain);
size_t message_size = GPR_SLICE_LENGTH(plain);
uint8_t *message_bytes = GRPC_SLICE_START_PTR(plain);
size_t message_size = GRPC_SLICE_LENGTH(plain);
while (message_size > 0) {
size_t protected_buffer_size_to_send = buffer_size;
size_t processed_message_size = message_size;

@ -397,7 +397,7 @@ static void test_default_ssl_roots(void) {
an empty slice. */
grpc_set_ssl_roots_override_callback(override_roots_permanent_failure);
roots = grpc_get_default_ssl_roots_for_testing();
GPR_ASSERT(GPR_SLICE_IS_EMPTY(roots));
GPR_ASSERT(GRPC_SLICE_IS_EMPTY(roots));
/* Cleanup. */
remove(roots_env_var_file_path);

@ -55,10 +55,10 @@ static void test_slice_malloc_returns_something_sensible(void) {
/* If there is a length, slice.data must be non-NULL. If length is zero
we don't care. */
if (length) {
GPR_ASSERT(GPR_SLICE_START_PTR(slice));
GPR_ASSERT(GRPC_SLICE_START_PTR(slice));
}
/* Returned slice length must be what was requested. */
GPR_ASSERT(GPR_SLICE_LENGTH(slice) == length);
GPR_ASSERT(GRPC_SLICE_LENGTH(slice) == length);
/* If the slice has a refcount, it must be destroyable. */
if (slice.refcount) {
GPR_ASSERT(slice.refcount->ref != NULL);
@ -66,7 +66,7 @@ static void test_slice_malloc_returns_something_sensible(void) {
}
/* We must be able to write to every byte of the data */
for (i = 0; i < length; i++) {
GPR_SLICE_START_PTR(slice)[i] = (uint8_t)i;
GRPC_SLICE_START_PTR(slice)[i] = (uint8_t)i;
}
/* And finally we must succeed in destroying the slice */
grpc_slice_unref(slice);
@ -97,9 +97,9 @@ static void test_slice_new_with_user_data(void) {
buf[1] = 1;
slice = grpc_slice_new_with_user_data(buf, 2, set_mark, &marker);
GPR_ASSERT(marker == 0);
GPR_ASSERT(GPR_SLICE_LENGTH(slice) == 2);
GPR_ASSERT(GPR_SLICE_START_PTR(slice)[0] == 0);
GPR_ASSERT(GPR_SLICE_START_PTR(slice)[1] == 1);
GPR_ASSERT(GRPC_SLICE_LENGTH(slice) == 2);
GPR_ASSERT(GRPC_SLICE_START_PTR(slice)[0] == 0);
GPR_ASSERT(GRPC_SLICE_START_PTR(slice)[1] == 1);
/* unref should cause destroy function to run. */
grpc_slice_unref(slice);
@ -152,7 +152,7 @@ static void test_slice_sub_works(unsigned length) {
beginning of the slice. */
slice = grpc_slice_malloc(length);
for (i = 0; i < length; i++) {
GPR_SLICE_START_PTR(slice)[i] = (uint8_t)i;
GRPC_SLICE_START_PTR(slice)[i] = (uint8_t)i;
}
/* Ensure that for all subsets length is correct and that we start on the
@ -160,9 +160,9 @@ static void test_slice_sub_works(unsigned length) {
for (i = 0; i < length; i++) {
for (j = i; j < length; j++) {
sub = grpc_slice_sub(slice, i, j);
GPR_ASSERT(GPR_SLICE_LENGTH(sub) == j - i);
GPR_ASSERT(GRPC_SLICE_LENGTH(sub) == j - i);
for (k = 0; k < j - i; k++) {
GPR_ASSERT(GPR_SLICE_START_PTR(sub)[k] == (uint8_t)(i + k));
GPR_ASSERT(GRPC_SLICE_START_PTR(sub)[k] == (uint8_t)(i + k));
}
grpc_slice_unref(sub);
}
@ -171,12 +171,12 @@ static void test_slice_sub_works(unsigned length) {
}
static void check_head_tail(grpc_slice slice, grpc_slice head, grpc_slice tail) {
GPR_ASSERT(GPR_SLICE_LENGTH(slice) ==
GPR_SLICE_LENGTH(head) + GPR_SLICE_LENGTH(tail));
GPR_ASSERT(0 == memcmp(GPR_SLICE_START_PTR(slice), GPR_SLICE_START_PTR(head),
GPR_SLICE_LENGTH(head)));
GPR_ASSERT(0 == memcmp(GPR_SLICE_START_PTR(slice) + GPR_SLICE_LENGTH(head),
GPR_SLICE_START_PTR(tail), GPR_SLICE_LENGTH(tail)));
GPR_ASSERT(GRPC_SLICE_LENGTH(slice) ==
GRPC_SLICE_LENGTH(head) + GRPC_SLICE_LENGTH(tail));
GPR_ASSERT(0 == memcmp(GRPC_SLICE_START_PTR(slice), GRPC_SLICE_START_PTR(head),
GRPC_SLICE_LENGTH(head)));
GPR_ASSERT(0 == memcmp(GRPC_SLICE_START_PTR(slice) + GRPC_SLICE_LENGTH(head),
GRPC_SLICE_START_PTR(tail), GRPC_SLICE_LENGTH(tail)));
}
static void test_slice_split_head_works(size_t length) {
@ -191,7 +191,7 @@ static void test_slice_split_head_works(size_t length) {
beginning of the slice. */
slice = grpc_slice_malloc(length);
for (i = 0; i < length; i++) {
GPR_SLICE_START_PTR(slice)[i] = (uint8_t)i;
GRPC_SLICE_START_PTR(slice)[i] = (uint8_t)i;
}
/* Ensure that for all subsets length is correct and that we start on the
@ -219,7 +219,7 @@ static void test_slice_split_tail_works(size_t length) {
beginning of the slice. */
slice = grpc_slice_malloc(length);
for (i = 0; i < length; i++) {
GPR_SLICE_START_PTR(slice)[i] = (uint8_t)i;
GRPC_SLICE_START_PTR(slice)[i] = (uint8_t)i;
}
/* Ensure that for all subsets length is correct and that we start on the
@ -242,9 +242,9 @@ static void test_slice_from_copied_string_works(void) {
LOG_TEST_NAME("test_slice_from_copied_string_works");
slice = grpc_slice_from_copied_string(text);
GPR_ASSERT(strlen(text) == GPR_SLICE_LENGTH(slice));
GPR_ASSERT(strlen(text) == GRPC_SLICE_LENGTH(slice));
GPR_ASSERT(0 ==
memcmp(text, GPR_SLICE_START_PTR(slice), GPR_SLICE_LENGTH(slice)));
memcmp(text, GRPC_SLICE_START_PTR(slice), GRPC_SLICE_LENGTH(slice)));
grpc_slice_unref(slice);
}

@ -63,7 +63,7 @@ static void test_read_one_slice(void) {
"Couldn't init byte buffer reader");
first_code = grpc_byte_buffer_reader_next(&reader, &first_slice);
GPR_ASSERT(first_code != 0);
GPR_ASSERT(memcmp(GPR_SLICE_START_PTR(first_slice), "test", 4) == 0);
GPR_ASSERT(memcmp(GRPC_SLICE_START_PTR(first_slice), "test", 4) == 0);
grpc_slice_unref(first_slice);
second_code = grpc_byte_buffer_reader_next(&reader, &second_slice);
GPR_ASSERT(second_code == 0);
@ -79,14 +79,14 @@ static void test_read_one_slice_malloc(void) {
LOG_TEST("test_read_one_slice_malloc");
slice = grpc_slice_malloc(4);
memcpy(GPR_SLICE_START_PTR(slice), "test", 4);
memcpy(GRPC_SLICE_START_PTR(slice), "test", 4);
buffer = grpc_raw_byte_buffer_create(&slice, 1);
grpc_slice_unref(slice);
GPR_ASSERT(grpc_byte_buffer_reader_init(&reader, buffer) &&
"Couldn't init byte buffer reader");
first_code = grpc_byte_buffer_reader_next(&reader, &first_slice);
GPR_ASSERT(first_code != 0);
GPR_ASSERT(memcmp(GPR_SLICE_START_PTR(first_slice), "test", 4) == 0);
GPR_ASSERT(memcmp(GRPC_SLICE_START_PTR(first_slice), "test", 4) == 0);
grpc_slice_unref(first_slice);
second_code = grpc_byte_buffer_reader_next(&reader, &second_slice);
GPR_ASSERT(second_code == 0);
@ -108,7 +108,7 @@ static void test_read_none_compressed_slice(void) {
"Couldn't init byte buffer reader");
first_code = grpc_byte_buffer_reader_next(&reader, &first_slice);
GPR_ASSERT(first_code != 0);
GPR_ASSERT(memcmp(GPR_SLICE_START_PTR(first_slice), "test", 4) == 0);
GPR_ASSERT(memcmp(GRPC_SLICE_START_PTR(first_slice), "test", 4) == 0);
grpc_slice_unref(first_slice);
second_code = grpc_byte_buffer_reader_next(&reader, &second_slice);
GPR_ASSERT(second_code == 0);
@ -143,7 +143,7 @@ static void read_compressed_slice(grpc_compression_algorithm algorithm,
grpc_slice_buffer_init(&sliceb_out);
input_slice = grpc_slice_malloc(input_size);
memset(GPR_SLICE_START_PTR(input_slice), 'a', input_size);
memset(GRPC_SLICE_START_PTR(input_slice), 'a', input_size);
grpc_slice_buffer_add(&sliceb_in, input_slice); /* takes ownership */
GPR_ASSERT(grpc_msg_compress(algorithm, &sliceb_in, &sliceb_out));
@ -153,10 +153,10 @@ static void read_compressed_slice(grpc_compression_algorithm algorithm,
"Couldn't init byte buffer reader");
while (grpc_byte_buffer_reader_next(&reader, &read_slice)) {
GPR_ASSERT(memcmp(GPR_SLICE_START_PTR(read_slice),
GPR_SLICE_START_PTR(input_slice) + read_count,
GPR_SLICE_LENGTH(read_slice)) == 0);
read_count += GPR_SLICE_LENGTH(read_slice);
GPR_ASSERT(memcmp(GRPC_SLICE_START_PTR(read_slice),
GRPC_SLICE_START_PTR(input_slice) + read_count,
GRPC_SLICE_LENGTH(read_slice)) == 0);
read_count += GRPC_SLICE_LENGTH(read_slice);
grpc_slice_unref(read_slice);
}
GPR_ASSERT(read_count == input_size);
@ -185,7 +185,7 @@ static void test_byte_buffer_from_reader(void) {
LOG_TEST("test_byte_buffer_from_reader");
slice = grpc_slice_malloc(4);
memcpy(GPR_SLICE_START_PTR(slice), "test", 4);
memcpy(GRPC_SLICE_START_PTR(slice), "test", 4);
buffer = grpc_raw_byte_buffer_create(&slice, 1);
grpc_slice_unref(slice);
GPR_ASSERT(grpc_byte_buffer_reader_init(&reader, buffer) &&
@ -195,7 +195,7 @@ static void test_byte_buffer_from_reader(void) {
GPR_ASSERT(buffer->type == buffer_from_reader->type);
GPR_ASSERT(buffer_from_reader->data.raw.compression == GRPC_COMPRESS_NONE);
GPR_ASSERT(buffer_from_reader->data.raw.slice_buffer.count == 1);
GPR_ASSERT(memcmp(GPR_SLICE_START_PTR(
GPR_ASSERT(memcmp(GRPC_SLICE_START_PTR(
buffer_from_reader->data.raw.slice_buffer.slices[0]),
"test", 4) == 0);
@ -217,9 +217,9 @@ static void test_readall(void) {
memset(lotsa_bs, 'b', 1024);
/* use slices large enough to overflow inlining */
slices[0] = grpc_slice_malloc(512);
memcpy(GPR_SLICE_START_PTR(slices[0]), lotsa_as, 512);
memcpy(GRPC_SLICE_START_PTR(slices[0]), lotsa_as, 512);
slices[1] = grpc_slice_malloc(1024);
memcpy(GPR_SLICE_START_PTR(slices[1]), lotsa_bs, 1024);
memcpy(GRPC_SLICE_START_PTR(slices[1]), lotsa_bs, 1024);
buffer = grpc_raw_byte_buffer_create(slices, 2);
grpc_slice_unref(slices[0]);
@ -229,9 +229,9 @@ static void test_readall(void) {
"Couldn't init byte buffer reader");
slice_out = grpc_byte_buffer_reader_readall(&reader);
GPR_ASSERT(GPR_SLICE_LENGTH(slice_out) == 512 + 1024);
GPR_ASSERT(memcmp(GPR_SLICE_START_PTR(slice_out), lotsa_as, 512) == 0);
GPR_ASSERT(memcmp(&(GPR_SLICE_START_PTR(slice_out)[512]), lotsa_bs, 1024) ==
GPR_ASSERT(GRPC_SLICE_LENGTH(slice_out) == 512 + 1024);
GPR_ASSERT(memcmp(GRPC_SLICE_START_PTR(slice_out), lotsa_as, 512) == 0);
GPR_ASSERT(memcmp(&(GRPC_SLICE_START_PTR(slice_out)[512]), lotsa_bs, 1024) ==
0);
grpc_slice_unref(slice_out);
grpc_byte_buffer_destroy(buffer);
@ -252,9 +252,9 @@ static void test_byte_buffer_copy(void) {
memset(lotsa_bs, 'b', 1024);
/* use slices large enough to overflow inlining */
slices[0] = grpc_slice_malloc(512);
memcpy(GPR_SLICE_START_PTR(slices[0]), lotsa_as, 512);
memcpy(GRPC_SLICE_START_PTR(slices[0]), lotsa_as, 512);
slices[1] = grpc_slice_malloc(1024);
memcpy(GPR_SLICE_START_PTR(slices[1]), lotsa_bs, 1024);
memcpy(GRPC_SLICE_START_PTR(slices[1]), lotsa_bs, 1024);
buffer = grpc_raw_byte_buffer_create(slices, 2);
grpc_slice_unref(slices[0]);
@ -265,9 +265,9 @@ static void test_byte_buffer_copy(void) {
"Couldn't init byte buffer reader");
slice_out = grpc_byte_buffer_reader_readall(&reader);
GPR_ASSERT(GPR_SLICE_LENGTH(slice_out) == 512 + 1024);
GPR_ASSERT(memcmp(GPR_SLICE_START_PTR(slice_out), lotsa_as, 512) == 0);
GPR_ASSERT(memcmp(&(GPR_SLICE_START_PTR(slice_out)[512]), lotsa_bs, 1024) ==
GPR_ASSERT(GRPC_SLICE_LENGTH(slice_out) == 512 + 1024);
GPR_ASSERT(memcmp(GRPC_SLICE_START_PTR(slice_out), lotsa_as, 512) == 0);
GPR_ASSERT(memcmp(&(GRPC_SLICE_START_PTR(slice_out)[512]), lotsa_bs, 1024) ==
0);
grpc_slice_unref(slice_out);
grpc_byte_buffer_destroy(buffer);

@ -77,8 +77,8 @@ static void test_vector(grpc_chttp2_hpack_parser *parser,
for (i = 0; i < nslices; i++) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
GPR_ASSERT(grpc_chttp2_hpack_parser_parse(
&exec_ctx, parser, GPR_SLICE_START_PTR(slices[i]),
GPR_SLICE_END_PTR(slices[i])) == GRPC_ERROR_NONE);
&exec_ctx, parser, GRPC_SLICE_START_PTR(slices[i]),
GRPC_SLICE_END_PTR(slices[i])) == GRPC_ERROR_NONE);
grpc_exec_ctx_finish(&exec_ctx);
}

@ -47,7 +47,7 @@ static void test_varint(uint32_t value, uint32_t prefix_bits, uint8_t prefix_or,
GPR_ASSERT(nbytes == expect_length);
slice = grpc_slice_malloc(nbytes);
GRPC_CHTTP2_WRITE_VARINT(value, prefix_bits, prefix_or,
GPR_SLICE_START_PTR(slice), nbytes);
GRPC_SLICE_START_PTR(slice), nbytes);
GPR_ASSERT(grpc_slice_cmp(expect, slice) == 0);
grpc_slice_unref(expect);
grpc_slice_unref(slice);

@ -279,7 +279,7 @@ static void verify_binary_header_size(const char *key, const uint8_t *value,
grpc_slice value_slice =
grpc_slice_from_copied_buffer((const char *)value, value_len);
grpc_slice base64_encoded = grpc_chttp2_base64_encode(value_slice);
size_t expected_size = 32 + strlen(key) + GPR_SLICE_LENGTH(base64_encoded);
size_t expected_size = 32 + strlen(key) + GRPC_SLICE_LENGTH(base64_encoded);
GPR_ASSERT(expected_size == elem_size);
grpc_slice_unref(value_slice);
grpc_slice_unref(base64_encoded);

@ -47,7 +47,7 @@ int main(int argc, char **argv) {
leak_check = false;
GPR_ASSERT(
GRPC_LOG_IF_ERROR("load_file", grpc_load_file(argv[1], 0, &buffer)));
LLVMFuzzerTestOneInput(GPR_SLICE_START_PTR(buffer), GPR_SLICE_LENGTH(buffer));
LLVMFuzzerTestOneInput(GRPC_SLICE_START_PTR(buffer), GRPC_SLICE_LENGTH(buffer));
grpc_slice_unref(buffer);
return 0;
}

@ -48,7 +48,7 @@ grpc_slice parse_hexstring(const char *hexstring) {
GPR_ASSERT((nibbles & 1) == 0);
slice = grpc_slice_malloc(nibbles / 2);
out = GPR_SLICE_START_PTR(slice);
out = GRPC_SLICE_START_PTR(slice);
nibbles = 0;
temp = 0;

@ -69,28 +69,28 @@ void grpc_split_slices(grpc_slice_split_mode mode, grpc_slice *src_slices,
*dst_slice_count = 1;
length = 0;
for (i = 0; i < src_slice_count; i++) {
length += GPR_SLICE_LENGTH(src_slices[i]);
length += GRPC_SLICE_LENGTH(src_slices[i]);
}
*dst_slices = gpr_malloc(sizeof(grpc_slice));
**dst_slices = grpc_slice_malloc(length);
length = 0;
for (i = 0; i < src_slice_count; i++) {
memcpy(GPR_SLICE_START_PTR(**dst_slices) + length,
GPR_SLICE_START_PTR(src_slices[i]),
GPR_SLICE_LENGTH(src_slices[i]));
length += GPR_SLICE_LENGTH(src_slices[i]);
memcpy(GRPC_SLICE_START_PTR(**dst_slices) + length,
GRPC_SLICE_START_PTR(src_slices[i]),
GRPC_SLICE_LENGTH(src_slices[i]));
length += GRPC_SLICE_LENGTH(src_slices[i]);
}
break;
case GRPC_SLICE_SPLIT_ONE_BYTE:
length = 0;
for (i = 0; i < src_slice_count; i++) {
length += GPR_SLICE_LENGTH(src_slices[i]);
length += GRPC_SLICE_LENGTH(src_slices[i]);
}
*dst_slice_count = length;
*dst_slices = gpr_malloc(sizeof(grpc_slice) * length);
length = 0;
for (i = 0; i < src_slice_count; i++) {
for (j = 0; j < GPR_SLICE_LENGTH(src_slices[i]); j++) {
for (j = 0; j < GRPC_SLICE_LENGTH(src_slices[i]); j++) {
(*dst_slices)[length] = grpc_slice_sub(src_slices[i], j, j + 1);
length++;
}
@ -125,13 +125,13 @@ grpc_slice grpc_slice_merge(grpc_slice *slices, size_t nslices) {
size_t i;
for (i = 0; i < nslices; i++) {
if (GPR_SLICE_LENGTH(slices[i]) + length > capacity) {
capacity = GPR_MAX(capacity * 2, GPR_SLICE_LENGTH(slices[i]) + length);
if (GRPC_SLICE_LENGTH(slices[i]) + length > capacity) {
capacity = GPR_MAX(capacity * 2, GRPC_SLICE_LENGTH(slices[i]) + length);
out = gpr_realloc(out, capacity);
}
memcpy(out + length, GPR_SLICE_START_PTR(slices[i]),
GPR_SLICE_LENGTH(slices[i]));
length += GPR_SLICE_LENGTH(slices[i]);
memcpy(out + length, GRPC_SLICE_START_PTR(slices[i]),
GRPC_SLICE_LENGTH(slices[i]));
length += GRPC_SLICE_LENGTH(slices[i]);
}
return grpc_slice_new(out, length, gpr_free);

@ -72,9 +72,9 @@ TEST_F(GrpclbTest, CreateRequest) {
LoadBalanceRequest request;
grpc_grpclb_request* c_req = grpc_grpclb_request_create(service_name.c_str());
grpc_slice slice = grpc_grpclb_request_encode(c_req);
const int num_bytes_written = GPR_SLICE_LENGTH(slice);
const int num_bytes_written = GRPC_SLICE_LENGTH(slice);
EXPECT_GT(num_bytes_written, 0);
request.ParseFromArray(GPR_SLICE_START_PTR(slice), num_bytes_written);
request.ParseFromArray(GRPC_SLICE_START_PTR(slice), num_bytes_written);
EXPECT_EQ(request.initial_request().name(), service_name);
grpc_slice_unref(slice);
grpc_grpclb_request_destroy(c_req);

@ -212,8 +212,8 @@ static void start_lb_server(server_fixture *sf, int *ports, size_t nports,
grpc_byte_buffer_reader_init(&bbr, request_payload_recv);
grpc_slice request_payload_slice = grpc_byte_buffer_reader_readall(&bbr);
grpc::lb::v1::LoadBalanceRequest request;
request.ParseFromArray(GPR_SLICE_START_PTR(request_payload_slice),
GPR_SLICE_LENGTH(request_payload_slice));
request.ParseFromArray(GRPC_SLICE_START_PTR(request_payload_slice),
GRPC_SLICE_LENGTH(request_payload_slice));
GPR_ASSERT(request.has_initial_request());
GPR_ASSERT(request.initial_request().name() == sf->servers_hostport);
grpc_slice_unref(request_payload_slice);

@ -81,11 +81,11 @@ TEST_F(ByteBufferTest, Length) {
}
bool SliceEqual(const Slice& a, grpc_slice b) {
if (a.size() != GPR_SLICE_LENGTH(b)) {
if (a.size() != GRPC_SLICE_LENGTH(b)) {
return false;
}
for (size_t i = 0; i < a.size(); i++) {
if (a.begin()[i] != GPR_SLICE_START_PTR(b)[i]) {
if (a.begin()[i] != GRPC_SLICE_START_PTR(b)[i]) {
return false;
}
}

@ -73,8 +73,8 @@ TEST_F(SliceTest, Cslice) {
Slice spp(s, Slice::STEAL_REF);
CheckSlice(spp, kContent);
grpc_slice c_slice = spp.c_slice();
EXPECT_EQ(GPR_SLICE_START_PTR(s), GPR_SLICE_START_PTR(c_slice));
EXPECT_EQ(GPR_SLICE_END_PTR(s), GPR_SLICE_END_PTR(c_slice));
EXPECT_EQ(GRPC_SLICE_START_PTR(s), GRPC_SLICE_START_PTR(c_slice));
EXPECT_EQ(GRPC_SLICE_END_PTR(s), GRPC_SLICE_END_PTR(c_slice));
grpc_slice_unref(c_slice);
}

Loading…
Cancel
Save