This also removes the conditional on `argc` in this function. The contained loop
is a no-op when `argc` is 0 and in this case `argv` is NULL, which it is well
defined to `free`.
* Written by Emden Gansner
*/
-#include <assert.h>
#include <unistd.h>
#include "builddate.h"
#include <gvpr/gprstate.h>
return argi;
}
-static void
-freeOpts (options* opts)
-{
- int i;
- assert(opts != NULL);
- if (opts->outFile != sfstdout)
- sfclose (opts->outFile);
- free (opts->inFiles);
- if (opts->useFile)
- free (opts->program);
- if (opts->argc) {
- for (i = 0; i < opts->argc; i++)
- free (opts->argv[i]);
- free (opts->argv);
- }
+static void freeOpts(options opts) {
+ if (opts.outFile != sfstdout)
+ sfclose(opts.outFile);
+ free(opts.inFiles);
+ if (opts.useFile)
+ free(opts.program);
+ for (int i = 0; i < opts.argc; i++)
+ free(opts.argv[i]);
+ free(opts.argv);
}
/* scanArgs:
freeCompileProg (xprog);
closeGPRState(state);
if (ing) closeIngraph (ing);
- freeOpts(&opts);
+ freeOpts(opts);
if (uopts) {
if (uopts->out) sfdisc (sfstdout, 0);