** Set the "time" to wait before starting a new GC cycle; cycle will ** start when memory use hits the threshold of ('estimate' * pause / ** PAUSEADJ). (Division by 'estimate' should be OK: it cannot be zero, ** because Lua cannot even start with less than PAUSEADJ bytes). */
| 1355 | ** because Lua cannot even start with less than PAUSEADJ bytes). |
| 1356 | */ |
| 1357 | static void setpause (global_State *g) { |
| 1358 | l_mem threshold, debt; |
| 1359 | int pause = getgcparam(g->gcpause); |
| 1360 | l_mem estimate = g->GCestimate / PAUSEADJ; /* adjust 'estimate' */ |
| 1361 | lua_assert(estimate > 0); |
| 1362 | threshold = (pause < MAX_LMEM / estimate) /* overflow? */ |
| 1363 | ? estimate * pause /* no overflow */ |
| 1364 | : MAX_LMEM; /* overflow; truncate to maximum */ |
| 1365 | debt = gettotalbytes(g) - threshold; |
| 1366 | if (debt > 0) debt = 0; |
| 1367 | luaE_setdebt(g, debt); |
| 1368 | } |
| 1369 | |
| 1370 | |
| 1371 | /* |
no test coverage detected