[gambit-list] How can I allocate a vector in a function?

Mikael mikael.rcv at gmail.com
Tue Mar 26 15:20:51 EDT 2013


In Gambit internally, if the C code (as part of allocating a device port or
whatever) wants to allocate an integer object (so, a Scheme fixnum or
bignum) or other object, how is this done?

I guess the main thing is that there needs to be a failure path, that's
trigged.. in case of heap overflow only, or would there be some
stack-technical things a that could make object allocation fail?

Brgds

2013/3/26 Marc Feeley <feeley at iro.umontreal.ca>

>
> On 2013-03-26, at 10:17 AM, Jason Felice <jason.m.felice at gmail.com> wrote:
>
> >
> > I don't have the environment to use the ___BEGIN_ALLOC_VECTOR() macros.
> (No ___hp).
> >
> > I know the size ahead of time.  If possible, I'd like to avoid passing
> ___hp all the way down.
> >
> > Actually, this is one place where I'd love documentation - the
> environment for writing C functions and how things are protected from gc,
> etc.   I can put it together after I figure it out.
>
> Use this instead:
>
> long length = 100;
> ___SCMOBJ init = ___FAL;
> ___SCMOBJ v = ___EXT(___make_vector)(length, init, ___STILL);
>
> An alternative is to create the vector in Scheme, and pass it to C to be
> filled in using mutation.
> Marc
>
> _______________________________________________
> Gambit-list mailing list
> Gambit-list at iro.umontreal.ca
> https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.iro.umontreal.ca/pipermail/gambit-list/attachments/20130326/e47b8b78/attachment.htm>


More information about the Gambit-list mailing list