… | |
… | |
472 | |
472 | |
473 | /* free all temporaries */ |
473 | /* free all temporaries */ |
474 | FREETMPS; |
474 | FREETMPS; |
475 | assert (PL_tmps_ix == -1); |
475 | assert (PL_tmps_ix == -1); |
476 | |
476 | |
|
|
477 | /* unwind all extra stacks */ |
477 | POPSTACK_TO (PL_mainstack); |
478 | POPSTACK_TO (PL_mainstack); |
|
|
479 | |
|
|
480 | /* unwind main stack */ |
|
|
481 | dounwind (-1); |
478 | } |
482 | } |
479 | |
483 | |
480 | while (PL_curstackinfo->si_next) |
484 | while (PL_curstackinfo->si_next) |
481 | PL_curstackinfo = PL_curstackinfo->si_next; |
485 | PL_curstackinfo = PL_curstackinfo->si_next; |
482 | |
486 | |
… | |
… | |
801 | #define TRANSFER(ta) transfer ((ta).prev, (ta).next) |
805 | #define TRANSFER(ta) transfer ((ta).prev, (ta).next) |
802 | |
806 | |
803 | static int |
807 | static int |
804 | coro_state_destroy (struct coro *coro) |
808 | coro_state_destroy (struct coro *coro) |
805 | { |
809 | { |
806 | if (coro->refcnt--) |
|
|
807 | return 0; |
|
|
808 | |
|
|
809 | if (coro->flags & CF_DESTROYED) |
810 | if (coro->flags & CF_DESTROYED) |
810 | return 0; |
811 | return 0; |
811 | |
812 | |
812 | coro->flags |= CF_DESTROYED; |
813 | coro->flags |= CF_DESTROYED; |
813 | |
814 | |
… | |
… | |
837 | |
838 | |
838 | return 1; |
839 | return 1; |
839 | } |
840 | } |
840 | |
841 | |
841 | static int |
842 | static int |
842 | coro_state_clear (pTHX_ SV *sv, MAGIC *mg) |
843 | coro_state_free (pTHX_ SV *sv, MAGIC *mg) |
843 | { |
844 | { |
844 | struct coro *coro = (struct coro *)mg->mg_ptr; |
845 | struct coro *coro = (struct coro *)mg->mg_ptr; |
845 | mg->mg_ptr = 0; |
846 | mg->mg_ptr = 0; |
846 | |
847 | |
|
|
848 | if (--coro->refcnt < 0) |
|
|
849 | { |
847 | coro_state_destroy (coro); |
850 | coro_state_destroy (coro); |
848 | |
|
|
849 | if (!coro->refcnt) |
|
|
850 | Safefree (coro); |
851 | Safefree (coro); |
|
|
852 | } |
851 | |
853 | |
852 | return 0; |
854 | return 0; |
853 | } |
855 | } |
854 | |
856 | |
855 | static int |
857 | static int |
… | |
… | |
862 | return 0; |
864 | return 0; |
863 | } |
865 | } |
864 | |
866 | |
865 | static MGVTBL coro_state_vtbl = { |
867 | static MGVTBL coro_state_vtbl = { |
866 | 0, 0, 0, 0, |
868 | 0, 0, 0, 0, |
867 | coro_state_clear, |
869 | coro_state_free, |
868 | 0, |
870 | 0, |
869 | #ifdef MGf_DUP |
871 | #ifdef MGf_DUP |
870 | coro_state_dup, |
872 | coro_state_dup, |
871 | #else |
873 | #else |
872 | # define MGf_DUP 0 |
874 | # define MGf_DUP 0 |