Memory Limits

lua-users home
wiki

It seems like the best way to do this is with something like the following:

struct myalloc_ud { int max; int cur; }

Then construct an allocator that just adds the new size and subtracts the old size from cur for every allocation (this will work because old size will be zero for a new allocation and new size will be zero for a deallocation) and return NULL if cur would exceed max. Pass this allocator and your userdata to lua_newstate.

-- SeanLynch


RecentChanges · preferences
edit · history
Last edited May 11, 2006 11:09 pm GMT (diff)