File tree Expand file tree Collapse file tree 1 file changed +6
-15
lines changed Expand file tree Collapse file tree 1 file changed +6
-15
lines changed Original file line number Diff line number Diff line change 6262
6363#include < string>
6464#include < vector>
65+ #include < list>
6566
6667#if defined(NODE_HAVE_I18N_SUPPORT)
6768#include < unicode/uvernum.h>
@@ -4411,34 +4412,24 @@ void Init(int* argc,
44114412
44124413
44134414struct AtExitCallback {
4414- AtExitCallback* next_;
44154415 void (*cb_)(void * arg);
44164416 void * arg_;
44174417};
44184418
4419- static AtExitCallback* at_exit_functions_ ;
4419+ static std::list< AtExitCallback> at_exit_functions ;
44204420
44214421
44224422// TODO(bnoordhuis) Turn into per-context event.
44234423void RunAtExit (Environment* env) {
4424- AtExitCallback* p = at_exit_functions_;
4425- at_exit_functions_ = nullptr ;
4426-
4427- while (p) {
4428- AtExitCallback* q = p->next_ ;
4429- p->cb_ (p->arg_ );
4430- delete p;
4431- p = q;
4424+ for (AtExitCallback at_exit : at_exit_functions) {
4425+ at_exit.cb_ (at_exit.arg_ );
44324426 }
4427+ at_exit_functions.clear ();
44334428}
44344429
44354430
44364431void AtExit (void (*cb)(void * arg), void * arg) {
4437- AtExitCallback* p = new AtExitCallback;
4438- p->cb_ = cb;
4439- p->arg_ = arg;
4440- p->next_ = at_exit_functions_;
4441- at_exit_functions_ = p;
4432+ at_exit_functions.push_back (AtExitCallback{cb, arg});
44424433}
44434434
44444435
You can’t perform that action at this time.
0 commit comments