Update clang-format to 5.0
diff --git a/src/ruby/ext/grpc/rb_byte_buffer.c b/src/ruby/ext/grpc/rb_byte_buffer.c
index 8aa7a7e..e11c7e8 100644
--- a/src/ruby/ext/grpc/rb_byte_buffer.c
+++ b/src/ruby/ext/grpc/rb_byte_buffer.c
@@ -26,14 +26,14 @@
#include <grpc/slice.h>
#include "rb_grpc.h"
-grpc_byte_buffer *grpc_rb_s_to_byte_buffer(char *string, size_t length) {
+grpc_byte_buffer* grpc_rb_s_to_byte_buffer(char* string, size_t length) {
grpc_slice slice = grpc_slice_from_copied_buffer(string, length);
- grpc_byte_buffer *buffer = grpc_raw_byte_buffer_create(&slice, 1);
+ grpc_byte_buffer* buffer = grpc_raw_byte_buffer_create(&slice, 1);
grpc_slice_unref(slice);
return buffer;
}
-VALUE grpc_rb_byte_buffer_to_s(grpc_byte_buffer *buffer) {
+VALUE grpc_rb_byte_buffer_to_s(grpc_byte_buffer* buffer) {
VALUE rb_string;
grpc_byte_buffer_reader reader;
grpc_slice next;
@@ -46,7 +46,7 @@
return Qnil;
}
while (grpc_byte_buffer_reader_next(&reader, &next) != 0) {
- rb_str_cat(rb_string, (const char *)GRPC_SLICE_START_PTR(next),
+ rb_str_cat(rb_string, (const char*)GRPC_SLICE_START_PTR(next),
GRPC_SLICE_LENGTH(next));
grpc_slice_unref(next);
}
@@ -59,6 +59,6 @@
rb_raise(rb_eRuntimeError,
"attempt to convert uninitialized grpc_slice to ruby string");
}
- return rb_str_new((char *)GRPC_SLICE_START_PTR(slice),
+ return rb_str_new((char*)GRPC_SLICE_START_PTR(slice),
GRPC_SLICE_LENGTH(slice));
}
diff --git a/src/ruby/ext/grpc/rb_byte_buffer.h b/src/ruby/ext/grpc/rb_byte_buffer.h
index c64a990..9cb58aa 100644
--- a/src/ruby/ext/grpc/rb_byte_buffer.h
+++ b/src/ruby/ext/grpc/rb_byte_buffer.h
@@ -24,10 +24,10 @@
#include <grpc/grpc.h>
/* Converts a char* with a length to a grpc_byte_buffer */
-grpc_byte_buffer *grpc_rb_s_to_byte_buffer(char *string, size_t length);
+grpc_byte_buffer* grpc_rb_s_to_byte_buffer(char* string, size_t length);
/* Converts a grpc_byte_buffer to a ruby string */
-VALUE grpc_rb_byte_buffer_to_s(grpc_byte_buffer *buffer);
+VALUE grpc_rb_byte_buffer_to_s(grpc_byte_buffer* buffer);
/* Converts a grpc_slice to a ruby string */
VALUE grpc_rb_slice_to_ruby_string(grpc_slice slice);
diff --git a/src/ruby/ext/grpc/rb_call.c b/src/ruby/ext/grpc/rb_call.c
index e920fc8..7f3ca2a 100644
--- a/src/ruby/ext/grpc/rb_call.c
+++ b/src/ruby/ext/grpc/rb_call.c
@@ -24,7 +24,6 @@
#include <grpc/grpc.h>
#include <grpc/impl/codegen/compression_types.h>
#include <grpc/support/alloc.h>
-#include <grpc/support/alloc.h>
#include <grpc/support/log.h>
#include "rb_byte_buffer.h"
@@ -81,11 +80,11 @@
static VALUE sym_cancelled;
typedef struct grpc_rb_call {
- grpc_call *wrapped;
- grpc_completion_queue *queue;
+ grpc_call* wrapped;
+ grpc_completion_queue* queue;
} grpc_rb_call;
-static void destroy_call(grpc_rb_call *call) {
+static void destroy_call(grpc_rb_call* call) {
/* Ensure that we only try to destroy the call once */
if (call->wrapped != NULL) {
grpc_call_unref(call->wrapped);
@@ -96,19 +95,19 @@
}
/* Destroys a Call. */
-static void grpc_rb_call_destroy(void *p) {
+static void grpc_rb_call_destroy(void* p) {
if (p == NULL) {
return;
}
- destroy_call((grpc_rb_call *)p);
+ destroy_call((grpc_rb_call*)p);
xfree(p);
}
-static size_t md_ary_datasize(const void *p) {
- const grpc_metadata_array *const ary = (grpc_metadata_array *)p;
+static size_t md_ary_datasize(const void* p) {
+ const grpc_metadata_array* const ary = (grpc_metadata_array*)p;
size_t i, datasize = sizeof(grpc_metadata_array);
for (i = 0; i < ary->count; ++i) {
- const grpc_metadata *const md = &ary->metadata[i];
+ const grpc_metadata* const md = &ary->metadata[i];
datasize += GRPC_SLICE_LENGTH(md->key);
datasize += GRPC_SLICE_LENGTH(md->value);
}
@@ -151,9 +150,9 @@
VALUE rb_error_code_details;
/* Obtains the error detail string for given error code */
-const char *grpc_call_error_detail_of(grpc_call_error err) {
+const char* grpc_call_error_detail_of(grpc_call_error err) {
VALUE detail_ref = rb_hash_aref(rb_error_code_details, UINT2NUM(err));
- const char *detail = "unknown error code!";
+ const char* detail = "unknown error code!";
if (detail_ref != Qnil) {
detail = StringValueCStr(detail_ref);
}
@@ -163,7 +162,7 @@
/* Called by clients to cancel an RPC on the server.
Can be called multiple times, from any thread. */
static VALUE grpc_rb_call_cancel(VALUE self) {
- grpc_rb_call *call = NULL;
+ grpc_rb_call* call = NULL;
grpc_call_error err;
if (RTYPEDDATA_DATA(self) == NULL) {
// This call has been closed
@@ -187,7 +186,7 @@
* message. */
static VALUE grpc_rb_call_cancel_with_status(VALUE self, VALUE status_code,
VALUE details) {
- grpc_rb_call *call = NULL;
+ grpc_rb_call* call = NULL;
grpc_call_error err;
if (RTYPEDDATA_DATA(self) == NULL) {
// This call has been closed
@@ -217,7 +216,7 @@
processed.
*/
static VALUE grpc_rb_call_close(VALUE self) {
- grpc_rb_call *call = NULL;
+ grpc_rb_call* call = NULL;
TypedData_Get_Struct(self, grpc_rb_call, &grpc_call_data_type, call);
if (call != NULL) {
destroy_call(call);
@@ -230,8 +229,8 @@
/* Called to obtain the peer that this call is connected to. */
static VALUE grpc_rb_call_get_peer(VALUE self) {
VALUE res = Qnil;
- grpc_rb_call *call = NULL;
- char *peer = NULL;
+ grpc_rb_call* call = NULL;
+ char* peer = NULL;
if (RTYPEDDATA_DATA(self) == NULL) {
rb_raise(grpc_rb_eCallError, "Cannot get peer value on closed call");
return Qnil;
@@ -246,9 +245,9 @@
/* Called to obtain the x509 cert of an authenticated peer. */
static VALUE grpc_rb_call_get_peer_cert(VALUE self) {
- grpc_rb_call *call = NULL;
+ grpc_rb_call* call = NULL;
VALUE res = Qnil;
- grpc_auth_context *ctx = NULL;
+ grpc_auth_context* ctx = NULL;
if (RTYPEDDATA_DATA(self) == NULL) {
rb_raise(grpc_rb_eCallError, "Cannot get peer cert on closed call");
return Qnil;
@@ -264,7 +263,7 @@
{
grpc_auth_property_iterator it = grpc_auth_context_find_properties_by_name(
ctx, GRPC_X509_PEM_CERT_PROPERTY_NAME);
- const grpc_auth_property *prop = grpc_auth_property_iterator_next(&it);
+ const grpc_auth_property* prop = grpc_auth_property_iterator_next(&it);
if (prop == NULL) {
return Qnil;
}
@@ -379,8 +378,8 @@
Sets credentials on a call */
static VALUE grpc_rb_call_set_credentials(VALUE self, VALUE credentials) {
- grpc_rb_call *call = NULL;
- grpc_call_credentials *creds;
+ grpc_rb_call* call = NULL;
+ grpc_call_credentials* creds;
grpc_call_error err;
if (RTYPEDDATA_DATA(self) == NULL) {
rb_raise(grpc_rb_eCallError, "Cannot set credentials of closed call");
@@ -407,12 +406,12 @@
grpc_rb_md_ary_capacity_hash_cb
*/
static int grpc_rb_md_ary_fill_hash_cb(VALUE key, VALUE val, VALUE md_ary_obj) {
- grpc_metadata_array *md_ary = NULL;
+ grpc_metadata_array* md_ary = NULL;
long array_length;
long i;
grpc_slice key_slice;
grpc_slice value_slice;
- char *tmp_str = NULL;
+ char* tmp_str = NULL;
if (TYPE(key) == T_SYMBOL) {
key_slice = grpc_slice_from_static_string(rb_id2name(SYM2ID(key)));
@@ -482,7 +481,7 @@
*/
static int grpc_rb_md_ary_capacity_hash_cb(VALUE key, VALUE val,
VALUE md_ary_obj) {
- grpc_metadata_array *md_ary = NULL;
+ grpc_metadata_array* md_ary = NULL;
(void)key;
@@ -503,7 +502,7 @@
/* grpc_rb_md_ary_convert converts a ruby metadata hash into
a grpc_metadata_array.
*/
-void grpc_rb_md_ary_convert(VALUE md_ary_hash, grpc_metadata_array *md_ary) {
+void grpc_rb_md_ary_convert(VALUE md_ary_hash, grpc_metadata_array* md_ary) {
VALUE md_ary_obj = Qnil;
if (md_ary_hash == Qnil) {
return; /* Do nothing if the expected has value is nil */
@@ -524,7 +523,7 @@
}
/* Converts a metadata array to a hash. */
-VALUE grpc_rb_md_ary_to_h(grpc_metadata_array *md_ary) {
+VALUE grpc_rb_md_ary_to_h(grpc_metadata_array* md_ary) {
VALUE key = Qnil;
VALUE new_ary = Qnil;
VALUE value = Qnil;
@@ -587,7 +586,7 @@
struct to the 'send_status_from_server' portion of an op.
*/
static void grpc_rb_op_update_status_from_server(
- grpc_op *op, grpc_metadata_array *md_ary, grpc_slice *send_status_details,
+ grpc_op* op, grpc_metadata_array* md_ary, grpc_slice* send_status_details,
VALUE status) {
VALUE code = rb_struct_aref(status, sym_code);
VALUE details = rb_struct_aref(status, sym_details);
@@ -627,7 +626,7 @@
grpc_metadata_array send_trailing_metadata;
/* Data being received */
- grpc_byte_buffer *recv_message;
+ grpc_byte_buffer* recv_message;
grpc_metadata_array recv_metadata;
grpc_metadata_array recv_trailing_metadata;
int recv_cancelled;
@@ -639,7 +638,7 @@
/* grpc_run_batch_stack_init ensures the run_batch_stack is properly
* initialized */
-static void grpc_run_batch_stack_init(run_batch_stack *st,
+static void grpc_run_batch_stack_init(run_batch_stack* st,
unsigned write_flag) {
MEMZERO(st, run_batch_stack, 1);
grpc_metadata_array_init(&st->send_metadata);
@@ -651,7 +650,7 @@
}
void grpc_rb_metadata_array_destroy_including_entries(
- grpc_metadata_array *array) {
+ grpc_metadata_array* array) {
size_t i;
if (array->metadata) {
for (i = 0; i < array->count; i++) {
@@ -664,7 +663,7 @@
/* grpc_run_batch_stack_cleanup ensures the run_batch_stack is properly
* cleaned up */
-static void grpc_run_batch_stack_cleanup(run_batch_stack *st) {
+static void grpc_run_batch_stack_cleanup(run_batch_stack* st) {
size_t i = 0;
grpc_rb_metadata_array_destroy_including_entries(&st->send_metadata);
@@ -693,7 +692,7 @@
/* grpc_run_batch_stack_fill_ops fills the run_batch_stack ops array from
* ops_hash */
-static void grpc_run_batch_stack_fill_ops(run_batch_stack *st, VALUE ops_hash) {
+static void grpc_run_batch_stack_fill_ops(run_batch_stack* st, VALUE ops_hash) {
VALUE this_op = Qnil;
VALUE this_value = Qnil;
VALUE ops_ary = rb_ary_new();
@@ -760,7 +759,7 @@
/* grpc_run_batch_stack_build_result fills constructs a ruby BatchResult struct
after the results have run */
-static VALUE grpc_run_batch_stack_build_result(run_batch_stack *st) {
+static VALUE grpc_run_batch_stack_build_result(run_batch_stack* st) {
size_t i = 0;
VALUE result = rb_struct_new(grpc_rb_sBatchResult, Qnil, Qnil, Qnil, Qnil,
Qnil, Qnil, Qnil, Qnil, NULL);
@@ -823,14 +822,14 @@
Only one operation of each type can be active at once in any given
batch */
static VALUE grpc_rb_call_run_batch(VALUE self, VALUE ops_hash) {
- run_batch_stack *st = NULL;
- grpc_rb_call *call = NULL;
+ run_batch_stack* st = NULL;
+ grpc_rb_call* call = NULL;
grpc_event ev;
grpc_call_error err;
VALUE result = Qnil;
VALUE rb_write_flag = rb_ivar_get(self, id_write_flag);
unsigned write_flag = 0;
- void *tag = (void *)&st;
+ void* tag = (void*)&st;
if (RTYPEDDATA_DATA(self) == NULL) {
rb_raise(grpc_rb_eCallError, "Cannot run batch on closed call");
@@ -997,8 +996,8 @@
rb_define_method(grpc_rb_cCall, "metadata=", grpc_rb_call_set_metadata, 1);
rb_define_method(grpc_rb_cCall, "trailing_metadata",
grpc_rb_call_get_trailing_metadata, 0);
- rb_define_method(grpc_rb_cCall, "trailing_metadata=",
- grpc_rb_call_set_trailing_metadata, 1);
+ rb_define_method(grpc_rb_cCall,
+ "trailing_metadata=", grpc_rb_call_set_trailing_metadata, 1);
rb_define_method(grpc_rb_cCall, "write_flag", grpc_rb_call_get_write_flag, 0);
rb_define_method(grpc_rb_cCall, "write_flag=", grpc_rb_call_set_write_flag,
1);
@@ -1035,15 +1034,15 @@
}
/* Gets the call from the ruby object */
-grpc_call *grpc_rb_get_wrapped_call(VALUE v) {
- grpc_rb_call *call = NULL;
+grpc_call* grpc_rb_get_wrapped_call(VALUE v) {
+ grpc_rb_call* call = NULL;
TypedData_Get_Struct(v, grpc_rb_call, &grpc_call_data_type, call);
return call->wrapped;
}
/* Obtains the wrapped object for a given call */
-VALUE grpc_rb_wrap_call(grpc_call *c, grpc_completion_queue *q) {
- grpc_rb_call *wrapper;
+VALUE grpc_rb_wrap_call(grpc_call* c, grpc_completion_queue* q) {
+ grpc_rb_call* wrapper;
if (c == NULL || q == NULL) {
return Qnil;
}
diff --git a/src/ruby/ext/grpc/rb_call.h b/src/ruby/ext/grpc/rb_call.h
index bfe8035..a2202eb 100644
--- a/src/ruby/ext/grpc/rb_call.h
+++ b/src/ruby/ext/grpc/rb_call.h
@@ -24,24 +24,24 @@
#include <grpc/grpc.h>
/* Gets the wrapped call from a VALUE. */
-grpc_call *grpc_rb_get_wrapped_call(VALUE v);
+grpc_call* grpc_rb_get_wrapped_call(VALUE v);
/* Gets the VALUE corresponding to given grpc_call. */
-VALUE grpc_rb_wrap_call(grpc_call *c, grpc_completion_queue *q);
+VALUE grpc_rb_wrap_call(grpc_call* c, grpc_completion_queue* q);
/* Provides the details of an call error */
-const char *grpc_call_error_detail_of(grpc_call_error err);
+const char* grpc_call_error_detail_of(grpc_call_error err);
/* Converts a metadata array to a hash. */
-VALUE grpc_rb_md_ary_to_h(grpc_metadata_array *md_ary);
+VALUE grpc_rb_md_ary_to_h(grpc_metadata_array* md_ary);
/* grpc_rb_md_ary_convert converts a ruby metadata hash into
a grpc_metadata_array.
*/
-void grpc_rb_md_ary_convert(VALUE md_ary_hash, grpc_metadata_array *md_ary);
+void grpc_rb_md_ary_convert(VALUE md_ary_hash, grpc_metadata_array* md_ary);
void grpc_rb_metadata_array_destroy_including_entries(
- grpc_metadata_array *md_ary);
+ grpc_metadata_array* md_ary);
/* grpc_rb_eCallError is the ruby class of the exception thrown during call
operations. */
diff --git a/src/ruby/ext/grpc/rb_call_credentials.c b/src/ruby/ext/grpc/rb_call_credentials.c
index 4214a08..be32597 100644
--- a/src/ruby/ext/grpc/rb_call_credentials.c
+++ b/src/ruby/ext/grpc/rb_call_credentials.c
@@ -44,13 +44,13 @@
VALUE mark;
/* The actual credentials */
- grpc_call_credentials *wrapped;
+ grpc_call_credentials* wrapped;
} grpc_rb_call_credentials;
typedef struct callback_params {
VALUE get_metadata;
grpc_auth_metadata_context context;
- void *user_data;
+ void* user_data;
grpc_credentials_plugin_metadata_cb callback;
} callback_params;
@@ -82,8 +82,8 @@
return result;
}
-static void grpc_rb_call_credentials_callback_with_gil(void *param) {
- callback_params *const params = (callback_params *)param;
+static void grpc_rb_call_credentials_callback_with_gil(void* param) {
+ callback_params* const params = (callback_params*)param;
VALUE auth_uri = rb_str_new_cstr(params->context.service_url);
/* Pass the arguments to the proc in a hash, which currently only has they key
'auth_uri' */
@@ -93,7 +93,7 @@
grpc_metadata_array md_ary;
grpc_status_code status;
VALUE details;
- char *error_details;
+ char* error_details;
grpc_metadata_array_init(&md_ary);
rb_hash_aset(args, ID2SYM(rb_intern("jwt_aud_uri")), auth_uri);
rb_ary_push(callback_args, params->get_metadata);
@@ -113,34 +113,34 @@
}
static int grpc_rb_call_credentials_plugin_get_metadata(
- void *state, grpc_auth_metadata_context context,
- grpc_credentials_plugin_metadata_cb cb, void *user_data,
+ void* state, grpc_auth_metadata_context context,
+ grpc_credentials_plugin_metadata_cb cb, void* user_data,
grpc_metadata creds_md[GRPC_METADATA_CREDENTIALS_PLUGIN_SYNC_MAX],
- size_t *num_creds_md, grpc_status_code *status,
- const char **error_details) {
- callback_params *params = gpr_malloc(sizeof(callback_params));
+ size_t* num_creds_md, grpc_status_code* status,
+ const char** error_details) {
+ callback_params* params = gpr_malloc(sizeof(callback_params));
params->get_metadata = (VALUE)state;
params->context = context;
params->user_data = user_data;
params->callback = cb;
grpc_rb_event_queue_enqueue(grpc_rb_call_credentials_callback_with_gil,
- (void *)(params));
+ (void*)(params));
return 0; // Async return.
}
-static void grpc_rb_call_credentials_plugin_destroy(void *state) {
+static void grpc_rb_call_credentials_plugin_destroy(void* state) {
(void)state;
// Not sure what needs to be done here
}
/* Destroys the credentials instances. */
-static void grpc_rb_call_credentials_free(void *p) {
- grpc_rb_call_credentials *wrapper;
+static void grpc_rb_call_credentials_free(void* p) {
+ grpc_rb_call_credentials* wrapper;
if (p == NULL) {
return;
}
- wrapper = (grpc_rb_call_credentials *)p;
+ wrapper = (grpc_rb_call_credentials*)p;
grpc_call_credentials_release(wrapper->wrapped);
wrapper->wrapped = NULL;
@@ -148,12 +148,12 @@
}
/* Protects the mark object from GC */
-static void grpc_rb_call_credentials_mark(void *p) {
- grpc_rb_call_credentials *wrapper = NULL;
+static void grpc_rb_call_credentials_mark(void* p) {
+ grpc_rb_call_credentials* wrapper = NULL;
if (p == NULL) {
return;
}
- wrapper = (grpc_rb_call_credentials *)p;
+ wrapper = (grpc_rb_call_credentials*)p;
if (wrapper->mark != Qnil) {
rb_gc_mark(wrapper->mark);
}
@@ -175,7 +175,7 @@
/* Allocates CallCredentials instances.
Provides safe initial defaults for the instance fields. */
static VALUE grpc_rb_call_credentials_alloc(VALUE cls) {
- grpc_rb_call_credentials *wrapper = ALLOC(grpc_rb_call_credentials);
+ grpc_rb_call_credentials* wrapper = ALLOC(grpc_rb_call_credentials);
wrapper->wrapped = NULL;
wrapper->mark = Qnil;
return TypedData_Wrap_Struct(cls, &grpc_rb_call_credentials_data_type,
@@ -185,9 +185,9 @@
/* Creates a wrapping object for a given call credentials. This should only be
* called with grpc_call_credentials objects that are not already associated
* with any Ruby object */
-VALUE grpc_rb_wrap_call_credentials(grpc_call_credentials *c, VALUE mark) {
+VALUE grpc_rb_wrap_call_credentials(grpc_call_credentials* c, VALUE mark) {
VALUE rb_wrapper;
- grpc_rb_call_credentials *wrapper;
+ grpc_rb_call_credentials* wrapper;
if (c == NULL) {
return Qnil;
}
@@ -208,8 +208,8 @@
proc: (required) Proc that generates auth metadata
Initializes CallCredential instances. */
static VALUE grpc_rb_call_credentials_init(VALUE self, VALUE proc) {
- grpc_rb_call_credentials *wrapper = NULL;
- grpc_call_credentials *creds = NULL;
+ grpc_rb_call_credentials* wrapper = NULL;
+ grpc_call_credentials* creds = NULL;
grpc_metadata_credentials_plugin plugin;
grpc_ruby_once_init();
@@ -223,7 +223,7 @@
rb_raise(rb_eTypeError, "Argument to CallCredentials#new must be a proc");
return Qnil;
}
- plugin.state = (void *)proc;
+ plugin.state = (void*)proc;
plugin.type = "";
creds = grpc_metadata_credentials_create_from_plugin(plugin, NULL);
@@ -239,11 +239,11 @@
return self;
}
-static VALUE grpc_rb_call_credentials_compose(int argc, VALUE *argv,
+static VALUE grpc_rb_call_credentials_compose(int argc, VALUE* argv,
VALUE self) {
- grpc_call_credentials *creds;
- grpc_call_credentials *other;
- grpc_call_credentials *prev = NULL;
+ grpc_call_credentials* creds;
+ grpc_call_credentials* other;
+ grpc_call_credentials* prev = NULL;
VALUE mark;
if (argc == 0) {
return self;
@@ -282,8 +282,8 @@
}
/* Gets the wrapped grpc_call_credentials from the ruby wrapper */
-grpc_call_credentials *grpc_rb_get_wrapped_call_credentials(VALUE v) {
- grpc_rb_call_credentials *wrapper = NULL;
+grpc_call_credentials* grpc_rb_get_wrapped_call_credentials(VALUE v) {
+ grpc_rb_call_credentials* wrapper = NULL;
TypedData_Get_Struct(v, grpc_rb_call_credentials,
&grpc_rb_call_credentials_data_type, wrapper);
return wrapper->wrapped;
diff --git a/src/ruby/ext/grpc/rb_channel.c b/src/ruby/ext/grpc/rb_channel.c
index f0af54d..1d11a53 100644
--- a/src/ruby/ext/grpc/rb_channel.c
+++ b/src/ruby/ext/grpc/rb_channel.c
@@ -54,9 +54,9 @@
static VALUE grpc_rb_cChannelArgs;
typedef struct bg_watched_channel {
- grpc_channel *channel;
+ grpc_channel* channel;
// these fields must only be accessed under global_connection_polling_mu
- struct bg_watched_channel *next;
+ struct bg_watched_channel* next;
int channel_destroyed;
int refcount;
} bg_watched_channel;
@@ -67,7 +67,7 @@
/* The actual channel (protected in a wrapper to tell when it's safe to
* destroy) */
- bg_watched_channel *bg_wrapped;
+ bg_watched_channel* bg_wrapped;
} grpc_rb_channel;
typedef enum { CONTINUOUS_WATCH, WATCH_STATE_API } watch_state_op_type;
@@ -82,40 +82,40 @@
int called_back;
} api_callback_args;
struct {
- bg_watched_channel *bg;
+ bg_watched_channel* bg;
} continuous_watch_callback_args;
} op;
} watch_state_op;
-static bg_watched_channel *bg_watched_channel_list_head = NULL;
+static bg_watched_channel* bg_watched_channel_list_head = NULL;
static void grpc_rb_channel_try_register_connection_polling(
- bg_watched_channel *bg);
-static void *wait_until_channel_polling_thread_started_no_gil(void *);
-static void wait_until_channel_polling_thread_started_unblocking_func(void *);
-static void *channel_init_try_register_connection_polling_without_gil(
- void *arg);
+ bg_watched_channel* bg);
+static void* wait_until_channel_polling_thread_started_no_gil(void*);
+static void wait_until_channel_polling_thread_started_unblocking_func(void*);
+static void* channel_init_try_register_connection_polling_without_gil(
+ void* arg);
typedef struct channel_init_try_register_stack {
- grpc_channel *channel;
- grpc_rb_channel *wrapper;
+ grpc_channel* channel;
+ grpc_rb_channel* wrapper;
} channel_init_try_register_stack;
-static grpc_completion_queue *channel_polling_cq;
+static grpc_completion_queue* channel_polling_cq;
static gpr_mu global_connection_polling_mu;
static gpr_cv global_connection_polling_cv;
static int abort_channel_polling = 0;
static int channel_polling_thread_started = 0;
-static int bg_watched_channel_list_lookup(bg_watched_channel *bg);
-static bg_watched_channel *bg_watched_channel_list_create_and_add(
- grpc_channel *channel);
-static void bg_watched_channel_list_free_and_remove(bg_watched_channel *bg);
-static void run_poll_channels_loop_unblocking_func(void *arg);
+static int bg_watched_channel_list_lookup(bg_watched_channel* bg);
+static bg_watched_channel* bg_watched_channel_list_create_and_add(
+ grpc_channel* channel);
+static void bg_watched_channel_list_free_and_remove(bg_watched_channel* bg);
+static void run_poll_channels_loop_unblocking_func(void* arg);
// Needs to be called under global_connection_polling_mu
static void grpc_rb_channel_watch_connection_state_op_complete(
- watch_state_op *op, int success) {
+ watch_state_op* op, int success) {
GPR_ASSERT(!op->op.api_callback_args.called_back);
op->op.api_callback_args.called_back = 1;
op->op.api_callback_args.success = success;
@@ -124,7 +124,7 @@
}
/* Avoids destroying a channel twice. */
-static void grpc_rb_channel_safe_destroy(bg_watched_channel *bg) {
+static void grpc_rb_channel_safe_destroy(bg_watched_channel* bg) {
gpr_mu_lock(&global_connection_polling_mu);
GPR_ASSERT(bg_watched_channel_list_lookup(bg));
if (!bg->channel_destroyed) {
@@ -138,18 +138,18 @@
gpr_mu_unlock(&global_connection_polling_mu);
}
-static void *channel_safe_destroy_without_gil(void *arg) {
- grpc_rb_channel_safe_destroy((bg_watched_channel *)arg);
+static void* channel_safe_destroy_without_gil(void* arg) {
+ grpc_rb_channel_safe_destroy((bg_watched_channel*)arg);
return NULL;
}
/* Destroys Channel instances. */
-static void grpc_rb_channel_free(void *p) {
- grpc_rb_channel *ch = NULL;
+static void grpc_rb_channel_free(void* p) {
+ grpc_rb_channel* ch = NULL;
if (p == NULL) {
return;
};
- ch = (grpc_rb_channel *)p;
+ ch = (grpc_rb_channel*)p;
if (ch->bg_wrapped != NULL) {
/* assumption made here: it's ok to directly gpr_mu_lock the global
@@ -164,12 +164,12 @@
}
/* Protects the mark object from GC */
-static void grpc_rb_channel_mark(void *p) {
- grpc_rb_channel *channel = NULL;
+static void grpc_rb_channel_mark(void* p) {
+ grpc_rb_channel* channel = NULL;
if (p == NULL) {
return;
}
- channel = (grpc_rb_channel *)p;
+ channel = (grpc_rb_channel*)p;
if (channel->credentials != Qnil) {
rb_gc_mark(channel->credentials);
}
@@ -189,7 +189,7 @@
/* Allocates grpc_rb_channel instances. */
static VALUE grpc_rb_channel_alloc(VALUE cls) {
- grpc_rb_channel *wrapper = ALLOC(grpc_rb_channel);
+ grpc_rb_channel* wrapper = ALLOC(grpc_rb_channel);
wrapper->bg_wrapped = NULL;
wrapper->credentials = Qnil;
return TypedData_Wrap_Struct(cls, &grpc_channel_data_type, wrapper);
@@ -203,14 +203,14 @@
secure_channel = Channel:new("myhost:443", {'arg1': 'value1'}, creds)
Creates channel instances. */
-static VALUE grpc_rb_channel_init(int argc, VALUE *argv, VALUE self) {
+static VALUE grpc_rb_channel_init(int argc, VALUE* argv, VALUE self) {
VALUE channel_args = Qnil;
VALUE credentials = Qnil;
VALUE target = Qnil;
- grpc_rb_channel *wrapper = NULL;
- grpc_channel *ch = NULL;
- grpc_channel_credentials *creds = NULL;
- char *target_chars = NULL;
+ grpc_rb_channel* wrapper = NULL;
+ grpc_channel* ch = NULL;
+ grpc_channel_credentials* creds = NULL;
+ char* target_chars = NULL;
grpc_channel_args args;
channel_init_try_register_stack stack;
int stop_waiting_for_thread_start = 0;
@@ -262,13 +262,13 @@
}
typedef struct get_state_stack {
- bg_watched_channel *bg;
+ bg_watched_channel* bg;
int try_to_connect;
int out;
} get_state_stack;
-static void *get_state_without_gil(void *arg) {
- get_state_stack *stack = (get_state_stack *)arg;
+static void* get_state_without_gil(void* arg) {
+ get_state_stack* stack = (get_state_stack*)arg;
gpr_mu_lock(&global_connection_polling_mu);
GPR_ASSERT(abort_channel_polling || channel_polling_thread_started);
@@ -292,10 +292,10 @@
constants defined in GRPC::Core::ConnectivityStates.
It also tries to connect if the chennel is idle in the second form. */
-static VALUE grpc_rb_channel_get_connectivity_state(int argc, VALUE *argv,
+static VALUE grpc_rb_channel_get_connectivity_state(int argc, VALUE* argv,
VALUE self) {
VALUE try_to_connect_param = Qfalse;
- grpc_rb_channel *wrapper = NULL;
+ grpc_rb_channel* wrapper = NULL;
get_state_stack stack;
/* "01" == 0 mandatory args, 1 (try_to_connect) is optional */
@@ -315,22 +315,22 @@
}
typedef struct watch_state_stack {
- grpc_channel *channel;
+ grpc_channel* channel;
gpr_timespec deadline;
int last_state;
} watch_state_stack;
-static void *wait_for_watch_state_op_complete_without_gvl(void *arg) {
- watch_state_stack *stack = (watch_state_stack *)arg;
- watch_state_op *op = NULL;
- void *success = (void *)0;
+static void* wait_for_watch_state_op_complete_without_gvl(void* arg) {
+ watch_state_stack* stack = (watch_state_stack*)arg;
+ watch_state_op* op = NULL;
+ void* success = (void*)0;
gpr_mu_lock(&global_connection_polling_mu);
// its unsafe to do a "watch" after "channel polling abort" because the cq has
// been shut down.
if (abort_channel_polling) {
gpr_mu_unlock(&global_connection_polling_mu);
- return (void *)0;
+ return (void*)0;
}
op = gpr_zalloc(sizeof(watch_state_op));
op->op_type = WATCH_STATE_API;
@@ -343,15 +343,15 @@
gpr_inf_future(GPR_CLOCK_REALTIME));
}
if (op->op.api_callback_args.success) {
- success = (void *)1;
+ success = (void*)1;
}
gpr_free(op);
gpr_mu_unlock(&global_connection_polling_mu);
return success;
}
-static void wait_for_watch_state_op_complete_unblocking_func(void *arg) {
- bg_watched_channel *bg = (bg_watched_channel *)arg;
+static void wait_for_watch_state_op_complete_unblocking_func(void* arg) {
+ bg_watched_channel* bg = (bg_watched_channel*)arg;
gpr_mu_lock(&global_connection_polling_mu);
if (!bg->channel_destroyed) {
grpc_channel_destroy(bg->channel);
@@ -370,9 +370,9 @@
static VALUE grpc_rb_channel_watch_connectivity_state(VALUE self,
VALUE last_state,
VALUE deadline) {
- grpc_rb_channel *wrapper = NULL;
+ grpc_rb_channel* wrapper = NULL;
watch_state_stack stack;
- void *op_success = 0;
+ void* op_success = 0;
TypedData_Get_Struct(self, grpc_rb_channel, &grpc_channel_data_type, wrapper);
@@ -405,15 +405,15 @@
VALUE method, VALUE host,
VALUE deadline) {
VALUE res = Qnil;
- grpc_rb_channel *wrapper = NULL;
- grpc_call *call = NULL;
- grpc_call *parent_call = NULL;
- grpc_completion_queue *cq = NULL;
+ grpc_rb_channel* wrapper = NULL;
+ grpc_call* call = NULL;
+ grpc_call* parent_call = NULL;
+ grpc_completion_queue* cq = NULL;
int flags = GRPC_PROPAGATE_DEFAULTS;
grpc_slice method_slice;
grpc_slice host_slice;
- grpc_slice *host_slice_ptr = NULL;
- char *tmp_str = NULL;
+ grpc_slice* host_slice_ptr = NULL;
+ char* tmp_str = NULL;
if (host != Qnil) {
host_slice =
@@ -466,7 +466,7 @@
/* Note this is an API-level call; a wrapped channel's finalizer doesn't call
* this */
static VALUE grpc_rb_channel_destroy(VALUE self) {
- grpc_rb_channel *wrapper = NULL;
+ grpc_rb_channel* wrapper = NULL;
TypedData_Get_Struct(self, grpc_rb_channel, &grpc_channel_data_type, wrapper);
if (wrapper->bg_wrapped != NULL) {
@@ -480,9 +480,9 @@
/* Called to obtain the target that this channel accesses. */
static VALUE grpc_rb_channel_get_target(VALUE self) {
- grpc_rb_channel *wrapper = NULL;
+ grpc_rb_channel* wrapper = NULL;
VALUE res = Qnil;
- char *target = NULL;
+ char* target = NULL;
TypedData_Get_Struct(self, grpc_rb_channel, &grpc_channel_data_type, wrapper);
target = grpc_channel_get_target(wrapper->bg_wrapped->channel);
@@ -493,8 +493,8 @@
}
/* Needs to be called under global_connection_polling_mu */
-static int bg_watched_channel_list_lookup(bg_watched_channel *target) {
- bg_watched_channel *cur = bg_watched_channel_list_head;
+static int bg_watched_channel_list_lookup(bg_watched_channel* target) {
+ bg_watched_channel* cur = bg_watched_channel_list_head;
while (cur != NULL) {
if (cur == target) {
@@ -507,9 +507,9 @@
}
/* Needs to be called under global_connection_polling_mu */
-static bg_watched_channel *bg_watched_channel_list_create_and_add(
- grpc_channel *channel) {
- bg_watched_channel *watched = gpr_zalloc(sizeof(bg_watched_channel));
+static bg_watched_channel* bg_watched_channel_list_create_and_add(
+ grpc_channel* channel) {
+ bg_watched_channel* watched = gpr_zalloc(sizeof(bg_watched_channel));
watched->channel = channel;
watched->next = bg_watched_channel_list_head;
@@ -520,8 +520,8 @@
/* Needs to be called under global_connection_polling_mu */
static void bg_watched_channel_list_free_and_remove(
- bg_watched_channel *target) {
- bg_watched_channel *bg = NULL;
+ bg_watched_channel* target) {
+ bg_watched_channel* bg = NULL;
GPR_ASSERT(bg_watched_channel_list_lookup(target));
GPR_ASSERT(target->channel_destroyed && target->refcount == 0);
@@ -544,10 +544,10 @@
/* Initialize a grpc_rb_channel's "protected grpc_channel" and try to push
* it onto the background thread for constant watches. */
-static void *channel_init_try_register_connection_polling_without_gil(
- void *arg) {
- channel_init_try_register_stack *stack =
- (channel_init_try_register_stack *)arg;
+static void* channel_init_try_register_connection_polling_without_gil(
+ void* arg) {
+ channel_init_try_register_stack* stack =
+ (channel_init_try_register_stack*)arg;
gpr_mu_lock(&global_connection_polling_mu);
stack->wrapper->bg_wrapped =
@@ -559,9 +559,9 @@
// Needs to be called under global_connection_poolling_mu
static void grpc_rb_channel_try_register_connection_polling(
- bg_watched_channel *bg) {
+ bg_watched_channel* bg) {
grpc_connectivity_state conn_state;
- watch_state_op *op = NULL;
+ watch_state_op* op = NULL;
GPR_ASSERT(channel_polling_thread_started || abort_channel_polling);
@@ -597,10 +597,10 @@
// indicates process shutdown.
// In the worst case, this stops polling channel connectivity
// early and falls back to current behavior.
-static void *run_poll_channels_loop_no_gil(void *arg) {
+static void* run_poll_channels_loop_no_gil(void* arg) {
grpc_event event;
- watch_state_op *op = NULL;
- bg_watched_channel *bg = NULL;
+ watch_state_op* op = NULL;
+ bg_watched_channel* bg = NULL;
(void)arg;
gpr_log(GPR_DEBUG, "GRPC_RUBY: run_poll_channels_loop_no_gil - begin");
@@ -618,15 +618,15 @@
}
gpr_mu_lock(&global_connection_polling_mu);
if (event.type == GRPC_OP_COMPLETE) {
- op = (watch_state_op *)event.tag;
+ op = (watch_state_op*)event.tag;
if (op->op_type == CONTINUOUS_WATCH) {
- bg = (bg_watched_channel *)op->op.continuous_watch_callback_args.bg;
+ bg = (bg_watched_channel*)op->op.continuous_watch_callback_args.bg;
bg->refcount--;
grpc_rb_channel_try_register_connection_polling(bg);
gpr_free(op);
} else if (op->op_type == WATCH_STATE_API) {
grpc_rb_channel_watch_connection_state_op_complete(
- (watch_state_op *)event.tag, event.success);
+ (watch_state_op*)event.tag, event.success);
} else {
GPR_ASSERT(0);
}
@@ -641,8 +641,8 @@
}
// Notify the channel polling loop to cleanup and shutdown.
-static void run_poll_channels_loop_unblocking_func(void *arg) {
- bg_watched_channel *bg = NULL;
+static void run_poll_channels_loop_unblocking_func(void* arg) {
+ bg_watched_channel* bg = NULL;
(void)arg;
gpr_mu_lock(&global_connection_polling_mu);
@@ -686,8 +686,8 @@
return Qnil;
}
-static void *wait_until_channel_polling_thread_started_no_gil(void *arg) {
- int *stop_waiting = (int *)arg;
+static void* wait_until_channel_polling_thread_started_no_gil(void* arg) {
+ int* stop_waiting = (int*)arg;
gpr_log(GPR_DEBUG, "GRPC_RUBY: wait for channel polling thread to start");
gpr_mu_lock(&global_connection_polling_mu);
while (!channel_polling_thread_started && !abort_channel_polling &&
@@ -701,8 +701,8 @@
}
static void wait_until_channel_polling_thread_started_unblocking_func(
- void *arg) {
- int *stop_waiting = (int *)arg;
+ void* arg) {
+ int* stop_waiting = (int*)arg;
gpr_mu_lock(&global_connection_polling_mu);
gpr_log(GPR_DEBUG,
"GRPC_RUBY: interrupt wait for channel polling thread to start");
@@ -711,7 +711,7 @@
gpr_mu_unlock(&global_connection_polling_mu);
}
-static void *set_abort_channel_polling_without_gil(void *arg) {
+static void* set_abort_channel_polling_without_gil(void* arg) {
(void)arg;
gpr_mu_lock(&global_connection_polling_mu);
abort_channel_polling = 1;
@@ -822,8 +822,8 @@
}
/* Gets the wrapped channel from the ruby wrapper */
-grpc_channel *grpc_rb_get_wrapped_channel(VALUE v) {
- grpc_rb_channel *wrapper = NULL;
+grpc_channel* grpc_rb_get_wrapped_channel(VALUE v) {
+ grpc_rb_channel* wrapper = NULL;
TypedData_Get_Struct(v, grpc_rb_channel, &grpc_channel_data_type, wrapper);
return wrapper->bg_wrapped->channel;
}
diff --git a/src/ruby/ext/grpc/rb_channel_credentials.c b/src/ruby/ext/grpc/rb_channel_credentials.c
index 83601ca..b23a32c 100644
--- a/src/ruby/ext/grpc/rb_channel_credentials.c
+++ b/src/ruby/ext/grpc/rb_channel_credentials.c
@@ -35,7 +35,7 @@
grpc_channel_credentials. */
static VALUE grpc_rb_cChannelCredentials = Qnil;
-static char *pem_root_certs = NULL;
+static char* pem_root_certs = NULL;
/* grpc_rb_channel_credentials wraps a grpc_channel_credentials. It provides a
* mark object that is used to hold references to any objects used to create
@@ -45,16 +45,16 @@
VALUE mark;
/* The actual credentials */
- grpc_channel_credentials *wrapped;
+ grpc_channel_credentials* wrapped;
} grpc_rb_channel_credentials;
/* Destroys the credentials instances. */
-static void grpc_rb_channel_credentials_free(void *p) {
- grpc_rb_channel_credentials *wrapper = NULL;
+static void grpc_rb_channel_credentials_free(void* p) {
+ grpc_rb_channel_credentials* wrapper = NULL;
if (p == NULL) {
return;
};
- wrapper = (grpc_rb_channel_credentials *)p;
+ wrapper = (grpc_rb_channel_credentials*)p;
grpc_channel_credentials_release(wrapper->wrapped);
wrapper->wrapped = NULL;
@@ -62,12 +62,12 @@
}
/* Protects the mark object from GC */
-static void grpc_rb_channel_credentials_mark(void *p) {
- grpc_rb_channel_credentials *wrapper = NULL;
+static void grpc_rb_channel_credentials_mark(void* p) {
+ grpc_rb_channel_credentials* wrapper = NULL;
if (p == NULL) {
return;
}
- wrapper = (grpc_rb_channel_credentials *)p;
+ wrapper = (grpc_rb_channel_credentials*)p;
if (wrapper->mark != Qnil) {
rb_gc_mark(wrapper->mark);
@@ -90,7 +90,7 @@
/* Allocates ChannelCredential instances.
Provides safe initial defaults for the instance fields. */
static VALUE grpc_rb_channel_credentials_alloc(VALUE cls) {
- grpc_rb_channel_credentials *wrapper = ALLOC(grpc_rb_channel_credentials);
+ grpc_rb_channel_credentials* wrapper = ALLOC(grpc_rb_channel_credentials);
wrapper->wrapped = NULL;
wrapper->mark = Qnil;
return TypedData_Wrap_Struct(cls, &grpc_rb_channel_credentials_data_type,
@@ -100,10 +100,10 @@
/* Creates a wrapping object for a given channel credentials. This should only
* be called with grpc_channel_credentials objects that are not already
* associated with any Ruby object. */
-VALUE grpc_rb_wrap_channel_credentials(grpc_channel_credentials *c,
+VALUE grpc_rb_wrap_channel_credentials(grpc_channel_credentials* c,
VALUE mark) {
VALUE rb_wrapper;
- grpc_rb_channel_credentials *wrapper;
+ grpc_rb_channel_credentials* wrapper;
if (c == NULL) {
return Qnil;
}
@@ -136,15 +136,15 @@
pem_private_key: (optional) PEM encoding of the client's private key
pem_cert_chain: (optional) PEM encoding of the client's cert chain
Initializes Credential instances. */
-static VALUE grpc_rb_channel_credentials_init(int argc, VALUE *argv,
+static VALUE grpc_rb_channel_credentials_init(int argc, VALUE* argv,
VALUE self) {
VALUE pem_root_certs = Qnil;
VALUE pem_private_key = Qnil;
VALUE pem_cert_chain = Qnil;
- grpc_rb_channel_credentials *wrapper = NULL;
- grpc_channel_credentials *creds = NULL;
+ grpc_rb_channel_credentials* wrapper = NULL;
+ grpc_channel_credentials* creds = NULL;
grpc_ssl_pem_key_cert_pair key_cert_pair;
- const char *pem_root_certs_cstr = NULL;
+ const char* pem_root_certs_cstr = NULL;
MEMZERO(&key_cert_pair, grpc_ssl_pem_key_cert_pair, 1);
grpc_ruby_once_init();
@@ -180,11 +180,11 @@
return self;
}
-static VALUE grpc_rb_channel_credentials_compose(int argc, VALUE *argv,
+static VALUE grpc_rb_channel_credentials_compose(int argc, VALUE* argv,
VALUE self) {
- grpc_channel_credentials *creds;
- grpc_call_credentials *other;
- grpc_channel_credentials *prev = NULL;
+ grpc_channel_credentials* creds;
+ grpc_call_credentials* other;
+ grpc_channel_credentials* prev = NULL;
VALUE mark;
if (argc == 0) {
return self;
@@ -210,7 +210,7 @@
}
static grpc_ssl_roots_override_result get_ssl_roots_override(
- char **pem_root_certs_ptr) {
+ char** pem_root_certs_ptr) {
*pem_root_certs_ptr = pem_root_certs;
if (pem_root_certs == NULL) {
return GRPC_SSL_ROOTS_OVERRIDE_FAIL;
@@ -220,7 +220,7 @@
}
static VALUE grpc_rb_set_default_roots_pem(VALUE self, VALUE roots) {
- char *roots_ptr = StringValueCStr(roots);
+ char* roots_ptr = StringValueCStr(roots);
size_t length = strlen(roots_ptr);
(void)self;
pem_root_certs = gpr_malloc((length + 1) * sizeof(char));
@@ -255,8 +255,8 @@
}
/* Gets the wrapped grpc_channel_credentials from the ruby wrapper */
-grpc_channel_credentials *grpc_rb_get_wrapped_channel_credentials(VALUE v) {
- grpc_rb_channel_credentials *wrapper = NULL;
+grpc_channel_credentials* grpc_rb_get_wrapped_channel_credentials(VALUE v) {
+ grpc_rb_channel_credentials* wrapper = NULL;
TypedData_Get_Struct(v, grpc_rb_channel_credentials,
&grpc_rb_channel_credentials_data_type, wrapper);
return wrapper->wrapped;
diff --git a/src/ruby/ext/grpc/rb_completion_queue.c b/src/ruby/ext/grpc/rb_completion_queue.c
index 4283c27..64264f5 100644
--- a/src/ruby/ext/grpc/rb_completion_queue.c
+++ b/src/ruby/ext/grpc/rb_completion_queue.c
@@ -30,16 +30,16 @@
/* Used to allow grpc_completion_queue_next call to release the GIL */
typedef struct next_call_stack {
- grpc_completion_queue *cq;
+ grpc_completion_queue* cq;
grpc_event event;
gpr_timespec timeout;
- void *tag;
+ void* tag;
volatile int interrupted;
} next_call_stack;
/* Calls grpc_completion_queue_pluck without holding the ruby GIL */
-static void *grpc_rb_completion_queue_pluck_no_gil(void *param) {
- next_call_stack *const next_call = (next_call_stack *)param;
+static void* grpc_rb_completion_queue_pluck_no_gil(void* param) {
+ next_call_stack* const next_call = (next_call_stack*)param;
gpr_timespec increment = gpr_time_from_millis(20, GPR_TIMESPAN);
gpr_timespec deadline;
do {
@@ -55,7 +55,7 @@
}
/* Helper function to free a completion queue. */
-void grpc_rb_completion_queue_destroy(grpc_completion_queue *cq) {
+void grpc_rb_completion_queue_destroy(grpc_completion_queue* cq) {
/* Every function that adds an event to a queue also synchronously plucks
that event from the queue, and holds a reference to the Ruby object that
holds the queue, so we only get to this point if all of those functions
@@ -64,15 +64,15 @@
grpc_completion_queue_destroy(cq);
}
-static void unblock_func(void *param) {
- next_call_stack *const next_call = (next_call_stack *)param;
+static void unblock_func(void* param) {
+ next_call_stack* const next_call = (next_call_stack*)param;
next_call->interrupted = 1;
}
/* Does the same thing as grpc_completion_queue_pluck, while properly releasing
the GVL and handling interrupts */
-grpc_event rb_completion_queue_pluck(grpc_completion_queue *queue, void *tag,
- gpr_timespec deadline, void *reserved) {
+grpc_event rb_completion_queue_pluck(grpc_completion_queue* queue, void* tag,
+ gpr_timespec deadline, void* reserved) {
next_call_stack next_call;
MEMZERO(&next_call, next_call_stack, 1);
next_call.cq = queue;
@@ -91,8 +91,8 @@
do {
next_call.interrupted = 0;
rb_thread_call_without_gvl(grpc_rb_completion_queue_pluck_no_gil,
- (void *)&next_call, unblock_func,
- (void *)&next_call);
+ (void*)&next_call, unblock_func,
+ (void*)&next_call);
/* If an interrupt prevented pluck from returning useful information, then
any plucks that did complete must have timed out */
} while (next_call.interrupted && next_call.event.type == GRPC_QUEUE_TIMEOUT);
diff --git a/src/ruby/ext/grpc/rb_completion_queue.h b/src/ruby/ext/grpc/rb_completion_queue.h
index 011b849..8c29089 100644
--- a/src/ruby/ext/grpc/rb_completion_queue.h
+++ b/src/ruby/ext/grpc/rb_completion_queue.h
@@ -23,14 +23,14 @@
#include <grpc/grpc.h>
-void grpc_rb_completion_queue_destroy(grpc_completion_queue *cq);
+void grpc_rb_completion_queue_destroy(grpc_completion_queue* cq);
/**
* Makes the implementation of CompletionQueue#pluck available in other files
*
* This avoids having code that holds the GIL repeated at multiple sites.
*/
-grpc_event rb_completion_queue_pluck(grpc_completion_queue *queue, void *tag,
- gpr_timespec deadline, void *reserved);
+grpc_event rb_completion_queue_pluck(grpc_completion_queue* queue, void* tag,
+ gpr_timespec deadline, void* reserved);
#endif /* GRPC_RB_COMPLETION_QUEUE_H_ */
diff --git a/src/ruby/ext/grpc/rb_compression_options.c b/src/ruby/ext/grpc/rb_compression_options.c
index 3365b17..e24f20d 100644
--- a/src/ruby/ext/grpc/rb_compression_options.c
+++ b/src/ruby/ext/grpc/rb_compression_options.c
@@ -47,17 +47,17 @@
* Ruby objects and don't have a mark for GC. */
typedef struct grpc_rb_compression_options {
/* The actual compression options that's being wrapped */
- grpc_compression_options *wrapped;
+ grpc_compression_options* wrapped;
} grpc_rb_compression_options;
/* Destroys the compression options instances and free the
* wrapped grpc compression options. */
-static void grpc_rb_compression_options_free(void *p) {
- grpc_rb_compression_options *wrapper = NULL;
+static void grpc_rb_compression_options_free(void* p) {
+ grpc_rb_compression_options* wrapper = NULL;
if (p == NULL) {
return;
};
- wrapper = (grpc_rb_compression_options *)p;
+ wrapper = (grpc_rb_compression_options*)p;
if (wrapper->wrapped != NULL) {
gpr_free(wrapper->wrapped);
@@ -85,7 +85,7 @@
Allocate the wrapped grpc compression options and
initialize it here too. */
static VALUE grpc_rb_compression_options_alloc(VALUE cls) {
- grpc_rb_compression_options *wrapper = NULL;
+ grpc_rb_compression_options* wrapper = NULL;
grpc_ruby_once_init();
@@ -103,7 +103,7 @@
VALUE grpc_rb_compression_options_disable_compression_algorithm_internal(
VALUE self, VALUE algorithm_to_disable) {
grpc_compression_algorithm compression_algorithm = 0;
- grpc_rb_compression_options *wrapper = NULL;
+ grpc_rb_compression_options* wrapper = NULL;
TypedData_Get_Struct(self, grpc_rb_compression_options,
&grpc_rb_compression_options_data_type, wrapper);
@@ -145,7 +145,7 @@
/* Sets the default compression level, given the name of a compression level.
* Throws an error if no algorithm matched. */
void grpc_rb_compression_options_set_default_level(
- grpc_compression_options *options, VALUE new_level_name) {
+ grpc_compression_options* options, VALUE new_level_name) {
options->default_level.level =
grpc_rb_compression_options_level_name_to_value_internal(new_level_name);
options->default_level.is_set = 1;
@@ -156,10 +156,10 @@
* algorithm_value is an out parameter.
* Raises an error if the name of the algorithm passed in is invalid. */
void grpc_rb_compression_options_algorithm_name_to_value_internal(
- grpc_compression_algorithm *algorithm_value, VALUE algorithm_name) {
+ grpc_compression_algorithm* algorithm_value, VALUE algorithm_name) {
grpc_slice name_slice;
VALUE algorithm_name_as_string = Qnil;
- char *tmp_str = NULL;
+ char* tmp_str = NULL;
Check_Type(algorithm_name, T_SYMBOL);
@@ -186,7 +186,7 @@
* readable algorithm name. */
VALUE grpc_rb_compression_options_is_algorithm_enabled(VALUE self,
VALUE algorithm_name) {
- grpc_rb_compression_options *wrapper = NULL;
+ grpc_rb_compression_options* wrapper = NULL;
grpc_compression_algorithm internal_algorithm_value;
TypedData_Get_Struct(self, grpc_rb_compression_options,
@@ -204,7 +204,7 @@
/* Sets the default algorithm to the name of the algorithm passed in.
* Raises an error if the name is not a valid compression algorithm name. */
void grpc_rb_compression_options_set_default_algorithm(
- grpc_compression_options *options, VALUE algorithm_name) {
+ grpc_compression_options* options, VALUE algorithm_name) {
grpc_rb_compression_options_algorithm_name_to_value_internal(
&options->default_algorithm.algorithm, algorithm_name);
options->default_algorithm.is_set = 1;
@@ -214,7 +214,7 @@
* algorithm.
* Fails if the algorithm name is invalid. */
void grpc_rb_compression_options_disable_algorithm(
- grpc_compression_options *compression_options, VALUE algorithm_name) {
+ grpc_compression_options* compression_options, VALUE algorithm_name) {
grpc_compression_algorithm internal_algorithm_value;
grpc_rb_compression_options_algorithm_name_to_value_internal(
@@ -226,8 +226,8 @@
/* Provides a ruby hash of GRPC core channel argument key-values that
* correspond to the compression settings on this instance. */
VALUE grpc_rb_compression_options_to_hash(VALUE self) {
- grpc_rb_compression_options *wrapper = NULL;
- grpc_compression_options *compression_options = NULL;
+ grpc_rb_compression_options* wrapper = NULL;
+ grpc_compression_options* compression_options = NULL;
VALUE channel_arg_hash = rb_hash_new();
VALUE key = Qnil;
VALUE value = Qnil;
@@ -284,7 +284,7 @@
* Fails if the enum value is invalid. */
VALUE grpc_rb_compression_options_algorithm_value_to_name_internal(
grpc_compression_algorithm internal_value) {
- char *algorithm_name = NULL;
+ char* algorithm_name = NULL;
if (!grpc_compression_algorithm_name(internal_value, &algorithm_name)) {
rb_raise(rb_eArgError, "Failed to convert algorithm value to name");
@@ -297,7 +297,7 @@
* Returns nil if no algorithm has been set. */
VALUE grpc_rb_compression_options_get_default_algorithm(VALUE self) {
grpc_compression_algorithm internal_value;
- grpc_rb_compression_options *wrapper = NULL;
+ grpc_rb_compression_options* wrapper = NULL;
TypedData_Get_Struct(self, grpc_rb_compression_options,
&grpc_rb_compression_options_data_type, wrapper);
@@ -316,7 +316,7 @@
* A nil return value means that it hasn't been set. */
VALUE grpc_rb_compression_options_get_default_level(VALUE self) {
grpc_compression_level internal_value;
- grpc_rb_compression_options *wrapper = NULL;
+ grpc_rb_compression_options* wrapper = NULL;
TypedData_Get_Struct(self, grpc_rb_compression_options,
&grpc_rb_compression_options_data_type, wrapper);
@@ -335,7 +335,7 @@
VALUE grpc_rb_compression_options_get_disabled_algorithms(VALUE self) {
VALUE disabled_algorithms = rb_ary_new();
grpc_compression_algorithm internal_value;
- grpc_rb_compression_options *wrapper = NULL;
+ grpc_rb_compression_options* wrapper = NULL;
TypedData_Get_Struct(self, grpc_rb_compression_options,
&grpc_rb_compression_options_data_type, wrapper);
@@ -363,8 +363,8 @@
* channel_arg hash = Hash.new[...]
* channel_arg_hash_with_compression_options = channel_arg_hash.merge(options)
*/
-VALUE grpc_rb_compression_options_init(int argc, VALUE *argv, VALUE self) {
- grpc_rb_compression_options *wrapper = NULL;
+VALUE grpc_rb_compression_options_init(int argc, VALUE* argv, VALUE self) {
+ grpc_rb_compression_options* wrapper = NULL;
VALUE default_algorithm = Qnil;
VALUE default_level = Qnil;
VALUE disabled_algorithms = Qnil;
diff --git a/src/ruby/ext/grpc/rb_event_thread.c b/src/ruby/ext/grpc/rb_event_thread.c
index b0bcb6f..281e41c 100644
--- a/src/ruby/ext/grpc/rb_event_thread.c
+++ b/src/ruby/ext/grpc/rb_event_thread.c
@@ -31,15 +31,15 @@
typedef struct grpc_rb_event {
// callback will be called with argument while holding the GVL
- void (*callback)(void *);
- void *argument;
+ void (*callback)(void*);
+ void* argument;
- struct grpc_rb_event *next;
+ struct grpc_rb_event* next;
} grpc_rb_event;
typedef struct grpc_rb_event_queue {
- grpc_rb_event *head;
- grpc_rb_event *tail;
+ grpc_rb_event* head;
+ grpc_rb_event* tail;
gpr_mu mu;
gpr_cv cv;
@@ -50,8 +50,8 @@
static grpc_rb_event_queue event_queue;
-void grpc_rb_event_queue_enqueue(void (*callback)(void *), void *argument) {
- grpc_rb_event *event = gpr_malloc(sizeof(grpc_rb_event));
+void grpc_rb_event_queue_enqueue(void (*callback)(void*), void* argument) {
+ grpc_rb_event* event = gpr_malloc(sizeof(grpc_rb_event));
event->callback = callback;
event->argument = argument;
event->next = NULL;
@@ -66,8 +66,8 @@
gpr_mu_unlock(&event_queue.mu);
}
-static grpc_rb_event *grpc_rb_event_queue_dequeue() {
- grpc_rb_event *event;
+static grpc_rb_event* grpc_rb_event_queue_dequeue() {
+ grpc_rb_event* event;
if (event_queue.head == NULL) {
event = NULL;
} else {
@@ -86,8 +86,8 @@
gpr_cv_destroy(&event_queue.cv);
}
-static void *grpc_rb_wait_for_event_no_gil(void *param) {
- grpc_rb_event *event = NULL;
+static void* grpc_rb_wait_for_event_no_gil(void* param) {
+ grpc_rb_event* event = NULL;
(void)param;
gpr_mu_lock(&event_queue.mu);
while (!event_queue.abort) {
@@ -102,7 +102,7 @@
return NULL;
}
-static void grpc_rb_event_unblocking_func(void *arg) {
+static void grpc_rb_event_unblocking_func(void* arg) {
(void)arg;
gpr_mu_lock(&event_queue.mu);
event_queue.abort = true;
@@ -113,10 +113,10 @@
/* This is the implementation of the thread that handles auth metadata plugin
* events */
static VALUE grpc_rb_event_thread(VALUE arg) {
- grpc_rb_event *event;
+ grpc_rb_event* event;
(void)arg;
while (true) {
- event = (grpc_rb_event *)rb_thread_call_without_gvl(
+ event = (grpc_rb_event*)rb_thread_call_without_gvl(
grpc_rb_wait_for_event_no_gil, NULL, grpc_rb_event_unblocking_func,
NULL);
if (event == NULL) {
diff --git a/src/ruby/ext/grpc/rb_event_thread.h b/src/ruby/ext/grpc/rb_event_thread.h
index 5bfecb9..fa9c14e 100644
--- a/src/ruby/ext/grpc/rb_event_thread.h
+++ b/src/ruby/ext/grpc/rb_event_thread.h
@@ -18,4 +18,4 @@
void grpc_rb_event_queue_thread_start();
-void grpc_rb_event_queue_enqueue(void (*callback)(void *), void *argument);
+void grpc_rb_event_queue_enqueue(void (*callback)(void*), void* argument);
diff --git a/src/ruby/ext/grpc/rb_grpc.c b/src/ruby/ext/grpc/rb_grpc.c
index b53f09e..f065a85 100644
--- a/src/ruby/ext/grpc/rb_grpc.c
+++ b/src/ruby/ext/grpc/rb_grpc.c
@@ -90,9 +90,9 @@
*/
gpr_timespec grpc_rb_time_timeval(VALUE time, int interval) {
gpr_timespec t;
- gpr_timespec *time_const;
- const char *tstr = interval ? "time interval" : "time";
- const char *want = " want <secs from epoch>|<Time>|<GRPC::TimeConst.*>";
+ gpr_timespec* time_const;
+ const char* tstr = interval ? "time interval" : "time";
+ const char* want = " want <secs from epoch>|<Time>|<GRPC::TimeConst.*>";
t.clock_type = GPR_CLOCK_REALTIME;
switch (TYPE(time)) {
@@ -201,7 +201,7 @@
/* Converts a wrapped time constant to a standard time. */
static VALUE grpc_rb_time_val_to_time(VALUE self) {
- gpr_timespec *time_const = NULL;
+ gpr_timespec* time_const = NULL;
gpr_timespec real_time;
TypedData_Get_Struct(self, gpr_timespec, &grpc_rb_timespec_data_type,
time_const);
@@ -236,15 +236,15 @@
rb_define_const(
grpc_rb_mTimeConsts, "ZERO",
TypedData_Wrap_Struct(grpc_rb_cTimeVal, &grpc_rb_timespec_data_type,
- (void *)&zero_realtime));
+ (void*)&zero_realtime));
rb_define_const(
grpc_rb_mTimeConsts, "INFINITE_FUTURE",
TypedData_Wrap_Struct(grpc_rb_cTimeVal, &grpc_rb_timespec_data_type,
- (void *)&inf_future_realtime));
+ (void*)&inf_future_realtime));
rb_define_const(
grpc_rb_mTimeConsts, "INFINITE_PAST",
TypedData_Wrap_Struct(grpc_rb_cTimeVal, &grpc_rb_timespec_data_type,
- (void *)&inf_past_realtime));
+ (void*)&inf_past_realtime));
rb_define_method(grpc_rb_cTimeVal, "to_time", grpc_rb_time_val_to_time, 0);
rb_define_method(grpc_rb_cTimeVal, "inspect", grpc_rb_time_val_inspect, 0);
rb_define_method(grpc_rb_cTimeVal, "to_s", grpc_rb_time_val_to_s, 0);
diff --git a/src/ruby/ext/grpc/rb_server.c b/src/ruby/ext/grpc/rb_server.c
index e96de4f..160c153 100644
--- a/src/ruby/ext/grpc/rb_server.c
+++ b/src/ruby/ext/grpc/rb_server.c
@@ -44,12 +44,12 @@
/* grpc_rb_server wraps a grpc_server. */
typedef struct grpc_rb_server {
/* The actual server */
- grpc_server *wrapped;
- grpc_completion_queue *queue;
+ grpc_server* wrapped;
+ grpc_completion_queue* queue;
gpr_atm shutdown_started;
} grpc_rb_server;
-static void destroy_server(grpc_rb_server *server, gpr_timespec deadline) {
+static void destroy_server(grpc_rb_server* server, gpr_timespec deadline) {
grpc_event ev;
// This can be started by app or implicitly by GC. Avoid a race between these.
if (gpr_atm_full_fetch_add(&server->shutdown_started, (gpr_atm)1) == 0) {
@@ -70,13 +70,13 @@
}
/* Destroys server instances. */
-static void grpc_rb_server_free(void *p) {
- grpc_rb_server *svr = NULL;
+static void grpc_rb_server_free(void* p) {
+ grpc_rb_server* svr = NULL;
gpr_timespec deadline;
if (p == NULL) {
return;
};
- svr = (grpc_rb_server *)p;
+ svr = (grpc_rb_server*)p;
deadline = gpr_time_add(gpr_now(GPR_CLOCK_REALTIME),
gpr_time_from_seconds(2, GPR_TIMESPAN));
@@ -105,7 +105,7 @@
/* Allocates grpc_rb_server instances. */
static VALUE grpc_rb_server_alloc(VALUE cls) {
- grpc_rb_server *wrapper = ALLOC(grpc_rb_server);
+ grpc_rb_server* wrapper = ALLOC(grpc_rb_server);
wrapper->wrapped = NULL;
wrapper->shutdown_started = (gpr_atm)0;
return TypedData_Wrap_Struct(cls, &grpc_rb_server_data_type, wrapper);
@@ -117,9 +117,9 @@
Initializes server instances. */
static VALUE grpc_rb_server_init(VALUE self, VALUE channel_args) {
- grpc_completion_queue *cq = NULL;
- grpc_rb_server *wrapper = NULL;
- grpc_server *srv = NULL;
+ grpc_completion_queue* cq = NULL;
+ grpc_rb_server* wrapper = NULL;
+ grpc_server* srv = NULL;
grpc_channel_args args;
MEMZERO(&args, grpc_channel_args, 1);
@@ -153,7 +153,7 @@
/* grpc_request_call_stack_init ensures the request_call_stack is properly
* initialized */
-static void grpc_request_call_stack_init(request_call_stack *st) {
+static void grpc_request_call_stack_init(request_call_stack* st) {
MEMZERO(st, request_call_stack, 1);
grpc_metadata_array_init(&st->md_ary);
grpc_call_details_init(&st->details);
@@ -161,7 +161,7 @@
/* grpc_request_call_stack_cleanup ensures the request_call_stack is properly
* cleaned up */
-static void grpc_request_call_stack_cleanup(request_call_stack *st) {
+static void grpc_request_call_stack_cleanup(request_call_stack* st) {
grpc_metadata_array_destroy(&st->md_ary);
grpc_call_details_destroy(&st->details);
}
@@ -171,14 +171,14 @@
Requests notification of a new call on a server. */
static VALUE grpc_rb_server_request_call(VALUE self) {
- grpc_rb_server *s = NULL;
- grpc_call *call = NULL;
+ grpc_rb_server* s = NULL;
+ grpc_call* call = NULL;
grpc_event ev;
grpc_call_error err;
request_call_stack st;
VALUE result;
- void *tag = (void *)&st;
- grpc_completion_queue *call_queue =
+ void* tag = (void*)&st;
+ grpc_completion_queue* call_queue =
grpc_completion_queue_create_for_pluck(NULL);
gpr_timespec deadline;
@@ -222,7 +222,7 @@
}
static VALUE grpc_rb_server_start(VALUE self) {
- grpc_rb_server *s = NULL;
+ grpc_rb_server* s = NULL;
TypedData_Get_Struct(self, grpc_rb_server, &grpc_rb_server_data_type, s);
if (s->wrapped == NULL) {
rb_raise(rb_eRuntimeError, "destroyed!");
@@ -244,10 +244,10 @@
server.destroy(timeout)
Destroys server instances. */
-static VALUE grpc_rb_server_destroy(int argc, VALUE *argv, VALUE self) {
+static VALUE grpc_rb_server_destroy(int argc, VALUE* argv, VALUE self) {
VALUE timeout = Qnil;
gpr_timespec deadline;
- grpc_rb_server *s = NULL;
+ grpc_rb_server* s = NULL;
/* "01" == 0 mandatory args, 1 (timeout) is optional */
rb_scan_args(argc, argv, "01", &timeout);
@@ -277,8 +277,8 @@
Adds a http2 port to server */
static VALUE grpc_rb_server_add_http2_port(VALUE self, VALUE port,
VALUE rb_creds) {
- grpc_rb_server *s = NULL;
- grpc_server_credentials *creds = NULL;
+ grpc_rb_server* s = NULL;
+ grpc_server_credentials* creds = NULL;
int recvd_port = 0;
TypedData_Get_Struct(self, grpc_rb_server, &grpc_rb_server_data_type, s);
@@ -335,8 +335,8 @@
}
/* Gets the wrapped server from the ruby wrapper */
-grpc_server *grpc_rb_get_wrapped_server(VALUE v) {
- grpc_rb_server *wrapper = NULL;
+grpc_server* grpc_rb_get_wrapped_server(VALUE v) {
+ grpc_rb_server* wrapper = NULL;
TypedData_Get_Struct(v, grpc_rb_server, &grpc_rb_server_data_type, wrapper);
return wrapper->wrapped;
}
diff --git a/src/ruby/ext/grpc/rb_server_credentials.c b/src/ruby/ext/grpc/rb_server_credentials.c
index 6d7b54c..368d5c2 100644
--- a/src/ruby/ext/grpc/rb_server_credentials.c
+++ b/src/ruby/ext/grpc/rb_server_credentials.c
@@ -38,16 +38,16 @@
/* Holder of ruby objects involved in constructing the server credentials */
VALUE mark;
/* The actual server credentials */
- grpc_server_credentials *wrapped;
+ grpc_server_credentials* wrapped;
} grpc_rb_server_credentials;
/* Destroys the server credentials instances. */
-static void grpc_rb_server_credentials_free(void *p) {
- grpc_rb_server_credentials *wrapper = NULL;
+static void grpc_rb_server_credentials_free(void* p) {
+ grpc_rb_server_credentials* wrapper = NULL;
if (p == NULL) {
return;
};
- wrapper = (grpc_rb_server_credentials *)p;
+ wrapper = (grpc_rb_server_credentials*)p;
/* Delete the wrapped object if the mark object is Qnil, which indicates that
no other object is the actual owner. */
@@ -60,12 +60,12 @@
}
/* Protects the mark object from GC */
-static void grpc_rb_server_credentials_mark(void *p) {
- grpc_rb_server_credentials *wrapper = NULL;
+static void grpc_rb_server_credentials_mark(void* p) {
+ grpc_rb_server_credentials* wrapper = NULL;
if (p == NULL) {
return;
}
- wrapper = (grpc_rb_server_credentials *)p;
+ wrapper = (grpc_rb_server_credentials*)p;
/* If it's not already cleaned up, mark the mark object */
if (wrapper->mark != Qnil) {
@@ -90,7 +90,7 @@
Provides safe initial defaults for the instance fields. */
static VALUE grpc_rb_server_credentials_alloc(VALUE cls) {
- grpc_rb_server_credentials *wrapper = ALLOC(grpc_rb_server_credentials);
+ grpc_rb_server_credentials* wrapper = ALLOC(grpc_rb_server_credentials);
wrapper->wrapped = NULL;
wrapper->mark = Qnil;
return TypedData_Wrap_Struct(cls, &grpc_rb_server_credentials_data_type,
@@ -128,9 +128,9 @@
static VALUE grpc_rb_server_credentials_init(VALUE self, VALUE pem_root_certs,
VALUE pem_key_certs,
VALUE force_client_auth) {
- grpc_rb_server_credentials *wrapper = NULL;
- grpc_server_credentials *creds = NULL;
- grpc_ssl_pem_key_cert_pair *key_cert_pairs = NULL;
+ grpc_rb_server_credentials* wrapper = NULL;
+ grpc_server_credentials* creds = NULL;
+ grpc_ssl_pem_key_cert_pair* key_cert_pairs = NULL;
VALUE cert = Qnil;
VALUE key = Qnil;
VALUE key_cert = Qnil;
@@ -235,8 +235,8 @@
}
/* Gets the wrapped grpc_server_credentials from the ruby wrapper */
-grpc_server_credentials *grpc_rb_get_wrapped_server_credentials(VALUE v) {
- grpc_rb_server_credentials *wrapper = NULL;
+grpc_server_credentials* grpc_rb_get_wrapped_server_credentials(VALUE v) {
+ grpc_rb_server_credentials* wrapper = NULL;
TypedData_Get_Struct(v, grpc_rb_server_credentials,
&grpc_rb_server_credentials_data_type, wrapper);
return wrapper->wrapped;