comparison gui/interface.c @ 37072:9ed2c7f5c941

Rewrite add_vf(). Prefer calloc() to malloc(). As a result, vf_settings[1] doesn't need to be cleared. Additionally, check the result of the allocation.
author ib
date Thu, 24 Apr 2014 12:50:14 +0000
parents c16af0693c42
children 3ec195585bfd
comparison
equal deleted inserted replaced
37071:c16af0693c42 37072:9ed2c7f5c941
297 vf_settings[i].name = strdup(vf); 297 vf_settings[i].name = strdup(vf);
298 vf_settings[i].attribs = NULL; 298 vf_settings[i].attribs = NULL;
299 memset(&vf_settings[i + 1], 0, sizeof(m_obj_settings_t)); 299 memset(&vf_settings[i + 1], 0, sizeof(m_obj_settings_t));
300 } 300 }
301 } else { 301 } else {
302 vf_settings = malloc(2 * sizeof(m_obj_settings_t)); 302 vf_settings = calloc(2, sizeof(m_obj_settings_t));
303
304 if (!vf_settings)
305 return;
306
303 vf_settings[0].name = strdup(vf); 307 vf_settings[0].name = strdup(vf);
304 vf_settings[0].attribs = NULL; 308 vf_settings[0].attribs = NULL;
305 vf_settings[1].name = NULL;
306 } 309 }
307 310
308 mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_GUI_MSG_AddingVideoFilter, vf); 311 mp_msg(MSGT_GPLAYER, MSGL_INFO, MSGTR_GUI_MSG_AddingVideoFilter, vf);
309 } 312 }
310 313