** 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). */
| 938 | ** less than PAUSEADJ bytes). |
| 939 | */ |
| 940 | static void setpause (global_State *g) { |
| 941 | l_mem threshold, debt; |
| 942 | l_mem estimate = g->GCestimate / PAUSEADJ; /* adjust 'estimate' */ |
| 943 | lua_assert(estimate > 0); |
| 944 | threshold = (g->gcpause < MAX_LMEM / estimate) /* overflow? */ |
| 945 | ? estimate * g->gcpause /* no overflow */ |
| 946 | : MAX_LMEM; /* overflow; truncate to maximum */ |
| 947 | debt = gettotalbytes(g) - threshold; |
| 948 | luaE_setdebt(g, debt); |
| 949 | } |
| 950 | |
| 951 | |
| 952 | /* |
no test coverage detected