From b41fa2453d61324745251fb793a31220917c265e Mon Sep 17 00:00:00 2001 From: tradke Date: Thu, 6 May 2004 13:35:52 +0000 Subject: Fixed errnoneous free() statement. This closes PR CactusPUGHIO/1673: "ieee_recombiner segfaults when attempting to recombine output from distributed grid arrays". git-svn-id: http://svn.cactuscode.org/arrangements/CactusPUGHIO/IOFlexIO/trunk@318 ebee0441-1374-4afa-a3b5-247f3ba15b9a --- src/util/ieee_recombiner.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/src/util/ieee_recombiner.c b/src/util/ieee_recombiner.c index 342e800..4b44ba9 100644 --- a/src/util/ieee_recombiner.c +++ b/src/util/ieee_recombiner.c @@ -112,7 +112,7 @@ int main (int argc, char **argv) max_filehandles -= 4; /* open input and output file */ - infiles = (IOFile *) malloc (1 * sizeof (IOFile)); + infiles = malloc (1 * sizeof (IOFile)); infiles [0] = IEEEopen (argv [1], "r"); if (! IOisValid (infiles [0])) { @@ -189,8 +189,8 @@ int main (int argc, char **argv) "output was performed by %d processors\n\n", nprocs, nioprocs); /* allocate memory for arrays */ - infiles = (IOFile *) realloc (infiles, nioprocs * sizeof (IOFile)); - infilenames = (char **) malloc (nioprocs * sizeof (char *)); + infiles = realloc (infiles, nioprocs * sizeof (IOFile)); + infilenames = malloc (nioprocs * sizeof (char *)); /* Now check that all chunked input files can be opened */ /* Also collect the number of datasets here */ @@ -224,7 +224,7 @@ int main (int argc, char **argv) for (ioproc = 0; ioproc < nioprocs; ioproc++) { /* build the input filename */ - infilenames [ioproc] = (char *) malloc (strlen (fname_template) + 10); + infilenames [ioproc] = malloc (strlen (fname_template) + 10); sprintf (infilenames [ioproc], fname_template, ioproc); infiles [ioproc] = IEEEopen (infilenames [ioproc], "r"); if (! IOisValid (infiles [ioproc])) @@ -247,8 +247,8 @@ int main (int argc, char **argv) nioprocs and an inner loop over the set. This means we need to keep the current set in an array for each file. */ - current_set = (int *) calloc (nioprocs, sizeof (int)); - num_chunks = (int *) malloc (nioprocs * sizeof (int)); + current_set = calloc (nioprocs, sizeof (int)); + num_chunks = malloc (nioprocs * sizeof (int)); /* compute the number of chunks per array dataset for each file */ for (ioproc = 0; ioproc < nioprocs; ioproc++) @@ -459,7 +459,6 @@ int main (int argc, char **argv) { if (ioproc <= max_filehandles) IOclose (infiles [ioproc]); - free (infiles [ioproc]); } IOclose (outfile); @@ -493,7 +492,7 @@ int readCommonAttributes (IOFile file, common_attrs_t *common_attrs) printf ("Cannot find name of dataset !\n"); return (-1); } - common_attrs->name = (char *) malloc ((attr_len+1) * sizeof (char)); + common_attrs->name = malloc ((attr_len+1) * sizeof (char)); IOreadAttribute (file, attr_index, common_attrs->name); /* read the group type of the dataset */ @@ -612,7 +611,7 @@ int verifyChunkAttributes (IOFile file, common_attrs_t *common_attrs, printf ("Cannot find name of chunk !\n"); return (-1); } - chunk_name = (char *) malloc ((attr_len+1) * sizeof (char)); + chunk_name = malloc ((attr_len+1) * sizeof (char)); IOreadAttribute (file, attr_index, chunk_name); if (strcmp (chunk_name, common_attrs->name)) { -- cgit v1.2.3