Previous 15994 Revisions Next

r7862 Sunday 18th April, 2010 at 23:25:54 UTC by Firewave
[WIMGTOOL] Fixed some allocation/deallocation mismatches with charconv.c function. Also removed some unused variables
[src/mess/tools/imgtool]charconv.c imgtool.c

src/mess/tools/imgtool/charconv.c
r7861r7862
2727   }
2828
2929   /* allocate space for result, twice the source len to be safe */
30   buffer = (char *) malloc(strlen(src) * 2 + 1);
30   buffer = (char *) osd_malloc(strlen(src) * 2 + 1);
3131
3232   /* point to the start */
3333   bufptr = buffer;
r7861r7862
7272   }
7373
7474   /* allocate space for result */
75   buffer = (char *) malloc(strlen(src) + 1);
75   buffer = (char *) osd_malloc(strlen(src) + 1);
7676
7777   /* point to the start */
7878   bufptr = buffer;
src/mess/tools/imgtool/imgtool.c
r7861r7862
14741474   if (alloc_path != NULL)
14751475      free(alloc_path);
14761476   if (new_fname != NULL)
1477      free(new_fname);
1477      osd_free(new_fname);
14781478   return err;
14791479}
14801480
r7861r7862
15191519   if (alloc_path != NULL)
15201520      free(alloc_path);
15211521   if (new_fname != NULL)
1522      free(new_fname);
1522      osd_free(new_fname);
15231523   return err;
15241524}
15251525
r7861r7862
16281628   if (alloc_path)
16291629      free(alloc_path);
16301630   if (new_fname)
1631      free(new_fname);
1631      osd_free(new_fname);
16321632   return err;
16331633}
16341634
r7861r7862
18471847imgtoolerr_t imgtool_partition_read_file(imgtool_partition *partition, const char *filename, const char *fork, imgtool_stream *destf, filter_getinfoproc filter)
18481848{
18491849   imgtoolerr_t err;
1850   imgtool_stream *newstream = NULL;
18511850   char *alloc_path = NULL;
18521851   union filterinfo u;
18531852
r7861r7862
18951894   }
18961895
18971896done:
1898   if (newstream)
1899      stream_close(newstream);
19001897   if (alloc_path)
19011898      free(alloc_path);
19021899   return err;
r7861r7862
19141911   imgtoolerr_t err;
19151912   char *buf = NULL;
19161913   char *s;
1917   imgtool_stream *newstream = NULL;
19181914   option_resolution *alloc_resolution = NULL;
19191915   char *alloc_path = NULL;
19201916   UINT64 free_space;
r7861r7862
20172013      free(buf);
20182014   if (alloc_path)
20192015      free(alloc_path);
2020   if (newstream)
2021      stream_close(newstream);
20222016   if (alloc_resolution)
20232017      option_resolution_close(alloc_resolution);
20242018   return err;
r7861r7862
20782072      goto done;
20792073   }
20802074
2081   filename = new_fname;
2082
2083   err = imgtool_partition_read_file(partition, filename, fork, f, filter);
2075   err = imgtool_partition_read_file(partition, new_fname, fork, f, filter);
20842076   if (err)
20852077      goto done;
20862078
r7861r7862
20902082   if (alloc_dest != NULL)
20912083      free(alloc_dest);
20922084   if (new_fname != NULL)
2093      free(new_fname);
2085      osd_free(new_fname);
20942086   return err;
20952087}
20962088
r7861r7862
21372129   if (f != NULL)
21382130      stream_close(f);
21392131   if (alloc_newfname != NULL)
2140      free(alloc_newfname);
2132      osd_free(alloc_newfname);
21412133   return err;
21422134}
21432135
r7861r7862
21852177   if (alloc_path)
21862178      free(alloc_path);
21872179   if (new_fname)
2188      free(new_fname);
2180      osd_free(new_fname);
21892181   return err;
21902182}
21912183
r7861r7862
22302222   if (alloc_path)
22312223      free(alloc_path);
22322224   if (new_fname)
2233      free(new_fname);
2225      osd_free(new_fname);
22342226   return err;
22352227}
22362228
r7861r7862
22762268   if (alloc_path)
22772269      free(alloc_path);
22782270   if (new_path)
2279      free(new_path);
2271      osd_free(new_path);
22802272   return err;
22812273}
22822274
r7861r7862
23222314   if (alloc_path)
23232315      free(alloc_path);
23242316   if (new_path)
2325      free(new_path);
2317      osd_free(new_path);
23262318   return err;
23272319}
23282320
r7861r7862
26312623   if (alloc_path != NULL)
26322624      free(alloc_path);
26332625   if (new_path != NULL)
2634      free(new_path);
2626      osd_free(new_path);
26352627   if (err && (enumeration != NULL))
26362628   {
26372629      free(enumeration);
r7861r7862
26902682         return IMGTOOLERR_BADFILENAME;
26912683
26922684      strcpy(ent->filename, new_fname);
2693      free(new_fname);
2685      osd_free(new_fname);
26942686   }
26952687
26962688   /* don't trust the module! */

Previous 15994 Revisions Next


© 1998-2018 The MESS Team