comparison libao2/audio_out.c @ 32537:8fa2f43cb760

Remove most of the NULL pointer check before free all over the code
author cboesch
date Sun, 14 Nov 2010 09:12:34 +0000
parents 32725ca88fed
children 277ec491a8a7
comparison
equal deleted inserted replaced
32536:187f26cba0ce 32537:8fa2f43cb760
147 int ao_len; 147 int ao_len;
148 if (strncmp(ao, "alsa9", 5) == 0 || strncmp(ao, "alsa1x", 6) == 0) { 148 if (strncmp(ao, "alsa9", 5) == 0 || strncmp(ao, "alsa1x", 6) == 0) {
149 mp_msg(MSGT_AO, MSGL_FATAL, MSGTR_AO_ALSA9_1x_Removed); 149 mp_msg(MSGT_AO, MSGL_FATAL, MSGTR_AO_ALSA9_1x_Removed);
150 exit_player(EXIT_NONE); 150 exit_player(EXIT_NONE);
151 } 151 }
152 if (ao_subdevice) { 152 free(ao_subdevice);
153 free(ao_subdevice); 153 ao_subdevice = NULL;
154 ao_subdevice = NULL;
155 }
156 ao_subdevice=strchr(ao,':'); 154 ao_subdevice=strchr(ao,':');
157 if(ao_subdevice){ 155 if(ao_subdevice){
158 ao_len = ao_subdevice - ao; 156 ao_len = ao_subdevice - ao;
159 ao_subdevice = strdup(&ao[ao_len + 1]); 157 ao_subdevice = strdup(&ao[ao_len + 1]);
160 } 158 }
179 mp_msg(MSGT_AO, MSGL_WARN, MSGTR_AO_NoSuchDriver, ao_len, ao); 177 mp_msg(MSGT_AO, MSGL_WARN, MSGTR_AO_NoSuchDriver, ao_len, ao);
180 // continue... 178 // continue...
181 ++ao_list; 179 ++ao_list;
182 if(!(ao_list[0])) return NULL; // do NOT fallback to others 180 if(!(ao_list[0])) return NULL; // do NOT fallback to others
183 } 181 }
184 if (ao_subdevice) { 182 free(ao_subdevice);
185 free(ao_subdevice); 183 ao_subdevice = NULL;
186 ao_subdevice = NULL;
187 }
188 184
189 mp_msg(MSGT_AO, MSGL_V, MSGTR_AO_TryingEveryKnown); 185 mp_msg(MSGT_AO, MSGL_V, MSGTR_AO_TryingEveryKnown);
190 186
191 // now try the rest... 187 // now try the rest...
192 for(i=0;audio_out_drivers[i];i++){ 188 for(i=0;audio_out_drivers[i];i++){