From 1f0aad98144e1ffc2fe5bc5793a9eb1c98e26bb2 Mon Sep 17 00:00:00 2001 From: Andrea Fioraldi Date: Wed, 25 Oct 2023 11:54:28 +0200 Subject: [PATCH] Fix lockstep plugin with old glib2 --- contrib/plugins/lockstep.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/contrib/plugins/lockstep.c b/contrib/plugins/lockstep.c index f0cb8792c6..33654c5c60 100644 --- a/contrib/plugins/lockstep.c +++ b/contrib/plugins/lockstep.c @@ -33,6 +33,25 @@ #include +static inline gpointer g_memdup2_qemu(gconstpointer mem, gsize byte_size) +{ +#if GLIB_CHECK_VERSION(2, 68, 0) + return g_memdup2(mem, byte_size); +#else + gpointer 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 +} +#define g_memdup2(m, s) g_memdup2_qemu(m, s) + QEMU_PLUGIN_EXPORT int qemu_plugin_version = QEMU_PLUGIN_VERSION; /* saved so we can uninstall later */