aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/lib/surface/call.c
diff options
context:
space:
mode:
authorGravatar Craig Tiller <ctiller@google.com>2017-03-29 14:15:12 -0700
committerGravatar Craig Tiller <ctiller@google.com>2017-03-29 14:15:12 -0700
commitb58de7238981dc5fa3a18db4941bddca75c0d521 (patch)
treec5decbcc673a165597b39aec54f8be9cada9d0be /src/core/lib/surface/call.c
parent18cf15758c34d99eb65f7f6847bc8da7e142a0df (diff)
Lazily allocate batch control objects
Diffstat (limited to 'src/core/lib/surface/call.c')
-rw-r--r--src/core/lib/surface/call.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/core/lib/surface/call.c b/src/core/lib/surface/call.c
index 50ddbc92aa..03b1fbf11a 100644
--- a/src/core/lib/surface/call.c
+++ b/src/core/lib/surface/call.c
@@ -163,7 +163,7 @@ struct grpc_call {
/* have we received initial metadata */
bool has_initial_md_been_received;
- batch_control active_batches[MAX_CONCURRENT_BATCHES];
+ batch_control *active_batches[MAX_CONCURRENT_BATCHES];
grpc_transport_stream_op_payload stream_op_payload;
/* first idx: is_receiving, second idx: is_trailing */
@@ -1022,7 +1022,11 @@ static batch_control *allocate_batch_control(grpc_call *call,
const grpc_op *ops,
size_t num_ops) {
int slot = batch_slot_for_op(ops[0].op);
- batch_control *bctl = &call->active_batches[slot];
+ batch_control **pslot = &call->active_batches[slot];
+ if (*pslot == NULL) {
+ *pslot = gpr_arena_alloc(call->arena, sizeof(batch_control));
+ }
+ batch_control *bctl = *pslot;
if (bctl->call != NULL) {
return NULL;
}