aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/lib/slice
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/lib/slice')
-rw-r--r--src/core/lib/slice/b64.cc30
-rw-r--r--src/core/lib/slice/b64.h8
-rw-r--r--src/core/lib/slice/percent_encoding.cc30
-rw-r--r--src/core/lib/slice/percent_encoding.h6
-rw-r--r--src/core/lib/slice/slice.cc104
-rw-r--r--src/core/lib/slice/slice_buffer.cc72
-rw-r--r--src/core/lib/slice/slice_hash_table.h22
-rw-r--r--src/core/lib/slice/slice_intern.cc64
-rw-r--r--src/core/lib/slice/slice_internal.h12
-rw-r--r--src/core/lib/slice/slice_string_helpers.cc18
-rw-r--r--src/core/lib/slice/slice_string_helpers.h6
11 files changed, 186 insertions, 186 deletions
diff --git a/src/core/lib/slice/b64.cc b/src/core/lib/slice/b64.cc
index 50264719a4..fe7a86ef84 100644
--- a/src/core/lib/slice/b64.cc
+++ b/src/core/lib/slice/b64.cc
@@ -54,11 +54,11 @@ static const char base64_url_safe_chars[] =
/* --- base64 functions. --- */
-char *grpc_base64_encode(const void *vdata, size_t data_size, int url_safe,
+char* grpc_base64_encode(const void* vdata, size_t data_size, int url_safe,
int multiline) {
size_t result_projected_size =
grpc_base64_estimate_encoded_size(data_size, url_safe, multiline);
- char *result = (char *)gpr_malloc(result_projected_size);
+ char* result = (char*)gpr_malloc(result_projected_size);
grpc_base64_encode_core(result, vdata, data_size, url_safe, multiline);
return result;
}
@@ -73,15 +73,15 @@ size_t grpc_base64_estimate_encoded_size(size_t data_size, int url_safe,
return result_projected_size;
}
-void grpc_base64_encode_core(char *result, const void *vdata, size_t data_size,
+void grpc_base64_encode_core(char* result, const void* vdata, size_t data_size,
int url_safe, int multiline) {
- const unsigned char *data = (const unsigned char *)vdata;
- const char *base64_chars =
+ const unsigned char* data = (const unsigned char*)vdata;
+ const char* base64_chars =
url_safe ? base64_url_safe_chars : base64_url_unsafe_chars;
const size_t result_projected_size =
grpc_base64_estimate_encoded_size(data_size, url_safe, multiline);
- char *current = result;
+ char* current = result;
size_t num_blocks = 0;
size_t i = 0;
@@ -122,27 +122,27 @@ void grpc_base64_encode_core(char *result, const void *vdata, size_t data_size,
result[current - result] = '\0';
}
-grpc_slice grpc_base64_decode(grpc_exec_ctx *exec_ctx, const char *b64,
+grpc_slice grpc_base64_decode(grpc_exec_ctx* exec_ctx, const char* b64,
int url_safe) {
return grpc_base64_decode_with_len(exec_ctx, b64, strlen(b64), url_safe);
}
-static void decode_one_char(const unsigned char *codes, unsigned char *result,
- size_t *result_offset) {
+static void decode_one_char(const unsigned char* codes, unsigned char* result,
+ size_t* result_offset) {
uint32_t packed = ((uint32_t)codes[0] << 2) | ((uint32_t)codes[1] >> 4);
result[(*result_offset)++] = (unsigned char)packed;
}
-static void decode_two_chars(const unsigned char *codes, unsigned char *result,
- size_t *result_offset) {
+static void decode_two_chars(const unsigned char* codes, unsigned char* result,
+ size_t* result_offset) {
uint32_t packed = ((uint32_t)codes[0] << 10) | ((uint32_t)codes[1] << 4) |
((uint32_t)codes[2] >> 2);
result[(*result_offset)++] = (unsigned char)(packed >> 8);
result[(*result_offset)++] = (unsigned char)(packed);
}
-static int decode_group(const unsigned char *codes, size_t num_codes,
- unsigned char *result, size_t *result_offset) {
+static int decode_group(const unsigned char* codes, size_t num_codes,
+ unsigned char* result, size_t* result_offset) {
GPR_ASSERT(num_codes <= 4);
/* Short end groups that may not have padding. */
@@ -185,10 +185,10 @@ static int decode_group(const unsigned char *codes, size_t num_codes,
return 1;
}
-grpc_slice grpc_base64_decode_with_len(grpc_exec_ctx *exec_ctx, const char *b64,
+grpc_slice grpc_base64_decode_with_len(grpc_exec_ctx* exec_ctx, const char* b64,
size_t b64_len, int url_safe) {
grpc_slice result = GRPC_SLICE_MALLOC(b64_len);
- unsigned char *current = GRPC_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;
diff --git a/src/core/lib/slice/b64.h b/src/core/lib/slice/b64.h
index 9b4dc65dbb..467f5d848a 100644
--- a/src/core/lib/slice/b64.h
+++ b/src/core/lib/slice/b64.h
@@ -28,7 +28,7 @@ extern "C" {
/* Encodes data using base64. It is the caller's responsability to free
the returned char * using gpr_free. Returns NULL on NULL input.
TODO(makdharma) : change the flags to bool from int */
-char *grpc_base64_encode(const void *data, size_t data_size, int url_safe,
+char* grpc_base64_encode(const void* data, size_t data_size, int url_safe,
int multiline);
/* estimate the upper bound on size of base64 encoded data. The actual size
@@ -39,16 +39,16 @@ size_t grpc_base64_estimate_encoded_size(size_t data_size, int url_safe,
/* Encodes data using base64 and write it to memory pointed to by result. It is
* the caller's responsiblity to allocate enough memory in |result| to fit the
* encoded data. */
-void grpc_base64_encode_core(char *result, const void *vdata, size_t data_size,
+void grpc_base64_encode_core(char* result, const void* vdata, size_t data_size,
int url_safe, int multiline);
/* Decodes data according to the base64 specification. Returns an empty
slice in case of failure. */
-grpc_slice grpc_base64_decode(grpc_exec_ctx *exec_ctx, const char *b64,
+grpc_slice grpc_base64_decode(grpc_exec_ctx* exec_ctx, const char* b64,
int url_safe);
/* Same as above except that the length is provided by the caller. */
-grpc_slice grpc_base64_decode_with_len(grpc_exec_ctx *exec_ctx, const char *b64,
+grpc_slice grpc_base64_decode_with_len(grpc_exec_ctx* exec_ctx, const char* b64,
size_t b64_len, int url_safe);
#ifdef __cplusplus
diff --git a/src/core/lib/slice/percent_encoding.cc b/src/core/lib/slice/percent_encoding.cc
index effc8d7ad6..894e43b191 100644
--- a/src/core/lib/slice/percent_encoding.cc
+++ b/src/core/lib/slice/percent_encoding.cc
@@ -32,19 +32,19 @@ const uint8_t grpc_compatible_percent_encoding_unreserved_bytes[256 / 8] = {
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
static bool is_unreserved_character(uint8_t c,
- const uint8_t *unreserved_bytes) {
+ const uint8_t* unreserved_bytes) {
return ((unreserved_bytes[c / 8] >> (c % 8)) & 1) != 0;
}
grpc_slice grpc_percent_encode_slice(grpc_slice slice,
- const uint8_t *unreserved_bytes) {
+ const uint8_t* unreserved_bytes) {
static const uint8_t hex[] = "0123456789ABCDEF";
// first pass: count the number of bytes needed to output this string
size_t output_length = 0;
- const uint8_t *slice_start = GRPC_SLICE_START_PTR(slice);
- const uint8_t *slice_end = GRPC_SLICE_END_PTR(slice);
- const uint8_t *p;
+ 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++) {
bool unres = is_unreserved_character(*p, unreserved_bytes);
@@ -57,7 +57,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 = GRPC_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;
@@ -71,7 +71,7 @@ grpc_slice grpc_percent_encode_slice(grpc_slice slice,
return out;
}
-static bool valid_hex(const uint8_t *p, const uint8_t *end) {
+static bool valid_hex(const uint8_t* p, const uint8_t* end) {
if (p >= end) return false;
return (*p >= '0' && *p <= '9') || (*p >= 'a' && *p <= 'f') ||
(*p >= 'A' && *p <= 'F');
@@ -85,10 +85,10 @@ 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 = GRPC_SLICE_START_PTR(slice_in);
- const uint8_t *in_end = GRPC_SLICE_END_PTR(slice_in);
+ const uint8_t* unreserved_bytes,
+ grpc_slice* slice_out) {
+ 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) {
@@ -111,7 +111,7 @@ bool grpc_strict_percent_decode_slice(grpc_slice slice_in,
}
p = GRPC_SLICE_START_PTR(slice_in);
*slice_out = GRPC_SLICE_MALLOC(out_length);
- uint8_t *q = GRPC_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]));
@@ -125,8 +125,8 @@ bool grpc_strict_percent_decode_slice(grpc_slice slice_in,
}
grpc_slice grpc_permissive_percent_decode_slice(grpc_slice slice_in) {
- const uint8_t *p = GRPC_SLICE_START_PTR(slice_in);
- const uint8_t *in_end = GRPC_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) {
@@ -149,7 +149,7 @@ grpc_slice grpc_permissive_percent_decode_slice(grpc_slice slice_in) {
}
p = GRPC_SLICE_START_PTR(slice_in);
grpc_slice out = GRPC_SLICE_MALLOC(out_length);
- uint8_t *q = GRPC_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)) {
diff --git a/src/core/lib/slice/percent_encoding.h b/src/core/lib/slice/percent_encoding.h
index 14a4deb44b..22b5e8df31 100644
--- a/src/core/lib/slice/percent_encoding.h
+++ b/src/core/lib/slice/percent_encoding.h
@@ -49,7 +49,7 @@ extern const uint8_t grpc_compatible_percent_encoding_unreserved_bytes[256 / 8];
unreserved_bytes is a bitfield indicating which bytes are considered
unreserved and thus do not need percent encoding */
grpc_slice grpc_percent_encode_slice(grpc_slice slice,
- const uint8_t *unreserved_bytes);
+ const uint8_t* unreserved_bytes);
/* Percent-decode a slice, strictly.
If the input is legal (contains no unreserved bytes, and legal % encodings),
returns true and sets *slice_out to the decoded slice.
@@ -57,8 +57,8 @@ grpc_slice grpc_percent_encode_slice(grpc_slice slice,
unreserved_bytes is a bitfield indicating which bytes are considered
unreserved and thus do not need percent encoding */
bool grpc_strict_percent_decode_slice(grpc_slice slice_in,
- const uint8_t *unreserved_bytes,
- grpc_slice *slice_out);
+ const uint8_t* unreserved_bytes,
+ grpc_slice* slice_out);
/* Percent-decode a slice, permissively.
If a % triplet can not be decoded, pass it through verbatim.
This cannot fail. */
diff --git a/src/core/lib/slice/slice.cc b/src/core/lib/slice/slice.cc
index 0764eda052..d8e3200136 100644
--- a/src/core/lib/slice/slice.cc
+++ b/src/core/lib/slice/slice.cc
@@ -26,8 +26,8 @@
#include "src/core/lib/iomgr/exec_ctx.h"
-char *grpc_slice_to_c_string(grpc_slice slice) {
- char *out = (char *)gpr_malloc(GRPC_SLICE_LENGTH(slice) + 1);
+char* grpc_slice_to_c_string(grpc_slice slice) {
+ char* out = (char*)gpr_malloc(GRPC_SLICE_LENGTH(slice) + 1);
memcpy(out, GRPC_SLICE_START_PTR(slice), GRPC_SLICE_LENGTH(slice));
out[GRPC_SLICE_LENGTH(slice)] = 0;
return out;
@@ -54,7 +54,7 @@ grpc_slice grpc_slice_ref_internal(grpc_slice slice) {
return slice;
}
-void grpc_slice_unref_internal(grpc_exec_ctx *exec_ctx, grpc_slice slice) {
+void grpc_slice_unref_internal(grpc_exec_ctx* exec_ctx, grpc_slice slice) {
if (slice.refcount) {
slice.refcount->vtable->unref(exec_ctx, slice.refcount);
}
@@ -74,8 +74,8 @@ void grpc_slice_unref(grpc_slice slice) {
/* grpc_slice_from_static_string support structure - a refcount that does
nothing */
-static void noop_ref(void *unused) {}
-static void noop_unref(grpc_exec_ctx *exec_ctx, void *unused) {}
+static void noop_ref(void* unused) {}
+static void noop_unref(grpc_exec_ctx* exec_ctx, void* unused) {}
static const grpc_slice_refcount_vtable noop_refcount_vtable = {
noop_ref, noop_unref, grpc_slice_default_eq_impl,
@@ -83,15 +83,15 @@ static const grpc_slice_refcount_vtable noop_refcount_vtable = {
static grpc_slice_refcount noop_refcount = {&noop_refcount_vtable,
&noop_refcount};
-grpc_slice grpc_slice_from_static_buffer(const void *s, size_t len) {
+grpc_slice grpc_slice_from_static_buffer(const void* s, size_t len) {
grpc_slice slice;
slice.refcount = &noop_refcount;
- slice.data.refcounted.bytes = (uint8_t *)s;
+ slice.data.refcounted.bytes = (uint8_t*)s;
slice.data.refcounted.length = len;
return slice;
}
-grpc_slice grpc_slice_from_static_string(const char *s) {
+grpc_slice grpc_slice_from_static_string(const char* s) {
return grpc_slice_from_static_buffer(s, strlen(s));
}
@@ -100,17 +100,17 @@ grpc_slice grpc_slice_from_static_string(const char *s) {
typedef struct new_slice_refcount {
grpc_slice_refcount rc;
gpr_refcount refs;
- void (*user_destroy)(void *);
- void *user_data;
+ void (*user_destroy)(void*);
+ void* user_data;
} new_slice_refcount;
-static void new_slice_ref(void *p) {
- new_slice_refcount *r = (new_slice_refcount *)p;
+static void new_slice_ref(void* p) {
+ new_slice_refcount* r = (new_slice_refcount*)p;
gpr_ref(&r->refs);
}
-static void new_slice_unref(grpc_exec_ctx *exec_ctx, void *p) {
- new_slice_refcount *r = (new_slice_refcount *)p;
+static void new_slice_unref(grpc_exec_ctx* exec_ctx, void* p) {
+ new_slice_refcount* r = (new_slice_refcount*)p;
if (gpr_unref(&r->refs)) {
r->user_destroy(r->user_data);
gpr_free(r);
@@ -121,12 +121,12 @@ static const grpc_slice_refcount_vtable new_slice_vtable = {
new_slice_ref, new_slice_unref, grpc_slice_default_eq_impl,
grpc_slice_default_hash_impl};
-grpc_slice grpc_slice_new_with_user_data(void *p, size_t len,
- void (*destroy)(void *),
- void *user_data) {
+grpc_slice grpc_slice_new_with_user_data(void* p, size_t len,
+ void (*destroy)(void*),
+ void* user_data) {
grpc_slice slice;
- new_slice_refcount *rc =
- (new_slice_refcount *)gpr_malloc(sizeof(new_slice_refcount));
+ new_slice_refcount* rc =
+ (new_slice_refcount*)gpr_malloc(sizeof(new_slice_refcount));
gpr_ref_init(&rc->refs, 1);
rc->rc.vtable = &new_slice_vtable;
rc->rc.sub_refcount = &rc->rc;
@@ -134,12 +134,12 @@ grpc_slice grpc_slice_new_with_user_data(void *p, size_t len,
rc->user_data = user_data;
slice.refcount = &rc->rc;
- slice.data.refcounted.bytes = (uint8_t *)p;
+ slice.data.refcounted.bytes = (uint8_t*)p;
slice.data.refcounted.length = len;
return slice;
}
-grpc_slice grpc_slice_new(void *p, size_t len, void (*destroy)(void *)) {
+grpc_slice grpc_slice_new(void* p, size_t len, void (*destroy)(void*)) {
/* Pass "p" to *destroy when the slice is no longer needed. */
return grpc_slice_new_with_user_data(p, len, destroy, p);
}
@@ -149,18 +149,18 @@ grpc_slice grpc_slice_new(void *p, size_t len, void (*destroy)(void *)) {
typedef struct new_with_len_slice_refcount {
grpc_slice_refcount rc;
gpr_refcount refs;
- void *user_data;
+ void* user_data;
size_t user_length;
- void (*user_destroy)(void *, size_t);
+ void (*user_destroy)(void*, size_t);
} new_with_len_slice_refcount;
-static void new_with_len_ref(void *p) {
- new_with_len_slice_refcount *r = (new_with_len_slice_refcount *)p;
+static void new_with_len_ref(void* p) {
+ new_with_len_slice_refcount* r = (new_with_len_slice_refcount*)p;
gpr_ref(&r->refs);
}
-static void new_with_len_unref(grpc_exec_ctx *exec_ctx, void *p) {
- new_with_len_slice_refcount *r = (new_with_len_slice_refcount *)p;
+static void new_with_len_unref(grpc_exec_ctx* exec_ctx, void* p) {
+ new_with_len_slice_refcount* r = (new_with_len_slice_refcount*)p;
if (gpr_unref(&r->refs)) {
r->user_destroy(r->user_data, r->user_length);
gpr_free(r);
@@ -171,10 +171,10 @@ static const grpc_slice_refcount_vtable new_with_len_vtable = {
new_with_len_ref, new_with_len_unref, grpc_slice_default_eq_impl,
grpc_slice_default_hash_impl};
-grpc_slice grpc_slice_new_with_len(void *p, size_t len,
- void (*destroy)(void *, size_t)) {
+grpc_slice grpc_slice_new_with_len(void* p, size_t len,
+ void (*destroy)(void*, size_t)) {
grpc_slice slice;
- new_with_len_slice_refcount *rc = (new_with_len_slice_refcount *)gpr_malloc(
+ new_with_len_slice_refcount* rc = (new_with_len_slice_refcount*)gpr_malloc(
sizeof(new_with_len_slice_refcount));
gpr_ref_init(&rc->refs, 1);
rc->rc.vtable = &new_with_len_vtable;
@@ -184,19 +184,19 @@ grpc_slice grpc_slice_new_with_len(void *p, size_t len,
rc->user_length = len;
slice.refcount = &rc->rc;
- slice.data.refcounted.bytes = (uint8_t *)p;
+ slice.data.refcounted.bytes = (uint8_t*)p;
slice.data.refcounted.length = len;
return slice;
}
-grpc_slice grpc_slice_from_copied_buffer(const char *source, size_t length) {
+grpc_slice grpc_slice_from_copied_buffer(const char* source, size_t length) {
if (length == 0) return grpc_empty_slice();
grpc_slice slice = GRPC_SLICE_MALLOC(length);
memcpy(GRPC_SLICE_START_PTR(slice), source, length);
return slice;
}
-grpc_slice grpc_slice_from_copied_string(const char *source) {
+grpc_slice grpc_slice_from_copied_string(const char* source) {
return grpc_slice_from_copied_buffer(source, strlen(source));
}
@@ -205,13 +205,13 @@ typedef struct {
gpr_refcount refs;
} malloc_refcount;
-static void malloc_ref(void *p) {
- malloc_refcount *r = (malloc_refcount *)p;
+static void malloc_ref(void* p) {
+ malloc_refcount* r = (malloc_refcount*)p;
gpr_ref(&r->refs);
}
-static void malloc_unref(grpc_exec_ctx *exec_ctx, void *p) {
- malloc_refcount *r = (malloc_refcount *)p;
+static void malloc_unref(grpc_exec_ctx* exec_ctx, void* p) {
+ malloc_refcount* r = (malloc_refcount*)p;
if (gpr_unref(&r->refs)) {
gpr_free(r);
}
@@ -233,8 +233,8 @@ grpc_slice grpc_slice_malloc_large(size_t length) {
refcount is a malloc_refcount
bytes is an array of bytes of the requested length
Both parts are placed in the same allocation returned from gpr_malloc */
- malloc_refcount *rc =
- (malloc_refcount *)gpr_malloc(sizeof(malloc_refcount) + length);
+ malloc_refcount* rc =
+ (malloc_refcount*)gpr_malloc(sizeof(malloc_refcount) + length);
/* Initial refcount on rc is 1 - and it's up to the caller to release
this reference. */
@@ -247,7 +247,7 @@ grpc_slice grpc_slice_malloc_large(size_t length) {
/* The slices refcount points back to the allocated block. */
slice.refcount = &rc->base;
/* The data bytes are placed immediately after the refcount struct */
- slice.data.refcounted.bytes = (uint8_t *)(rc + 1);
+ slice.data.refcounted.bytes = (uint8_t*)(rc + 1);
/* And the length of the block is set to the requested length */
slice.data.refcounted.length = length;
return slice;
@@ -307,7 +307,7 @@ grpc_slice grpc_slice_sub(grpc_slice source, size_t begin, size_t end) {
return subset;
}
-grpc_slice grpc_slice_split_tail_maybe_ref(grpc_slice *source, size_t split,
+grpc_slice grpc_slice_split_tail_maybe_ref(grpc_slice* source, size_t split,
grpc_slice_ref_whom ref_whom) {
grpc_slice tail;
@@ -358,11 +358,11 @@ grpc_slice grpc_slice_split_tail_maybe_ref(grpc_slice *source, size_t split,
return tail;
}
-grpc_slice grpc_slice_split_tail(grpc_slice *source, size_t split) {
+grpc_slice grpc_slice_split_tail(grpc_slice* source, size_t split) {
return grpc_slice_split_tail_maybe_ref(source, split, GRPC_SLICE_REF_BOTH);
}
-grpc_slice grpc_slice_split_head(grpc_slice *source, size_t split) {
+grpc_slice grpc_slice_split_head(grpc_slice* source, size_t split) {
grpc_slice head;
if (source->refcount == NULL) {
@@ -423,7 +423,7 @@ int grpc_slice_cmp(grpc_slice a, grpc_slice b) {
GRPC_SLICE_LENGTH(a));
}
-int grpc_slice_str_cmp(grpc_slice a, const char *b) {
+int grpc_slice_str_cmp(grpc_slice a, const char* b) {
size_t b_length = strlen(b);
int d = (int)(GRPC_SLICE_LENGTH(a) - b_length);
if (d != 0) return d;
@@ -438,13 +438,13 @@ int grpc_slice_is_equivalent(grpc_slice a, grpc_slice b) {
a.data.refcounted.bytes == b.data.refcounted.bytes;
}
-int grpc_slice_buf_start_eq(grpc_slice a, const void *b, size_t len) {
+int grpc_slice_buf_start_eq(grpc_slice a, const void* b, size_t len) {
if (GRPC_SLICE_LENGTH(a) < len) return 0;
return 0 == memcmp(GRPC_SLICE_START_PTR(a), b, len);
}
int grpc_slice_rchr(grpc_slice s, char c) {
- const char *b = (const char *)GRPC_SLICE_START_PTR(s);
+ const char* b = (const char*)GRPC_SLICE_START_PTR(s);
int i;
for (i = (int)GRPC_SLICE_LENGTH(s) - 1; i != -1 && b[i] != c; i--)
;
@@ -452,16 +452,16 @@ int grpc_slice_rchr(grpc_slice s, char c) {
}
int grpc_slice_chr(grpc_slice s, char c) {
- const char *b = (const char *)GRPC_SLICE_START_PTR(s);
- const char *p = (const char *)memchr(b, c, GRPC_SLICE_LENGTH(s));
+ const char* b = (const char*)GRPC_SLICE_START_PTR(s);
+ const char* p = (const char*)memchr(b, c, GRPC_SLICE_LENGTH(s));
return p == NULL ? -1 : (int)(p - b);
}
int grpc_slice_slice(grpc_slice haystack, grpc_slice needle) {
size_t haystack_len = GRPC_SLICE_LENGTH(haystack);
- const uint8_t *haystack_bytes = GRPC_SLICE_START_PTR(haystack);
+ const uint8_t* haystack_bytes = GRPC_SLICE_START_PTR(haystack);
size_t needle_len = GRPC_SLICE_LENGTH(needle);
- const uint8_t *needle_bytes = GRPC_SLICE_START_PTR(needle);
+ const uint8_t* needle_bytes = GRPC_SLICE_START_PTR(needle);
if (haystack_len == 0 || needle_len == 0) return -1;
if (haystack_len < needle_len) return -1;
@@ -469,8 +469,8 @@ int grpc_slice_slice(grpc_slice haystack, grpc_slice needle) {
return grpc_slice_eq(haystack, needle) ? 0 : -1;
if (needle_len == 1) return grpc_slice_chr(haystack, (char)*needle_bytes);
- const uint8_t *last = haystack_bytes + haystack_len - needle_len;
- for (const uint8_t *cur = haystack_bytes; cur != last; ++cur) {
+ const uint8_t* last = haystack_bytes + haystack_len - needle_len;
+ for (const uint8_t* cur = haystack_bytes; cur != last; ++cur) {
if (0 == memcmp(cur, needle_bytes, needle_len)) {
return (int)(cur - haystack_bytes);
}
diff --git a/src/core/lib/slice/slice_buffer.cc b/src/core/lib/slice/slice_buffer.cc
index 63ffc0b00d..3b71fdd4ea 100644
--- a/src/core/lib/slice/slice_buffer.cc
+++ b/src/core/lib/slice/slice_buffer.cc
@@ -30,7 +30,7 @@
/* grow a buffer; requires GRPC_SLICE_BUFFER_INLINE_ELEMENTS > 1 */
#define GROW(x) (3 * (x) / 2)
-static void maybe_embiggen(grpc_slice_buffer *sb) {
+static void maybe_embiggen(grpc_slice_buffer* sb) {
/* How far away from sb->base_slices is sb->slices pointer */
size_t slice_offset = (size_t)(sb->slices - sb->base_slices);
size_t slice_count = sb->count + slice_offset;
@@ -46,10 +46,10 @@ static void maybe_embiggen(grpc_slice_buffer *sb) {
GPR_ASSERT(sb->capacity > slice_count);
if (sb->base_slices == sb->inlined) {
sb->base_slices =
- (grpc_slice *)gpr_malloc(sb->capacity * sizeof(grpc_slice));
+ (grpc_slice*)gpr_malloc(sb->capacity * sizeof(grpc_slice));
memcpy(sb->base_slices, sb->inlined, slice_count * sizeof(grpc_slice));
} else {
- sb->base_slices = (grpc_slice *)gpr_realloc(
+ sb->base_slices = (grpc_slice*)gpr_realloc(
sb->base_slices, sb->capacity * sizeof(grpc_slice));
}
@@ -58,30 +58,30 @@ static void maybe_embiggen(grpc_slice_buffer *sb) {
}
}
-void grpc_slice_buffer_init(grpc_slice_buffer *sb) {
+void grpc_slice_buffer_init(grpc_slice_buffer* sb) {
sb->count = 0;
sb->length = 0;
sb->capacity = GRPC_SLICE_BUFFER_INLINE_ELEMENTS;
sb->base_slices = sb->slices = sb->inlined;
}
-void grpc_slice_buffer_destroy_internal(grpc_exec_ctx *exec_ctx,
- grpc_slice_buffer *sb) {
+void grpc_slice_buffer_destroy_internal(grpc_exec_ctx* exec_ctx,
+ grpc_slice_buffer* sb) {
grpc_slice_buffer_reset_and_unref_internal(exec_ctx, sb);
if (sb->base_slices != sb->inlined) {
gpr_free(sb->base_slices);
}
}
-void grpc_slice_buffer_destroy(grpc_slice_buffer *sb) {
+void grpc_slice_buffer_destroy(grpc_slice_buffer* sb) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_slice_buffer_destroy_internal(&exec_ctx, sb);
grpc_exec_ctx_finish(&exec_ctx);
}
-uint8_t *grpc_slice_buffer_tiny_add(grpc_slice_buffer *sb, size_t n) {
- grpc_slice *back;
- uint8_t *out;
+uint8_t* grpc_slice_buffer_tiny_add(grpc_slice_buffer* sb, size_t n) {
+ grpc_slice* back;
+ uint8_t* out;
sb->length += n;
@@ -103,7 +103,7 @@ add_new:
return back->data.inlined.bytes;
}
-size_t grpc_slice_buffer_add_indexed(grpc_slice_buffer *sb, grpc_slice s) {
+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;
@@ -112,7 +112,7 @@ size_t grpc_slice_buffer_add_indexed(grpc_slice_buffer *sb, grpc_slice s) {
return out;
}
-void grpc_slice_buffer_add(grpc_slice_buffer *sb, grpc_slice s) {
+void grpc_slice_buffer_add(grpc_slice_buffer* sb, grpc_slice s) {
size_t n = sb->count;
/* if both the last slice in the slice buffer and the slice being added
are inlined (that is, that they carry their data inside the slice data
@@ -120,7 +120,7 @@ void grpc_slice_buffer_add(grpc_slice_buffer *sb, grpc_slice s) {
into the back slice, preventing many small slices being passed into
writes */
if (!s.refcount && n) {
- grpc_slice *back = &sb->slices[n - 1];
+ grpc_slice* back = &sb->slices[n - 1];
if (!back->refcount &&
back->data.inlined.length < GRPC_SLICE_INLINED_SIZE) {
if (s.data.inlined.length + back->data.inlined.length <=
@@ -149,22 +149,22 @@ void grpc_slice_buffer_add(grpc_slice_buffer *sb, grpc_slice s) {
grpc_slice_buffer_add_indexed(sb, s);
}
-void grpc_slice_buffer_addn(grpc_slice_buffer *sb, grpc_slice *s, size_t n) {
+void grpc_slice_buffer_addn(grpc_slice_buffer* sb, grpc_slice* s, size_t n) {
size_t i;
for (i = 0; i < n; i++) {
grpc_slice_buffer_add(sb, s[i]);
}
}
-void grpc_slice_buffer_pop(grpc_slice_buffer *sb) {
+void grpc_slice_buffer_pop(grpc_slice_buffer* sb) {
if (sb->count != 0) {
size_t count = --sb->count;
sb->length -= GRPC_SLICE_LENGTH(sb->slices[count]);
}
}
-void grpc_slice_buffer_reset_and_unref_internal(grpc_exec_ctx *exec_ctx,
- grpc_slice_buffer *sb) {
+void grpc_slice_buffer_reset_and_unref_internal(grpc_exec_ctx* exec_ctx,
+ grpc_slice_buffer* sb) {
size_t i;
for (i = 0; i < sb->count; i++) {
grpc_slice_unref_internal(exec_ctx, sb->slices[i]);
@@ -174,13 +174,13 @@ void grpc_slice_buffer_reset_and_unref_internal(grpc_exec_ctx *exec_ctx,
sb->length = 0;
}
-void grpc_slice_buffer_reset_and_unref(grpc_slice_buffer *sb) {
+void grpc_slice_buffer_reset_and_unref(grpc_slice_buffer* sb) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
grpc_slice_buffer_reset_and_unref_internal(&exec_ctx, sb);
grpc_exec_ctx_finish(&exec_ctx);
}
-void grpc_slice_buffer_swap(grpc_slice_buffer *a, grpc_slice_buffer *b) {
+void grpc_slice_buffer_swap(grpc_slice_buffer* a, grpc_slice_buffer* b) {
size_t a_offset = (size_t)(a->slices - a->base_slices);
size_t b_offset = (size_t)(b->slices - b->base_slices);
@@ -207,7 +207,7 @@ void grpc_slice_buffer_swap(grpc_slice_buffer *a, grpc_slice_buffer *b) {
memcpy(a->base_slices, b->inlined, b_count * sizeof(grpc_slice));
} else {
/* no inlining: easy swap */
- GPR_SWAP(grpc_slice *, a->base_slices, b->base_slices);
+ GPR_SWAP(grpc_slice*, a->base_slices, b->base_slices);
}
/* Update the slices pointers (cannot do a GPR_SWAP on slices fields here).
@@ -222,8 +222,8 @@ void grpc_slice_buffer_swap(grpc_slice_buffer *a, grpc_slice_buffer *b) {
GPR_SWAP(size_t, a->length, b->length);
}
-void grpc_slice_buffer_move_into(grpc_slice_buffer *src,
- grpc_slice_buffer *dst) {
+void grpc_slice_buffer_move_into(grpc_slice_buffer* src,
+ grpc_slice_buffer* dst) {
/* anything to move? */
if (src->count == 0) {
return;
@@ -239,8 +239,8 @@ void grpc_slice_buffer_move_into(grpc_slice_buffer *src,
src->length = 0;
}
-static void slice_buffer_move_first_maybe_ref(grpc_slice_buffer *src, size_t n,
- grpc_slice_buffer *dst,
+static void slice_buffer_move_first_maybe_ref(grpc_slice_buffer* src, size_t n,
+ grpc_slice_buffer* dst,
bool incref) {
GPR_ASSERT(src->length >= n);
if (src->length == n) {
@@ -279,20 +279,20 @@ static void slice_buffer_move_first_maybe_ref(grpc_slice_buffer *src, size_t n,
GPR_ASSERT(src->count > 0);
}
-void grpc_slice_buffer_move_first(grpc_slice_buffer *src, size_t n,
- grpc_slice_buffer *dst) {
+void grpc_slice_buffer_move_first(grpc_slice_buffer* src, size_t n,
+ grpc_slice_buffer* dst) {
slice_buffer_move_first_maybe_ref(src, n, dst, true);
}
-void grpc_slice_buffer_move_first_no_ref(grpc_slice_buffer *src, size_t n,
- grpc_slice_buffer *dst) {
+void grpc_slice_buffer_move_first_no_ref(grpc_slice_buffer* src, size_t n,
+ grpc_slice_buffer* dst) {
slice_buffer_move_first_maybe_ref(src, n, dst, false);
}
-void grpc_slice_buffer_move_first_into_buffer(grpc_exec_ctx *exec_ctx,
- grpc_slice_buffer *src, size_t n,
- void *dst) {
- char *dstp = (char *)dst;
+void grpc_slice_buffer_move_first_into_buffer(grpc_exec_ctx* exec_ctx,
+ grpc_slice_buffer* src, size_t n,
+ void* dst) {
+ char* dstp = (char*)dst;
GPR_ASSERT(src->length >= n);
while (n > 0) {
@@ -316,8 +316,8 @@ void grpc_slice_buffer_move_first_into_buffer(grpc_exec_ctx *exec_ctx,
}
}
-void grpc_slice_buffer_trim_end(grpc_slice_buffer *sb, size_t n,
- grpc_slice_buffer *garbage) {
+void grpc_slice_buffer_trim_end(grpc_slice_buffer* sb, size_t n,
+ grpc_slice_buffer* garbage) {
GPR_ASSERT(n <= sb->length);
sb->length -= n;
for (;;) {
@@ -340,7 +340,7 @@ void grpc_slice_buffer_trim_end(grpc_slice_buffer *sb, size_t n,
}
}
-grpc_slice grpc_slice_buffer_take_first(grpc_slice_buffer *sb) {
+grpc_slice grpc_slice_buffer_take_first(grpc_slice_buffer* sb) {
grpc_slice slice;
GPR_ASSERT(sb->count > 0);
slice = sb->slices[0];
@@ -351,7 +351,7 @@ grpc_slice grpc_slice_buffer_take_first(grpc_slice_buffer *sb) {
return slice;
}
-void grpc_slice_buffer_undo_take_first(grpc_slice_buffer *sb,
+void grpc_slice_buffer_undo_take_first(grpc_slice_buffer* sb,
grpc_slice slice) {
sb->slices--;
sb->slices[0] = slice;
diff --git a/src/core/lib/slice/slice_hash_table.h b/src/core/lib/slice/slice_hash_table.h
index 41250df738..f86f25ea7c 100644
--- a/src/core/lib/slice/slice_hash_table.h
+++ b/src/core/lib/slice/slice_hash_table.h
@@ -39,7 +39,7 @@ typedef struct grpc_slice_hash_table grpc_slice_hash_table;
typedef struct grpc_slice_hash_table_entry {
grpc_slice key;
- void *value; /* Must not be NULL. */
+ void* value; /* Must not be NULL. */
} grpc_slice_hash_table_entry;
/** Creates a new hash table of containing \a entries, which is an array
@@ -48,18 +48,18 @@ typedef struct grpc_slice_hash_table_entry {
value_cmp will be used to compare values in the context of \a
grpc_slice_hash_table_cmp. If NULL, raw pointer (\a GPR_ICMP) comparison
will be used. */
-grpc_slice_hash_table *grpc_slice_hash_table_create(
- size_t num_entries, grpc_slice_hash_table_entry *entries,
- void (*destroy_value)(grpc_exec_ctx *exec_ctx, void *value),
- int (*value_cmp)(void *a, void *b));
+grpc_slice_hash_table* grpc_slice_hash_table_create(
+ size_t num_entries, grpc_slice_hash_table_entry* entries,
+ void (*destroy_value)(grpc_exec_ctx* exec_ctx, void* value),
+ int (*value_cmp)(void* a, void* b));
-grpc_slice_hash_table *grpc_slice_hash_table_ref(grpc_slice_hash_table *table);
-void grpc_slice_hash_table_unref(grpc_exec_ctx *exec_ctx,
- grpc_slice_hash_table *table);
+grpc_slice_hash_table* grpc_slice_hash_table_ref(grpc_slice_hash_table* table);
+void grpc_slice_hash_table_unref(grpc_exec_ctx* exec_ctx,
+ grpc_slice_hash_table* table);
/** Returns the value from \a table associated with \a key.
Returns NULL if \a key is not found. */
-void *grpc_slice_hash_table_get(const grpc_slice_hash_table *table,
+void* grpc_slice_hash_table_get(const grpc_slice_hash_table* table,
const grpc_slice key);
/** Compares \a a vs. \a b.
@@ -68,8 +68,8 @@ void *grpc_slice_hash_table_get(const grpc_slice_hash_table *table,
* - else, it contains fewer (resp. more) entries,
* - else, if strcmp(a_key, b_key) < 1 (resp. > 1),
* - else, if value_cmp(a_value, b_value) < 1 (resp. > 1). */
-int grpc_slice_hash_table_cmp(const grpc_slice_hash_table *a,
- const grpc_slice_hash_table *b);
+int grpc_slice_hash_table_cmp(const grpc_slice_hash_table* a,
+ const grpc_slice_hash_table* b);
#ifdef __cplusplus
}
diff --git a/src/core/lib/slice/slice_intern.cc b/src/core/lib/slice/slice_intern.cc
index 1ea9a2aa67..50a0eba49c 100644
--- a/src/core/lib/slice/slice_intern.cc
+++ b/src/core/lib/slice/slice_intern.cc
@@ -43,12 +43,12 @@ typedef struct interned_slice_refcount {
size_t length;
gpr_atm refcnt;
uint32_t hash;
- struct interned_slice_refcount *bucket_next;
+ struct interned_slice_refcount* bucket_next;
} interned_slice_refcount;
typedef struct slice_shard {
gpr_mu mu;
- interned_slice_refcount **strs;
+ interned_slice_refcount** strs;
size_t count;
size_t capacity;
} slice_shard;
@@ -69,17 +69,17 @@ static static_metadata_hash_ent
static uint32_t max_static_metadata_hash_probe;
static uint32_t static_metadata_hash_values[GRPC_STATIC_MDSTR_COUNT];
-static void interned_slice_ref(void *p) {
- interned_slice_refcount *s = (interned_slice_refcount *)p;
+static void interned_slice_ref(void* p) {
+ interned_slice_refcount* s = (interned_slice_refcount*)p;
GPR_ASSERT(gpr_atm_no_barrier_fetch_add(&s->refcnt, 1) > 0);
}
-static void interned_slice_destroy(interned_slice_refcount *s) {
- slice_shard *shard = &g_shards[SHARD_IDX(s->hash)];
+static void interned_slice_destroy(interned_slice_refcount* s) {
+ slice_shard* shard = &g_shards[SHARD_IDX(s->hash)];
gpr_mu_lock(&shard->mu);
GPR_ASSERT(0 == gpr_atm_no_barrier_load(&s->refcnt));
- interned_slice_refcount **prev_next;
- interned_slice_refcount *cur;
+ interned_slice_refcount** prev_next;
+ interned_slice_refcount* cur;
for (prev_next = &shard->strs[TABLE_IDX(s->hash, shard->capacity)],
cur = *prev_next;
cur != s; prev_next = &cur->bucket_next, cur = cur->bucket_next)
@@ -90,24 +90,24 @@ static void interned_slice_destroy(interned_slice_refcount *s) {
gpr_mu_unlock(&shard->mu);
}
-static void interned_slice_unref(grpc_exec_ctx *exec_ctx, void *p) {
- interned_slice_refcount *s = (interned_slice_refcount *)p;
+static void interned_slice_unref(grpc_exec_ctx* exec_ctx, void* p) {
+ interned_slice_refcount* s = (interned_slice_refcount*)p;
if (1 == gpr_atm_full_fetch_add(&s->refcnt, -1)) {
interned_slice_destroy(s);
}
}
-static void interned_slice_sub_ref(void *p) {
- interned_slice_ref(((char *)p) - offsetof(interned_slice_refcount, sub));
+static void interned_slice_sub_ref(void* p) {
+ interned_slice_ref(((char*)p) - offsetof(interned_slice_refcount, sub));
}
-static void interned_slice_sub_unref(grpc_exec_ctx *exec_ctx, void *p) {
+static void interned_slice_sub_unref(grpc_exec_ctx* exec_ctx, void* p) {
interned_slice_unref(exec_ctx,
- ((char *)p) - offsetof(interned_slice_refcount, sub));
+ ((char*)p) - offsetof(interned_slice_refcount, sub));
}
static uint32_t interned_slice_hash(grpc_slice slice) {
- interned_slice_refcount *s = (interned_slice_refcount *)slice.refcount;
+ interned_slice_refcount* s = (interned_slice_refcount*)slice.refcount;
return s->hash;
}
@@ -122,16 +122,16 @@ static const grpc_slice_refcount_vtable interned_slice_sub_vtable = {
interned_slice_sub_ref, interned_slice_sub_unref,
grpc_slice_default_eq_impl, grpc_slice_default_hash_impl};
-static void grow_shard(slice_shard *shard) {
+static void grow_shard(slice_shard* shard) {
size_t capacity = shard->capacity * 2;
size_t i;
- interned_slice_refcount **strtab;
+ interned_slice_refcount** strtab;
interned_slice_refcount *s, *next;
GPR_TIMER_BEGIN("grow_strtab", 0);
- strtab = (interned_slice_refcount **)gpr_zalloc(
- sizeof(interned_slice_refcount *) * capacity);
+ strtab = (interned_slice_refcount**)gpr_zalloc(
+ sizeof(interned_slice_refcount*) * capacity);
for (i = 0; i < shard->capacity; i++) {
for (s = shard->strs[i]; s; s = next) {
@@ -149,10 +149,10 @@ static void grow_shard(slice_shard *shard) {
GPR_TIMER_END("grow_strtab", 0);
}
-static grpc_slice materialize(interned_slice_refcount *s) {
+static grpc_slice materialize(interned_slice_refcount* s) {
grpc_slice slice;
slice.refcount = &s->base;
- slice.data.refcounted.bytes = (uint8_t *)(s + 1);
+ slice.data.refcounted.bytes = (uint8_t*)(s + 1);
slice.data.refcounted.length = s->length;
return slice;
}
@@ -176,7 +176,7 @@ uint32_t grpc_slice_hash(grpc_slice s) {
}
grpc_slice grpc_slice_maybe_static_intern(grpc_slice slice,
- bool *returned_slice_is_different) {
+ bool* returned_slice_is_different) {
if (GRPC_IS_STATIC_METADATA_STRING(slice)) {
return slice;
}
@@ -218,8 +218,8 @@ grpc_slice grpc_slice_intern(grpc_slice slice) {
}
}
- interned_slice_refcount *s;
- slice_shard *shard = &g_shards[SHARD_IDX(hash)];
+ interned_slice_refcount* s;
+ slice_shard* shard = &g_shards[SHARD_IDX(hash)];
gpr_mu_lock(&shard->mu);
@@ -244,8 +244,8 @@ grpc_slice grpc_slice_intern(grpc_slice slice) {
/* not found: create a new string */
/* string data goes after the internal_string header */
- s = (interned_slice_refcount *)gpr_malloc(sizeof(*s) +
- GRPC_SLICE_LENGTH(slice));
+ s = (interned_slice_refcount*)gpr_malloc(sizeof(*s) +
+ GRPC_SLICE_LENGTH(slice));
gpr_atm_rel_store(&s->refcnt, 1);
s->length = GRPC_SLICE_LENGTH(slice);
s->hash = hash;
@@ -279,12 +279,12 @@ void grpc_slice_intern_init(void) {
g_hash_seed = (uint32_t)gpr_now(GPR_CLOCK_REALTIME).tv_nsec;
}
for (size_t i = 0; i < SHARD_COUNT; i++) {
- slice_shard *shard = &g_shards[i];
+ slice_shard* shard = &g_shards[i];
gpr_mu_init(&shard->mu);
shard->count = 0;
shard->capacity = INITIAL_SHARD_CAPACITY;
- shard->strs = (interned_slice_refcount **)gpr_zalloc(sizeof(*shard->strs) *
- shard->capacity);
+ shard->strs = (interned_slice_refcount**)gpr_zalloc(sizeof(*shard->strs) *
+ shard->capacity);
}
for (size_t i = 0; i < GPR_ARRAY_SIZE(static_metadata_hash); i++) {
static_metadata_hash[i].hash = 0;
@@ -311,16 +311,16 @@ void grpc_slice_intern_init(void) {
void grpc_slice_intern_shutdown(void) {
for (size_t i = 0; i < SHARD_COUNT; i++) {
- slice_shard *shard = &g_shards[i];
+ slice_shard* shard = &g_shards[i];
gpr_mu_destroy(&shard->mu);
/* TODO(ctiller): GPR_ASSERT(shard->count == 0); */
if (shard->count != 0) {
gpr_log(GPR_DEBUG, "WARNING: %" PRIuPTR " metadata strings were leaked",
shard->count);
for (size_t j = 0; j < shard->capacity; j++) {
- for (interned_slice_refcount *s = shard->strs[j]; s;
+ for (interned_slice_refcount* s = shard->strs[j]; s;
s = s->bucket_next) {
- char *text =
+ char* text =
grpc_dump_slice(materialize(s), GPR_DUMP_HEX | GPR_DUMP_ASCII);
gpr_log(GPR_DEBUG, "LEAKED: %s", text);
gpr_free(text);
diff --git a/src/core/lib/slice/slice_internal.h b/src/core/lib/slice/slice_internal.h
index fcf70a0e55..2439fc0826 100644
--- a/src/core/lib/slice/slice_internal.h
+++ b/src/core/lib/slice/slice_internal.h
@@ -29,11 +29,11 @@ extern "C" {
#endif
grpc_slice grpc_slice_ref_internal(grpc_slice slice);
-void grpc_slice_unref_internal(grpc_exec_ctx *exec_ctx, grpc_slice slice);
-void grpc_slice_buffer_reset_and_unref_internal(grpc_exec_ctx *exec_ctx,
- grpc_slice_buffer *sb);
-void grpc_slice_buffer_destroy_internal(grpc_exec_ctx *exec_ctx,
- grpc_slice_buffer *sb);
+void grpc_slice_unref_internal(grpc_exec_ctx* exec_ctx, grpc_slice slice);
+void grpc_slice_buffer_reset_and_unref_internal(grpc_exec_ctx* exec_ctx,
+ grpc_slice_buffer* sb);
+void grpc_slice_buffer_destroy_internal(grpc_exec_ctx* exec_ctx,
+ grpc_slice_buffer* sb);
/* Check if a slice is interned */
bool grpc_slice_is_interned(grpc_slice slice);
@@ -46,7 +46,7 @@ void grpc_test_only_set_slice_hash_seed(uint32_t key);
// used for surface boundaries where we might receive an un-interned static
// string
grpc_slice grpc_slice_maybe_static_intern(grpc_slice slice,
- bool *returned_slice_is_different);
+ bool* returned_slice_is_different);
uint32_t grpc_static_slice_hash(grpc_slice s);
int grpc_static_slice_eq(grpc_slice a, grpc_slice b);
diff --git a/src/core/lib/slice/slice_string_helpers.cc b/src/core/lib/slice/slice_string_helpers.cc
index d461c474d2..5385be9866 100644
--- a/src/core/lib/slice/slice_string_helpers.cc
+++ b/src/core/lib/slice/slice_string_helpers.cc
@@ -25,8 +25,8 @@
#include "src/core/lib/slice/slice_internal.h"
#include "src/core/lib/support/string.h"
-char *grpc_dump_slice(grpc_slice s, uint32_t flags) {
- return gpr_dump((const char *)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s),
+char* grpc_dump_slice(grpc_slice s, uint32_t flags) {
+ return gpr_dump((const char*)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s),
flags);
}
@@ -35,11 +35,11 @@ char *grpc_dump_slice(grpc_slice s, uint32_t flags) {
* str.
*
* Returns 1 and updates \a begin and \a end. Returns 0 otherwise. */
-static int slice_find_separator_offset(const grpc_slice str, const char *sep,
- const size_t read_offset, size_t *begin,
- size_t *end) {
+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 = GRPC_SLICE_START_PTR(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) {
@@ -56,7 +56,7 @@ static int slice_find_separator_offset(const grpc_slice str, const char *sep,
return 0;
}
-void grpc_slice_split(grpc_slice str, const char *sep, grpc_slice_buffer *dst) {
+void grpc_slice_split(grpc_slice str, const char* sep, grpc_slice_buffer* dst) {
const size_t sep_len = strlen(sep);
size_t begin, end;
@@ -74,7 +74,7 @@ void grpc_slice_split(grpc_slice str, const char *sep, grpc_slice_buffer *dst) {
}
}
-bool grpc_parse_slice_to_uint32(grpc_slice str, uint32_t *result) {
- return gpr_parse_bytes_to_uint32((const char *)GRPC_SLICE_START_PTR(str),
+bool grpc_parse_slice_to_uint32(grpc_slice str, uint32_t* result) {
+ return gpr_parse_bytes_to_uint32((const char*)GRPC_SLICE_START_PTR(str),
GRPC_SLICE_LENGTH(str), result) != 0;
}
diff --git a/src/core/lib/slice/slice_string_helpers.h b/src/core/lib/slice/slice_string_helpers.h
index bcfb33bfb3..acbc41e711 100644
--- a/src/core/lib/slice/slice_string_helpers.h
+++ b/src/core/lib/slice/slice_string_helpers.h
@@ -33,13 +33,13 @@ extern "C" {
#endif
/* Calls gpr_dump on a slice. */
-char *grpc_dump_slice(grpc_slice slice, uint32_t flags);
+char* grpc_dump_slice(grpc_slice slice, uint32_t flags);
/** Split \a str by the separator \a sep. Results are stored in \a dst, which
* should be a properly initialized instance. */
-void grpc_slice_split(grpc_slice str, const char *sep, grpc_slice_buffer *dst);
+void grpc_slice_split(grpc_slice str, const char* sep, grpc_slice_buffer* dst);
-bool grpc_parse_slice_to_uint32(grpc_slice str, uint32_t *result);
+bool grpc_parse_slice_to_uint32(grpc_slice str, uint32_t* result);
#ifdef __cplusplus
}