mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-05-06 03:28:03 +02:00
std-aux: add nm_memcpy() helper for handling copy of zero bytes
This commit is contained in:
parent
50b6f3d6d3
commit
263832a455
1 changed files with 11 additions and 0 deletions
|
|
@ -501,6 +501,17 @@ nm_memeq(const void *s1, const void *s2, size_t len)
|
|||
return nm_memcmp(s1, s2, len) == 0;
|
||||
}
|
||||
|
||||
static inline void *
|
||||
nm_memcpy(void *restrict dest, const void *restrict src, size_t n)
|
||||
{
|
||||
/* Workaround undefined behavior in memcpy() with NULL pointers. */
|
||||
if (n == 0)
|
||||
return dest;
|
||||
|
||||
nm_assert(src);
|
||||
return memcpy(dest, src, n);
|
||||
}
|
||||
|
||||
/*
|
||||
* Very similar to g_str_has_prefix() with the obvious meaning.
|
||||
* Differences:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue