Project

General

Profile

Bug #4400 » bug4400-atexit.patch

kosaki (Motohiro KOSAKI), 02/15/2011 08:25 PM

View differences:

eval_jump.c (作業コピー)
54 54
    struct end_proc_data *next;
55 55
};
56 56

  
57
static struct end_proc_data *end_procs, *ephemeral_end_procs, *tmp_end_procs;
57
static struct end_proc_data *end_procs, *ephemeral_end_procs;
58 58

  
59 59
void
60 60
rb_set_end_proc(void (*func)(VALUE), VALUE data)
......
91 91
	rb_gc_mark(link->data);
92 92
	link = link->next;
93 93
    }
94
    link = tmp_end_procs;
95
    while (link) {
96
	rb_gc_mark(link->data);
97
	link = link->next;
98
    }
99 94
}
100 95

  
101 96
void
......
107 102
    volatile int safe = rb_safe_level();
108 103

  
109 104
    while (ephemeral_end_procs) {
110
	tmp_end_procs = link = ephemeral_end_procs;
111
	ephemeral_end_procs = 0;
112
	while (link) {
113
	    PUSH_TAG();
114
	    if ((status = EXEC_TAG()) == 0) {
115
		rb_set_safe_level_force(link->safe);
116
		(*link->func) (link->data);
117
	    }
118
	    POP_TAG();
119
	    if (status) {
120
		error_handle(status);
121
	    }
122
	    tmp = link;
123
	    tmp_end_procs = link = link->next;
124
	    xfree(tmp);
105
	link = ephemeral_end_procs;
106
	ephemeral_end_procs = link->next;
107

  
108
	PUSH_TAG();
109
	if ((status = EXEC_TAG()) == 0) {
110
	    rb_set_safe_level_force(link->safe);
111
	    (*link->func) (link->data);
125 112
	}
113
	POP_TAG();
114
	if (status) {
115
	    error_handle(status);
116
	}
117
	xfree(link);
126 118
    }
119

  
127 120
    while (end_procs) {
128
	tmp_end_procs = link = end_procs;
129
	end_procs = 0;
130
	while (link) {
131
	    PUSH_TAG();
132
	    if ((status = EXEC_TAG()) == 0) {
133
		rb_set_safe_level_force(link->safe);
134
		(*link->func) (link->data);
135
	    }
136
	    POP_TAG();
137
	    if (status) {
138
		error_handle(status);
139
	    }
140
	    tmp = link;
141
	    tmp_end_procs = link = link->next;
142
	    xfree(tmp);
121
	link = end_procs;
122
	end_procs = link->next;
123

  
124
	PUSH_TAG();
125
	if ((status = EXEC_TAG()) == 0) {
126
	    rb_set_safe_level_force(link->safe);
127
	    (*link->func) (link->data);
143 128
	}
129
	POP_TAG();
130
	if (status) {
131
	    error_handle(status);
132
	}
133
	xfree(link);
144 134
    }
145 135
    rb_set_safe_level_force(safe);
146 136
}