X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flibpspp%2Fstr.c;h=6840393a11c0599ef07b04f565f8b0cf99b7202b;hb=8381768f3394a907c621cb9acbb77b83f5cd4875;hp=5a554b7b2acaba573aa602f1991e83a7de9145bb;hpb=0fa141762183890ebd139ccd9264f08db9011539;p=pspp-builds.git diff --git a/src/libpspp/str.c b/src/libpspp/str.c index 5a554b7b..6840393a 100644 --- a/src/libpspp/str.c +++ b/src/libpspp/str.c @@ -358,6 +358,25 @@ ss_alloc_uninit (struct substring *new, size_t cnt) new->length = cnt; } +/* Makes a pool_alloc_unaligned()'d copy of the contents of OLD + in POOL, and stores it in NEW. */ +void +ss_alloc_substring_pool (struct substring *new, struct substring old, + struct pool *pool) +{ + new->string = pool_alloc_unaligned (pool, old.length); + new->length = old.length; + memcpy (new->string, old.string, old.length); +} + +/* Allocates room for a CNT-character string in NEW in POOL. */ +void +ss_alloc_uninit_pool (struct substring *new, size_t cnt, struct pool *pool) +{ + new->string = pool_alloc_unaligned (pool, cnt); + new->length = cnt; +} + /* Frees the string that SS points to. */ void ss_dealloc (struct substring *ss)