X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flibpspp%2Fstr.c;h=79f3c912e9b649cf39d3ab9a0b37510e25867bf5;hb=4f535d301fd8181ae3fbfeb023f4e016a91064d9;hp=8243aa0690aad24a9b519db9bd1838724d32d729;hpb=845f87804138053543fafe97994d18c78e65be23;p=pspp-builds.git diff --git a/src/libpspp/str.c b/src/libpspp/str.c index 8243aa06..79f3c912 100644 --- a/src/libpspp/str.c +++ b/src/libpspp/str.c @@ -1222,6 +1222,17 @@ ds_cstr (const struct string *st_) return st->ss.string; } +/* Returns the value of ST as a null-terminated string and then + reinitialized ST as an empty string. The caller must free the + returned string with free(). */ +char * +ds_steal_cstr (struct string *st) +{ + char *s = ds_cstr (st); + ds_init_empty (st); + return s; +} + /* Reads characters from STREAM and appends them to ST, stopping after MAX_LENGTH characters, after appending a newline, or after an I/O error or end of file was encountered, whichever