Annotate with allocation size attribute.

This commit is contained in:
Marcus Meissner 2008-09-04 13:39:58 +02:00 committed by Alexandre Julliard
parent 980ffb8eb4
commit 96412ee564
15 changed files with 38 additions and 26 deletions

View File

@ -175,8 +175,8 @@ typedef struct
/* undocumented functions */
LPVOID WINAPI Alloc (DWORD);
LPVOID WINAPI ReAlloc (LPVOID, DWORD);
LPVOID WINAPI Alloc (DWORD) __WINE_ALLOC_SIZE(1);
LPVOID WINAPI ReAlloc (LPVOID, DWORD) __WINE_ALLOC_SIZE(2);
BOOL WINAPI Free (LPVOID);
DWORD WINAPI GetSize (LPVOID);

View File

@ -30,7 +30,7 @@
extern HINSTANCE COMDLG32_hInstance;
void COMDLG32_SetCommDlgExtendedError(DWORD err);
LPVOID COMDLG32_AllocMem(int size);
LPVOID COMDLG32_AllocMem(int size) __WINE_ALLOC_SIZE(1);
/* handle<-handle16 conversion */
#define HINSTANCE_32(h16) ((HINSTANCE)(ULONG_PTR)(h16))

View File

@ -141,22 +141,22 @@ BOOL NavigateToChm(HHInfo*,LPCWSTR,LPCWSTR);
/* memory allocation functions */
static inline void *heap_alloc(size_t len)
static inline void __WINE_ALLOC_SIZE(1) *heap_alloc(size_t len)
{
return HeapAlloc(GetProcessHeap(), 0, len);
}
static inline void *heap_alloc_zero(size_t len)
static inline void __WINE_ALLOC_SIZE(1) *heap_alloc_zero(size_t len)
{
return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
}
static inline void *heap_realloc(void *mem, size_t len)
static inline void __WINE_ALLOC_SIZE(2) *heap_realloc(void *mem, size_t len)
{
return HeapReAlloc(GetProcessHeap(), 0, mem, len);
}
static inline void *heap_realloc_zero(void *mem, size_t len)
static inline void __WINE_ALLOC_SIZE(2) *heap_realloc_zero(void *mem, size_t len)
{
return HeapReAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, mem, len);
}

View File

@ -51,7 +51,7 @@ extern HINSTANCE LOCALSPL_hInstance;
/* ## Memory allocation functions ## */
static inline void *heap_alloc( size_t len )
static inline void __WINE_ALLOC_SIZE(1) *heap_alloc( size_t len )
{
return HeapAlloc( GetProcessHeap(), 0, len );
}

View File

@ -490,7 +490,7 @@ void hlink_frame_navigate(HTMLDocument*,IHlinkFrame*,LPCWSTR,nsIInputStream*,DWO
void call_property_onchanged(ConnectionPoint*,DISPID);
HRESULT call_set_active_object(IOleInPlaceUIWindow*,IOleInPlaceActiveObject*);
void *nsalloc(size_t);
void *nsalloc(size_t) __WINE_ALLOC_SIZE(1);
void nsfree(void*);
void nsACString_Init(nsACString*,const char*);
@ -654,17 +654,17 @@ extern LONG module_ref;
/* memory allocation functions */
static inline void *heap_alloc(size_t len)
static inline void __WINE_ALLOC_SIZE(1) *heap_alloc(size_t len)
{
return HeapAlloc(GetProcessHeap(), 0, len);
}
static inline void *heap_alloc_zero(size_t len)
static inline void __WINE_ALLOC_SIZE(1) *heap_alloc_zero(size_t len)
{
return HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len);
}
static inline void *heap_realloc(void *mem, size_t len)
static inline void __WINE_ALLOC_SIZE(2) *heap_realloc(void *mem, size_t len)
{
return HeapReAlloc(GetProcessHeap(), 0, mem, len);
}

View File

@ -1040,21 +1040,25 @@ extern const WCHAR cszRootDrive[];
extern const WCHAR cszbs[];
/* memory allocation macro functions */
static void *msi_alloc( size_t len ) __WINE_ALLOC_SIZE(1);
static inline void *msi_alloc( size_t len )
{
return HeapAlloc( GetProcessHeap(), 0, len );
}
static void *msi_alloc_zero( size_t len ) __WINE_ALLOC_SIZE(1);
static inline void *msi_alloc_zero( size_t len )
{
return HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, len );
}
static void *msi_realloc( void *mem, size_t len ) __WINE_ALLOC_SIZE(2);
static inline void *msi_realloc( void *mem, size_t len )
{
return HeapReAlloc( GetProcessHeap(), 0, mem, len );
}
static void *msi_realloc_zero( void *mem, size_t len ) __WINE_ALLOC_SIZE(2);
static inline void *msi_realloc_zero( void *mem, size_t len )
{
return HeapReAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY, mem, len );

View File

@ -1357,6 +1357,8 @@ static void TLB_abort(void)
{
DebugBreak();
}
static void * TLB_Alloc(unsigned size) __WINE_ALLOC_SIZE(1);
static void * TLB_Alloc(unsigned size)
{
void * ret;

View File

@ -23,7 +23,7 @@
extern HANDLE me_heap;
static inline void *heap_alloc( size_t len )
static inline void __WINE_ALLOC_SIZE(1) *heap_alloc( size_t len )
{
return HeapAlloc( me_heap, 0, len );
}
@ -33,7 +33,7 @@ static inline BOOL heap_free( void *ptr )
return HeapFree( me_heap, 0, ptr );
}
static inline void *heap_realloc( void *ptr, size_t len )
static inline void __WINE_ALLOC_SIZE(2) *heap_realloc( void *ptr, size_t len )
{
return HeapReAlloc( me_heap, 0, ptr, len );
}

View File

@ -343,7 +343,7 @@ HRESULT WINAPI CoGetInstanceFromFile(COSERVERINFO* pServerInfo, CLSID* pClsid, I
HRESULT WINAPI CoGetInstanceFromIStorage(COSERVERINFO* pServerInfo, CLSID* pClsid, IUnknown* punkOuter, DWORD dwClsCtx, IStorage* pstg, DWORD dwCount, MULTI_QI* pResults);
HRESULT WINAPI CoGetMalloc(DWORD dwMemContext, LPMALLOC* lpMalloc);
LPVOID WINAPI CoTaskMemAlloc(ULONG size);
LPVOID WINAPI CoTaskMemAlloc(ULONG size) __WINE_ALLOC_SIZE(1);
void WINAPI CoTaskMemFree(LPVOID ptr);
LPVOID WINAPI CoTaskMemRealloc(LPVOID ptr, ULONG size);

View File

@ -652,7 +652,7 @@ RPCRTAPI LONG RPC_ENTRY
NdrDcomAsyncStubCall( struct IRpcStubBuffer* pThis, struct IRpcChannelBuffer* pChannel, PRPC_MESSAGE pRpcMsg, DWORD * pdwStubPhase );
RPCRTAPI void* RPC_ENTRY
NdrAllocate( PMIDL_STUB_MESSAGE pStubMsg, size_t Len );
NdrAllocate( PMIDL_STUB_MESSAGE pStubMsg, size_t Len ) __WINE_ALLOC_SIZE(2);
RPCRTAPI void RPC_ENTRY
NdrClearOutParameters( PMIDL_STUB_MESSAGE pStubMsg, PFORMAT_STRING pFormat, void *ArgAddr );

View File

@ -40,7 +40,7 @@ DECLARE_HANDLE(HPSXA);
#endif
UINT WINAPI SHAddFromPropSheetExtArray(HPSXA,LPFNADDPROPSHEETPAGE,LPARAM);
LPVOID WINAPI SHAlloc(ULONG);
LPVOID WINAPI SHAlloc(ULONG) __WINE_ALLOC_SIZE(1);
HRESULT WINAPI SHCoCreateInstance(LPCWSTR,const CLSID*,IUnknown*,REFIID,LPVOID*);
HPSXA WINAPI SHCreatePropSheetExtArray(HKEY,LPCWSTR,UINT);
HPSXA WINAPI SHCreatePropSheetExtArrayEx(HKEY,LPCWSTR,UINT,IDataObject*);

View File

@ -1744,7 +1744,7 @@ WINBASEAPI UINT WINAPI GetWindowsDirectoryW(LPWSTR,UINT);
WINBASEAPI ATOM WINAPI GlobalAddAtomA(LPCSTR);
WINBASEAPI ATOM WINAPI GlobalAddAtomW(LPCWSTR);
#define GlobalAddAtom WINELIB_NAME_AW(GlobalAddAtom)
WINBASEAPI HGLOBAL WINAPI GlobalAlloc(UINT,SIZE_T);
WINBASEAPI HGLOBAL WINAPI GlobalAlloc(UINT,SIZE_T) __WINE_ALLOC_SIZE(2);
WINBASEAPI SIZE_T WINAPI GlobalCompact(DWORD);
WINBASEAPI ATOM WINAPI GlobalDeleteAtom(ATOM);
WINBASEAPI ATOM WINAPI GlobalFindAtomA(LPCSTR);
@ -1760,20 +1760,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);
WINBASEAPI HGLOBAL WINAPI GlobalReAlloc(HGLOBAL,SIZE_T,UINT) __WINE_ALLOC_SIZE(3);
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 HasOverlappedCompleted(lpOverlapped) ((lpOverlapped)->Internal != STATUS_PENDING)
WINBASEAPI LPVOID WINAPI HeapAlloc(HANDLE,DWORD,SIZE_T);
WINBASEAPI LPVOID WINAPI HeapAlloc(HANDLE,DWORD,SIZE_T) __WINE_ALLOC_SIZE(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);
WINBASEAPI LPVOID WINAPI HeapReAlloc(HANDLE,DWORD,LPVOID,SIZE_T) __WINE_ALLOC_SIZE(4);
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);
@ -1822,13 +1822,13 @@ WINBASEAPI HMODULE WINAPI LoadLibraryExW(LPCWSTR,HANDLE,DWORD);
#define LoadLibraryEx WINELIB_NAME_AW(LoadLibraryEx)
WINBASEAPI HINSTANCE WINAPI LoadModule(LPCSTR,LPVOID);
WINBASEAPI HGLOBAL WINAPI LoadResource(HMODULE,HRSRC);
WINBASEAPI HLOCAL WINAPI LocalAlloc(UINT,SIZE_T);
WINBASEAPI HLOCAL WINAPI LocalAlloc(UINT,SIZE_T) __WINE_ALLOC_SIZE(2);
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);
WINBASEAPI HLOCAL WINAPI LocalReAlloc(HLOCAL,SIZE_T,UINT) __WINE_ALLOC_SIZE(3);
WINBASEAPI SIZE_T WINAPI LocalShrink(HGLOBAL,UINT);
WINBASEAPI SIZE_T WINAPI LocalSize(HLOCAL);
WINBASEAPI BOOL WINAPI LocalUnlock(HLOCAL);

View File

@ -3806,8 +3806,8 @@ WINADVAPI BOOL WINAPI CryptVerifySignatureW (HCRYPTHASH, CONST BYTE *, DWORD, HC
#define CryptVerifySignature WINELIB_NAME_AW(CryptVerifySignature)
/* crypt32.dll functions */
LPVOID WINAPI CryptMemAlloc(ULONG cbSize);
LPVOID WINAPI CryptMemRealloc(LPVOID pv, ULONG cbSize);
LPVOID WINAPI CryptMemAlloc(ULONG cbSize) __WINE_ALLOC_SIZE(1);
LPVOID WINAPI CryptMemRealloc(LPVOID pv, ULONG cbSize) __WINE_ALLOC_SIZE(2);
VOID WINAPI CryptMemFree(LPVOID pv);
BOOL WINAPI CryptBinaryToStringA(const BYTE *pbBinary,

View File

@ -162,6 +162,12 @@ extern "C" {
# define DECLSPEC_HIDDEN
#endif
#if defined(__GNUC__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3)))
#define __WINE_ALLOC_SIZE(x) __attribute__((__alloc_size__(x)))
#else
#define __WINE_ALLOC_SIZE(x)
#endif
/* Anonymous union/struct handling */
#ifndef NONAMELESSSTRUCT

View File

@ -2094,7 +2094,7 @@ NTSYSAPI PVOID WINAPI RtlAddVectoredExceptionHandler(ULONG,PVECTORED_EXCEPTI
NTSYSAPI NTSTATUS WINAPI RtlAdjustPrivilege(ULONG,BOOLEAN,BOOLEAN,PBOOLEAN);
NTSYSAPI NTSTATUS WINAPI RtlAllocateAndInitializeSid(PSID_IDENTIFIER_AUTHORITY,BYTE,DWORD,DWORD,DWORD,DWORD,DWORD,DWORD,DWORD,DWORD,PSID *);
NTSYSAPI RTL_HANDLE * WINAPI RtlAllocateHandle(RTL_HANDLE_TABLE *,ULONG *);
NTSYSAPI PVOID WINAPI RtlAllocateHeap(HANDLE,ULONG,SIZE_T);
NTSYSAPI PVOID WINAPI RtlAllocateHeap(HANDLE,ULONG,SIZE_T) __WINE_ALLOC_SIZE(3);
NTSYSAPI WCHAR WINAPI RtlAnsiCharToUnicodeChar(LPSTR *);
NTSYSAPI DWORD WINAPI RtlAnsiStringToUnicodeSize(const STRING *);
NTSYSAPI NTSTATUS WINAPI RtlAnsiStringToUnicodeString(PUNICODE_STRING,PCANSI_STRING,BOOLEAN);