diff --git a/src/core/lib/compression/stream_compression_gzip.c b/src/core/lib/compression/stream_compression_gzip.c index 5d21bf27ae0..502bf44a913 100644 --- a/src/core/lib/compression/stream_compression_gzip.c +++ b/src/core/lib/compression/stream_compression_gzip.c @@ -19,7 +19,7 @@ #include #include -#include "src/core/lib/compression/stream_compression.h" +#include "src/core/lib/compression/stream_compression_gzip.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/slice/slice_internal.h" @@ -201,6 +201,7 @@ grpc_stream_compression_context_create_gzip( return NULL; } + gzip_ctx->base.vtable = &grpc_stream_compression_gzip_vtable; return (grpc_stream_compression_context *)gzip_ctx; } diff --git a/src/core/lib/compression/stream_compression_identity.c b/src/core/lib/compression/stream_compression_identity.c index 91ee06d7831..19eb6a9a00d 100644 --- a/src/core/lib/compression/stream_compression_identity.c +++ b/src/core/lib/compression/stream_compression_identity.c @@ -19,21 +19,30 @@ #include #include -#include "src/core/lib/compression/stream_compression.h" +#include "src/core/lib/compression/stream_compression_identity.h" #include "src/core/lib/iomgr/exec_ctx.h" #include "src/core/lib/slice/slice_internal.h" #define OUTPUT_BLOCK_SIZE (1024) +/* Singleton context used for all identity streams. */ +static grpc_stream_compression_context identity_ctx = { + .vtable = &grpc_stream_compression_identity_vtable +}; + static void grpc_stream_compression_pass_through(grpc_slice_buffer *in, grpc_slice_buffer *out, size_t *output_size, size_t max_output_size) { if (max_output_size >= in->length) { - *output_size = in->length; + if (output_size) { + *output_size = in->length; + } grpc_slice_buffer_move_into(in, out); } else { - *output_size = max_output_size; + if (output_size) { + *output_size = max_output_size; + } grpc_slice_buffer_move_first(in, max_output_size, out); } } @@ -59,7 +68,9 @@ static bool grpc_stream_decompress_identity( return false; } grpc_stream_compression_pass_through(in, out, output_size, max_output_size); - *end_of_context = false; + if (end_of_context) { + *end_of_context = false; + } return true; } @@ -69,7 +80,7 @@ grpc_stream_compression_context_create_identity( GPR_ASSERT(method == GRPC_STREAM_COMPRESSION_IDENTITY_COMPRESS || method == GRPC_STREAM_COMPRESSION_IDENTITY_DECOMPRESS); /* No context needed in this case. Use fake context instead. */ - return (grpc_stream_compression_context *)1; + return (grpc_stream_compression_context *)&identity_ctx; } static void grpc_stream_compression_context_destroy_identity(