Skip to content

Commit

Permalink
use reallocarray instead of realloc (nmemb * size)
Browse files Browse the repository at this point in the history
  • Loading branch information
yellowman committed May 30, 2016
1 parent 2a62d58 commit b7b3430
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion stringlist.c
Expand Up @@ -62,7 +62,8 @@ sl_add(StringList *sl, char *name)
{
if (sl->sl_cur == sl->sl_max - 1) {
sl->sl_max += _SL_CHUNKSIZE;
sl->sl_str = realloc(sl->sl_str, sl->sl_max * sizeof(char *));
sl->sl_str = reallocarray(sl->sl_str, sl->sl_max,
sizeof(char *));
if (sl->sl_str == NULL)
err(1, "stringlist");
}
Expand Down

0 comments on commit b7b3430

Please sign in to comment.