Commit df7a0f02 authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

core: config: Remove remaining calls to xmalloc/xstrdup

parent eb7a3d08
......@@ -349,20 +349,41 @@ ssize_t config_GetPszChoices(const char *name,
return cfg->list.psz_cb(name, values, texts);
}
char **vals = xmalloc (sizeof (*vals) * count);
char **txts = xmalloc (sizeof (*txts) * count);
char **vals = malloc (sizeof (*vals) * count);
char **txts = malloc (sizeof (*txts) * count);
if (!vals || !txts)
{
free (vals);
free (txts);
errno = ENOMEM;
return -1;
}
for (size_t i = 0; i < count; i++)
size_t i;
for (i = 0; i < count; i++)
{
vals[i] = xstrdup ((cfg->list.psz[i] != NULL) ? cfg->list.psz[i] : "");
vals[i] = strdup ((cfg->list.psz[i] != NULL) ? cfg->list.psz[i] : "");
/* FIXME: use module_gettext() instead */
txts[i] = xstrdup ((cfg->list_text[i] != NULL)
txts[i] = strdup ((cfg->list_text[i] != NULL)
? vlc_gettext (cfg->list_text[i]) : "");
if (!vals[i] || !txts[i])
goto error;
}
*values = vals;
*texts = txts;
return count;
error:
for (size_t j = 0; j <= i; ++j)
{
free (vals[j]);
free (txts[j]);
}
free(vals);
free(txts);
errno = ENOMEM;
return -1;
}
static int confcmp (const void *a, const void *b)
......
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