Kouhei Sutou
null+****@clear*****
Thu Oct 3 17:55:08 JST 2013
Kouhei Sutou 2013-10-03 17:55:08 +0900 (Thu, 03 Oct 2013) New Revision: 9ecaf59d4204cd21d53b15aff406901519f32586 https://github.com/groonga/groonga/commit/9ecaf59d4204cd21d53b15aff406901519f32586 Message: Use union to group mruby related varaibles I will add more variables. Modified files: lib/ctx_impl.h lib/ctx_impl_mrb.c lib/mrb.c Modified: lib/ctx_impl.h (+3 -1) =================================================================== --- lib/ctx_impl.h 2013-10-03 17:20:05 +0900 (8a1d41f) +++ lib/ctx_impl.h 2013-10-03 17:55:08 +0900 (f8bec40) @@ -176,7 +176,9 @@ struct _grn_ctx_impl { msgpack_packer msgpacker; #endif #ifdef GRN_WITH_MRUBY - mrb_state *mrb; + union { + mrb_state *state; + } mrb; #endif }; Modified: lib/ctx_impl_mrb.c (+5 -5) =================================================================== --- lib/ctx_impl_mrb.c 2013-10-03 17:20:05 +0900 (0970b17) +++ lib/ctx_impl_mrb.c 2013-10-03 17:55:08 +0900 (6cd9fea) @@ -26,18 +26,18 @@ grn_ctx_impl_mrb_init(grn_ctx *ctx) const char *grn_mruby_enabled; grn_mruby_enabled = getenv("GRN_MRUBY_ENABLED"); if (grn_mruby_enabled && strcmp(grn_mruby_enabled, "no") == 0) { - ctx->impl->mrb = NULL; + ctx->impl->mrb.state = NULL; } else { - ctx->impl->mrb = mrb_open(); + ctx->impl->mrb.state = mrb_open(); } } void grn_ctx_impl_mrb_fin(grn_ctx *ctx) { - if (ctx->impl->mrb) { - mrb_close(ctx->impl->mrb); - ctx->impl->mrb = NULL; + if (ctx->impl->mrb.state) { + mrb_close(ctx->impl->mrb.state); + ctx->impl->mrb.state = NULL; } } #else Modified: lib/mrb.c (+1 -1) =================================================================== --- lib/mrb.c 2013-10-03 17:20:05 +0900 (47af811) +++ lib/mrb.c 2013-10-03 17:55:08 +0900 (b75e887) @@ -28,7 +28,7 @@ mrb_value grn_mrb_eval(grn_ctx *ctx, const char *script, int script_length) { - mrb_state *mrb = ctx->impl->mrb; + mrb_state *mrb = ctx->impl->mrb.state; int n; mrb_value result; struct mrb_parser_state *parser; -------------- next part -------------- HTML����������������������������...Download