benilla-re systems structs docs

luaS_newlstr

function · lua · primitive

Address
0x6f9d00 · 132 bytes, up to 0x6f9d83
Meaning
Returns the interned string of a block of bytes, creating it when absent
Confidence
verified, proof two
Finding
lua/object#strings

Finding: Strings in lua: objects and tables

A string is interned: luaS_newlstr hashes a block (the length seeds h, then h ^= (h<<5) + (h>>2) + byte for every step-th byte from the end, step = (len>>5) + 1), looks in the bucket hash & (size-1) for equal length and bytes, and calls newlstr otherwise. newlstr allocates len + 0x11 bytes, links it into the bucket and doubles the table through luaS_resize when the count passes the size. luaS_newudata allocates a userdata block. luaS_freeall frees the string table.

functionnamedecided by
0x6f9c30luaS_freeallpasses lstring.c and the vector size <<2 to luaM_irealloc (0x6f9c46)
0x6f9c50luaS_resizeallocates size*4 (0x6f9c76), moves each chain by hash & (new-1), frees the old vector (0x6f9ce5)
0x6f9d00luaS_newlstrstep len>>5 (0x6f9d0f), h<<5 and h>>2 mixing (0x6f9d2a, 0x6f9d31), newlstr (0x6f9d76)
0x6f9d90newlstrallocates len+0x11 (0x6f9dae), grows at nuse > size below 0x3ffffffe (0x6f9e0f, 0x6f9e19)
0x6f9e30luaS_newudataallocates size+0x10 (0x6f9e45), tag 7, metatable [G+0x48], linked into [G+0x14]

The derivation is in the doc.

Callers 18

Callees 1

Calls and jumps by a bare address, from tables/calls.tsv.