diff --git a/include/winbase.h b/include/winbase.h index 0a0bfde9d10..879f412186a 100644 --- a/include/winbase.h +++ b/include/winbase.h @@ -2349,7 +2349,8 @@ WINBASEAPI BOOL WINAPI GetXStateFeaturesMask(CONTEXT*,DWORD64*); WINBASEAPI ATOM WINAPI GlobalAddAtomA(LPCSTR); WINBASEAPI ATOM WINAPI GlobalAddAtomW(LPCWSTR); #define GlobalAddAtom WINELIB_NAME_AW(GlobalAddAtom) -WINBASEAPI HGLOBAL WINAPI GlobalAlloc(UINT,SIZE_T) __WINE_ALLOC_SIZE(2); +WINBASEAPI HGLOBAL WINAPI GlobalFree(HGLOBAL); +WINBASEAPI HGLOBAL WINAPI GlobalAlloc(UINT,SIZE_T) __WINE_ALLOC_SIZE(2) __WINE_MALLOC(GlobalFree, 1); WINBASEAPI SIZE_T WINAPI GlobalCompact(DWORD); WINBASEAPI ATOM WINAPI GlobalDeleteAtom(ATOM); WINBASEAPI ATOM WINAPI GlobalFindAtomA(LPCSTR); @@ -2357,7 +2358,6 @@ WINBASEAPI ATOM WINAPI GlobalFindAtomW(LPCWSTR); #define GlobalFindAtom WINELIB_NAME_AW(GlobalFindAtom) WINBASEAPI VOID WINAPI GlobalFix(HGLOBAL); WINBASEAPI UINT WINAPI GlobalFlags(HGLOBAL); -WINBASEAPI HGLOBAL WINAPI GlobalFree(HGLOBAL); WINBASEAPI UINT WINAPI GlobalGetAtomNameA(ATOM,LPSTR,INT); WINBASEAPI UINT WINAPI GlobalGetAtomNameW(ATOM,LPWSTR,INT); #define GlobalGetAtomName WINELIB_NAME_AW(GlobalGetAtomName) @@ -2365,20 +2365,20 @@ WINBASEAPI HGLOBAL WINAPI GlobalHandle(LPCVOID); WINBASEAPI LPVOID WINAPI GlobalLock(HGLOBAL); WINBASEAPI VOID WINAPI GlobalMemoryStatus(LPMEMORYSTATUS); WINBASEAPI BOOL WINAPI GlobalMemoryStatusEx(LPMEMORYSTATUSEX); -WINBASEAPI HGLOBAL WINAPI GlobalReAlloc(HGLOBAL,SIZE_T,UINT) __WINE_ALLOC_SIZE(2); +WINBASEAPI HGLOBAL WINAPI GlobalReAlloc(HGLOBAL,SIZE_T,UINT) __WINE_ALLOC_SIZE(2) __WINE_REALLOC(GlobalFree, 1); WINBASEAPI SIZE_T WINAPI GlobalSize(HGLOBAL); WINBASEAPI VOID WINAPI GlobalUnfix(HGLOBAL); WINBASEAPI BOOL WINAPI GlobalUnlock(HGLOBAL); WINBASEAPI BOOL WINAPI GlobalUnWire(HGLOBAL); WINBASEAPI LPVOID WINAPI GlobalWire(HGLOBAL); #define HasOverlappedIoCompleted(lpOverlapped) ((lpOverlapped)->Internal != STATUS_PENDING) -WINBASEAPI LPVOID WINAPI HeapAlloc(HANDLE,DWORD,SIZE_T) __WINE_ALLOC_SIZE(3); +WINBASEAPI BOOL WINAPI HeapFree(HANDLE,DWORD,LPVOID); +WINBASEAPI LPVOID WINAPI HeapAlloc(HANDLE,DWORD,SIZE_T) __WINE_ALLOC_SIZE(3) __WINE_MALLOC(HeapFree, 3); WINBASEAPI SIZE_T WINAPI HeapCompact(HANDLE,DWORD); WINBASEAPI HANDLE WINAPI HeapCreate(DWORD,SIZE_T,SIZE_T); WINBASEAPI BOOL WINAPI HeapDestroy(HANDLE); -WINBASEAPI BOOL WINAPI HeapFree(HANDLE,DWORD,LPVOID); WINBASEAPI BOOL WINAPI HeapLock(HANDLE); -WINBASEAPI LPVOID WINAPI HeapReAlloc(HANDLE,DWORD,LPVOID,SIZE_T) __WINE_ALLOC_SIZE(4); +WINBASEAPI LPVOID WINAPI HeapReAlloc(HANDLE,DWORD,LPVOID,SIZE_T) __WINE_ALLOC_SIZE(4) __WINE_REALLOC(HeapFree, 3); WINBASEAPI BOOL WINAPI HeapQueryInformation(HANDLE,HEAP_INFORMATION_CLASS,PVOID,SIZE_T,PSIZE_T); WINBASEAPI BOOL WINAPI HeapSetInformation(HANDLE,HEAP_INFORMATION_CLASS,PVOID,SIZE_T); WINBASEAPI SIZE_T WINAPI HeapSize(HANDLE,DWORD,LPCVOID); @@ -2438,13 +2438,13 @@ WINBASEAPI HMODULE WINAPI LoadLibraryExW(LPCWSTR,HANDLE,DWORD); WINBASEAPI DWORD WINAPI LoadModule(LPCSTR,LPVOID); WINBASEAPI HMODULE WINAPI LoadPackagedLibrary(LPCWSTR,DWORD); WINBASEAPI HGLOBAL WINAPI LoadResource(HMODULE,HRSRC); -WINBASEAPI HLOCAL WINAPI LocalAlloc(UINT,SIZE_T) __WINE_ALLOC_SIZE(2); +WINBASEAPI HLOCAL WINAPI LocalFree(HLOCAL); +WINBASEAPI HLOCAL WINAPI LocalAlloc(UINT,SIZE_T) __WINE_ALLOC_SIZE(2) __WINE_MALLOC(LocalFree, 1); WINBASEAPI SIZE_T WINAPI LocalCompact(UINT); WINBASEAPI UINT WINAPI LocalFlags(HLOCAL); -WINBASEAPI HLOCAL WINAPI LocalFree(HLOCAL); WINBASEAPI HLOCAL WINAPI LocalHandle(LPCVOID); WINBASEAPI LPVOID WINAPI LocalLock(HLOCAL); -WINBASEAPI HLOCAL WINAPI LocalReAlloc(HLOCAL,SIZE_T,UINT) __WINE_ALLOC_SIZE(2); +WINBASEAPI HLOCAL WINAPI LocalReAlloc(HLOCAL,SIZE_T,UINT) __WINE_ALLOC_SIZE(2) __WINE_REALLOC(LocalFree, 1); WINBASEAPI SIZE_T WINAPI LocalShrink(HGLOBAL,UINT); WINBASEAPI SIZE_T WINAPI LocalSize(HLOCAL); WINBASEAPI BOOL WINAPI LocalUnlock(HLOCAL); diff --git a/include/winnt.h b/include/winnt.h index c80efee077d..ff9b55b7ea2 100644 --- a/include/winnt.h +++ b/include/winnt.h @@ -203,6 +203,13 @@ extern "C" { #else #define __WINE_ALLOC_SIZE(x) #endif +#if defined(__GNUC__) && ((__GNUC__ > 11) || ((__GNUC__ == 11) && (__GNUC_MINOR__ >= 2))) +#define __WINE_MALLOC(x, y) __attribute__((malloc, malloc(x, y))) +#define __WINE_REALLOC(x, y) __attribute__((malloc(x, y))) +#else +#define __WINE_MALLOC(x, y) +#define __WINE_REALLOC(x, y) +#endif /* Anonymous union/struct handling */