luaS_newlstr
function · lua · primitive
- Address
0x6f9d00· 132 bytes, up to0x6f9d83- 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.
| function | name | decided by |
|---|---|---|
0x6f9c30 | luaS_freeall | passes lstring.c and the vector size <<2 to luaM_irealloc (0x6f9c46) |
0x6f9c50 | luaS_resize | allocates size*4 (0x6f9c76), moves each chain by hash & (new-1), frees the old vector (0x6f9ce5) |
0x6f9d00 | luaS_newlstr | step len>>5 (0x6f9d0f), h<<5 and h>>2 mixing (0x6f9d2a, 0x6f9d31), newlstr (0x6f9d76) |
0x6f9d90 | newlstr | allocates len+0x11 (0x6f9dae), grows at nuse > size below 0x3ffffffe (0x6f9e0f, 0x6f9e19) |
0x6f9e30 | luaS_newudata | allocates size+0x10 (0x6f9e45), tag 7, metatable [G+0x48], linked into [G+0x14] |
The derivation is in the doc.
Callers 18
- lua_pushlstring lua
- lua_concat lua
- luaO_pushvfstring lua
- pushstr lua
- adjust_varargs lua
- seterrorobj lua
- f_luaopen lua
- luaT_init lua
- luaV_tostring lua
- luaV_concat lua
- luaV_execute lua
- luaY_parser lua
- new_localvarstr lua
- LoadString lua
- luaX_init lua
- luaX_lex lua
- read_long_string lua
- read_string lua
Callees 1
- newlstr lua
Calls and jumps by a bare address, from tables/calls.tsv.