Mercurial > octave
comparison src/symtab.cc @ 9981:692ab4eaf965
clean up top-level variables when exiting Octave
author | Jaroslav Hajek <highegg@gmail.com> |
---|---|
date | Mon, 14 Dec 2009 12:11:53 +0100 |
parents | 633f9d837982 |
children | a5a05b2ebb9d |
comparison
equal
deleted
inserted
replaced
9980:e352f8366b02 | 9981:692ab4eaf965 |
---|---|
1326 | 1326 |
1327 for (table_const_iterator p = table.begin (); p != table.end (); p++) | 1327 for (table_const_iterator p = table.begin (); p != table.end (); p++) |
1328 p->second.dump (os, " "); | 1328 p->second.dump (os, " "); |
1329 | 1329 |
1330 os << "\n"; | 1330 os << "\n"; |
1331 } | |
1332 } | |
1333 | |
1334 void symbol_table::cleanup (void) | |
1335 { | |
1336 // Clear variables in top scope. | |
1337 all_instances[xtop_scope]->clear_all (); | |
1338 | |
1339 // Clear function table. This is a hard clear, ignoring mlocked functions. | |
1340 fcn_table.clear (); | |
1341 | |
1342 // Clear variables in global scope. | |
1343 // FIXME: are there any? | |
1344 all_instances[xglobal_scope]->clear_all (); | |
1345 | |
1346 // Clear global variables. | |
1347 global_table.clear (); | |
1348 | |
1349 // Delete all possibly remaining scopes. | |
1350 for (all_instances_iterator iter = all_instances.begin (); | |
1351 iter != all_instances.end (); iter++) | |
1352 { | |
1353 scope_id scope = iter->first; | |
1354 if (scope != xglobal_scope && scope != xtop_scope) | |
1355 scope_id_cache::free (scope); | |
1356 | |
1357 // First zero the table entry to avoid possible duplicate delete. | |
1358 symbol_table *inst = iter->second; | |
1359 iter->second = 0; | |
1360 | |
1361 // Now delete the scope. Note that there may be side effects, such as | |
1362 // deleting other scopes. | |
1363 delete inst; | |
1331 } | 1364 } |
1332 } | 1365 } |
1333 | 1366 |
1334 DEFUN (ignore_function_time_stamp, args, nargout, | 1367 DEFUN (ignore_function_time_stamp, args, nargout, |
1335 "-*- texinfo -*-\n\ | 1368 "-*- texinfo -*-\n\ |