summaryrefslogtreecommitdiff
path: root/sh-i18n--envsubst.c
diff options
context:
space:
mode:
Diffstat (limited to 'sh-i18n--envsubst.c')
-rw-r--r--sh-i18n--envsubst.c21
1 files changed, 2 insertions, 19 deletions
diff --git a/sh-i18n--envsubst.c b/sh-i18n--envsubst.c
index 5ddd688..2842a22 100644
--- a/sh-i18n--envsubst.c
+++ b/sh-i18n--envsubst.c
@@ -208,11 +208,8 @@ string_list_append (string_list_ty *slp, const char *s)
/* Grow the list. */
if (slp->nitems >= slp->nitems_max)
{
- size_t nbytes;
-
slp->nitems_max = slp->nitems_max * 2 + 4;
- nbytes = slp->nitems_max * sizeof (slp->item[0]);
- slp->item = (const char **) xrealloc (slp->item, nbytes);
+ REALLOC_ARRAY(slp->item, slp->nitems_max);
}
/* Add the string to the end of the list. */
@@ -237,18 +234,6 @@ string_list_sort (string_list_ty *slp)
qsort (slp->item, slp->nitems, sizeof (slp->item[0]), cmp_string);
}
-/* Test whether a string list contains a given string. */
-static inline int
-string_list_member (const string_list_ty *slp, const char *s)
-{
- size_t j;
-
- for (j = 0; j < slp->nitems; ++j)
- if (strcmp (slp->item[j], s) == 0)
- return 1;
- return 0;
-}
-
/* Test whether a sorted string list contains a given string. */
static int
sorted_string_list_member (const string_list_ty *slp, const char *s)
@@ -290,9 +275,7 @@ static string_list_ty variables_set;
static void
note_variable (const char *var_ptr, size_t var_len)
{
- char *string = xmalloc (var_len + 1);
- memcpy (string, var_ptr, var_len);
- string[var_len] = '\0';
+ char *string = xmemdupz (var_ptr, var_len);
string_list_append (&variables_set, string);
}