X-Git-Url: http://git.annexia.org/?a=blobdiff_plain;f=generator%2Fgenerator_ruby.ml;h=82d0018b11ca249f5af4a0e4fc4a1527be32c107;hb=19e2f5aa4fd4ed70b505661d918b5575616ad441;hp=eee6b7e7bc95cdf854ef85cf221651f4ba170e36;hpb=675f336319058fdbaf11ee004968b4543a5a9815;p=libguestfs.git diff --git a/generator/generator_ruby.ml b/generator/generator_ruby.ml index eee6b7e..82d0018 100644 --- a/generator/generator_ruby.ml +++ b/generator/generator_ruby.ml @@ -50,6 +50,15 @@ let rec generate_ruby_c () = #define RARRAY_LEN(r) (RARRAY((r))->len) #endif +/* For Ruby < 1.8 */ +#ifndef RSTRING_LEN +#define RSTRING_LEN(r) (RSTRING((r))->len) +#endif + +#ifndef RSTRING_PTR +#define RSTRING_PTR(r) (RSTRING((r))->ptr) +#endif + static VALUE m_guestfs; /* guestfs module */ static VALUE c_guestfs; /* guestfs_h handle */ static VALUE e_Error; /* used for all errors */ @@ -84,6 +93,7 @@ ruby_guestfs_free (void *gvp) rb_gc_unregister_address (roots[i]); free (roots[i]); } + free (roots); } } @@ -246,13 +256,21 @@ ruby_event_callback_wrapper_wrapper (VALUE argvv) VALUE fn, eventv, event_handlev, bufv, arrayv; fn = argv[0]; - eventv = argv[1]; - event_handlev = argv[2]; - bufv = argv[3]; - arrayv = argv[4]; - rb_funcall (fn, rb_intern (\"call\"), 4, - eventv, event_handlev, bufv, arrayv); + /* Check the Ruby callback still exists. For reasons which are not + * fully understood, even though we registered this as a global root, + * it is still possible for the callback to go away (fn value remains + * but its type changes from T_DATA to T_NONE). (RHBZ#733297) + */ + if (rb_type (fn) != T_NONE) { + eventv = argv[1]; + event_handlev = argv[2]; + bufv = argv[3]; + arrayv = argv[4]; + + rb_funcall (fn, rb_intern (\"call\"), 4, + eventv, event_handlev, bufv, arrayv); + } return Qnil; } @@ -338,10 +356,6 @@ ruby_user_cancel (VALUE gv) doc ^ "\n\n" ^ protocol_limit_warning else doc in let doc = - if List.mem DangerWillRobinson flags then - doc ^ "\n\n" ^ danger_will_robinson - else doc in - let doc = match deprecation_notice flags with | None -> doc | Some txt -> doc ^ "\n\n" ^ txt in @@ -412,11 +426,11 @@ ruby_user_cancel (VALUE gv) pr " const char *%s = StringValueCStr (%sv);\n" n n; | BufferIn n -> pr " Check_Type (%sv, T_STRING);\n" n; - pr " const char *%s = RSTRING (%sv)->ptr;\n" n n; + pr " const char *%s = RSTRING_PTR (%sv);\n" n n; pr " if (!%s)\n" n; pr " rb_raise (rb_eTypeError, \"expected string for parameter %%s of %%s\",\n"; pr " \"%s\", \"%s\");\n" n name; - pr " size_t %s_size = RSTRING (%sv)->len;\n" n n + pr " size_t %s_size = RSTRING_LEN (%sv);\n" n n | OptString n -> pr " const char *%s = !NIL_P (%sv) ? StringValueCStr (%sv) : NULL;\n" n n n | StringList n | DeviceList n ->