[libdvdnav-devel] [PATCH 25/33] Use calloc instead of malloc, then memset
beandog at gentoo.org
beandog at gentoo.org
Thu Jan 15 21:45:37 CET 2015
From: Steve Dibb <steve.dibb at gmail.com>
---
src/ifo_read.c | 15 ++++-----------
1 file changed, 4 insertions(+), 11 deletions(-)
diff --git a/src/ifo_read.c b/src/ifo_read.c
index 22f71e6..d6ec6b2 100644
--- a/src/ifo_read.c
+++ b/src/ifo_read.c
@@ -290,12 +290,10 @@ ifo_handle_t *ifoOpen(dvd_reader_t *dvd, int title) {
int bup_file_opened = 0;
char ifo_filename[13];
- ifofile = malloc(sizeof(ifo_handle_t));
+ ifofile = calloc(1, sizeof(ifo_handle_t));
if(!ifofile)
return NULL;
- memset(ifofile, 0, sizeof(ifo_handle_t));
-
ifofile->file = DVDOpenFile(dvd, title, DVD_READ_INFO_FILE);
if(!ifofile->file) { /* Failed to open IFO, try to open BUP */
ifofile->file = DVDOpenFile(dvd, title, DVD_READ_INFO_BACKUP_FILE);
@@ -357,11 +355,10 @@ ifoOpen_try_bup:
/* Try BUP instead */
ifoClose(ifofile);
- ifofile = malloc(sizeof(ifo_handle_t));
+ ifofile = calloc(1, sizeof(ifo_handle_t));
if(!ifofile)
return NULL;
- memset(ifofile, 0, sizeof(ifo_handle_t));
ifofile->file = DVDOpenFile(dvd, title, DVD_READ_INFO_BACKUP_FILE);
if (title)
@@ -423,12 +420,10 @@ ifoOpen_fail:
ifo_handle_t *ifoOpenVMGI(dvd_reader_t *dvd) {
ifo_handle_t *ifofile;
- ifofile = malloc(sizeof(ifo_handle_t));
+ ifofile = calloc(1, sizeof(ifo_handle_t));
if(!ifofile)
return NULL;
- memset(ifofile, 0, sizeof(ifo_handle_t));
-
ifofile->file = DVDOpenFile(dvd, 0, DVD_READ_INFO_FILE);
if(!ifofile->file) /* Should really catch any error and try to fallback */
ifofile->file = DVDOpenFile(dvd, 0, DVD_READ_INFO_BACKUP_FILE);
@@ -450,12 +445,10 @@ ifo_handle_t *ifoOpenVMGI(dvd_reader_t *dvd) {
ifo_handle_t *ifoOpenVTSI(dvd_reader_t *dvd, int title) {
ifo_handle_t *ifofile;
- ifofile = malloc(sizeof(ifo_handle_t));
+ ifofile = calloc(1, sizeof(ifo_handle_t));
if(!ifofile)
return NULL;
- memset(ifofile, 0, sizeof(ifo_handle_t));
-
if(title <= 0 || title > 99) {
fprintf(stderr, "libdvdread: ifoOpenVTSI invalid title (%d).\n", title);
free(ifofile);
--
2.0.4
More information about the libdvdnav-devel
mailing list