diff --git a/dlls/gdi/gdiobj.c b/dlls/gdi/gdiobj.c index 0087c76b47e..d4f835d811d 100644 --- a/dlls/gdi/gdiobj.c +++ b/dlls/gdi/gdiobj.c @@ -1459,7 +1459,7 @@ DWORD WINAPI GdiSeeGdiDo16( WORD wReqType, WORD wParam1, WORD wParam2, case 0x0002: /* LocalFree */ return LOCAL_Free( GDI_HeapSel, wParam1 ); case 0x0003: /* LocalCompact */ - return LOCAL_Compact( GDI_HeapSel, wParam3, 0 ); + return LOCAL_Compact( GDI_HeapSel, wParam3 ); case 0x0103: /* LocalHeap */ return GDI_HeapSel; default: diff --git a/dlls/kernel/kernel32.spec b/dlls/kernel/kernel32.spec index 4f092370456..66c285b7aac 100644 --- a/dlls/kernel/kernel32.spec +++ b/dlls/kernel/kernel32.spec @@ -1138,6 +1138,14 @@ @ stdcall LocalInit16(long long long) @ stdcall LocalLock16(long) @ stdcall LocalUnlock16(long) +@ stdcall LocalReAlloc16(long long long) +@ stdcall LocalFree16(long) +@ stdcall LocalSize16(long) +@ stdcall LocalHandle16(long) +@ stdcall LocalFlags16(long) +@ stdcall LocalCompact16(long) +@ stdcall LocalCountFree16() +@ stdcall LocalHeapSize16() @ stdcall LockResource16(long) @ stdcall SelectorAccessRights16(long long long) @ stdcall SetSelectorBase(long long) @@ -1169,13 +1177,4 @@ # Wine dll separation hacks, these will go away, don't use them # @ cdecl DOSMEM_AllocSelector(long) -@ cdecl LOCAL_Alloc(long long long) -@ cdecl LOCAL_Compact(long long long) -@ cdecl LOCAL_CountFree(long) -@ cdecl LOCAL_Free(long long) -@ cdecl LOCAL_HeapSize(long) -@ cdecl LOCAL_Lock(long long) -@ cdecl LOCAL_ReAlloc(long long long long) -@ cdecl LOCAL_Size(long long) -@ cdecl LOCAL_Unlock(long long) @ stdcall NE_DefResourceHandler(long long long) diff --git a/dlls/kernel/local16.c b/dlls/kernel/local16.c index ad07950ca5f..5d513fe79fa 100644 --- a/dlls/kernel/local16.c +++ b/dlls/kernel/local16.c @@ -726,9 +726,9 @@ static WORD LOCAL_GetFreeSpace(WORD ds, WORD countdiscard) /*********************************************************************** - * LOCAL_Compact + * local_compact */ -WORD LOCAL_Compact( HANDLE16 ds, UINT16 minfree, UINT16 flags ) +static UINT16 local_compact( HANDLE16 ds, UINT16 minfree, UINT16 flags ) { char *ptr = MapSL( MAKESEGPTR( ds, 0 ) ); LOCALHEAPINFO *pInfo; @@ -845,7 +845,7 @@ WORD LOCAL_Compact( HANDLE16 ds, UINT16 minfree, UINT16 flags ) } table = *(WORD *)pEntry; } - return LOCAL_Compact(ds, 0xffff, LMEM_NODISCARD); + return local_compact(ds, 0xffff, LMEM_NODISCARD); } @@ -931,7 +931,7 @@ notify_done: arena = LOCAL_FindFreeBlock( ds, size ); if (arena == 0) { /* no space: try to make some */ - LOCAL_Compact( ds, size, flags ); + local_compact( ds, size, flags ); arena = LOCAL_FindFreeBlock( ds, size ); } if (arena == 0) { @@ -1117,12 +1117,11 @@ static void LOCAL_FreeHandleEntry( HANDLE16 ds, HLOCAL16 handle ) /*********************************************************************** - * LOCAL_Free - * - * Implementation of LocalFree(). + * LocalFree (KERNEL.7) */ -HLOCAL16 LOCAL_Free( HANDLE16 ds, HLOCAL16 handle ) +HLOCAL16 WINAPI LocalFree16( HLOCAL16 handle ) { + HANDLE16 ds = CURRENT_DS; char *ptr = MapSL( MAKESEGPTR( ds, 0 ) ); TRACE("%04x ds=%04x\n", handle, ds ); @@ -1150,15 +1149,13 @@ HLOCAL16 LOCAL_Free( HANDLE16 ds, HLOCAL16 handle ) /*********************************************************************** - * LOCAL_Alloc - * - * Implementation of LocalAlloc(). - * + * LocalAlloc (KERNEL.5) */ -HLOCAL16 LOCAL_Alloc( HANDLE16 ds, WORD flags, WORD size ) +HLOCAL16 WINAPI LocalAlloc16( UINT16 flags, WORD size ) { + HANDLE16 ds = CURRENT_DS; + HLOCAL16 handle = 0; char *ptr; - HLOCAL16 handle; TRACE("%04x %d ds=%04x\n", flags, size, ds ); @@ -1171,7 +1168,7 @@ HLOCAL16 LOCAL_Alloc( HANDLE16 ds, WORD flags, WORD size ) if(size) { if (!(hmem = LOCAL_GetBlock( ds, size + MOVEABLE_PREFIX, flags ))) - return 0; + goto exit; } else /* We just need to allocate a discarded handle */ hmem = 0; @@ -1180,7 +1177,7 @@ HLOCAL16 LOCAL_Alloc( HANDLE16 ds, WORD flags, WORD size ) WARN("Couldn't get handle.\n"); if(hmem) LOCAL_FreeArena( ds, ARENA_HEADER(hmem) ); - return 0; + goto exit; } ptr = MapSL( MAKESEGPTR( ds, 0 ) ); plhe = (LOCALHANDLEENTRY *)(ptr + handle); @@ -1199,21 +1196,21 @@ HLOCAL16 LOCAL_Alloc( HANDLE16 ds, WORD flags, WORD size ) } else /* FIXED */ { - if(!size) - return 0; - handle = LOCAL_GetBlock( ds, size, flags ); + if(size) handle = LOCAL_GetBlock( ds, size, flags ); } + +exit: + CURRENT_STACK16->ecx = handle; /* must be returned in cx too */ return handle; } /*********************************************************************** - * LOCAL_ReAlloc - * - * Implementation of LocalReAlloc(). + * LocalReAlloc (KERNEL.6) */ -HLOCAL16 LOCAL_ReAlloc( HANDLE16 ds, HLOCAL16 handle, WORD size, WORD flags ) +HLOCAL16 WINAPI LocalReAlloc16( HLOCAL16 handle, WORD size, UINT16 flags ) { + HANDLE16 ds = CURRENT_DS; char *ptr = MapSL( MAKESEGPTR( ds, 0 ) ); LOCALHEAPINFO *pInfo; LOCALARENA *pArena, *pNext; @@ -1433,20 +1430,11 @@ static HLOCAL16 LOCAL_InternalLock( LPSTR heap, HLOCAL16 handle ) /*********************************************************************** - * LOCAL_Lock + * LocalUnlock (KERNEL.9) */ -void *LOCAL_Lock( HANDLE16 ds, HLOCAL16 handle ) -{ - char *ptr = MapSL( MAKESEGPTR( ds, 0 ) ); - return handle ? ptr + LOCAL_InternalLock( ptr, handle ) : NULL; -} - - -/*********************************************************************** - * LOCAL_Unlock - */ -BOOL16 LOCAL_Unlock( HANDLE16 ds, HLOCAL16 handle ) +BOOL16 WINAPI LocalUnlock16( HLOCAL16 handle ) { + HANDLE16 ds = CURRENT_DS; char *ptr = MapSL( MAKESEGPTR( ds, 0 ) ); TRACE("%04x\n", handle ); @@ -1463,12 +1451,11 @@ BOOL16 LOCAL_Unlock( HANDLE16 ds, HLOCAL16 handle ) /*********************************************************************** - * LOCAL_Size - * - * Implementation of LocalSize(). + * LocalSize (KERNEL.10) */ -WORD LOCAL_Size( HANDLE16 ds, HLOCAL16 handle ) +UINT16 WINAPI LocalSize16( HLOCAL16 handle ) { + HANDLE16 ds = CURRENT_DS; char *ptr = MapSL( MAKESEGPTR( ds, 0 ) ); LOCALARENA *pArena; @@ -1489,12 +1476,11 @@ WORD LOCAL_Size( HANDLE16 ds, HLOCAL16 handle ) /*********************************************************************** - * LOCAL_Flags - * - * Implementation of LocalFlags(). + * LocalFlags (KERNEL.12) */ -WORD LOCAL_Flags( HANDLE16 ds, HLOCAL16 handle ) +UINT16 WINAPI LocalFlags16( HLOCAL16 handle ) { + HANDLE16 ds = CURRENT_DS; char *ptr = MapSL( MAKESEGPTR( ds, 0 ) ); if (HANDLE_MOVEABLE(handle)) @@ -1514,25 +1500,22 @@ WORD LOCAL_Flags( HANDLE16 ds, HLOCAL16 handle ) /*********************************************************************** - * LOCAL_HeapSize - * - * Implementation of LocalHeapSize(). + * LocalHeapSize (KERNEL.162) */ -WORD LOCAL_HeapSize( HANDLE16 ds ) +WORD WINAPI LocalHeapSize16(void) { + HANDLE16 ds = CURRENT_DS; LOCALHEAPINFO *pInfo = LOCAL_GetHeap( ds ); - if (!pInfo) return 0; - return pInfo->last - pInfo->first; + return pInfo ? pInfo->last - pInfo->first : 0; } /*********************************************************************** - * LOCAL_CountFree - * - * Implementation of LocalCountFree(). + * LocalCountFree (KERNEL.161) */ -WORD LOCAL_CountFree( HANDLE16 ds ) +WORD WINAPI LocalCountFree16(void) { + HANDLE16 ds = CURRENT_DS; WORD arena, total; LOCALARENA *pArena; LOCALHEAPINFO *pInfo; @@ -1561,12 +1544,11 @@ WORD LOCAL_CountFree( HANDLE16 ds ) /*********************************************************************** - * LOCAL_Handle - * - * Implementation of LocalHandle(). + * LocalHandle (KERNEL.11) */ -HLOCAL16 LOCAL_Handle( HANDLE16 ds, WORD addr ) +HLOCAL16 WINAPI LocalHandle16( WORD addr ) { + HANDLE16 ds = CURRENT_DS; char *ptr = MapSL( MAKESEGPTR( ds, 0 ) ); LOCALHEAPINFO *pInfo; WORD table; @@ -1594,33 +1576,6 @@ HLOCAL16 LOCAL_Handle( HANDLE16 ds, WORD addr ) } -/*********************************************************************** - * LocalAlloc (KERNEL.5) - */ -HLOCAL16 WINAPI LocalAlloc16( UINT16 flags, WORD size ) -{ - HLOCAL16 ret = LOCAL_Alloc( CURRENT_DS, flags, size ); - CURRENT_STACK16->ecx = ret; /* must be returned in cx too */ - return ret; -} - - -/*********************************************************************** - * LocalReAlloc (KERNEL.6) - */ -HLOCAL16 WINAPI LocalReAlloc16( HLOCAL16 handle, WORD size, UINT16 flags ) -{ - return LOCAL_ReAlloc( CURRENT_DS, handle, size, flags ); -} - - -/*********************************************************************** - * LocalFree (KERNEL.7) - */ -HLOCAL16 WINAPI LocalFree16( HLOCAL16 handle ) -{ - return LOCAL_Free( CURRENT_DS, handle ); -} /*********************************************************************** @@ -1636,49 +1591,13 @@ SEGPTR WINAPI LocalLock16( HLOCAL16 handle ) } -/*********************************************************************** - * LocalUnlock (KERNEL.9) - */ -BOOL16 WINAPI LocalUnlock16( HLOCAL16 handle ) -{ - return LOCAL_Unlock( CURRENT_DS, handle ); -} - - -/*********************************************************************** - * LocalSize (KERNEL.10) - */ -UINT16 WINAPI LocalSize16( HLOCAL16 handle ) -{ - return LOCAL_Size( CURRENT_DS, handle ); -} - - -/*********************************************************************** - * LocalHandle (KERNEL.11) - */ -HLOCAL16 WINAPI LocalHandle16( WORD addr ) -{ - return LOCAL_Handle( CURRENT_DS, addr ); -} - - -/*********************************************************************** - * LocalFlags (KERNEL.12) - */ -UINT16 WINAPI LocalFlags16( HLOCAL16 handle ) -{ - return LOCAL_Flags( CURRENT_DS, handle ); -} - - /*********************************************************************** * LocalCompact (KERNEL.13) */ UINT16 WINAPI LocalCompact16( UINT16 minfree ) { TRACE("%04x\n", minfree ); - return LOCAL_Compact( CURRENT_DS, minfree, 0 ); + return local_compact( CURRENT_DS, minfree, 0 ); } @@ -1745,25 +1664,6 @@ DWORD WINAPI GetHeapSpaces16( HMODULE16 module ) } -/*********************************************************************** - * LocalCountFree (KERNEL.161) - */ -WORD WINAPI LocalCountFree16(void) -{ - return LOCAL_CountFree( CURRENT_DS ); -} - - -/*********************************************************************** - * LocalHeapSize (KERNEL.162) - */ -WORD WINAPI LocalHeapSize16(void) -{ - TRACE("(void)\n" ); - return LOCAL_HeapSize( CURRENT_DS ); -} - - /*********************************************************************** * LocalHandleDelta (KERNEL.310) */ diff --git a/include/local.h b/include/local.h index bf17b6da782..b3fc9f95b04 100644 --- a/include/local.h +++ b/include/local.h @@ -23,22 +23,133 @@ #include #include +#include +#include /* These function are equivalent to the Local* API functions, */ /* excepted that they need DS as the first parameter. This */ /* allows managing several heaps from the emulation library. */ +static inline HLOCAL16 LOCAL_Alloc( HANDLE16 ds, UINT16 flags, WORD size ) +{ + HANDLE16 oldDS = CURRENT_DS; + HLOCAL16 ret; + + CURRENT_DS = ds; + ret = LocalAlloc16 (flags, size); + CURRENT_DS = oldDS; + return ret; +} + +static inline HLOCAL16 LOCAL_ReAlloc( HANDLE16 ds, HLOCAL16 handle, WORD size, UINT16 flags ) +{ + HANDLE16 oldDS = CURRENT_DS; + HLOCAL16 ret; + + CURRENT_DS = ds; + ret = LocalReAlloc16 (handle, size, flags); + CURRENT_DS = oldDS; + return ret; +} + +static inline HLOCAL16 LOCAL_Free( HANDLE16 ds, HLOCAL16 handle ) +{ + HANDLE16 oldDS = CURRENT_DS; + HLOCAL16 ret; + + CURRENT_DS = ds; + ret = LocalFree16 (handle); + CURRENT_DS = oldDS; + return ret; +} +static inline HLOCAL16 LOCAL_Handle( HANDLE16 ds, WORD addr ) +{ + HANDLE16 oldDS = CURRENT_DS; + HLOCAL16 ret; + + CURRENT_DS = ds; + ret = LocalHandle16 (addr); + CURRENT_DS = oldDS; + return ret; +} + +static inline UINT16 LOCAL_Size( HANDLE16 ds, HLOCAL16 handle ) +{ + HANDLE16 oldDS = CURRENT_DS; + UINT16 ret; + + CURRENT_DS = ds; + ret = LocalSize16 (handle); + CURRENT_DS = oldDS; + return ret; +} + +static inline UINT16 LOCAL_Flags( HANDLE16 ds, HLOCAL16 handle ) +{ + HANDLE16 oldDS = CURRENT_DS; + UINT16 ret; + + CURRENT_DS = ds; + ret = LocalFlags16 (handle); + CURRENT_DS = oldDS; + return ret; +} + + +static inline UINT16 LOCAL_HeapSize( HANDLE16 ds ) +{ + HANDLE16 oldDS = CURRENT_DS; + UINT16 ret; + + CURRENT_DS = ds; + ret = LocalHeapSize16 (); + CURRENT_DS = oldDS; + return ret; +} + +static inline UINT16 LOCAL_CountFree( HANDLE16 ds ) +{ + HANDLE16 oldDS = CURRENT_DS; + UINT16 ret; + + CURRENT_DS = ds; + ret = LocalCountFree16 (); + CURRENT_DS = oldDS; + return ret; +} + +static inline void *LOCAL_Lock( HANDLE16 ds, HLOCAL16 handle ) +{ + HANDLE16 oldDS = CURRENT_DS; + SEGPTR ret; + + CURRENT_DS = ds; + ret = LocalLock16 (handle); + CURRENT_DS = oldDS; + + return MapSL(ret); +} + +static inline BOOL16 LOCAL_Unlock( HANDLE16 ds, HLOCAL16 handle ) +{ + HANDLE16 oldDS = CURRENT_DS; + BOOL16 ret; + + CURRENT_DS = ds; + ret = LocalUnlock16 (handle); + CURRENT_DS = oldDS; + return ret; +} + +static inline WORD LOCAL_Compact( HANDLE16 ds, UINT16 minfree ) +{ + HANDLE16 oldDS = CURRENT_DS; + WORD ret; + + CURRENT_DS = ds; + ret = LocalCompact16 (minfree); + CURRENT_DS = oldDS; + return ret; +} -extern HLOCAL16 LOCAL_Alloc( HANDLE16 ds, UINT16 flags, WORD size ); -extern HLOCAL16 LOCAL_ReAlloc( HANDLE16 ds, HLOCAL16 handle, - WORD size, UINT16 flags ); -extern HLOCAL16 LOCAL_Free( HANDLE16 ds, HLOCAL16 handle ); -extern HLOCAL16 LOCAL_Handle( HANDLE16 ds, WORD addr ); -extern UINT16 LOCAL_Size( HANDLE16 ds, HLOCAL16 handle ); -extern UINT16 LOCAL_Flags( HANDLE16 ds, HLOCAL16 handle ); -extern UINT16 LOCAL_HeapSize( HANDLE16 ds ); -extern UINT16 LOCAL_CountFree( HANDLE16 ds ); -extern void *LOCAL_Lock( HANDLE16 ds, HLOCAL16 handle ); -extern BOOL16 LOCAL_Unlock( HANDLE16 ds, HLOCAL16 handle ); -extern WORD LOCAL_Compact( HANDLE16 ds, UINT16 minfree, UINT16 flags ); #endif /* __WINE_LOCAL_H */ diff --git a/windows/user.c b/windows/user.c index cf0ef18e3bd..91e1289650c 100644 --- a/windows/user.c +++ b/windows/user.c @@ -553,7 +553,7 @@ DWORD WINAPI UserSeeUserDo16(WORD wReqType, WORD wParam1, WORD wParam2, WORD wPa case USUD_LOCALFREE: return LOCAL_Free(USER_HeapSel, wParam1); case USUD_LOCALCOMPACT: - return LOCAL_Compact(USER_HeapSel, wParam3, 0); + return LOCAL_Compact(USER_HeapSel, wParam3); case USUD_LOCALHEAP: return USER_HeapSel; case USUD_FIRSTCLASS: