Browse Source

added comment and assert about an (impossible) division by zero

pull/9/head
Roberto Ierusalimschy 10 years ago
parent
commit
e9885efc7c
  1. 9
      lgc.c

9
lgc.c

@ -1,5 +1,5 @@
/*
** $Id: lgc.c,v 2.196 2014/10/03 12:54:37 roberto Exp roberto $
** $Id: lgc.c,v 2.197 2014/10/25 11:50:46 roberto Exp roberto $
** Garbage Collector
** See Copyright Notice in lua.h
*/
@ -909,12 +909,15 @@ void luaC_checkfinalizer (lua_State *L, GCObject *o, Table *mt) {
/*
** set a reasonable "time" to wait before starting a new GC cycle;
** cycle will start when memory use hits threshold
** Set a reasonable "time" to wait before starting a new GC cycle; cycle
** will start when memory use hits threshold. (Division by 'estimate'
** should be OK: it cannot be zero (because Lua cannot even start with
** less than PAUSEADJ bytes).
*/
static void setpause (global_State *g) {
l_mem threshold, debt;
l_mem estimate = g->GCestimate / PAUSEADJ; /* adjust 'estimate' */
lua_assert(estimate > 0);
threshold = (g->gcpause < MAX_LMEM / estimate) /* overflow? */
? estimate * g->gcpause /* no overflow */
: MAX_LMEM; /* overflow; truncate to maximum */

Loading…
Cancel
Save