… | |
… | |
487 | * still there is a memleak of 128 bytes... |
487 | * still there is a memleak of 128 bytes... |
488 | */ |
488 | */ |
489 | STATIC void |
489 | STATIC void |
490 | destroy_stacks(pTHX) |
490 | destroy_stacks(pTHX) |
491 | { |
491 | { |
|
|
492 | int destruct = PL_main_cv != Nullcv; |
|
|
493 | |
|
|
494 | if (destruct) |
|
|
495 | { |
492 | /* is this ugly, I ask? */ |
496 | /* is this ugly, I ask? */ |
493 | while (PL_scopestack_ix) |
497 | while (PL_scopestack_ix) |
494 | LEAVE; |
498 | LEAVE; |
495 | |
499 | |
496 | /* sure it is, but more important: is it correct?? :/ */ |
500 | /* sure it is, but more important: is it correct?? :/ */ |
497 | while (PL_tmps_ix > PL_tmps_floor) /* should only ever be one iteration */ |
501 | while (PL_tmps_ix > PL_tmps_floor) /* should only ever be one iteration */ |
498 | FREETMPS; |
502 | FREETMPS; |
|
|
503 | } |
499 | |
504 | |
500 | while (PL_curstackinfo->si_next) |
505 | while (PL_curstackinfo->si_next) |
501 | PL_curstackinfo = PL_curstackinfo->si_next; |
506 | PL_curstackinfo = PL_curstackinfo->si_next; |
502 | |
507 | |
503 | while (PL_curstackinfo) |
508 | while (PL_curstackinfo) |
… | |
… | |
508 | dSP; |
513 | dSP; |
509 | SWITCHSTACK (PL_curstack, PL_curstackinfo->si_stack); |
514 | SWITCHSTACK (PL_curstack, PL_curstackinfo->si_stack); |
510 | PUTBACK; /* possibly superfluous */ |
515 | PUTBACK; /* possibly superfluous */ |
511 | } |
516 | } |
512 | |
517 | |
513 | if (PL_main_cv != Nullcv) /* don't during destruction. hack? */ |
518 | if (destruct) |
|
|
519 | { |
514 | dounwind(-1); |
520 | dounwind(-1); |
515 | |
|
|
516 | SvREFCNT_dec(PL_curstackinfo->si_stack); |
521 | SvREFCNT_dec(PL_curstackinfo->si_stack); |
|
|
522 | } |
|
|
523 | |
517 | Safefree(PL_curstackinfo->si_cxstack); |
524 | Safefree(PL_curstackinfo->si_cxstack); |
518 | Safefree(PL_curstackinfo); |
525 | Safefree(PL_curstackinfo); |
519 | PL_curstackinfo = p; |
526 | PL_curstackinfo = p; |
520 | } |
527 | } |
521 | |
528 | |