Use g_memdup2() where available and add fallback for older GLib versions
g_memdup() is deprecated since GLib 2.68 and we want to avoid deprecation warnings with recent versions of GLib.
g_memdup() is deprecated since GLib 2.68 and we want to avoid deprecation warnings with recent versions of GLib.