[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Making a modifiable copy of a string in C
- From: Andrew Gierth <andrew@...>
- Date: Sun, 07 Apr 2019 13:14:51 +0100
>>>>> "Marc" == Marc Balmer <firstname.lastname@example.org> writes:
Marc> I somewhat agree. But the string copy is only used within my C
Marc> function, so it does not really matter if it is modified, since
Marc> Lua code never sees or uses this string. Therefore my question if
Marc> this has any "technical" side/bad effects.
You can't know if lua code ever sees the string, because strings are
interned; there is only one copy of any given short string. So trying to
make a "copy" with lua_tolstring will actually just return the original
pointer for strings under a certain length.