Skip to content

Commit

Permalink
Add xstrdup()
Browse files Browse the repository at this point in the history
  • Loading branch information
Rémi Denis-Courmont committed Oct 12, 2012
1 parent cf98594 commit d1e140e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
8 changes: 8 additions & 0 deletions include/vlc_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -889,6 +889,14 @@ static inline void *xcalloc (size_t n, size_t size)
return ptr;
}

static inline char *xstrdup (const char *str)
{
char *ptr = strdup (str);
if (unlikely(ptr == NULL))
abort ();
return ptr;
}

/*****************************************************************************
* libvlc features
*****************************************************************************/
Expand Down
6 changes: 2 additions & 4 deletions src/config/core.c
Original file line number Diff line number Diff line change
Expand Up @@ -414,12 +414,10 @@ ssize_t config_GetPszChoices (vlc_object_t *obj, const char *name,

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 */
txts[i] = strdup ((cfg->list_text[i] != NULL)
txts[i] = xstrdup ((cfg->list_text[i] != NULL)
? vlc_gettext (cfg->list_text[i]) : "");
if (unlikely(vals[i] == NULL || txts[i] == NULL))
abort ();
}

*values = vals;
Expand Down

0 comments on commit d1e140e

Please sign in to comment.