summaryrefslogtreecommitdiffstats
path: root/wsutil/array.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-19 04:14:53 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-09-19 04:14:53 +0000
commita86c5f7cae7ec9a3398300555a0b644689d946a1 (patch)
tree39fe4b107c71174fd1e8a8ceb9a4d2aa14116248 /wsutil/array.h
parentReleasing progress-linux version 4.2.6-1~progress7.99u1. (diff)
downloadwireshark-a86c5f7cae7ec9a3398300555a0b644689d946a1.tar.xz
wireshark-a86c5f7cae7ec9a3398300555a0b644689d946a1.zip
Merging upstream version 4.4.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'wsutil/array.h')
-rw-r--r--wsutil/array.h25
1 files changed, 25 insertions, 0 deletions
diff --git a/wsutil/array.h b/wsutil/array.h
new file mode 100644
index 00000000..1e23b5f6
--- /dev/null
+++ b/wsutil/array.h
@@ -0,0 +1,25 @@
+/** @file
+ * Utility functions/macros for handling arrays, C and/or glib.
+ *
+ * Wireshark - Network traffic analyzer
+ * By Gerald Combs <gerald@wireshark.org>
+ * Copyright 1998 Gerald Combs
+ *
+ * SPDX-License-Identifier: GPL-2.0-or-later
+ */
+
+#ifndef __WSUTIL_ARRAY_H__
+#define __WSUTIL_ARRAY_H__
+
+#include <stdlib.h>
+#include <glib.h>
+
+/** Useful when you have an array whose size is known at compile-time. */
+#define array_length(x) (sizeof (x) / sizeof (x)[0])
+
+/** glib doesn't have g_ptr_array_len, of all things! */
+#ifndef g_ptr_array_len
+#define g_ptr_array_len(a) ((a) ? (a)->len : 0)
+#endif
+
+#endif /* __WSUTIL_ARRAY_H__ */