change example code to do mrb_close()

I was hoping this would cause valgrind to complain less, but there is still
a lot of memory leaked (does mrb_close() actually free all of the managed
blocks?)  Anyway this helps somewhat and is good practice
This commit is contained in:
Mitchell Blank Jr
2012-05-22 01:03:54 -07:00
parent 8c084b9645
commit d1cd10421f
5 changed files with 8 additions and 0 deletions
+1
View File
@@ -2291,6 +2291,7 @@ p(fib(30), \"\\n\")\n\
codedump_all(mrb, n);
#endif
mrb_run(mrb, mrb_proc_new(mrb, mrb->irep[0]), mrb_nil_value());
mrb_close(mrb);
return 0;
}
+1
View File
@@ -55,6 +55,7 @@ main(void)
else {
/* no */
}
mrb_close(mrb);
return 0;
}
+1
View File
@@ -227,6 +227,7 @@ main(void)
}
}
}
mrb_close(mrb_interpreter);
return 0;
}
+4
View File
@@ -163,12 +163,14 @@ main(int argc, char **argv)
if (n < 0 || args.rfp == NULL) {
cleanup(&args);
usage(argv[0]);
mrb_close(mrb);
return n;
}
p = mrb_parse_file(mrb, args.rfp);
if (!p || !p->tree || p->nerr) {
cleanup(&args);
mrb_close(mrb);
return -1;
}
@@ -183,6 +185,7 @@ main(int argc, char **argv)
if (n < 0 || args.check_syntax) {
cleanup(&args);
mrb_close(mrb);
return n;
}
if (args.initname) {
@@ -196,6 +199,7 @@ main(int argc, char **argv)
}
cleanup(&args);
mrb_close(mrb);
return n;
}
+1
View File
@@ -130,6 +130,7 @@ cleanup(mrb_state *mrb, struct _args *args)
mrb_free(mrb, args->cmdline);
if (args->argv)
mrb_free(mrb, args->argv);
mrb_close(mrb);
}
int