lua-users home
lua-l archive

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


Lua goes to some trouble to ensure that it is possible to signal a memory allocation error without allocating memory, by preallocating the out of memory error string, which is #define'd as MEMERRMSG in lmem.h. However, this is not exposed to the API.

There are a number of occasions where it would be useful to be able to throw a memory allocation error, so it would be handy to have:

  /** Throws an out of memory error without allocating any memory */
  void lua_nomemoryerror (lua_State *L);

in the API, rather than having to dig through the source every time to remember the precise spelling of that error message.

As an extra added bonus, it could also arrange for LUA_ERRMEM to be returned to the lua_pcall which catches the error.