comparison ifo_read.c @ 67:8fab3ce417ed src

Clean up malloc calls Both malloc calls have a cast to the type of the pointer's type. This is not necessary in C and is poor style.
author erik
date Sat, 13 Aug 2011 17:28:37 +0000
parents fb0ccb03eb7d
children 3748dde919dd
comparison
equal deleted inserted replaced
66:d16d554fa215 67:8fab3ce417ed
1139 1139
1140 1140
1141 int ifoRead_VTS_PTT_SRPT(ifo_handle_t *ifofile) { 1141 int ifoRead_VTS_PTT_SRPT(ifo_handle_t *ifofile) {
1142 vts_ptt_srpt_t *vts_ptt_srpt; 1142 vts_ptt_srpt_t *vts_ptt_srpt;
1143 int info_length, i, j; 1143 int info_length, i, j;
1144 uint32_t *data; 1144 uint32_t *data = NULL;
1145 1145
1146 if(!ifofile) 1146 if(!ifofile)
1147 return 0; 1147 return 0;
1148 1148
1149 if(!ifofile->vtsi_mat) 1149 if(!ifofile->vtsi_mat)
1154 1154
1155 if(!DVDFileSeek_(ifofile->file, 1155 if(!DVDFileSeek_(ifofile->file,
1156 ifofile->vtsi_mat->vts_ptt_srpt * DVD_BLOCK_LEN)) 1156 ifofile->vtsi_mat->vts_ptt_srpt * DVD_BLOCK_LEN))
1157 return 0; 1157 return 0;
1158 1158
1159 vts_ptt_srpt = (vts_ptt_srpt_t *)malloc(sizeof(vts_ptt_srpt_t)); 1159 vts_ptt_srpt = malloc(sizeof(vts_ptt_srpt_t));
1160 if(!vts_ptt_srpt) 1160 if(!vts_ptt_srpt)
1161 return 0; 1161 return 0;
1162 1162
1163 ifofile->vts_ptt_srpt = vts_ptt_srpt; 1163 ifofile->vts_ptt_srpt = vts_ptt_srpt;
1164 1164
1174 CHECK_ZERO(vts_ptt_srpt->zero_1); 1174 CHECK_ZERO(vts_ptt_srpt->zero_1);
1175 CHECK_VALUE(vts_ptt_srpt->nr_of_srpts != 0); 1175 CHECK_VALUE(vts_ptt_srpt->nr_of_srpts != 0);
1176 CHECK_VALUE(vts_ptt_srpt->nr_of_srpts < 100); /* ?? */ 1176 CHECK_VALUE(vts_ptt_srpt->nr_of_srpts < 100); /* ?? */
1177 1177
1178 info_length = vts_ptt_srpt->last_byte + 1 - VTS_PTT_SRPT_SIZE; 1178 info_length = vts_ptt_srpt->last_byte + 1 - VTS_PTT_SRPT_SIZE;
1179 1179 data = malloc(info_length);
1180 data = (uint32_t *)malloc(info_length);
1181 if(!data) { 1180 if(!data) {
1182 free(vts_ptt_srpt); 1181 free(vts_ptt_srpt);
1183 ifofile->vts_ptt_srpt = 0; 1182 ifofile->vts_ptt_srpt = 0;
1184 return 0; 1183 return 0;
1185 } 1184 }