* [Caml-list] problem with array access in a c function
@ 2011-05-15 13:50 Joel Reymont
2011-05-15 13:59 ` [Caml-list] " Joel Reymont
0 siblings, 1 reply; 2+ messages in thread
From: Joel Reymont @ 2011-05-15 13:50 UTC (permalink / raw)
To: caml-list
The types are at the bottom here, in the Poll module:
https://github.com/wagerlabs/ocaml-zmq/blob/master/src/ZMQ.ml
The C function in question is caml_zmq_poll_of_pollitem_array here:
https://github.com/wagerlabs/ocaml-zmq/blob/master/src/poll.c
I can grab the number of elements in the array just fine, e.g.
int n = Wosize_val(pollitem_array);
This will give me n of 1 or 2, depending on the number of tuples in the array.
This sets current_elem to 0x400 (1024)
current_elem = Field(pollitem_array, n);
This returns 1
int block = Is_block(current_elem);
And this crashes
int tag = Tag_val(current_elem);
Subsequent attempts to pull out the custom data crash as well.
Interestingly enough, Field(current_value, 0) and Field(current_value, 1) are 8 bytes apart.
I'm on a 64-bit machine and I expect tuple elements to be pointers since one is a custom block and the other a variant.
What am I doing wrong?
Thanks, Joel
--------------------------------------------------------------------------
- for hire: mac osx device driver ninja, kernel extensions and usb drivers
---------------------+------------+---------------------------------------
http://wagerlabs.com | @wagerlabs | http://www.linkedin.com/in/joelreymont
---------------------+------------+---------------------------------------
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2011-05-15 13:59 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-15 13:50 [Caml-list] problem with array access in a c function Joel Reymont
2011-05-15 13:59 ` [Caml-list] " Joel Reymont
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).