Skip to content
Snippets Groups Projects
Commit ac9a6031 authored by Craig Tiller's avatar Craig Tiller
Browse files

Sprinkle constants here and there

parent 9d77ed5e
No related branches found
No related tags found
No related merge requests found
...@@ -117,8 +117,9 @@ void grpc_chttp2_encode_data(uint32_t id, gpr_slice_buffer *inbuf, ...@@ -117,8 +117,9 @@ void grpc_chttp2_encode_data(uint32_t id, gpr_slice_buffer *inbuf,
gpr_slice_buffer *outbuf) { gpr_slice_buffer *outbuf) {
gpr_slice hdr; gpr_slice hdr;
uint8_t *p; uint8_t *p;
static const size_t header_size = 9;
hdr = gpr_slice_malloc(9); hdr = gpr_slice_malloc(header_size);
p = GPR_SLICE_START_PTR(hdr); p = GPR_SLICE_START_PTR(hdr);
GPR_ASSERT(write_bytes < (1 << 24)); GPR_ASSERT(write_bytes < (1 << 24));
*p++ = (uint8_t)(write_bytes >> 16); *p++ = (uint8_t)(write_bytes >> 16);
...@@ -134,7 +135,7 @@ void grpc_chttp2_encode_data(uint32_t id, gpr_slice_buffer *inbuf, ...@@ -134,7 +135,7 @@ void grpc_chttp2_encode_data(uint32_t id, gpr_slice_buffer *inbuf,
gpr_slice_buffer_move_first(inbuf, write_bytes, outbuf); gpr_slice_buffer_move_first(inbuf, write_bytes, outbuf);
stats->framing_bytes += 9; stats->framing_bytes += header_size;
stats->data_bytes += write_bytes; stats->data_bytes += write_bytes;
} }
......
...@@ -40,8 +40,9 @@ ...@@ -40,8 +40,9 @@
gpr_slice grpc_chttp2_rst_stream_create(uint32_t id, uint32_t code, gpr_slice grpc_chttp2_rst_stream_create(uint32_t id, uint32_t code,
grpc_transport_one_way_stats *stats) { grpc_transport_one_way_stats *stats) {
gpr_slice slice = gpr_slice_malloc(13); static const size_t frame_size = 13;
stats->framing_bytes += 13; gpr_slice slice = gpr_slice_malloc(frame_size);
stats->framing_bytes += frame_size;
uint8_t *p = GPR_SLICE_START_PTR(slice); uint8_t *p = GPR_SLICE_START_PTR(slice);
*p++ = 0; *p++ = 0;
......
...@@ -38,8 +38,9 @@ ...@@ -38,8 +38,9 @@
gpr_slice grpc_chttp2_window_update_create( gpr_slice grpc_chttp2_window_update_create(
uint32_t id, uint32_t window_update, grpc_transport_one_way_stats *stats) { uint32_t id, uint32_t window_update, grpc_transport_one_way_stats *stats) {
gpr_slice slice = gpr_slice_malloc(13); static const size_t frame_size = 13;
stats->header_bytes += 13; gpr_slice slice = gpr_slice_malloc(frame_size);
stats->header_bytes += frame_size;
uint8_t *p = GPR_SLICE_START_PTR(slice); uint8_t *p = GPR_SLICE_START_PTR(slice);
GPR_ASSERT(window_update); GPR_ASSERT(window_update);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment