http://qs1969.pair.com?node_id=1180095


in reply to Re: Is this a sane/safe way to pass an aref into a C function?
in thread Is this a sane/safe way to pass an aref into a C function?

Hey BrowserUK, thanks for responding.

1) I was casting to int because it was what I had the first time it worked, and hadn't yet done further testing (disclaimer: I am literally learning C as I go through this process).

2) Yep, I have full intention to ensure that each 'byte' will be < 256 && > -1 or so to speak (ie. a proper uint8_t). This is a piece of a much larger scenario, where I'll be tearing apart the bits and manipulating and in many cases ensuring each bit range is within proper bounds (ie.,eg: are bits 5-4 set correctly) and my lack of understanding of a few things likely had me leave out some items. There will be added checks for everything, but I tried to keep the sample small.

3) See this node for the why. Again, I'm just coming into the C/XS/bitwise world, so I may not be explaining myself correctly. Essentially, that node shares that I'm working on something where I need a dynamic number of bytes incoming, without having to change the underlying C code, specifically because in some cases, I'll just want to pass the data straight through, other times, I'll need/want to perform bitwise operations on it.

Really, I summarized this thread into a single problem, where maybe I should have explained it for what it was... looking for a solution to two separate issues while taking up as little time of others as possible ;)