Alexandre Julliard : user: Added fast A-> W mapping for LB_GETTEXT and CB_GETLBTEXT.

Alexandre Julliard julliard at wine.codeweavers.com
Mon May 22 05:19:06 CDT 2006


Module: wine
Branch: refs/heads/master
Commit: 19b428755cccd3b70513e36a4680ad9c81f575ae
URL:    http://source.winehq.org/git/?p=wine.git;a=commit;h=19b428755cccd3b70513e36a4680ad9c81f575ae

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Sat May 20 18:55:34 2006 +0200

user: Added fast A->W mapping for LB_GETTEXT and CB_GETLBTEXT.

---

 dlls/user/winproc.c |   41 ++++++++++++++++++-----------------------
 1 files changed, 18 insertions(+), 23 deletions(-)

diff --git a/dlls/user/winproc.c b/dlls/user/winproc.c
index 8e71bfc..470bbce 100644
--- a/dlls/user/winproc.c
+++ b/dlls/user/winproc.c
@@ -775,17 +775,6 @@ static INT WINPROC_MapMsg32ATo32W( HWND 
     case LB_GETTEXTLEN:
         return 1;  /* need to map result */
 
-    case LB_GETTEXT:                /* FIXME: fixed sized buffer */
-    case CB_GETLBTEXT:
-        if ( WINPROC_TestLBForStr( hwnd, msg ))
-        {
-            LPARAM *ptr = HeapAlloc( GetProcessHeap(), 0, 512 * sizeof(WCHAR) + sizeof(LPARAM) );
-            if (!ptr) return -1;
-            *ptr++ = *plparam;  /* Store previous lParam */
-            *plparam = (LPARAM)ptr;
-        }
-        return 1;
-
 /* Multiline edit */
     case EM_GETLINE:
         { WORD len = (WORD)*plparam;
@@ -885,18 +874,6 @@ static LRESULT WINPROC_UnmapMsg32ATo32W(
         HeapFree( GetProcessHeap(), 0, (void *)lParam );
         break;
 
-    case LB_GETTEXT:
-    case CB_GETLBTEXT:
-        if ( WINPROC_TestLBForStr( hwnd, msg ))
-        {
-            LPARAM *ptr = (LPARAM *)lParam - 1;
-            if (result >= 0)
-                result = WideCharToMultiByte( CP_ACP, 0, (LPWSTR)lParam, -1,
-                                              (LPSTR)*ptr, 0x7fffffff, NULL, NULL ) - 1;
-            HeapFree( GetProcessHeap(), 0, ptr );
-        }
-        break;
-
 /* Multiline edit */
     case EM_GETLINE:
         {
@@ -2713,6 +2690,24 @@ LRESULT WINPROC_CallProcAtoW( winproc_ca
         }
         break;
 
+    case LB_GETTEXT:
+    case CB_GETLBTEXT:
+        if (lParam && WINPROC_TestLBForStr( hwnd, msg ))
+        {
+            WCHAR buffer[512];  /* FIXME: fixed sized buffer */
+
+            ret = callback( hwnd, msg, wParam, (LPARAM)buffer, result, arg );
+            if (*result >= 0)
+            {
+                DWORD len;
+                RtlUnicodeToMultiByteN( (LPSTR)lParam, ~0u, &len,
+                                        buffer, (strlenW(buffer) + 1) * sizeof(WCHAR) );
+                *result = len - 1;
+            }
+        }
+        else ret = callback( hwnd, msg, wParam, lParam, result, arg );
+        break;
+
     default:
         if( (unmap = WINPROC_MapMsg32ATo32W( hwnd, msg, &wParam, &lParam )) == -1) {
             ERR_(msg)("Message translation failed. (msg=%s,wp=%08x,lp=%08lx)\n",




More information about the wine-cvs mailing list