File tree 1 file changed +6
-15
lines changed
1 file changed +6
-15
lines changed Original file line number Diff line number Diff line change 63
63
64
64
#include < string>
65
65
#include < vector>
66
+ #include < list>
66
67
67
68
#if defined(NODE_HAVE_I18N_SUPPORT)
68
69
#include < unicode/uvernum.h>
@@ -4290,34 +4291,24 @@ void Init(int* argc,
4290
4291
4291
4292
4292
4293
struct AtExitCallback {
4293
- AtExitCallback* next_;
4294
4294
void (*cb_)(void * arg);
4295
4295
void * arg_;
4296
4296
};
4297
4297
4298
- static AtExitCallback* at_exit_functions_ ;
4298
+ static std::list< AtExitCallback> at_exit_functions ;
4299
4299
4300
4300
4301
4301
// TODO(bnoordhuis) Turn into per-context event.
4302
4302
void RunAtExit (Environment* env) {
4303
- AtExitCallback* p = at_exit_functions_;
4304
- at_exit_functions_ = nullptr ;
4305
-
4306
- while (p) {
4307
- AtExitCallback* q = p->next_ ;
4308
- p->cb_ (p->arg_ );
4309
- delete p;
4310
- p = q;
4303
+ for (AtExitCallback at_exit : at_exit_functions) {
4304
+ at_exit.cb_ (at_exit.arg_ );
4311
4305
}
4306
+ at_exit_functions.clear ();
4312
4307
}
4313
4308
4314
4309
4315
4310
void AtExit (void (*cb)(void * arg), void * arg) {
4316
- AtExitCallback* p = new AtExitCallback;
4317
- p->cb_ = cb;
4318
- p->arg_ = arg;
4319
- p->next_ = at_exit_functions_;
4320
- at_exit_functions_ = p;
4311
+ at_exit_functions.push_back (AtExitCallback{cb, arg});
4321
4312
}
4322
4313
4323
4314
You can’t perform that action at this time.
0 commit comments