lua-users home
lua-l archive

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


slight correction: calling luaL_error seems to be not good idea here -
this will NOT show the correct Lua line number in some function
(instead it showed the Lua line number of the last function
invocation, if my memory overflow happens inside some function).

... but using luaL_error in this lmem.c anyway seems to be "NOT
nice"... . (I had to #include lauxlib.h into lmem.c top... this really
"of course" was a very brutal change).

So now I looked a bit around in lmem.c for other error messages and I
found luaG_runerror... .

With luaG_runerror I get the correct line number error message now,
also in this case (I recognized, that there is already an error
message luaM_toobig() for this case predefined in lmem.c, just is
"hardly ever" invoked (only in lstring.c, if string size would get
larger than MAXINT ... which of course is "a bit" a rough limit :) ).

So my code snippet above in the function luaM_malloc_ just needs to be
changed to the following 2 lines:

    if( size > MALLOCMEM_MAXBYTES)
      luaM_toobig(L);

(and MALLOCMEM_MAXBYTES I defined in my luaconf.h to 5000).

... this works fine now as it looks so far... .