** 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). */
| 1455 | ** because Lua cannot even start with less than PAUSEADJ bytes). |
| 1456 | */ |
| 1457 | static void setpause (global_State *g) { |
| 1458 | l_mem threshold, debt; |
| 1459 | int pause = getgcparam(g->gcpause); |
| 1460 | l_mem estimate = g->GCestimate / PAUSEADJ; /* adjust 'estimate' */ |
| 1461 | lua_assert(estimate > 0); |
| 1462 | threshold = (pause < MAX_LMEM / estimate) /* overflow? */ |
| 1463 | ? estimate * pause /* no overflow */ |
| 1464 | : MAX_LMEM; /* overflow; truncate to maximum */ |
| 1465 | debt = gettotalbytes(g) - threshold; |
| 1466 | if (debt > 0) debt = 0; |
| 1467 | luaE_setdebt(g, debt); |
| 1468 | } |
| 1469 | |
| 1470 | |
| 1471 | /* |
no test coverage detected