aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/ruby
diff options
context:
space:
mode:
authorGravatar Yuki Yugui Sonoda <yugui@yugui.jp>2015-04-11 14:59:59 +0900
committerGravatar Yuki Yugui Sonoda <yugui@yugui.jp>2015-04-16 18:45:14 +0900
commitd98db4a647cb943f53ea7dd5568c6ed4e809ea9f (patch)
tree8a6dc27395250c16486c7f5de7b50c7bfbd25270 /src/ruby
parentc9b7d1cb04485111a61e462fc93c52c64cc1007f (diff)
Use TypedData for TmpChannelArgs
Diffstat (limited to 'src/ruby')
-rw-r--r--src/ruby/ext/grpc/rb_channel_args.c16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/ruby/ext/grpc/rb_channel_args.c b/src/ruby/ext/grpc/rb_channel_args.c
index 0e2cdac1a1..acd545f5d2 100644
--- a/src/ruby/ext/grpc/rb_channel_args.c
+++ b/src/ruby/ext/grpc/rb_channel_args.c
@@ -38,6 +38,13 @@
#include "rb_grpc.h"
+static rb_data_type_t grpc_rb_channel_args_data_type = {
+ "grpc_channel_args",
+ {GRPC_RB_GC_NOT_MARKED, GRPC_RB_GC_DONT_FREE, GRPC_RB_MEMSIZE_UNAVAILABLE},
+ NULL, NULL,
+ RUBY_TYPED_FREE_IMMEDIATELY
+};
+
/* A callback the processes the hash key values in channel_args hash */
static int grpc_rb_channel_create_in_process_add_args_hash_cb(VALUE key,
VALUE val,
@@ -60,7 +67,8 @@ static int grpc_rb_channel_create_in_process_add_args_hash_cb(VALUE key,
return ST_STOP;
}
- Data_Get_Struct(args_obj, grpc_channel_args, args);
+ TypedData_Get_Struct(args_obj, grpc_channel_args,
+ &grpc_rb_channel_args_data_type, args);
if (args->num_args <= 0) {
rb_raise(rb_eRuntimeError, "hash_cb bug: num_args is %lu for key:%s",
args->num_args, StringValueCStr(key));
@@ -126,9 +134,9 @@ static VALUE grpc_rb_hash_convert_to_channel_args0(VALUE as_value) {
MEMZERO(params->dst->args, grpc_arg, num_args);
rb_hash_foreach(params->src_hash,
grpc_rb_channel_create_in_process_add_args_hash_cb,
- Data_Wrap_Struct(grpc_rb_cChannelArgs,
- GRPC_RB_GC_NOT_MARKED,
- GRPC_RB_GC_DONT_FREE, params->dst));
+ TypedData_Wrap_Struct(grpc_rb_cChannelArgs,
+ &grpc_rb_channel_args_data_type,
+ params->dst));
/* reset num_args as grpc_rb_channel_create_in_process_add_args_hash_cb
* decrements it during has processing */
params->dst->num_args = num_args;