Fixed minor memory leaks

This commit is contained in:
Pierre Pronchery 2008-06-03 10:00:14 +00:00
parent d186d30613
commit 8b811beb6d
2 changed files with 11 additions and 1 deletions

View File

@ -207,6 +207,7 @@ static int _new_target(Code * code, char const * target,
int code_delete(Code * code)
{
int ret = 0;
size_t i;
#ifdef DEBUG
fprintf(stderr, "DEBUG: %s()\n", __func__);
@ -217,7 +218,11 @@ int code_delete(Code * code)
ret = _code_target_exit(code);
plugin_delete(code->plugin);
}
for(i = 0; i < code->variables_cnt; i++)
free(code->variables[i].name);
free(code->variables);
for(i = 0; i < code->types_cnt; i++)
free(code->types[i].name);
free(code->types);
object_delete(code);
return ret;

View File

@ -68,6 +68,7 @@ static int _main_add_option(C99Prefs * prefs, char const * option);
int main(int argc, char * argv[])
{
int ret;
C99Prefs prefs;
int o;
@ -128,7 +129,11 @@ int main(int argc, char * argv[])
&& prefs.outfile != NULL
&& optind + 1 != argc)
return _usage();
return _c99(&prefs, argc - optind, &argv[optind]) == 0 ? 0 : 2;
ret = _c99(&prefs, argc - optind, &argv[optind]);
free(prefs.paths);
free(prefs.defines);
free(prefs.undefines);
return (ret == 0) ? 0 : 2;
}
static int _main_default_paths(C99Prefs * prefs)