X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?p=pspp-builds.git;a=blobdiff_plain;f=src%2Flibpspp%2Fstr.c;h=afe32de9f2049bfcc5a80ac7a95b36b348be4cb7;hp=ccd7739c647b87d989b9cbc867810d915839770c;hb=8830c95bb9e8d72621787866141a27fc22e8c786;hpb=69c134ad8584c6c0dbbd908ed8ed278e920445a9 diff --git a/src/libpspp/str.c b/src/libpspp/str.c index ccd7739c..afe32de9 100644 --- a/src/libpspp/str.c +++ b/src/libpspp/str.c @@ -1441,3 +1441,25 @@ ds_relocate (struct string *st) free ((char *) rel); } } + + + + +/* Operations on uint8_t "strings" */ + +/* Copies buffer SRC, of SRC_SIZE bytes, to DST, of DST_SIZE bytes. + DST is truncated to DST_SIZE bytes or padded on the right with + copies of PAD as needed. */ +void +u8_buf_copy_rpad (uint8_t *dst, size_t dst_size, + const uint8_t *src, size_t src_size, + char pad) +{ + if (src_size >= dst_size) + memmove (dst, src, dst_size); + else + { + memmove (dst, src, src_size); + memset (&dst[src_size], pad, dst_size - src_size); + } +}