On 2013-05-03 20:04, Pedro Melendez wrote:
> [...]
> I am developing a prototype of a server that would serve 3D seismic
> images across the network.
> [...]

Hello Pedro,

it's nice to see I'm not the only geophysicist who likes to use Scheme :-)

> [...]
> Giving the size of the file, I want to share the memory space between C
> and Chicken and avoid copying values between areas. Is that even
> possible?
> [...]

Both CHICKEN's blobs and SRFI-4 homogeneous vectors can be converted to
native pointers to their data contents through the FFI.

As a silly example, this will allocate a big array of floating point
numbers, set one of the array elements using native code and read it
bacl from Scheme:

  (use srfi-4)

  (define big-array
    (make-f64vector (expt 2 20)))

  (define set-some-element!
    (foreign-lambda* void ((nonnull-f64vector v))
      "v[1024] = 42.23;"))

  (set-some-element! big-array)

  (display (f64vector-ref big-array 1024))
  (newline)

If your data is not a homogeneous numeric array, you could use blobs
instead.

If you absolutely have to allocate unmanaged memory on the C side an
pass pointers there back to Scheme rather than creating managed Scheme
objects and passing pointers to their contents to the C code, take a
look at CHICKEN's lolevel unit. CHICKEN Scheme can also deal with raw
native pointers to a certain degree!

Ciao,
Thomas


-- 
When C++ is your hammer, every problem looks like your thumb.


_______________________________________________
Chicken-users mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/chicken-users

Reply via email to