diff --git a/debian/libwsutil0.symbols b/debian/libwsutil0.symbols index 69847c743d..016bbd6a00 100644 --- a/debian/libwsutil0.symbols +++ b/debian/libwsutil0.symbols @@ -78,7 +78,6 @@ libwsutil.so.0 libwsutil0 #MINVER# find_last_pathname_separator@Base 1.12.0~rc1 format_size_wmem@Base 3.5.0 free_progdirs@Base 2.3.0 - g_memdup2@Base 3.5.0 get_basename@Base 1.12.0~rc1 get_copyright_info@Base 1.99.0 get_cur_groupname@Base 1.10.0 diff --git a/wsutil/CMakeLists.txt b/wsutil/CMakeLists.txt index 6c4cfadd04..b9ac0dafcc 100644 --- a/wsutil/CMakeLists.txt +++ b/wsutil/CMakeLists.txt @@ -127,7 +127,6 @@ set(WSUTIL_COMMON_FILES to_str.c type_util.c unicode-utils.c - glib-compat.c ws_assert.c ws_getopt.c ws_mempbrk.c diff --git a/wsutil/glib-compat.c b/wsutil/glib-compat.c deleted file mode 100644 index 8744a9528a..0000000000 --- a/wsutil/glib-compat.c +++ /dev/null @@ -1,43 +0,0 @@ -/* -* Provide some functions that are not present in older -* GLIB versions (down to 2.22) -* -* Wireshark - Network traffic analyzer -* By Gerald Combs -* Copyright 1998 Gerald Combs -* -* SPDX-License-Identifier: GPL-2.0-or-later -*/ -#include "config.h" - -#include -#include - -#include "glib-compat.h" -#if !GLIB_CHECK_VERSION(2, 68, 0) -/** -* g_memdup2: -* mem: the memory to copy -* byte_size: the number of bytes to copy. -* -* Allocates byte_size bytes of memory, and copies byte_size bytes into it from mem . If mem is NULL it returns NULL. -* -* This replaces g_memdup(), which was prone to integer overflows when converting the argument from a gsize to a guint. -* -* Since: 2.68 -**/ -gpointer -g_memdup2(gconstpointer mem, gsize byte_size) -{ - 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 diff --git a/wsutil/glib-compat.h b/wsutil/glib-compat.h index 788f5fb41c..7864dffc2c 100644 --- a/wsutil/glib-compat.h +++ b/wsutil/glib-compat.h @@ -21,7 +21,20 @@ extern "C" { #endif /* __cplusplus */ #if !GLIB_CHECK_VERSION(2, 68, 0) -WS_DLL_PUBLIC gpointer g_memdup2(gconstpointer mem, gsize byte_size); +static inline gpointer +g_memdup2(gconstpointer mem, gsize byte_size) +{ + 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 #ifdef __cplusplus