X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flibpspp%2Fstr.c;h=3cff0492c7d508d99d9ce0b5c77c57879bc1faf7;hb=8af88c0b7ea2fe75df7e45497988ed0371006a86;hp=f054c9ef28833046760957f2de9aabc7da6ec8dc;hpb=cdcdc851b79c8f9ddcaaa358a80670bbb21d61f2;p=pspp-builds.git diff --git a/src/libpspp/str.c b/src/libpspp/str.c index f054c9ef..3cff0492 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" @@ -1393,3 +1394,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); + } +}