[gambit-list] Returning a byte array from C
feeley at iro.umontreal.ca
Tue Sep 24 11:22:16 EDT 2013
On 2013-09-23, at 11:14 AM, Vijay Mathew <vijay.the.lisper at gmail.com> wrote:
> The following C function is a wrapper for the `read' system call.
> It returns a pair that contains the number of bytes read and the data.
> Is this the right way to initialize a u8vector from C?
There are a few things I would do differently, such as heap overflow checking. But for the particular task of providing a wrapper to the read system call I would use a different interface. Why don't you allocate the buffer in Scheme before calling read? That would simplify the C code (avoiding GC issues) and would be more efficient.
More information about the Gambit-list