I’m having fits with passing pointers to a function I’ve imported via
DL::Importable. I’m wrapping a simple opaque blob library (part of
libdnet). However, the function I’m wrapping doesn’t seem to work as I
expect it to.
extern "int blob_read(void *blob, void *buf, int size)"
Basically, read the specified amount (size) from the blob, and put it
in buf. return status code. From what I’ve read, I should be able to
wrap this with something akin to:
def read (blob, len) ptr = DL.malloc(len) ret = Dnet.blob_read(blob, ptr.ref, len) return ret.to_s end
However, I get a EXC_BAD_ACCESS segv duing the to_s call. How should I
be getting access to buf?
My current test is attached. I have validated that the shared object
works as expected, when using dlopen/dlsym in C. (dnet.c works as an
example usage of the C api)