chicken-users
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-users] return a pair of ints from a C function?


From: Shawn Rutledge
Subject: Re: [Chicken-users] return a pair of ints from a C function?
Date: Thu, 31 Jul 2008 15:11:05 -0700

On Thu, Jul 31, 2008 at 1:39 PM, felix winkelmann <address@hidden> wrote:
> The C_alloc is a macro that actually does alloca(), so you are allocating
> stack data that is not live after returning from the function. You will

Hmm, I thought C_return made that OK, because it's normal for objects
to live on the stack.  But you are saying that's only true if I use
foreign-primitive?

> either have to use `foreign-primitive`(to create a CPS function), or

Why don't you prefer that approach?

> pass a pre-allocated pair (which I recommend):
>
> C_word g2d_glyphs_baseline(struct G2dGlyphs* glyphs, C_word p)
> {
>  C_set_block_item(p, 0, C_fix(10));
>  C_set_block_item(p, 1, C_fix(256));
>  return p;
> }
>
> (completely untested)
>
>
> cheers,
> felix
>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]