LinuxKPI: string.h implement memcpy_and_pad()
Add a memcpy variant which takes length of source and destination buffers and a padding character in case there is free space in the destination. This is used by a wireless driver. MFC after: 3 days Reviewed by: emaste Differential Revision: https://reviews.freebsd.org/D37226
This commit is contained in:
parent
4a67f1df8b
commit
6a647ae514
@ -236,4 +236,17 @@ memset_p(void **p, void *v, size_t n)
|
||||
return (memset64((uint64_t *)p, (uintptr_t)v, n));
|
||||
}
|
||||
|
||||
static inline void
|
||||
memcpy_and_pad(void *dst, size_t dstlen, const void *src, size_t len, int ch)
|
||||
{
|
||||
|
||||
if (len >= dstlen) {
|
||||
memcpy(dst, src, dstlen);
|
||||
} else {
|
||||
memcpy(dst, src, len);
|
||||
/* Pad with given padding character. */
|
||||
memset((char *)dst + len, ch, dstlen - len);
|
||||
}
|
||||
}
|
||||
|
||||
#endif /* _LINUXKPI_LINUX_STRING_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user