Short strings can be external, too

That complicates a little object equality (and therefore table access
for long strings), but the old behavior was somewhat weird. (Short
strings, a concept otherwise absent from the manual, could not be
external.)
This commit is contained in:
Roberto Ierusalimschy
2025-07-15 14:40:27 -03:00
parent c612685d4b
commit 60b6599e83
9 changed files with 168 additions and 120 deletions

View File

@@ -345,8 +345,8 @@ static void *freelib (void *ud, void *ptr, size_t osize, size_t nsize) {
** Create a library string that, when deallocated, will unload 'plib'
*/
static void createlibstr (lua_State *L, void *plib) {
static const char dummy[] = /* common long body for all library strings */
"01234567890123456789012345678901234567890123456789";
/* common content for all library strings */
static const char dummy[] = "01234567890";
lua_pushexternalstring(L, dummy, sizeof(dummy) - 1, freelib, plib);
}