[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: LuaJIT 2 ffi (casting / force hotpath)
- From: Florian Weimer <fw@...>
- Date: Sat, 22 Jan 2011 13:23:07 +0100
>> I think the lifetime should extend to full expression, that is, beyond
>> the call. The reason is that a function might return a pointer that
>> is passed in, such as:
>> char *check_string(char *);
>> If this is called as
>> then the returned pointer will not keep the original pointer live.
> How would the system know that the returned pointer matches the input
> pointer, if you know, you can just store it locally.
It could keep a weak-value table from C pointers to cdata objects.
But this is not necessary if freeing is deferred until the full
expression has been evaluated.
> Wouldn't you have the same problem in C, if you don't store a new
> allocated pointer before the function call, how'd you be able to
> manage the memory after the function call?
C doesn't have the problem because it doesn't have destructors.