… | |
… | |
10 | |
10 | |
11 | modules::modules (impl::srcinf const &si, char const * const name, bool norestart, bool (*init)(module *), void (*fini)(), |
11 | modules::modules (impl::srcinf const &si, char const * const name, bool norestart, bool (*init)(module *), void (*fini)(), |
12 | char const * const vendor, char const * const modversion) |
12 | char const * const vendor, char const * const modversion) |
13 | { |
13 | { |
14 | if (provides (name)) |
14 | if (provides (name)) |
15 | throw module_exception (si, "Trying to register two modules with the same name: %s", name); |
15 | throw module_exception (si, "Trying to register two modules with the same name: %s", name); |
16 | module *mod = new module (name, norestart, init, fini, vendor, modversion); |
16 | module *mod = new module (name, norestart, init, fini, vendor, modversion); |
17 | modlist ().push_back (mod); |
17 | modlist ().push_back (mod); |
18 | provides (name); |
18 | provides (name); |
19 | } |
19 | } |
20 | |
20 | |
… | |
… | |
74 | } |
74 | } |
75 | |
75 | |
76 | void |
76 | void |
77 | modules::cleanup () |
77 | modules::cleanup () |
78 | { |
78 | { |
79 | list_type::iterator it = modlist().begin (); |
79 | while (!modlist ().empty ()) |
80 | list_type::iterator et = modlist().end (); |
80 | { |
|
|
81 | module *m = modlist ().back (); |
81 | |
82 | |
82 | while (--et != it) |
|
|
83 | { |
|
|
84 | module *m = *et; |
|
|
85 | if (m->enabled) |
83 | if (m->enabled) |
86 | m->fini (); |
84 | m->fini (); |
87 | delete m; |
85 | delete m; |
|
|
86 | |
|
|
87 | modlist ().pop_back (); |
88 | } |
88 | } |
89 | } |
89 | } |