[gambit-list] Converting (unsigned char *) into u8vector?
Taylor Venable
taylor at metasyntax.net
Tue May 19 22:26:58 EDT 2009
On Tue, May 19, 2009 at 12:15:49PM -0400, Marc Feeley wrote:
>
> On 18-May-09, at 10:30 PM, Taylor Venable wrote:
>
>> I have some binary data which is stored in an (unsigned char *) and I
>> want to convert it into a u8vector. So I tried writing a conversion
>> function like this:
>>
>
> The ___BEGIN_ALLOC_xxx macros defined in gambit.h allocate "movable"
> objects from the heap. They are meant to be called from code generated
> by the Gambit Scheme compiler, where ___hp (the heap pointer) is in
> scope. These macros should not be called from user code because some
> tricky invariants must be maintained when using movable objects.
>
> Instead you should call ___alloc_scmobj and specify with the last
> parameter that a "still" object (which is not moved by the GC) is
> requested. This avoids some garbage collection issues.
>
> So the code should look like this (untested):
Thanks for the explanation and code. This worked exactly, and I was
able to use it to write the conversion in the other direction as well.
--
Taylor Christopher Venable
http://real.metasyntax.net:2357/
More information about the Gambit-list
mailing list