about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorKartik K. Agaram <vc@akkartik.com>2016-09-11 19:08:58 -0700
committerKartik K. Agaram <vc@akkartik.com>2016-09-11 19:08:58 -0700
commitb7a38a1dd4dedbb4c83dcc61801aa588420543b4 (patch)
treeb19739ce48fd873d56a466b257314d3719526888
parent4c0c5eb5a4119ab097b3ec77190a057bf81b945d (diff)
downloadmu-b7a38a1dd4dedbb4c83dcc61801aa588420543b4.tar.gz
3330
Fix CI #2: memory leaks.
-rw-r--r--018type_abbreviations.cc7
1 files changed, 7 insertions, 0 deletions
diff --git a/018type_abbreviations.cc b/018type_abbreviations.cc
index 354de61d..99491d79 100644
--- a/018type_abbreviations.cc
+++ b/018type_abbreviations.cc
@@ -16,6 +16,8 @@ map<string, type_tree*> Type_abbreviations, Type_abbreviations_snapshot;
 Type_abbreviations_snapshot = Type_abbreviations;
 :(before "End restore_snapshots")
 restore_type_abbreviations();
+:(before "End One-time Setup")
+atexit(clear_type_abbreviations);
 :(code)
 void restore_type_abbreviations() {
   for (map<string, type_tree*>::iterator p = Type_abbreviations.begin(); p != Type_abbreviations.end(); ++p) {
@@ -25,6 +27,11 @@ void restore_type_abbreviations() {
   Type_abbreviations.clear();
   Type_abbreviations = Type_abbreviations_snapshot;
 }
+void clear_type_abbreviations() {
+  for (map<string, type_tree*>::iterator p = Type_abbreviations.begin(); p != Type_abbreviations.end(); ++p)
+    delete p->second;
+  Type_abbreviations.clear();
+}
 
 :(before "End Command Handlers")
 else if (command == "type") {