mirror of
https://github.com/systemd/systemd.git
synced 2025-01-09 01:18:19 +03:00
basic/memory-util: make mempcpy_typesafe() take number of obj rather than raw size
Follow-up for eda6223942
This commit is contained in:
parent
34fb408f8b
commit
47941afd17
@ -35,7 +35,12 @@ static inline void* mempcpy_safe(void *dst, const void *src, size_t n) {
|
||||
return mempcpy(dst, src, n);
|
||||
}
|
||||
|
||||
#define mempcpy_typesafe(dst, src, n) (typeof((dst)[0])*) mempcpy_safe(dst, src, n)
|
||||
#define mempcpy_typesafe(dst, src, n) \
|
||||
({ \
|
||||
size_t _sz_; \
|
||||
assert_se(MUL_SAFE(&_sz_, sizeof((dst)[0]), n)); \
|
||||
(typeof((dst)[0])*) mempcpy_safe(dst, src, _sz_); \
|
||||
})
|
||||
|
||||
/* Normal memcmp() requires s1 and s2 to be nonnull. We do nothing if n is 0. */
|
||||
static inline int memcmp_safe(const void *s1, const void *s2, size_t n) {
|
||||
|
Loading…
Reference in New Issue
Block a user