|
On 9/04/2014 5:48 PM, Rena wrote:
The `osize` field of lua_Alloc() when `ptr=NULL` tells you the type of object being allocated. But I'm not sure how to detect that it's *that particular string* Lua is allocating memory for, other than setting a flag just before the lua_pushlstring() and having the allocator check for that flag and a string of that length. But that seems quite fragile.
That was the kind of thing I had in mind. Why do you think that it's fragile?I was thinking you would define a C function to allocate these particular "shared strings". That function sets the flag, calls lua_pushlstring(), and then unsets the flag.
Alternatively, simply allocate all strings with the refcount (or all strings above a certain size).
Ross.