version 1.2, 2015/05/20 22:22:59 |
version 1.3, 2015/05/20 23:00:43 |
|
|
|
|
sl->sl_cur = 0; |
sl->sl_cur = 0; |
sl->sl_max = _SL_CHUNKSIZE; |
sl->sl_max = _SL_CHUNKSIZE; |
sl->sl_str = malloc(sl->sl_max * sizeof(char *)); |
sl->sl_str = reallocarray(NULL, sl->sl_max, sizeof(char *)); |
if (sl->sl_str == NULL) |
if (sl->sl_str == NULL) |
err(1, "stringlist"); |
err(1, "stringlist"); |
return sl; |
return sl; |
Line 63 sl_add(StringList *sl, char *name) |
|
Line 63 sl_add(StringList *sl, char *name) |
|
{ |
{ |
if (sl->sl_cur == sl->sl_max - 1) { |
if (sl->sl_cur == sl->sl_max - 1) { |
sl->sl_max += _SL_CHUNKSIZE; |
sl->sl_max += _SL_CHUNKSIZE; |
sl->sl_str = reallocf(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) |
if (sl->sl_str == NULL) |
return (-1); |
return (-1); |
} |
} |