X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flibpspp%2Fstr.c;h=ef2be7d068479ee023b484386a9d53d537d30407;hb=7a2039fb1ebfd48013ab259b28091e74e7f50588;hp=70edaeede16c0ac5bdf871d620b690cbd7118d59;hpb=6a28b70283f37b5cd08423098c9d39cef9f6add5;p=pspp-builds.git diff --git a/src/libpspp/str.c b/src/libpspp/str.c index 70edaeed..ef2be7d0 100644 --- a/src/libpspp/str.c +++ b/src/libpspp/str.c @@ -247,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. */ @@ -285,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); }