Skip to content

Commit

Permalink
Add LibC definition lost when merging in dl. Fixes #3462.
Browse files Browse the repository at this point in the history
headius committed May 16, 2018

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent 6a1ee91 commit 482159b
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/ruby/stdlib/fiddle/jruby.rb
Original file line number Diff line number Diff line change
@@ -164,6 +164,14 @@ def self.__freefunc__(free)
end
end

module LibC
extend FFI::Library
ffi_lib FFI::Library::LIBC
MALLOC = attach_function :malloc, [ :size_t ], :pointer
REALLOC = attach_function :realloc, [ :pointer, :size_t ], :pointer
FREE = attach_function :free, [ :pointer ], :void
end

def self.malloc(size, free = nil)
self.new(LibC.malloc(size), size, free ? free : LibC::FREE)
end

0 comments on commit 482159b

Please sign in to comment.