* fix another small memory leak in #include handling

* more code formatting changes because I'm a jerk whose mental lexer
   needs whitespace to properly tokenize code.
This commit is contained in:
Steve Beattie 2009-07-24 12:18:12 +00:00
parent 5a8a692628
commit 1b069745b3
2 changed files with 11 additions and 6 deletions

View file

@ -218,8 +218,10 @@ FILE *search_path(char *filename, char **fullpath)
exit(1);
}
newf = fopen(buf, "r");
if (newf && fullpath) *fullpath = buf;
else free(buf);
if (newf && fullpath)
*fullpath = buf;
else
free(buf);
buf = NULL;
if (newf)
break;

View file

@ -147,6 +147,9 @@ void include_filename(char *filename, int search)
free(dirent_path);
closedir(dir);
}
if (fullpath)
free(fullpath);
}
%}
@ -202,16 +205,16 @@ LT_EQUAL <=
{WS}+ { /* Eat whitespace */ }
\<([^\> \t\n]+)\> { /* <filename> */
char *filename = strdup(yytext);
filename[strlen(filename)-1]='\0';
include_filename(filename+1, 1);
filename[strlen(filename) - 1] = '\0';
include_filename(filename + 1, 1);
free(filename);
BEGIN(INITIAL);
}
\"([^\" \t\n]+)\" { /* "filename" */
char *filename = strdup(yytext);
filename[strlen(filename)-1]='\0';
include_filename(filename+1, 0);
filename[strlen(filename) - 1] = '\0';
include_filename(filename + 1, 0);
free(filename);
BEGIN(INITIAL);
}