Sha256: 7372b91ede4398041ad82fab106a0aee9958797b9c1e71da1e2b47b626e541d6

Contents?: true

Size: 596 Bytes

Versions: 4

Compression:

Stored size: 596 Bytes

Contents

# encoding: utf-8

module LibC
  extend FFI::Library
  # figures out the correct libc for each platform including Windows
  library = ffi_lib(FFI::Library::LIBC).first

  # Size_t not working properly on Windows
  find_type(:size_t) rescue typedef(:ulong, :size_t)

  # memory allocators
  attach_function :malloc, [:size_t], :pointer
  attach_function :free, [:pointer], :void
  
  # get a pointer to the free function; used for XS::Message deallocation
  Free = library.find_symbol('free')

  # memory movers
  attach_function :memcpy, [:pointer, :pointer, :size_t], :pointer
end # module LibC

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ffi-rxs-1.2.1 lib/ffi-rxs/libc.rb
ffi-rxs-1.2.0 lib/ffi-rxs/libc.rb
ffi-rxs-1.1.0 lib/ffi-rxs/libc.rb
ffi-rxs-1.0.1 lib/ffi-rxs/libc.rb