X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=main.c;h=78293d6d7615a3682a6153ff6b221381e5dc44cf;hb=1d745fd1f9b0448a00140cef0b68d9a3aa73f1f1;hp=9a76706b06653412f017945dde44aa891ccdc06e;hpb=fa14ca93d2b60f722d55c24214fde7ac84581ad0;p=xonotic%2Fgmqcc.git diff --git a/main.c b/main.c index 9a76706..78293d6 100644 --- a/main.c +++ b/main.c @@ -21,8 +21,6 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ -#include -#include #include #include @@ -531,7 +529,7 @@ static bool options_parse(int argc, char **argv) { } /* returns the line number, or -1 on error */ -static bool progs_nextline(char **out, size_t *alen,FILE *src) { +static bool progs_nextline(char **out, size_t *alen, fs_file_t *src) { int len; char *line; char *start; @@ -559,10 +557,9 @@ static bool progs_nextline(char **out, size_t *alen,FILE *src) { int main(int argc, char **argv) { size_t itr; int retval = 0; - bool opts_output_free = false; bool operators_free = false; bool progs_src = false; - FILE *outfile = NULL; + fs_file_t *outfile = NULL; struct parser_s *parser = NULL; struct ftepp_s *ftepp = NULL; @@ -667,10 +664,10 @@ int main(int argc, char **argv) { } if (!vec_size(items)) { - FILE *src; - char *line = NULL; - size_t linelen = 0; - bool hasline = false; + fs_file_t *src; + char *line = NULL; + size_t linelen = 0; + bool hasline = false; progs_src = true; @@ -692,8 +689,7 @@ int main(int argc, char **argv) { item.type = TYPE_QC; vec_push(items, item); } else if (!opts_output_wasset) { - OPTS_OPTION_STR(OPTION_OUTPUT) = util_strdup(line); - opts_output_free = true; + OPTS_OPTION_DUP(OPTION_OUTPUT) = util_strdup(line); hasline = true; } } @@ -782,8 +778,12 @@ cleanup: if (!OPTS_OPTION_BOOL(OPTION_PP_ONLY)) if(parser) parser_cleanup(parser); - if (opts_output_free) - mem_d(OPTS_OPTION_STR(OPTION_OUTPUT)); + + /* free allocated option strings */ + for (itr = 0; itr < OPTION_COUNT; itr++) + if (OPTS_OPTION_DUPED(itr)) + mem_d(OPTS_OPTION_STR(itr)); + if (operators_free) mem_d((void*)operators);