On 12 June 2013 12:51, Dirk Laurie <
dirk.laurie@gmail.com> wrote:
>
> Can one find out the memory size of a userdata block from the API?
> (I.e. by including only `lua.h`, `lualib.h` and 'lauxlib.h`, not `lobject.h`.)
Try lua_rawlen (Lua 5.2) or lua_objlen (Lua 5.1), quoting the manual:
size_t lua_rawlen (lua_State *L, int index);
Returns the raw "length" of the value at the given index: for strings, this is the string length; for tables, this is the result of the length operator ('#') with no metamethods; for userdata, this is the size of the block of memory allocated for the userdata; for other values, it is 0.