From: paulbarker Date: Mon, 10 Sep 2007 10:17:19 +0000 (-0000) Subject: Delayed destruction of arguments list until cpp_preproc_destroy() in cpp module. X-Git-Tag: v0.6.2~5^2~4^2~2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ca7439276ed7b1258734b1329194e35d8ff03c4c;p=yasm Delayed destruction of arguments list until cpp_preproc_destroy() in cpp module. svn path=/branches/multiarch/; revision=1940 --- diff --git a/modules/preprocs/cpp/cpp-preproc.c b/modules/preprocs/cpp/cpp-preproc.c index a35b2544..ec0a3d6d 100644 --- a/modules/preprocs/cpp/cpp-preproc.c +++ b/modules/preprocs/cpp/cpp-preproc.c @@ -111,11 +111,6 @@ cpp_build_cmdline(yasm_preproc_cpp *pp) APPEND(arg->op); APPEND(" "); APPEND(arg->param); - - /* Remove this element from the list and free it. */ - TAILQ_REMOVE(&pp->cpp_args, arg, entry); - yasm_xfree(arg->param); - yasm_xfree(arg); } /* Append final arguments. */ @@ -133,11 +128,6 @@ cpp_invoke(yasm_preproc_cpp *pp) cmdline = cpp_build_cmdline(pp); -#if 0 - /* Print the command line before executing. */ - printf("%s\n", cmdline); -#endif - pp->f = popen(cmdline, "r"); if (!pp->f) yasm__fatal( N_("Failed to execute preprocessor") ); @@ -145,6 +135,19 @@ cpp_invoke(yasm_preproc_cpp *pp) yasm_xfree(cmdline); } +/* Free memory used by the list of arguments. */ +static void +cpp_destroy_args(yasm_preproc_cpp *pp) +{ + cpp_arg_entry *arg; + + while ( (arg = TAILQ_FIRST(&pp->cpp_args)) ) { + TAILQ_REMOVE(&pp->cpp_args, arg, entry); + yasm_xfree(arg->param); + yasm_xfree(arg); + } +} + /******************************************************************************* Interface functions. *******************************************************************************/ @@ -175,6 +178,8 @@ cpp_preproc_destroy(yasm_preproc *preproc) yasm__fatal( N_("Preprocessor exited with failure") ); } + cpp_destroy_args(pp); + yasm_xfree(pp->filename); yasm_xfree(pp); }