[gtk+/gtk-2-24] gdk/win32: remove extra allocation for \r removal
- From: Marc-Andre Lureau <malureau src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gtk+/gtk-2-24] gdk/win32: remove extra allocation for \r removal
- Date: Thu, 24 Apr 2014 14:16:37 +0000 (UTC)
commit 10430feb8dbb397c42ea929dd40e411de7cd446f
Author: Marc-André Lureau <marcandre lureau gmail com>
Date: Wed Nov 6 14:33:19 2013 +0100
gdk/win32: remove extra allocation for \r removal
Although I can't find explicit documentation for clipboard pointer, it
seems to be possible to modify clibpoard memory without side-effects.
According to MSDN,
http://msdn.microsoft.com/en-us/library/windows/desktop/aa366596%28v=vs.85%29.aspx
"The global and local functions are supported for porting from 16-bit
code, or for maintaining source code compatibility with 16-bit
Windows. Starting with 32-bit Windows, the global and local functions
are implemented as wrapper functions that call the corresponding heap
functions using a handle to the process's default heap."
"Memory objects allocated by GlobalAlloc and LocalAlloc are in private,
committed pages with read/write access that cannot be accessed by other
processes. Memory allocated by using GlobalAlloc with GMEM_DDESHARE is
not actually shared globally as it is in 16-bit Windows. This value has
no effect and is available only for compatibility. "
https://bugzilla.gnome.org/show_bug.cgi?id=711553
gdk/win32/gdkselection-win32.c | 10 ++++------
1 files changed, 4 insertions(+), 6 deletions(-)
---
diff --git a/gdk/win32/gdkselection-win32.c b/gdk/win32/gdkselection-win32.c
index 1b497c5..8be7e73 100644
--- a/gdk/win32/gdkselection-win32.c
+++ b/gdk/win32/gdkselection-win32.c
@@ -529,21 +529,20 @@ gdk_selection_convert (GdkWindow *requestor,
if ((hdata = GetClipboardData (CF_UNICODETEXT)) != NULL)
{
- wchar_t *ptr, *wcs, *p, *q;
+ wchar_t *ptr, *p, *q;
guchar *data;
glong length, wclen;
if ((ptr = GlobalLock (hdata)) != NULL)
{
length = GlobalSize (hdata);
-
+
GDK_NOTE (DND, g_print ("... CF_UNICODETEXT: %ld bytes\n",
length));
/* Strip out \r */
- wcs = g_new (wchar_t, length / 2 + 1);
p = ptr;
- q = wcs;
+ q = ptr;
wclen = 0;
while (p < ptr + length / 2)
{
@@ -555,8 +554,7 @@ gdk_selection_convert (GdkWindow *requestor,
p++;
}
- data = g_utf16_to_utf8 (wcs, wclen, NULL, NULL, NULL);
- g_free (wcs);
+ data = g_utf16_to_utf8 (ptr, wclen, NULL, NULL, NULL);
if (data)
selection_property_store (requestor, _utf8_string, 8,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]