diff options
author | Craig Tiller <ctiller@google.com> | 2015-02-03 11:55:13 -0800 |
---|---|---|
committer | Craig Tiller <ctiller@google.com> | 2015-02-03 11:55:13 -0800 |
commit | bd5920751ed66b886083250c8ef472470c6e2aec (patch) | |
tree | a066a3f20caab130b11acceebc300115823a124d | |
parent | d24480f3c897e133474bfc26ca34ac57521c4c4d (diff) |
Fix alloc of zero request
-rw-r--r-- | src/core/surface/byte_buffer_queue.c | 9 |
1 files changed, 4 insertions, 5 deletions
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 <grpc/support/alloc.h> +#include <grpc/support/useful.h> -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; } |