From dcf35bd5566c0fbbfb081baa0b5e11495fec46ba Mon Sep 17 00:00:00 2001 From: Thomas Schmitt Date: Sat, 25 Aug 2007 16:02:58 +0000 Subject: [PATCH] More memory management changes proposed by Joris Dobbelsteen --- cdrskin/cdrskin_timestamp.h | 2 +- libburn/file.c | 8 +++----- libburn/mmc.c | 9 ++------- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/cdrskin/cdrskin_timestamp.h b/cdrskin/cdrskin_timestamp.h index 2e06fb9..07beaba 100644 --- a/cdrskin/cdrskin_timestamp.h +++ b/cdrskin/cdrskin_timestamp.h @@ -1 +1 @@ -#define Cdrskin_timestamP "2007.08.25.085709" +#define Cdrskin_timestamP "2007.08.25.155931" diff --git a/libburn/file.c b/libburn/file.c index 2fef9a1..6191dc8 100644 --- a/libburn/file.c +++ b/libburn/file.c @@ -93,7 +93,7 @@ struct burn_source *burn_file_source_new(const char *path, const char *subpath) { struct burn_source_file *fs; struct burn_source *src; - int fd1, fd2 = 0; + int fd1 = -1, fd2 = -1; if (!path) return NULL; @@ -113,15 +113,13 @@ struct burn_source *burn_file_source_new(const char *path, const char *subpath) if (fs == NULL) { failure:; close(fd1); - if (subpath != NULL) + if (fd2 >= 0) close(fd2); return NULL; } fs->datafd = fd1; - - if (subpath) - fs->subfd = fd2; + fs->subfd = fd2; /* ts A70125 */ fs->fixed_size = 0; diff --git a/libburn/mmc.c b/libburn/mmc.c index 40783e8..1eee05b 100644 --- a/libburn/mmc.c +++ b/libburn/mmc.c @@ -959,10 +959,7 @@ static int mmc_read_toc_al(struct burn_drive *d, int *alloc_len) d->status = BURN_DISC_UNSUITABLE; d->toc_entries = 0; /* Prefering memory leaks over fandangos */ - d->toc_entry = malloc(sizeof(struct burn_toc_entry)); - if (d->toc_entry != NULL) /* ts A70825 */ - memset(&(d->toc_entry[0]), 0, - sizeof(struct burn_toc_entry)); + d->toc_entry = calloc(1, sizeof(struct burn_toc_entry)); return 0; } @@ -982,11 +979,9 @@ static int mmc_read_toc_al(struct burn_drive *d, int *alloc_len) ts A61007 : if re-enabled then not via Assert. a ssert(((dlen - 2) % 11) == 0); */ - d->toc_entry = malloc(d->toc_entries * sizeof(struct burn_toc_entry)); + d->toc_entry = calloc(d->toc_entries, sizeof(struct burn_toc_entry)); if(d->toc_entry == NULL) /* ts A70825 */ return 0; - for (i = 0; i < d->toc_entries; i++) - memset(&(d->toc_entry[i]), 0, sizeof(struct burn_toc_entry)); tdata = c.page->data + 4; burn_print(12, "TOC:\n");