diff options
Diffstat (limited to 'src/php/ext')
-rw-r--r-- | src/php/ext/grpc/call.c | 16 | ||||
-rw-r--r-- | src/php/ext/grpc/call.h | 3 |
2 files changed, 16 insertions, 3 deletions
diff --git a/src/php/ext/grpc/call.c b/src/php/ext/grpc/call.c index c4997f720d..9c0f3f8a91 100644 --- a/src/php/ext/grpc/call.c +++ b/src/php/ext/grpc/call.c @@ -174,6 +174,18 @@ bool create_metadata_array(zval *array, grpc_metadata_array *metadata) { return true; } +void grpc_php_metadata_array_destroy_including_entries( + grpc_metadata_array* array) { + size_t i; + if (array->metadata) { + for (i = 0; i < array->count; i++) { + grpc_slice_unref(array->metadata[i].key); + grpc_slice_unref(array->metadata[i].value); + } + } + grpc_metadata_array_destroy(array); +} + /* Wraps a grpc_call struct in a PHP object. Owned indicates whether the struct should be destroyed at the end of the object's lifecycle */ zval *grpc_php_wrap_call(grpc_call *wrapped, bool owned TSRMLS_DC) { @@ -502,8 +514,8 @@ PHP_METHOD(Call, startBatch) { } cleanup: - grpc_metadata_array_destroy(&metadata); - grpc_metadata_array_destroy(&trailing_metadata); + grpc_php_metadata_array_destroy_including_entries(&metadata); + grpc_php_metadata_array_destroy_including_entries(&trailing_metadata); grpc_metadata_array_destroy(&recv_metadata); grpc_metadata_array_destroy(&recv_trailing_metadata); grpc_slice_unref(recv_status_details); diff --git a/src/php/ext/grpc/call.h b/src/php/ext/grpc/call.h index 5bde5d5390..104ac301c1 100644 --- a/src/php/ext/grpc/call.h +++ b/src/php/ext/grpc/call.h @@ -69,5 +69,6 @@ void grpc_init_call(TSRMLS_D); /* Populates a grpc_metadata_array with the data in a PHP array object. Returns true on success and false on failure */ bool create_metadata_array(zval *array, grpc_metadata_array *metadata); - +void grpc_php_metadata_array_destroy_including_entries( + grpc_metadata_array* array); #endif /* NET_GRPC_PHP_GRPC_CHANNEL_H_ */ |