Your C code is similar to the following Ruby code:
module Marshal
alias hal_dump dump
end
dump
is a singleton method but also a private instance method (that combination is a so-called module function). You only define an alias of the private instance method.
p Marshal.private_instance_methods.grep(/dump/) # => [:dump, :hal_dump]
That's also why you don't get an error. However you want to define an alias of the singleton method. That can be done by opening the singleton class. A corrected Ruby version might look like this:
p Marshal.methods.grep(/dump/) # => [:dump]
class << Marshal
alias hal_dump dump
end
p Marshal.methods.grep(/dump/) # => [:dump, :hal_dump]
The MRI C API implements the rb_singleton_class()
function. It returns the singleton class and can be used like this to fix your code:
rb_define_alias(rb_singleton_class(Marshal), "hal_dump", "dump");