summaryrefslogtreecommitdiffstats
path: root/wsutil/glib-compat.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 20:34:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-10 20:34:10 +0000
commite4ba6dbc3f1e76890b22773807ea37fe8fa2b1bc (patch)
tree68cb5ef9081156392f1dd62a00c6ccc1451b93df /wsutil/glib-compat.h
parentInitial commit. (diff)
downloadwireshark-e4ba6dbc3f1e76890b22773807ea37fe8fa2b1bc.tar.xz
wireshark-e4ba6dbc3f1e76890b22773807ea37fe8fa2b1bc.zip
Adding upstream version 4.2.2.upstream/4.2.2
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'wsutil/glib-compat.h')
-rw-r--r--wsutil/glib-compat.h46
1 files changed, 46 insertions, 0 deletions
diff --git a/wsutil/glib-compat.h b/wsutil/glib-compat.h
new file mode 100644
index 00000000..08c87009
--- /dev/null
+++ b/wsutil/glib-compat.h
@@ -0,0 +1,46 @@
+/** @file
+*
+* Definitions to provide some functions that are not present in older
+* GLIB versions we support (currently down to 2.50)
+*
+* Wireshark - Network traffic analyzer
+* By Gerald Combs <gerald@wireshark.org>
+* Copyright 1998 Gerald Combs
+*
+* SPDX-License-Identifier: GPL-2.0-or-later
+*/
+#ifndef GLIB_COMPAT_H
+#define GLIB_COMPAT_H
+
+#include "ws_symbol_export.h"
+#include "ws_attributes.h"
+
+#include <glib.h>
+#include <string.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#if !GLIB_CHECK_VERSION(2, 68, 0)
+static inline void *
+g_memdup2(gconstpointer mem, size_t byte_size)
+{
+ void * new_mem;
+
+ if (mem && byte_size != 0) {
+ new_mem = g_malloc(byte_size);
+ memcpy(new_mem, mem, byte_size);
+ }
+ else
+ new_mem = NULL;
+
+ return new_mem;
+}
+#endif
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* GLIB_COMPAT_H */