diff --git a/C/heapgc.c b/C/heapgc.c index badd63c7e..1c8aaf386 100644 --- a/C/heapgc.c +++ b/C/heapgc.c @@ -2090,12 +2090,12 @@ mark_choicepoints(register choiceptr gc_B, tr_fr_ptr saved_TR, bool very_verbose restart_cp: switch (opnum) { case _Nstop: - if (gc_B->cp_b != NULL) { - nargs = 0; - break; - } else { - /* this is the last choice point, the work is done ;-) */ - return; + if (gc_B->cp_env == LCL0) { + return; + } else { + // This must be a border choicepoint, just move up + gc_B = (choiceptr)(gc_B->cp_env[E_B]); + continue; } case _retry_c: case _retry_userc: @@ -3025,11 +3025,14 @@ sweep_choicepoints(choiceptr gc_B USES_REGS) sweep_environments(gc_B->cp_env, EnvSizeInCells, NULL PASS_REGS); - if (gc_B->cp_b != NULL) { - break; - } else - return; - case _trust_fail: + if (gc_B->cp_env == LCL0) { + return; + } else { + // This must be a border choicepoint, just move up + gc_B = (choiceptr)(gc_B->cp_env[E_B]); + continue; + } + case _trust_fail: break; case _or_else: case _or_last: diff --git a/C/utilpreds.c b/C/utilpreds.c index 2247f9344..153f8abbb 100644 --- a/C/utilpreds.c +++ b/C/utilpreds.c @@ -52,14 +52,13 @@ typedef struct non_single_struct_t { } #define def_aux_overflow() \ - aux_overflow:{ \ + while (to_visit_max-to_visit0 < 32) { \ size_t d1 = to_visit-to_visit0; \ - size_t d2 = to_visit_max-to_visit0; \ - to_visit0 = Realloc(to_visit0,(d2+128)*sizeof(struct non_single_struct_t)); \ + size_t d2 = to_visit_max-to_visit0; \ + size_t d3 = Yap_Min(d2+1024, d2 *2); \ + to_visit0 = Realloc(to_visit0,d3*sizeof(struct non_single_struct_t)); \ to_visit = to_visit0+d1; \ - to_visit_max = to_visit0+(d2+128); \ - pt0--; \ - goto restart; \ + to_visit_max = to_visit0+(d3); \ } #define def_global_overflow() \