X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=lib%2Fstring_helpers.c;h=2ddc10bd9add65efaa4f4322bd4cfd0cf9423f23;hb=refs%2Fheads%2Ftizen_8.0;hp=3806a52ce697ae091a2d9e10995c49e56a1d4f53;hpb=d6c338a741295c04ed84679153448b2fffd2c9cf;p=platform%2Fkernel%2Flinux-rpi.git diff --git a/lib/string_helpers.c b/lib/string_helpers.c index 3806a52..2ddc10b 100644 --- a/lib/string_helpers.c +++ b/lib/string_helpers.c @@ -696,3 +696,23 @@ void kfree_strarray(char **array, size_t n) kfree(array); } EXPORT_SYMBOL_GPL(kfree_strarray); + +/** + * memcpy_and_pad - Copy one buffer to another with padding + * @dest: Where to copy to + * @dest_len: The destination buffer size + * @src: Where to copy from + * @count: The number of bytes to copy + * @pad: Character to use for padding if space is left in destination. + */ +void memcpy_and_pad(void *dest, size_t dest_len, const void *src, size_t count, + int pad) +{ + if (dest_len > count) { + memcpy(dest, src, count); + memset(dest + count, pad, dest_len - count); + } else { + memcpy(dest, src, dest_len); + } +} +EXPORT_SYMBOL(memcpy_and_pad);