Commit d1e140e0 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Add xstrdup()

parent cf98594d
...@@ -889,6 +889,14 @@ static inline void *xcalloc (size_t n, size_t size) ...@@ -889,6 +889,14 @@ static inline void *xcalloc (size_t n, size_t size)
return ptr; return ptr;
} }
static inline char *xstrdup (const char *str)
{
char *ptr = strdup (str);
if (unlikely(ptr == NULL))
abort ();
return ptr;
}
/***************************************************************************** /*****************************************************************************
* libvlc features * libvlc features
*****************************************************************************/ *****************************************************************************/
......
...@@ -414,12 +414,10 @@ ssize_t config_GetPszChoices (vlc_object_t *obj, const char *name, ...@@ -414,12 +414,10 @@ ssize_t config_GetPszChoices (vlc_object_t *obj, const char *name,
for (size_t i = 0; i < count; i++) for (size_t i = 0; i < count; i++)
{ {
vals[i] = strdup ((cfg->list.psz[i] != NULL) ? cfg->list.psz[i] : ""); vals[i] = xstrdup ((cfg->list.psz[i] != NULL) ? cfg->list.psz[i] : "");
/* FIXME: use module_gettext() instead */ /* FIXME: use module_gettext() instead */
txts[i] = strdup ((cfg->list_text[i] != NULL) txts[i] = xstrdup ((cfg->list_text[i] != NULL)
? vlc_gettext (cfg->list_text[i]) : ""); ? vlc_gettext (cfg->list_text[i]) : "");
if (unlikely(vals[i] == NULL || txts[i] == NULL))
abort ();
} }
*values = vals; *values = vals;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment