From bd5920751ed66b886083250c8ef472470c6e2aec Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Tue, 3 Feb 2015 11:55:13 -0800 Subject: Fix alloc of zero request --- src/core/surface/byte_buffer_queue.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/core') diff --git a/src/core/surface/byte_buffer_queue.c b/src/core/surface/byte_buffer_queue.c index 36c082f484..dc280a60c5 100644 --- a/src/core/surface/byte_buffer_queue.c +++ b/src/core/surface/byte_buffer_queue.c @@ -33,16 +33,15 @@ #include "src/core/surface/byte_buffer_queue.h" #include +#include -static void bba_destroy(grpc_bbq_array *array) { - gpr_free(array->data); -} +static void bba_destroy(grpc_bbq_array *array) { gpr_free(array->data); } /* Append an operation to an array, expanding as needed */ static void bba_push(grpc_bbq_array *a, grpc_byte_buffer *buffer) { if (a->count == a->capacity) { - a->capacity *= 2; - a->data = gpr_realloc(a->data, sizeof(grpc_byte_buffer*) * a->capacity); + a->capacity = GPR_MAX(a->capacity * 2, 8); + a->data = gpr_realloc(a->data, sizeof(grpc_byte_buffer *) * a->capacity); } a->data[a->count++] = buffer; } -- cgit v1.2.3