PHP_GRPC_FREE_STD_ZVAL(inner_array);
}
efree(str_key);
+#if PHP_MAJOR_VERSION >= 7
efree(str_val);
+#endif
}
return array;
}
int cancelled;
grpc_call_error error;
+ #if PHP_MAJOR_VERSION < 7
+ char *message_str;
+ size_t message_len;
+ #else
zend_string* zmessage = NULL;
+ #endif // PHP_MAJOR_VERSION < 7
grpc_metadata_array_init(&metadata);
grpc_metadata_array_init(&trailing_metadata);
}
grpc_completion_queue_pluck(completion_queue, call->wrapped,
gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
+#if PHP_MAJOR_VERSION >= 7
zval *recv_md;
+#endif
for (int i = 0; i < op_num; i++) {
switch(ops[i].op) {
case GRPC_OP_SEND_INITIAL_METADATA:
add_property_bool(result, "send_status", true);
break;
case GRPC_OP_RECV_INITIAL_METADATA:
+#if PHP_MAJOR_VERSION < 7
+ array = grpc_parse_metadata_array(&recv_metadata TSRMLS_CC);
+ add_property_zval(result, "metadata", array);
+#else
recv_md = grpc_parse_metadata_array(&recv_metadata);
add_property_zval(result, "metadata", recv_md);
zval_ptr_dtor(recv_md);
PHP_GRPC_FREE_STD_ZVAL(recv_md);
+#endif
PHP_GRPC_DELREF(array);
break;
case GRPC_OP_RECV_MESSAGE:
+#if PHP_MAJOR_VERSION < 7
+ byte_buffer_to_string(message, &message_str, &message_len);
+#else
zmessage = byte_buffer_to_zend_string(message);
+#endif // PHP_MAJOR_VERSION < 7
+#if PHP_MAJOR_VERSION < 7
+ if (message_str == NULL) {
+#else
if (zmessage == NULL) {
+#endif // PHP_MAJOR_VERSION < 7
add_property_null(result, "message");
} else {
+#if PHP_MAJOR_VERSION < 7
+ php_grpc_add_property_stringl(result, "message", message_str,
+ message_len, false);
+#else
zval zmessage_val;
ZVAL_NEW_STR(&zmessage_val, zmessage);
add_property_zval(result, "message", &zmessage_val);
zval_ptr_dtor(&zmessage_val);
+#endif // PHP_MAJOR_VERSION < 7
}
break;
case GRPC_OP_RECV_STATUS_ON_CLIENT:
PHP_GRPC_MAKE_STD_ZVAL(recv_status);
object_init(recv_status);
+#if PHP_MAJOR_VERSION < 7
+ array = grpc_parse_metadata_array(&recv_trailing_metadata TSRMLS_CC);
+ add_property_zval(recv_status, "metadata", array);
+#else
recv_md = grpc_parse_metadata_array(&recv_trailing_metadata);
add_property_zval(recv_status, "metadata", recv_md);
zval_ptr_dtor(recv_md);
PHP_GRPC_FREE_STD_ZVAL(recv_md);
+#endif
PHP_GRPC_DELREF(array);
add_property_long(recv_status, "code", status);
char *status_details_text = grpc_slice_to_c_string(recv_status_details);
true);
gpr_free(status_details_text);
add_property_zval(result, "status", recv_status);
+#if PHP_MAJOR_VERSION >= 7
zval_ptr_dtor(recv_status);
+#endif
PHP_GRPC_DELREF(recv_status);
PHP_GRPC_FREE_STD_ZVAL(recv_status);
break;
}
if (ops[i].op == GRPC_OP_RECV_MESSAGE) {
grpc_byte_buffer_destroy(message);
+ #if PHP_MAJOR_VERSION < 7
+ PHP_GRPC_FREE_STD_ZVAL(message_str);
+ #endif // PHP_MAJOR_VERSION < 7
}
}
RETURN_DESTROY_ZVAL(result);