Subject:
Re: [ruby-ffi] FFI check & questions
From:
Matijs van Zuijlen
Date:
2/27/12 10:14 AM
To:
ruby-ffi@googlegroups.com

Hi Jeffrey,

On 02/27/2012 02:26 AM, Jeffrey Jones wrote:
I am in the process of looking at using the following library from ruby
(http://www.datalogics.com/products/pdf2img/) using FFI but have run into a few
issues mainly due to my lack of FFI experience and general lack of C++.

[...]

The following Gist has the example C++ code (Posted with permission) and my Ruby
code along side some example output. https://gist.github.com/1920005

[...]

On line 22 of the ruby file I have defined the second argument as an :int, this
is probably wrong but it suffices for the moment I think. I assume the real
value is an Enumeration, struct or something along those lines. It is not
documented so I will ask the original developers.

You should take a look at the file 'pdf2imglib.h', to see what the values of that enumeration are. In particular, what integer value corresponds to GIFoutput.

Questions:

1. On line 40 of the ruby file the required memory is apparently 4Gb, this is
obviously wrong, does anyone know why? (I assume I have messed something up
somewhere)

Perhaps setting the output type to 0 is wrong. I'm not sure what output type would demand 4GB, though.

2. Can anyone see any other obvious mistakes on my part?

I'm guessing allocating 4GB is not going very well. Do check the that the resulting pointer isn't null, i.e., with picBuf.null?

Regards,
-- 
Matijs