lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

I'm interested in using Lua in an environment in which large C strings will
already have been allocated.  I do not want to copy these large strings into
Lua's string pool - this would be wasteful.  (We're talking multi-hundred-K
strings that will be used briefly and then forgotten.)

I know that I can use userdata to hold pointers into external strings, and
I'm prepared to do that if necessary.  But I'd prefer a way to make Lua see
normal strings, while also 'cheating' on the memory management.  (The
userdata approach involves duplicating lots of the string library, or at
least lots of the string library interface.)

I think what I'm asking for is a way to create a Lua string object that has
all the normal string behaviors *except* with regard its target data, which
I want to escape Lua's normal memory management -- such that Lua will not
try to free that data when the object is GC'd.

Any clues?  Perhaps a feature I hadn't noticed?  adTHANKSvance
Chip Salzenberg <>