summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Haller <thaller@redhat.com>2018-09-06 14:17:22 +0200
committerThomas Haller <thaller@redhat.com>2018-09-07 11:24:17 +0200
commit0feeeaac636e39e724a2b3dc848b0fe12858d859 (patch)
tree2b97233fe6b555670bc0713758634e91a131917d
parent085a3694463caf2c7a8e214fea351353c66dbad4 (diff)
downloadNetworkManager-0feeeaac636e39e724a2b3dc848b0fe12858d859.tar.gz
shared: add nm_utils_mem_all_zero()
-rw-r--r--shared/nm-utils/nm-shared-utils.h16
1 files changed, 16 insertions, 0 deletions
diff --git a/shared/nm-utils/nm-shared-utils.h b/shared/nm-utils/nm-shared-utils.h
index ce5fd9986e..778938e09c 100644
--- a/shared/nm-utils/nm-shared-utils.h
+++ b/shared/nm-utils/nm-shared-utils.h
@@ -190,6 +190,22 @@ nm_ip_addr_set (int addr_family, gpointer dst, const NMIPAddr *src)
/*****************************************************************************/
+static inline gboolean
+nm_utils_mem_all_zero (gconstpointer mem, gsize len)
+{
+ const guint8 *p;
+
+ for (p = mem; len-- > 0; p++) {
+ if (*p != 0)
+ return FALSE;
+ }
+
+ /* incidentally, a buffer with len==0, is also *all-zero*. */
+ return TRUE;
+}
+
+/*****************************************************************************/
+
/* 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