X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flibpspp%2Fstr.c;h=552968b5c837d02411e4e101a7ba419b1b0d7a32;hb=46b52782d51c442adc7fefe498c5392138f6c9fe;hp=9a7c6da8bfa8c36e50cca3cfd7b7bfe99a6cf0db;hpb=57166a5a5c4016b83b9a35ac32c219ff853dc9ce;p=pspp-builds.git diff --git a/src/libpspp/str.c b/src/libpspp/str.c index 9a7c6da8..552968b5 100644 --- a/src/libpspp/str.c +++ b/src/libpspp/str.c @@ -26,6 +26,7 @@ #include #include +#include #include "minmax.h" #include "xalloc.h" #include "xsize.h" @@ -1396,3 +1397,20 @@ ds_put_char_multiple (struct string *st, int ch, size_t cnt) { memset (ds_put_uninit (st, cnt), ch, cnt); } + + +/* If relocation has been enabled, replace ST, + with its relocated version */ +void +ds_relocate (struct string *st) +{ + const char *orig = ds_cstr (st); + const char *rel = relocate (orig); + + if ( orig != rel) + { + ds_clear (st); + ds_put_cstr (st, rel); + free ((char *) rel); + } +}