aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/lib/slice
diff options
context:
space:
mode:
authorGravatar Noah Eisen <ncteisen@google.com>2018-02-09 09:34:04 -0800
committerGravatar Noah Eisen <ncteisen@google.com>2018-02-09 09:34:04 -0800
commit4d20a666850b732cf1562487fb5f46ab9654105f (patch)
tree9059162d0f125e02780f506c2476d5d9bbc0eb7d /src/core/lib/slice
parentcddf6f838aa48c8d5c9f75cee5a8ed8abdcb25b9 (diff)
Run clang fmt
Diffstat (limited to 'src/core/lib/slice')
-rw-r--r--src/core/lib/slice/b64.cc9
-rw-r--r--src/core/lib/slice/slice.cc20
-rw-r--r--src/core/lib/slice/slice_buffer.cc18
-rw-r--r--src/core/lib/slice/slice_hash_table.cc3
-rw-r--r--src/core/lib/slice/slice_intern.cc21
-rw-r--r--src/core/lib/slice/slice_string_helpers.cc9
6 files changed, 46 insertions, 34 deletions
diff --git a/src/core/lib/slice/b64.cc b/src/core/lib/slice/b64.cc
index 1d938be11c..3e19b7197f 100644
--- a/src/core/lib/slice/b64.cc
+++ b/src/core/lib/slice/b64.cc
@@ -128,13 +128,15 @@ grpc_slice grpc_base64_decode(const char* b64, int url_safe) {
static void decode_one_char(const unsigned char* codes, unsigned char* result,
size_t* result_offset) {
- uint32_t packed = (static_cast<uint32_t>(codes[0]) << 2) | (static_cast<uint32_t>(codes[1]) >> 4);
+ uint32_t packed = (static_cast<uint32_t>(codes[0]) << 2) |
+ (static_cast<uint32_t>(codes[1]) >> 4);
result[(*result_offset)++] = static_cast<unsigned char>(packed);
}
static void decode_two_chars(const unsigned char* codes, unsigned char* result,
size_t* result_offset) {
- uint32_t packed = (static_cast<uint32_t>(codes[0]) << 10) | (static_cast<uint32_t>(codes[1]) << 4) |
+ uint32_t packed = (static_cast<uint32_t>(codes[0]) << 10) |
+ (static_cast<uint32_t>(codes[1]) << 4) |
(static_cast<uint32_t>(codes[2]) >> 2);
result[(*result_offset)++] = static_cast<unsigned char>(packed >> 8);
result[(*result_offset)++] = static_cast<unsigned char>(packed);
@@ -175,7 +177,8 @@ static int decode_group(const unsigned char* codes, size_t num_codes,
decode_two_chars(codes, result, result_offset);
} else {
/* No padding. */
- uint32_t packed = (static_cast<uint32_t>(codes[0]) << 18) | (static_cast<uint32_t>(codes[1]) << 12) |
+ uint32_t packed = (static_cast<uint32_t>(codes[0]) << 18) |
+ (static_cast<uint32_t>(codes[1]) << 12) |
(static_cast<uint32_t>(codes[2]) << 6) | codes[3];
result[(*result_offset)++] = static_cast<unsigned char>(packed >> 16);
result[(*result_offset)++] = static_cast<unsigned char>(packed >> 8);
diff --git a/src/core/lib/slice/slice.cc b/src/core/lib/slice/slice.cc
index 136cce1d1e..476d941fbb 100644
--- a/src/core/lib/slice/slice.cc
+++ b/src/core/lib/slice/slice.cc
@@ -173,8 +173,8 @@ static const grpc_slice_refcount_vtable new_with_len_vtable = {
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 = static_cast<new_with_len_slice_refcount*>(gpr_malloc(
- sizeof(new_with_len_slice_refcount)));
+ new_with_len_slice_refcount* rc = static_cast<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;
rc->rc.sub_refcount = &rc->rc;
@@ -232,8 +232,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 =
- static_cast<malloc_refcount*>(gpr_malloc(sizeof(malloc_refcount) + length));
+ malloc_refcount* rc = static_cast<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. */
@@ -314,7 +314,8 @@ grpc_slice grpc_slice_split_tail_maybe_ref(grpc_slice* source, size_t split,
/* inlined data, copy it out */
GPR_ASSERT(source->data.inlined.length >= split);
tail.refcount = nullptr;
- tail.data.inlined.length = static_cast<uint8_t>(source->data.inlined.length - split);
+ tail.data.inlined.length =
+ static_cast<uint8_t>(source->data.inlined.length - split);
memcpy(tail.data.inlined.bytes, source->data.inlined.bytes + split,
tail.data.inlined.length);
source->data.inlined.length = static_cast<uint8_t>(split);
@@ -443,15 +444,15 @@ int grpc_slice_buf_start_eq(grpc_slice a, const void* b, size_t len) {
}
int grpc_slice_rchr(grpc_slice s, char c) {
- const char* b = reinterpret_cast<const char*>GRPC_SLICE_START_PTR(s);
+ const char* b = reinterpret_cast<const char*> GRPC_SLICE_START_PTR(s);
int i;
- for (i = static_cast<int>GRPC_SLICE_LENGTH(s) - 1; i != -1 && b[i] != c; i--)
+ for (i = static_cast<int> GRPC_SLICE_LENGTH(s) - 1; i != -1 && b[i] != c; i--)
;
return i;
}
int grpc_slice_chr(grpc_slice s, char c) {
- const char* b = reinterpret_cast<const char*>GRPC_SLICE_START_PTR(s);
+ const char* b = reinterpret_cast<const char*> GRPC_SLICE_START_PTR(s);
const char* p = static_cast<const char*>(memchr(b, c, GRPC_SLICE_LENGTH(s)));
return p == nullptr ? -1 : static_cast<int>(p - b);
}
@@ -466,7 +467,8 @@ int grpc_slice_slice(grpc_slice haystack, grpc_slice needle) {
if (haystack_len < needle_len) return -1;
if (haystack_len == needle_len)
return grpc_slice_eq(haystack, needle) ? 0 : -1;
- if (needle_len == 1) return grpc_slice_chr(haystack, static_cast<char>(*needle_bytes));
+ if (needle_len == 1)
+ return grpc_slice_chr(haystack, static_cast<char>(*needle_bytes));
const uint8_t* last = haystack_bytes + haystack_len - needle_len;
for (const uint8_t* cur = haystack_bytes; cur != last; ++cur) {
diff --git a/src/core/lib/slice/slice_buffer.cc b/src/core/lib/slice/slice_buffer.cc
index 84a2b5f6d9..0416c9d371 100644
--- a/src/core/lib/slice/slice_buffer.cc
+++ b/src/core/lib/slice/slice_buffer.cc
@@ -45,12 +45,12 @@ static void maybe_embiggen(grpc_slice_buffer* sb) {
sb->capacity = GROW(sb->capacity);
GPR_ASSERT(sb->capacity > slice_count);
if (sb->base_slices == sb->inlined) {
- sb->base_slices =
- static_cast<grpc_slice*>(gpr_malloc(sb->capacity * sizeof(grpc_slice)));
+ sb->base_slices = static_cast<grpc_slice*>(
+ gpr_malloc(sb->capacity * sizeof(grpc_slice)));
memcpy(sb->base_slices, sb->inlined, slice_count * sizeof(grpc_slice));
} else {
- sb->base_slices = static_cast<grpc_slice*>(gpr_realloc(
- sb->base_slices, sb->capacity * sizeof(grpc_slice)));
+ sb->base_slices = static_cast<grpc_slice*>(
+ gpr_realloc(sb->base_slices, sb->capacity * sizeof(grpc_slice)));
}
sb->slices = sb->base_slices + slice_offset;
@@ -89,7 +89,8 @@ uint8_t* grpc_slice_buffer_tiny_add(grpc_slice_buffer* sb, size_t n) {
if ((back->data.inlined.length + n) > sizeof(back->data.inlined.bytes))
goto add_new;
out = back->data.inlined.bytes + back->data.inlined.length;
- back->data.inlined.length = static_cast<uint8_t>(back->data.inlined.length + n);
+ back->data.inlined.length =
+ static_cast<uint8_t>(back->data.inlined.length + n);
return out;
add_new:
@@ -125,8 +126,8 @@ void grpc_slice_buffer_add(grpc_slice_buffer* sb, grpc_slice s) {
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 =
- static_cast<uint8_t>(back->data.inlined.length + s.data.inlined.length);
+ back->data.inlined.length = static_cast<uint8_t>(
+ back->data.inlined.length + s.data.inlined.length);
} else {
size_t cp1 = GRPC_SLICE_INLINED_SIZE - back->data.inlined.length;
memcpy(back->data.inlined.bytes + back->data.inlined.length,
@@ -136,7 +137,8 @@ void grpc_slice_buffer_add(grpc_slice_buffer* sb, grpc_slice s) {
back = &sb->slices[n];
sb->count = n + 1;
back->refcount = nullptr;
- back->data.inlined.length = static_cast<uint8_t>(s.data.inlined.length - cp1);
+ back->data.inlined.length =
+ static_cast<uint8_t>(s.data.inlined.length - cp1);
memcpy(back->data.inlined.bytes, s.data.inlined.bytes + cp1,
s.data.inlined.length - cp1);
}
diff --git a/src/core/lib/slice/slice_hash_table.cc b/src/core/lib/slice/slice_hash_table.cc
index 1818b126ca..2342e90485 100644
--- a/src/core/lib/slice/slice_hash_table.cc
+++ b/src/core/lib/slice/slice_hash_table.cc
@@ -67,7 +67,8 @@ grpc_slice_hash_table* grpc_slice_hash_table_create(
// Keep load factor low to improve performance of lookups.
table->size = num_entries * 2;
const size_t entry_size = sizeof(grpc_slice_hash_table_entry) * table->size;
- table->entries = static_cast<grpc_slice_hash_table_entry*>(gpr_zalloc(entry_size));
+ table->entries =
+ static_cast<grpc_slice_hash_table_entry*>(gpr_zalloc(entry_size));
for (size_t i = 0; i < num_entries; ++i) {
grpc_slice_hash_table_entry* entry = &entries[i];
grpc_slice_hash_table_add(table, entry->key, entry->value);
diff --git a/src/core/lib/slice/slice_intern.cc b/src/core/lib/slice/slice_intern.cc
index f4aad73e0f..2d633c4903 100644
--- a/src/core/lib/slice/slice_intern.cc
+++ b/src/core/lib/slice/slice_intern.cc
@@ -98,15 +98,18 @@ static void interned_slice_unref(void* p) {
}
static void interned_slice_sub_ref(void* p) {
- interned_slice_ref((static_cast<char*>(p)) - offsetof(interned_slice_refcount, sub));
+ interned_slice_ref((static_cast<char*>(p)) -
+ offsetof(interned_slice_refcount, sub));
}
static void interned_slice_sub_unref(void* p) {
- interned_slice_unref((static_cast<char*>(p)) - offsetof(interned_slice_refcount, sub));
+ interned_slice_unref((static_cast<char*>(p)) -
+ offsetof(interned_slice_refcount, sub));
}
static uint32_t interned_slice_hash(grpc_slice slice) {
- interned_slice_refcount* s = reinterpret_cast<interned_slice_refcount*>(slice.refcount);
+ interned_slice_refcount* s =
+ reinterpret_cast<interned_slice_refcount*>(slice.refcount);
return s->hash;
}
@@ -129,8 +132,8 @@ static void grow_shard(slice_shard* shard) {
interned_slice_refcount** strtab;
interned_slice_refcount *s, *next;
- strtab = static_cast<interned_slice_refcount**>(gpr_zalloc(
- sizeof(interned_slice_refcount*) * capacity));
+ strtab = static_cast<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) {
@@ -237,8 +240,8 @@ grpc_slice grpc_slice_intern(grpc_slice slice) {
/* not found: create a new string */
/* string data goes after the internal_string header */
- s = static_cast<interned_slice_refcount*>(gpr_malloc(sizeof(*s) +
- GRPC_SLICE_LENGTH(slice)));
+ s = static_cast<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;
@@ -275,8 +278,8 @@ void grpc_slice_intern_init(void) {
gpr_mu_init(&shard->mu);
shard->count = 0;
shard->capacity = INITIAL_SHARD_CAPACITY;
- shard->strs = static_cast<interned_slice_refcount**>(gpr_zalloc(sizeof(*shard->strs) *
- shard->capacity));
+ shard->strs = static_cast<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;
diff --git a/src/core/lib/slice/slice_string_helpers.cc b/src/core/lib/slice/slice_string_helpers.cc
index 2015040c12..f91ece3b98 100644
--- a/src/core/lib/slice/slice_string_helpers.cc
+++ b/src/core/lib/slice/slice_string_helpers.cc
@@ -26,8 +26,8 @@
#include "src/core/lib/slice/slice_internal.h"
char* grpc_dump_slice(grpc_slice s, uint32_t flags) {
- return gpr_dump(reinterpret_cast<const char*>GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s),
- flags);
+ return gpr_dump(reinterpret_cast<const char*> GRPC_SLICE_START_PTR(s),
+ GRPC_SLICE_LENGTH(s), flags);
}
/** Finds the initial (\a begin) and final (\a end) offsets of the next
@@ -110,6 +110,7 @@ void grpc_slice_split_without_space(grpc_slice str, const char* sep,
}
bool grpc_parse_slice_to_uint32(grpc_slice str, uint32_t* result) {
- return gpr_parse_bytes_to_uint32(reinterpret_cast<const char*>GRPC_SLICE_START_PTR(str),
- GRPC_SLICE_LENGTH(str), result) != 0;
+ return gpr_parse_bytes_to_uint32(
+ reinterpret_cast<const char*> GRPC_SLICE_START_PTR(str),
+ GRPC_SLICE_LENGTH(str), result) != 0;
}