Created
August 6, 2012 14:49
-
-
Save chuckremes/3274964 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'ffi' | |
module LibC | |
extend FFI::Library | |
library = ffi_lib(FFI::Library::LIBC).first | |
# memory allocators | |
attach_function :malloc, [:size_t], :pointer | |
end # module LibC | |
string = 'some string' | |
pointer = LibC.malloc(string.size + 1) | |
pointer.write_string(string) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment