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