** 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). */
| 1057 | ** because Lua cannot even start with less than PAUSEADJ bytes). |
| 1058 | */ |
| 1059 | static void setpause (global_State *g) { |
| 1060 | l_mem threshold, debt; |
| 1061 | int pause = getgcparam(g->gcpause); |
| 1062 | l_mem estimate = g->GCestimate / PAUSEADJ; /* adjust 'estimate' */ |
| 1063 | lua_assert(estimate > 0); |
| 1064 | threshold = (pause < MAX_LMEM / estimate) /* overflow? */ |
| 1065 | ? estimate * pause /* no overflow */ |
| 1066 | : MAX_LMEM; /* overflow; truncate to maximum */ |
| 1067 | debt = gettotalbytes(g) - threshold; |
| 1068 | if (debt > 0) debt = 0; |
| 1069 | luaE_setdebt(g, debt); |
| 1070 | } |
| 1071 | |
| 1072 | |
| 1073 | /* |
no test coverage detected