Use g_memdup2() where available and add fallback for older GLib versions
Size is constant here, so no problem in any case, but g_memdup() is now deprecated and we don't want deprecation warnings.
Size is constant here, so no problem in any case, but g_memdup() is now deprecated and we don't want deprecation warnings.