Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-cw
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wine
wine-cw
Commits
ea196ef0
Commit
ea196ef0
authored
Jul 13, 2012
by
Nikolay Sivov
Committed by
Alexandre Julliard
Jul 13, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ole32: COM cleanup of storage IStream implementation.
parent
91049f5e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
42 additions
and
56 deletions
+42
-56
stg_stream.c
dlls/ole32/stg_stream.c
+19
-39
storage32.c
dlls/ole32/storage32.c
+15
-8
storage32.h
dlls/ole32/storage32.h
+8
-9
No files found.
dlls/ole32/stg_stream.c
View file @
ea196ef0
...
...
@@ -74,9 +74,6 @@ static void StgStreamImpl_Destroy(StgStreamImpl* This)
This
->
parentStorage
=
0
;
/*
* Finally, free the memory used-up by the class.
*/
HeapFree
(
GetProcessHeap
(),
0
,
This
);
}
...
...
@@ -89,41 +86,24 @@ static HRESULT WINAPI StgStreamImpl_QueryInterface(
REFIID
riid
,
/* [in] */
void
**
ppvObject
)
/* [iid_is][out] */
{
StgStreamImpl
*
const
This
=
(
StgStreamImpl
*
)
iface
;
StgStreamImpl
*
This
=
impl_from_IStream
(
iface
)
;
/*
* Perform a sanity check on the parameters.
*/
if
(
ppvObject
==
0
)
return
E_INVALIDARG
;
/*
* Initialize the return parameter.
*/
*
ppvObject
=
0
;
/*
* Compare the riid with the interface IDs implemented by this object.
*/
if
(
IsEqualIID
(
&
IID_IUnknown
,
riid
)
||
IsEqualIID
(
&
IID_IPersist
,
riid
)
||
IsEqualIID
(
&
IID_IPersistStream
,
riid
)
||
IsEqualIID
(
&
IID_ISequentialStream
,
riid
)
||
IsEqualIID
(
&
IID_IStream
,
riid
))
{
*
ppvObject
=
This
;
*
ppvObject
=
&
This
->
IStream_iface
;
}
/*
* Check that we obtained an interface.
*/
if
((
*
ppvObject
)
==
0
)
else
return
E_NOINTERFACE
;
/*
* Query Interface always increases the reference count by one when it is
* successful
*/
IStream_AddRef
(
iface
);
return
S_OK
;
...
...
@@ -136,7 +116,7 @@ static HRESULT WINAPI StgStreamImpl_QueryInterface(
static
ULONG
WINAPI
StgStreamImpl_AddRef
(
IStream
*
iface
)
{
StgStreamImpl
*
const
This
=
(
StgStreamImpl
*
)
iface
;
StgStreamImpl
*
This
=
impl_from_IStream
(
iface
)
;
return
InterlockedIncrement
(
&
This
->
ref
);
}
...
...
@@ -147,7 +127,7 @@ static ULONG WINAPI StgStreamImpl_AddRef(
static
ULONG
WINAPI
StgStreamImpl_Release
(
IStream
*
iface
)
{
StgStreamImpl
*
const
This
=
(
StgStreamImpl
*
)
iface
;
StgStreamImpl
*
This
=
impl_from_IStream
(
iface
)
;
ULONG
ref
;
...
...
@@ -179,7 +159,7 @@ static HRESULT WINAPI StgStreamImpl_Read(
ULONG
cb
,
/* [in] */
ULONG
*
pcbRead
)
/* [out] */
{
StgStreamImpl
*
const
This
=
(
StgStreamImpl
*
)
iface
;
StgStreamImpl
*
This
=
impl_from_IStream
(
iface
)
;
ULONG
bytesReadBuffer
;
HRESULT
res
;
...
...
@@ -235,7 +215,7 @@ static HRESULT WINAPI StgStreamImpl_Write(
ULONG
cb
,
/* [in] */
ULONG
*
pcbWritten
)
/* [out] */
{
StgStreamImpl
*
const
This
=
(
StgStreamImpl
*
)
iface
;
StgStreamImpl
*
This
=
impl_from_IStream
(
iface
)
;
ULONG
bytesWritten
=
0
;
HRESULT
res
;
...
...
@@ -316,7 +296,7 @@ static HRESULT WINAPI StgStreamImpl_Seek(
DWORD
dwOrigin
,
/* [in] */
ULARGE_INTEGER
*
plibNewPosition
)
/* [out] */
{
StgStreamImpl
*
const
This
=
(
StgStreamImpl
*
)
iface
;
StgStreamImpl
*
This
=
impl_from_IStream
(
iface
)
;
ULARGE_INTEGER
newPosition
;
DirEntry
currentEntry
;
...
...
@@ -389,7 +369,7 @@ static HRESULT WINAPI StgStreamImpl_SetSize(
IStream
*
iface
,
ULARGE_INTEGER
libNewSize
)
/* [in] */
{
StgStreamImpl
*
const
This
=
(
StgStreamImpl
*
)
iface
;
StgStreamImpl
*
This
=
impl_from_IStream
(
iface
)
;
HRESULT
hr
;
...
...
@@ -441,7 +421,7 @@ static HRESULT WINAPI StgStreamImpl_CopyTo(
ULARGE_INTEGER
*
pcbRead
,
/* [out] */
ULARGE_INTEGER
*
pcbWritten
)
/* [out] */
{
StgStreamImpl
*
const
This
=
(
StgStreamImpl
*
)
iface
;
StgStreamImpl
*
This
=
impl_from_IStream
(
iface
)
;
HRESULT
hr
=
S_OK
;
BYTE
tmpBuffer
[
128
];
ULONG
bytesRead
,
bytesWritten
,
copySize
;
...
...
@@ -516,7 +496,7 @@ static HRESULT WINAPI StgStreamImpl_Commit(
IStream
*
iface
,
DWORD
grfCommitFlags
)
/* [in] */
{
StgStreamImpl
*
const
This
=
(
StgStreamImpl
*
)
iface
;
StgStreamImpl
*
This
=
impl_from_IStream
(
iface
)
;
if
(
!
This
->
parentStorage
)
{
...
...
@@ -547,7 +527,7 @@ static HRESULT WINAPI StgStreamImpl_LockRegion(
ULARGE_INTEGER
cb
,
/* [in] */
DWORD
dwLockType
)
/* [in] */
{
StgStreamImpl
*
const
This
=
(
StgStreamImpl
*
)
iface
;
StgStreamImpl
*
This
=
impl_from_IStream
(
iface
)
;
if
(
!
This
->
parentStorage
)
{
...
...
@@ -565,7 +545,7 @@ static HRESULT WINAPI StgStreamImpl_UnlockRegion(
ULARGE_INTEGER
cb
,
/* [in] */
DWORD
dwLockType
)
/* [in] */
{
StgStreamImpl
*
const
This
=
(
StgStreamImpl
*
)
iface
;
StgStreamImpl
*
This
=
impl_from_IStream
(
iface
)
;
if
(
!
This
->
parentStorage
)
{
...
...
@@ -590,7 +570,7 @@ static HRESULT WINAPI StgStreamImpl_Stat(
STATSTG
*
pstatstg
,
/* [out] */
DWORD
grfStatFlag
)
/* [in] */
{
StgStreamImpl
*
const
This
=
(
StgStreamImpl
*
)
iface
;
StgStreamImpl
*
This
=
impl_from_IStream
(
iface
)
;
DirEntry
currentEntry
;
HRESULT
hr
;
...
...
@@ -650,7 +630,7 @@ static HRESULT WINAPI StgStreamImpl_Clone(
IStream
*
iface
,
IStream
**
ppstm
)
/* [out] */
{
StgStreamImpl
*
const
This
=
(
StgStreamImpl
*
)
iface
;
StgStreamImpl
*
This
=
impl_from_IStream
(
iface
)
;
HRESULT
hres
;
StgStreamImpl
*
new_stream
;
LARGE_INTEGER
seek_pos
;
...
...
@@ -672,7 +652,7 @@ static HRESULT WINAPI StgStreamImpl_Clone(
if
(
!
new_stream
)
return
STG_E_INSUFFICIENTMEMORY
;
/* Currently the only reason for new_stream=0 */
*
ppstm
=
(
IStream
*
)
new_stream
;
*
ppstm
=
&
new_stream
->
IStream_iface
;
IStream_AddRef
(
*
ppstm
);
seek_pos
.
QuadPart
=
This
->
currentPosition
.
QuadPart
;
...
...
@@ -687,7 +667,7 @@ static HRESULT WINAPI StgStreamImpl_Clone(
/*
* Virtual function table for the StgStreamImpl class.
*/
static
const
IStreamVtbl
StgStream
Impl_
Vtbl
=
static
const
IStreamVtbl
StgStreamVtbl
=
{
StgStreamImpl_QueryInterface
,
StgStreamImpl_AddRef
,
...
...
@@ -725,12 +705,12 @@ StgStreamImpl* StgStreamImpl_Construct(
newStream
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
StgStreamImpl
));
if
(
newStream
!=
0
)
if
(
newStream
)
{
/*
* Set-up the virtual function table and reference count.
*/
newStream
->
lpVtbl
=
&
StgStreamImpl_
Vtbl
;
newStream
->
IStream_iface
.
lpVtbl
=
&
StgStream
Vtbl
;
newStream
->
ref
=
0
;
newStream
->
parentStorage
=
parentStorage
;
...
...
dlls/ole32/storage32.c
View file @
ea196ef0
...
...
@@ -524,10 +524,10 @@ static HRESULT WINAPI StorageBaseImpl_OpenStream(
newStream
=
StgStreamImpl_Construct
(
This
,
grfMode
,
streamEntryRef
);
if
(
newStream
!=
0
)
if
(
newStream
)
{
newStream
->
grfMode
=
grfMode
;
*
ppstm
=
(
IStream
*
)
newStream
;
*
ppstm
=
&
newStream
->
IStream_iface
;
IStream_AddRef
(
*
ppstm
);
...
...
@@ -1007,10 +1007,9 @@ static HRESULT WINAPI StorageBaseImpl_CreateStream(
*/
newStream
=
StgStreamImpl_Construct
(
This
,
grfMode
,
newStreamEntryRef
);
if
(
newStream
!=
0
)
if
(
newStream
)
{
*
ppstm
=
(
IStream
*
)
newStream
;
*
ppstm
=
&
newStream
->
IStream_iface
;
IStream_AddRef
(
*
ppstm
);
}
else
...
...
@@ -1684,11 +1683,19 @@ static HRESULT StorageBaseImpl_CopyChildEntryTo(StorageBaseImpl *This,
*/
if
(
hr
==
S_OK
)
{
pstrChild
=
(
IStream
*
)
StgStreamImpl_Construct
(
This
,
STGM_READ
|
STGM_SHARE_EXCLUSIVE
,
srcEntry
);
if
(
pstrChild
)
IStream_AddRef
(
pstrChild
);
StgStreamImpl
*
streamimpl
=
StgStreamImpl_Construct
(
This
,
STGM_READ
|
STGM_SHARE_EXCLUSIVE
,
srcEntry
);
if
(
streamimpl
)
{
pstrChild
=
&
streamimpl
->
IStream_iface
;
if
(
pstrChild
)
IStream_AddRef
(
pstrChild
);
}
else
{
pstrChild
=
NULL
;
hr
=
E_OUTOFMEMORY
;
}
}
if
(
hr
==
S_OK
)
...
...
dlls/ole32/storage32.h
View file @
ea196ef0
...
...
@@ -418,26 +418,20 @@ SmallBlockChainStream* Storage32Impl_BigBlocksToSmallBlocks(
/****************************************************************************
* StgStreamImpl definitions.
*
* This class implements the IStream
32
interface and represents a stream
* This class implements the IStream interface and represents a stream
* located inside a storage object.
*/
struct
StgStreamImpl
{
const
IStreamVtbl
*
lpVtbl
;
/* Needs to be the first item in the struct
* since we want to cast this to an IStream pointer */
IStream
IStream_iface
;
LONG
ref
;
/*
* We are an entry in the storage object's stream handler list
*/
struct
list
StrmListEntry
;
/*
* Reference count
*/
LONG
ref
;
/*
* Storage that is the parent(owner) of the stream
*/
StorageBaseImpl
*
parentStorage
;
...
...
@@ -458,6 +452,11 @@ struct StgStreamImpl
ULARGE_INTEGER
currentPosition
;
};
static
inline
StgStreamImpl
*
impl_from_IStream
(
IStream
*
iface
)
{
return
CONTAINING_RECORD
(
iface
,
StgStreamImpl
,
IStream_iface
);
}
/*
* Method definition for the StgStreamImpl class.
*/
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment