lua

A copy of the Lua development repository
Log | Files | Refs | README

commit e9885efc7c6ef785811c09e1576fb00540ace22c
parent 59fbbf0a65d4729b65adf07b4d8b4770495cc9b8
Author: Roberto Ierusalimschy <roberto@inf.puc-rio.br>
Date:   Wed, 29 Oct 2014 13:02:28 -0200

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

Diffstat:
Mlgc.c | 9++++++---
1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/lgc.c b/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 */