lua-users home
lua-l archive

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


--- Mike Pall <mikelu-0707@mike.de> wrote:
> And ... IMHO mutable strings probably won't have
> less management
> overhead than buffers implemented with userdatas.
> Yes, I know,
> passing userdatas to C APIs expecting plain strings
> doesn't work
> right now. But this can be changed.
> 
At the moment, I am using a relatively dirty hack. I
need a "memory buffer" which needs to be rewritten to
lots of times, sort of mutable string, see my other
post about FUSE.

I wrote a C function for the replace function. This
obviously would invalidate the hash but since it is
only used as buffer and not in other place for key,
that is fine. The only problem is that string in lua
is hashed on creation, I need to have an equivalent of
"malloc" without ending up using an existing one.
Didn't think about this initially and ("0"):rep(4096)
failed badly(of course). Now I do a
io.open("/dev/urandom"):read(4096) to create such
thing. To speed things up, I wrote a simple RC4
generator to generate the random stream faster using
/dev/urandom as the seed.





 
____________________________________________________________________________________
Be a PS3 game guru.
Get your game face on with the latest PS3 news and previews at Yahoo! Games.
http://videogames.yahoo.com/platform?platform=120121