macos: Move from g_memdup() to g_memdup2()

The g_memdup() function is replaced by a safer version in newer versions
of GLib.
This commit is contained in:
Emmanuele Bassi 2021-02-04 19:13:36 +00:00
parent 504b5bbd1b
commit 435d12680d
2 changed files with 6 additions and 4 deletions

View File

@ -23,6 +23,7 @@
#include "gdkmacosclipboard-private.h"
#include "gdkmacosutils-private.h"
#include "gdk-private.h"
struct _GdkMacosClipboard
{
@ -213,7 +214,7 @@ create_stream_from_nsdata (NSData *data)
const guint8 *bytes = [data bytes];
gsize len = [data length];
return g_memory_input_stream_new_from_data (g_memdup (bytes, len), len, g_free);
return g_memory_input_stream_new_from_data (g_memdup2 (bytes, len), len, g_free);
}
static void
@ -309,7 +310,7 @@ _gdk_macos_clipboard_read_async (GdkClipboard *clipboard,
color[2] = 0xffff * [nscolor blueComponent];
color[3] = 0xffff * [nscolor alphaComponent];
stream = g_memory_input_stream_new_from_data (g_memdup (&color, sizeof color),
stream = g_memory_input_stream_new_from_data (g_memdup2 (&color, sizeof color),
sizeof color,
g_free);
}

View File

@ -28,6 +28,8 @@
#include "gdkmacosdevice.h"
#include "gdkmacosseat-private.h"
#include "gdk-private.h"
typedef struct
{
NSUInteger device_id;
@ -622,6 +624,5 @@ _gdk_macos_seat_get_tablet_axes_from_nsevent (GdkMacosSeat *seat,
[nsevent rotation], &tablet->axes[GDK_AXIS_ROTATION]);
}
return g_memdup (tablet->axes,
sizeof (double) * GDK_AXIS_LAST);
return g_memdup2 (tablet->axes, sizeof (double) * GDK_AXIS_LAST);
}