Get rid of capacity argument to ds_init() and update all callers.
[pspp-builds.git] / src / libpspp / str.c
index cd9f1aa6f0159f7585778cdc02d0f56d9c03b263..ef2be7d068479ee023b484386a9d53d537d30407 100644 (file)
@@ -25,7 +25,6 @@
 #include <limits.h>
 #include <stdlib.h>
 
-#include <libpspp/va_copy.h>
 #include <libpspp/alloc.h>
 #include <libpspp/message.h>
 
@@ -248,13 +247,13 @@ ds_create (struct string *st, const char *s)
   strcpy (st->string, s);
 }
 
-/* Initializes ST, making room for at least CAPACITY characters. */
+/* Initializes ST as an empty string. */
 void
-ds_init (struct string *st, size_t capacity)
+ds_init (struct string *st)
 {
   st->length = 0;
-  st->capacity = MAX (8, capacity);
-  st->string = xmalloc (st->capacity + 1);
+  st->capacity = 0;
+  st->string = NULL;
 }
 
 /* Frees ST. */
@@ -286,7 +285,7 @@ ds_init_substring (struct string *dst,
                    const struct string *src, size_t idx, size_t cnt)
 {
   assert (dst != src);
-  ds_init (dst, cnt);
+  ds_init (dst);
   ds_assign_substring (dst, src, idx, cnt);
 }