mirror of
https://gitlab.freedesktop.org/NetworkManager/NetworkManager.git
synced 2026-04-21 13:30:54 +02:00
glib-aux: add nm_memcmp_n()/nm_memeq_n() helpers
This commit is contained in:
parent
8ad4f7b70f
commit
e60843e245
1 changed files with 19 additions and 0 deletions
|
|
@ -1174,6 +1174,25 @@ _NM_IN_STRSET_EVAL_op_streq_ascii_case(const char *x1, const char *x)
|
|||
|
||||
/*****************************************************************************/
|
||||
|
||||
static inline int
|
||||
nm_memcmp_n(gconstpointer p1, gsize len1, gconstpointer p2, gsize len2, gsize element_size)
|
||||
{
|
||||
nm_assert(element_size > 0);
|
||||
|
||||
NM_CMP_DIRECT(len1, len2);
|
||||
if (len1 > 0)
|
||||
NM_CMP_DIRECT_MEMCMP(p1, p2, len1 * element_size);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static inline int
|
||||
nm_memeq_n(gconstpointer p1, gsize len1, gconstpointer p2, gsize len2, gsize element_size)
|
||||
{
|
||||
return nm_memcmp_n(p1, len1, p2, len2, element_size) == 0;
|
||||
}
|
||||
|
||||
/*****************************************************************************/
|
||||
|
||||
/* like g_memdup(). The difference is that the @size argument is of type
|
||||
* gsize, while g_memdup() has type guint. Since, the size of container types
|
||||
* like GArray is guint as well, this means trying to g_memdup() an
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue