Commit 2605b76c authored by Michael Stefaniuc's avatar Michael Stefaniuc Committed by Alexandre Julliard

ole32: Use an iface instead of a vtbl pointer in FileLockBytesImpl.

parent f27f7544
...@@ -47,7 +47,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(storage); ...@@ -47,7 +47,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(storage);
typedef struct FileLockBytesImpl typedef struct FileLockBytesImpl
{ {
const ILockBytesVtbl *lpVtbl; ILockBytes ILockBytes_iface;
LONG ref; LONG ref;
ULARGE_INTEGER filesize; ULARGE_INTEGER filesize;
HANDLE hfile; HANDLE hfile;
...@@ -57,6 +57,11 @@ typedef struct FileLockBytesImpl ...@@ -57,6 +57,11 @@ typedef struct FileLockBytesImpl
static const ILockBytesVtbl FileLockBytesImpl_Vtbl; static const ILockBytesVtbl FileLockBytesImpl_Vtbl;
static inline FileLockBytesImpl *impl_from_ILockBytes(ILockBytes *iface)
{
return CONTAINING_RECORD(iface, FileLockBytesImpl, ILockBytes_iface);
}
/*********************************************************** /***********************************************************
* Prototypes for private methods * Prototypes for private methods
*/ */
...@@ -100,7 +105,7 @@ HRESULT FileLockBytesImpl_Construct(HANDLE hFile, DWORD openFlags, LPCWSTR pwcsN ...@@ -100,7 +105,7 @@ HRESULT FileLockBytesImpl_Construct(HANDLE hFile, DWORD openFlags, LPCWSTR pwcsN
if (!This) if (!This)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
This->lpVtbl = &FileLockBytesImpl_Vtbl; This->ILockBytes_iface.lpVtbl = &FileLockBytesImpl_Vtbl;
This->ref = 1; This->ref = 1;
This->hfile = hFile; This->hfile = hFile;
This->filesize.u.LowPart = GetFileSize(This->hfile, This->filesize.u.LowPart = GetFileSize(This->hfile,
...@@ -126,7 +131,7 @@ HRESULT FileLockBytesImpl_Construct(HANDLE hFile, DWORD openFlags, LPCWSTR pwcsN ...@@ -126,7 +131,7 @@ HRESULT FileLockBytesImpl_Construct(HANDLE hFile, DWORD openFlags, LPCWSTR pwcsN
TRACE("file len %u\n", This->filesize.u.LowPart); TRACE("file len %u\n", This->filesize.u.LowPart);
*pLockBytes = (ILockBytes*)This; *pLockBytes = &This->ILockBytes_iface;
return S_OK; return S_OK;
} }
...@@ -151,13 +156,13 @@ static HRESULT WINAPI FileLockBytesImpl_QueryInterface(ILockBytes *iface, REFIID ...@@ -151,13 +156,13 @@ static HRESULT WINAPI FileLockBytesImpl_QueryInterface(ILockBytes *iface, REFIID
static ULONG WINAPI FileLockBytesImpl_AddRef(ILockBytes *iface) static ULONG WINAPI FileLockBytesImpl_AddRef(ILockBytes *iface)
{ {
FileLockBytesImpl* This = (FileLockBytesImpl*)iface; FileLockBytesImpl* This = impl_from_ILockBytes(iface);
return InterlockedIncrement(&This->ref); return InterlockedIncrement(&This->ref);
} }
static ULONG WINAPI FileLockBytesImpl_Release(ILockBytes *iface) static ULONG WINAPI FileLockBytesImpl_Release(ILockBytes *iface)
{ {
FileLockBytesImpl* This = (FileLockBytesImpl*)iface; FileLockBytesImpl* This = impl_from_ILockBytes(iface);
ULONG ref; ULONG ref;
ref = InterlockedDecrement(&This->ref); ref = InterlockedDecrement(&This->ref);
...@@ -187,7 +192,7 @@ static HRESULT WINAPI FileLockBytesImpl_ReadAt( ...@@ -187,7 +192,7 @@ static HRESULT WINAPI FileLockBytesImpl_ReadAt(
ULONG cb, /* [in] */ ULONG cb, /* [in] */
ULONG* pcbRead) /* [out] */ ULONG* pcbRead) /* [out] */
{ {
FileLockBytesImpl* This = (FileLockBytesImpl*)iface; FileLockBytesImpl* This = impl_from_ILockBytes(iface);
ULONG bytes_left = cb; ULONG bytes_left = cb;
LPBYTE readPtr = pv; LPBYTE readPtr = pv;
BOOL ret; BOOL ret;
...@@ -242,7 +247,7 @@ static HRESULT WINAPI FileLockBytesImpl_WriteAt( ...@@ -242,7 +247,7 @@ static HRESULT WINAPI FileLockBytesImpl_WriteAt(
ULONG cb, /* [in] */ ULONG cb, /* [in] */
ULONG* pcbWritten) /* [out] */ ULONG* pcbWritten) /* [out] */
{ {
FileLockBytesImpl* This = (FileLockBytesImpl*)iface; FileLockBytesImpl* This = impl_from_ILockBytes(iface);
ULONG size_needed = ulOffset.u.LowPart + cb; ULONG size_needed = ulOffset.u.LowPart + cb;
ULONG bytes_left = cb; ULONG bytes_left = cb;
const BYTE *writePtr = pv; const BYTE *writePtr = pv;
...@@ -307,7 +312,7 @@ static HRESULT WINAPI FileLockBytesImpl_Flush(ILockBytes* iface) ...@@ -307,7 +312,7 @@ static HRESULT WINAPI FileLockBytesImpl_Flush(ILockBytes* iface)
*/ */
static HRESULT WINAPI FileLockBytesImpl_SetSize(ILockBytes* iface, ULARGE_INTEGER newSize) static HRESULT WINAPI FileLockBytesImpl_SetSize(ILockBytes* iface, ULARGE_INTEGER newSize)
{ {
FileLockBytesImpl* This = (FileLockBytesImpl*)iface; FileLockBytesImpl* This = impl_from_ILockBytes(iface);
HRESULT hr = S_OK; HRESULT hr = S_OK;
LARGE_INTEGER newpos; LARGE_INTEGER newpos;
...@@ -343,7 +348,7 @@ static HRESULT WINAPI FileLockBytesImpl_UnlockRegion(ILockBytes* iface, ...@@ -343,7 +348,7 @@ static HRESULT WINAPI FileLockBytesImpl_UnlockRegion(ILockBytes* iface,
static HRESULT WINAPI FileLockBytesImpl_Stat(ILockBytes* iface, static HRESULT WINAPI FileLockBytesImpl_Stat(ILockBytes* iface,
STATSTG *pstatstg, DWORD grfStatFlag) STATSTG *pstatstg, DWORD grfStatFlag)
{ {
FileLockBytesImpl* This = (FileLockBytesImpl*)iface; FileLockBytesImpl* This = impl_from_ILockBytes(iface);
if (!(STATFLAG_NONAME & grfStatFlag) && This->pwcsName) if (!(STATFLAG_NONAME & grfStatFlag) && This->pwcsName)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment