Subject:
[ruby-ffi] Re: LibC.malloc buffer
From:
Wayne Meissner
Date:
9/25/12 4:59 PM
To:
ruby-ffi@googlegroups.com


You'll need to post some code (preferably a cut-down example just illustrating the problem), or else people cannot help you.

Where does LibC.malloc come from?  Did you map it yourself, or use the one from ffi-libc?

Pointer#size will return 2^64 (or 2^32 on 32bit systems) for pointers that are not size-constrained (such as pointers returned from native functions), so ignore it in this scenario.



On Tuesday, 25 September 2012 18:00:04 UTC+10, subsonnic wrote:
Hi,

when i create a FFI::Pointer object by LibC.malloc(8096) i get

/usr/local/lib/ruby/gems/1.9.1/gems/rsml-0.1/lib/rsml/sml_file.rb:54: [BUG] Segmentation fault
ruby 1.9.3p125 (2012-02-16 revision 34643) [x86_64-linux]


Then i checked the buffer size.

p "buffer size: #{buffer.size}"             =====>            "buffer size: 9223372036854775807"

Why the buffer size is so big? How i can get a buffer width length of 8096 bytes?

I will rewrite
unsigned char buffer[8096];

Thanks for help