[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Searching for prior art.
- From: Julien Cugnière <julien.cugniere@...>
- Date: Tue, 11 Jan 2022 11:38:13 +0100
Le lun. 10 janv. 2022 à 12:53, Xmilia Hermit <xmilia.hermit@gmail.com> a écrit :
> Francisco Olarte wrote:
> >> This might be a problem for the SSO since it would need to create a heap
> >> string whenever a C function tries to get a pointer to the string since
> >> it could be moved to a different stack index and the pointer still needs
> >> to be valid.
> > It is, a show stopper for me. Thanks.
>
> I did think a bit more about this problem. It could be solved by a
> second "stack".
If you have lots of memory, and consider that stack reallocations in
the middle of a C function don't happen too often, a simpler (but
somewhat dirty) solution would be that when reallocating the stack,
you don't deallocate the old one (until the C function returns). That
way, pointer references to short strings stay valid. This wastes a bit
of memory holding useless stack slots in memory, but I think a well
written C function isn't supposed to reallocate the stack more than a
couple times. And most functions are fine with the default 20 stack
slots.
Julien Cugnière