Use MapLS/UnMapLS instead of SEGPTR_* macros.

diff --git a/windows/class.c b/windows/class.c
index ddc7cb6..8e10d0c 100644
--- a/windows/class.c
+++ b/windows/class.c
@@ -24,7 +24,6 @@
 #include "wingdi.h"
 #include "wine/winuser16.h"
 #include "wine/unicode.h"
-#include "heap.h"
 #include "win.h"
 #include "user.h"
 #include "controls.h"
@@ -45,6 +44,7 @@
     INT              cbClsExtra;    /* Class extra bytes */
     INT              cbWndExtra;    /* Window extra bytes */
     LPWSTR           menuName;      /* Default menu name (Unicode followed by ASCII) */
+    SEGPTR           segMenuName;   /* Default menu name as SEGPTR */
     struct tagDCE   *dce;           /* Class DCE (if CS_CLASSDC) */
     HINSTANCE        hInstance;     /* Module that created the task */
     HICON            hIcon;         /* Default icon */
@@ -163,6 +163,20 @@
 
 
 /***********************************************************************
+ *           CLASS_GetMenuName16
+ *
+ * Get the menu name as a SEGPTR.
+ */
+inline static SEGPTR CLASS_GetMenuName16( CLASS *classPtr )
+{
+    if (!HIWORD(classPtr->menuName)) return (SEGPTR)classPtr->menuName;
+    if (!classPtr->segMenuName)
+        classPtr->segMenuName = MapLS( CLASS_GetMenuNameA(classPtr) );
+    return classPtr->segMenuName;
+}
+
+
+/***********************************************************************
  *           CLASS_GetMenuNameW
  *
  * Get the menu name as a Unicode string.
@@ -180,12 +194,14 @@
  */
 static void CLASS_SetMenuNameA( CLASS *classPtr, LPCSTR name )
 {
-    if (HIWORD(classPtr->menuName)) SEGPTR_FREE( classPtr->menuName );
+    UnMapLS( classPtr->segMenuName );
+    classPtr->segMenuName = 0;
+    if (HIWORD(classPtr->menuName)) HeapFree( GetProcessHeap(), 0, classPtr->menuName );
     if (HIWORD(name))
     {
         DWORD lenA = strlen(name) + 1;
         DWORD lenW = MultiByteToWideChar( CP_ACP, 0, name, lenA, NULL, 0 );
-        classPtr->menuName = SEGPTR_ALLOC( lenA + lenW*sizeof(WCHAR) );
+        classPtr->menuName = HeapAlloc( GetProcessHeap(), 0, lenA + lenW*sizeof(WCHAR) );
         MultiByteToWideChar( CP_ACP, 0, name, lenA, classPtr->menuName, lenW );
         memcpy( classPtr->menuName + lenW, name, lenA );
     }
@@ -200,12 +216,14 @@
  */
 static void CLASS_SetMenuNameW( CLASS *classPtr, LPCWSTR name )
 {
-    if (HIWORD(classPtr->menuName)) SEGPTR_FREE( classPtr->menuName );
+    UnMapLS( classPtr->segMenuName );
+    classPtr->segMenuName = 0;
+    if (HIWORD(classPtr->menuName)) HeapFree( GetProcessHeap(), 0, classPtr->menuName );
     if (HIWORD(name))
     {
         DWORD lenW = strlenW(name) + 1;
         DWORD lenA = WideCharToMultiByte( CP_ACP, 0, name, lenW, NULL, 0, NULL, NULL );
-        classPtr->menuName = SEGPTR_ALLOC( lenA + lenW*sizeof(WCHAR) );
+        classPtr->menuName = HeapAlloc( GetProcessHeap(), 0, lenA + lenW*sizeof(WCHAR) );
         memcpy( classPtr->menuName, name, lenW*sizeof(WCHAR) );
         WideCharToMultiByte( CP_ACP, 0, name, lenW,
                              (char *)(classPtr->menuName + lenW), lenA, NULL, NULL );
@@ -245,6 +263,7 @@
     GlobalDeleteAtom( classPtr->atomName );
     WINPROC_FreeProc( classPtr->winprocA, WIN_PROC_CLASS );
     WINPROC_FreeProc( classPtr->winprocW, WIN_PROC_CLASS );
+    UnMapLS( classPtr->segMenuName );
     HeapFree( GetProcessHeap(), 0, classPtr->menuName );
     HeapFree( GetProcessHeap(), 0, classPtr );
     return TRUE;
@@ -789,8 +808,10 @@
         release_class_ptr( class );
         return ret;
     case GCL_MENUNAME:
-        ret = GetClassLongA( hwnd, offset );
-        return (LONG)SEGPTR_GET( (void *)ret );
+        if (!(class = get_class_ptr( hwnd, FALSE ))) return 0;
+        ret = (LONG)CLASS_GetMenuName16( class );
+        release_class_ptr( class );
+        return ret;
     default:
         return GetClassLongA( hwnd, offset );
     }
@@ -1094,9 +1115,7 @@
     wc->hCursor       = classPtr->hCursor;
     wc->hbrBackground = classPtr->hbrBackground;
     wc->lpszClassName = name;
-    wc->lpszMenuName  = (SEGPTR)CLASS_GetMenuNameA( classPtr );
-    if (HIWORD(wc->lpszMenuName))  /* Make it a SEGPTR */
-        wc->lpszMenuName = SEGPTR_GET( (LPSTR)wc->lpszMenuName );
+    wc->lpszMenuName  = CLASS_GetMenuName16( classPtr );
     return TRUE;
 }
 
@@ -1206,10 +1225,8 @@
     wc->hCursor       = classPtr->hCursor;
     wc->hbrBackground = classPtr->hbrBackground;
     wc->lpszClassName = (SEGPTR)0;
-    wc->lpszMenuName  = (SEGPTR)CLASS_GetMenuNameA( classPtr );
-    if (HIWORD(wc->lpszMenuName))  /* Make it a SEGPTR */
-        wc->lpszMenuName = SEGPTR_GET( (LPSTR)wc->lpszMenuName );
-    wc->lpszClassName  = name;
+    wc->lpszMenuName  = CLASS_GetMenuName16( classPtr );
+    wc->lpszClassName = name;
 
     /* We must return the atom of the class here instead of just TRUE. */
     return atom;
diff --git a/windows/dialog.c b/windows/dialog.c
index d86b66b..f0d77b6 100644
--- a/windows/dialog.c
+++ b/windows/dialog.c
@@ -42,10 +42,10 @@
     INT16      y;
     INT16      cx;
     INT16      cy;
-    UINT     id;
+    UINT       id;
     LPCSTR     className;
     LPCSTR     windowName;
-    LPVOID     data;
+    LPCVOID    data;
 } DLG_CONTROL_INFO;
 
   /* Dialog template */
@@ -296,26 +296,21 @@
 	p += strlen(p) + 1;
     }
 
-    if (*p)
-    {
-        /* Additional CTLDATA available for this control. */
-        info->data = SEGPTR_ALLOC(*p);
-        memcpy( info->data, p + 1, *p );
-    }
+    if (*p) info->data = p + 1;
     else info->data = NULL;
 
     p += *p + 1;
 
     if(int_id)
-      TRACE("   %s %04x %d, %d, %d, %d, %d, %08lx, %08lx\n", 
+      TRACE("   %s %04x %d, %d, %d, %d, %d, %08lx, %p\n",
 		      info->className,  LOWORD(info->windowName),
 		      info->id, info->x, info->y, info->cx, info->cy,
-		      info->style, (DWORD)SEGPTR_GET(info->data) );
+		      info->style, info->data );
     else
-      TRACE("   %s '%s' %d, %d, %d, %d, %d, %08lx, %08lx\n", 
+      TRACE("   %s '%s' %d, %d, %d, %d, %d, %08lx, %p\n",
 		      info->className,  info->windowName,
 		      info->id, info->x, info->y, info->cx, info->cy,
-		      info->style, (DWORD)SEGPTR_GET(info->data) );
+		      info->style, info->data );
 
     return p;
 }
@@ -414,7 +409,7 @@
             DPRINTF("\n");
             TRACE("  END\n" );
         }
-        info->data = (LPVOID)(p + 1);
+        info->data = p + 1;
         p += GET_WORD(p) / sizeof(WORD);
     }
     else info->data = NULL;
@@ -444,6 +439,8 @@
         if (!win32)
         {
             HINSTANCE16 instance;
+            SEGPTR segptr;
+
             template = DIALOG_GetControl16( template, &info );
             if (HIWORD(info.className) && !strcmp( info.className, "EDIT") &&
                 !(GetWindowLongW( hwnd, GWL_STYLE ) & DS_LOCALEDIT))
@@ -462,6 +459,7 @@
             }
             else instance = (HINSTANCE16)hInst;
 
+            segptr = MapLS( info.data );
             hwndCtrl = WIN_Handle32( CreateWindowEx16( info.exStyle | WS_EX_NOPARENTNOTIFY,
                                                        info.className, info.windowName,
                                                        info.style | WS_CHILD,
@@ -470,9 +468,8 @@
                                                        MulDiv(info.cx, dlgInfo->xBaseUnit, 4),
                                                        MulDiv(info.cy, dlgInfo->yBaseUnit, 8),
                                                        WIN_Handle16(hwnd), (HMENU16)info.id,
-                                                       instance, (LPVOID)SEGPTR_GET(info.data) ));
-
-	    if (info.data) SEGPTR_FREE(info.data);
+                                                       instance, (LPVOID)segptr ));
+            UnMapLS( segptr );
         }
         else
         {
@@ -493,7 +490,7 @@
                                           MulDiv(info.cx, dlgInfo->xBaseUnit, 4),
                                           MulDiv(info.cy, dlgInfo->yBaseUnit, 8),
                                           hwnd, (HMENU)info.id,
-                                          hInst, info.data );
+                                          hInst, (LPVOID)info.data );
         }
         if (!hwndCtrl) return FALSE;
 
diff --git a/windows/mdi.c b/windows/mdi.c
index e6469a8..db2137e 100644
--- a/windows/mdi.c
+++ b/windows/mdi.c
@@ -544,24 +544,21 @@
     }
     else
     {
-    	MDICREATESTRUCT16 *cs16;
-        LPSTR title, cls;
+        MDICREATESTRUCT16 cs16;
+        SEGPTR title, cls, seg_cs16;
 
         WIN_ReleaseWndPtr( wndParent );
-        cs16 = SEGPTR_NEW(MDICREATESTRUCT16);
-        STRUCT32_MDICREATESTRUCT32Ato16( cs, cs16 );
-        title = SEGPTR_STRDUP( cs->szTitle );
-        cls   = SEGPTR_STRDUP( cs->szClass );
-        cs16->szTitle = SEGPTR_GET(title);
-        cs16->szClass = SEGPTR_GET(cls);
-
+        STRUCT32_MDICREATESTRUCT32Ato16( cs, &cs16 );
+        cs16.szTitle = title = MapLS( cs->szTitle );
+        cs16.szClass = cls = MapLS( cs->szClass );
+        seg_cs16 = MapLS( &cs16 );
         hwnd = WIN_Handle32( CreateWindow16( cs->szClass, cs->szTitle, style,
-                                             cs16->x, cs16->y, cs16->cx, cs16->cy,
+                                             cs16.x, cs16.y, cs16.cx, cs16.cy,
                                              WIN_Handle16(parent), (HMENU)wIDmenu,
-                                             cs16->hOwner, (LPVOID)SEGPTR_GET(cs16) ));
-        SEGPTR_FREE( title );
-        SEGPTR_FREE( cls );
-        SEGPTR_FREE( cs16 );
+                                             cs16.hOwner, (LPVOID)seg_cs16 ));
+        UnMapLS( seg_cs16 );
+        UnMapLS( title );
+        UnMapLS( cls );
     }
 
     /* MDI windows are WS_CHILD so they won't be activated by CreateWindow */