** get GC debt and convert it from Kb to 'work units' (avoid zero debt ** and overflows) */
| 1117 | ** and overflows) |
| 1118 | */ |
| 1119 | static l_mem getdebt(global_State *g) { |
| 1120 | l_mem debt = g->GCdebt; |
| 1121 | int stepmul = g->gcstepmul; |
| 1122 | if (debt <= 0) return 0; /* minimal debt */ |
| 1123 | else { |
| 1124 | debt = (debt / STEPMULADJ) + 1; |
| 1125 | debt = (debt < MAX_LMEM / stepmul) ? debt * stepmul : MAX_LMEM; |
| 1126 | return debt; |
| 1127 | } |
| 1128 | } |
| 1129 | |
| 1130 | /* |
| 1131 | ** performs a basic GC step when collector is running |