Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
W
wine-winehq
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-winehq
Commits
9da3365e
Commit
9da3365e
authored
Nov 23, 2009
by
Vincent Povirk
Committed by
Alexandre Julliard
Nov 24, 2009
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ole32: Allocate the StorageImpl in StorageImpl_Construct.
This makes cleanup after errors much easier, as we can just use the regular destructor.
parent
6c3961f0
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
68 deletions
+54
-68
storage32.c
dlls/ole32/storage32.c
+54
-68
No files found.
dlls/ole32/storage32.c
View file @
9da3365e
...
...
@@ -2233,14 +2233,15 @@ static const IStorageVtbl Storage32Impl_Vtbl =
};
static
HRESULT
StorageImpl_Construct
(
StorageImpl
*
This
,
HANDLE
hFile
,
LPCOLESTR
pwcsName
,
ILockBytes
*
pLkbyt
,
DWORD
openFlags
,
BOOL
fileBased
,
BOOL
create
)
BOOL
create
,
StorageImpl
**
result
)
{
StorageImpl
*
This
;
HRESULT
hr
=
S_OK
;
DirEntry
currentEntry
;
BOOL
readSuccessful
;
...
...
@@ -2249,6 +2250,10 @@ static HRESULT StorageImpl_Construct(
if
(
FAILED
(
validateSTGM
(
openFlags
)
))
return
STG_E_INVALIDFLAG
;
This
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
StorageImpl
));
if
(
!
This
)
return
E_OUTOFMEMORY
;
memset
(
This
,
0
,
sizeof
(
StorageImpl
));
list_init
(
&
This
->
base
.
strmHead
);
...
...
@@ -2259,6 +2264,7 @@ static HRESULT StorageImpl_Construct(
This
->
base
.
pssVtbl
=
&
IPropertySetStorage_Vtbl
;
This
->
base
.
v_destructor
=
StorageImpl_Destroy
;
This
->
base
.
openFlags
=
(
openFlags
&
~
STGM_CREATE
);
This
->
base
.
ref
=
1
;
This
->
create
=
create
;
/*
...
...
@@ -2273,7 +2279,10 @@ static HRESULT StorageImpl_Construct(
This
->
pwcsName
=
HeapAlloc
(
GetProcessHeap
(),
0
,
(
lstrlenW
(
pwcsName
)
+
1
)
*
sizeof
(
WCHAR
));
if
(
!
This
->
pwcsName
)
return
STG_E_INSUFFICIENTMEMORY
;
{
hr
=
STG_E_INSUFFICIENTMEMORY
;
goto
end
;
}
strcpyW
(
This
->
pwcsName
,
pwcsName
);
}
...
...
@@ -2289,7 +2298,10 @@ static HRESULT StorageImpl_Construct(
fileBased
);
if
(
This
->
bigBlockFile
==
0
)
return
E_FAIL
;
{
hr
=
E_FAIL
;
goto
end
;
}
if
(
create
)
{
...
...
@@ -2341,9 +2353,7 @@ static HRESULT StorageImpl_Construct(
if
(
FAILED
(
hr
))
{
BIGBLOCKFILE_Destructor
(
This
->
bigBlockFile
);
return
hr
;
goto
end
;
}
}
...
...
@@ -2362,12 +2372,18 @@ static HRESULT StorageImpl_Construct(
*/
if
(
!
(
This
->
rootBlockChain
=
BlockChainStream_Construct
(
This
,
&
This
->
rootStartBlock
,
DIRENTRY_NULL
)))
return
STG_E_READFAULT
;
{
hr
=
STG_E_READFAULT
;
goto
end
;
}
if
(
!
(
This
->
smallBlockDepotChain
=
BlockChainStream_Construct
(
This
,
&
This
->
smallBlockDepotStart
,
DIRENTRY_NULL
)))
return
STG_E_READFAULT
;
{
hr
=
STG_E_READFAULT
;
goto
end
;
}
/*
* Write the root storage entry (memory only)
...
...
@@ -2420,8 +2436,8 @@ static HRESULT StorageImpl_Construct(
if
(
!
readSuccessful
)
{
/* TODO CLEANUP */
return
STG_E_READFAULT
;
hr
=
STG_E_READFAULT
;
goto
end
;
}
/*
...
...
@@ -2429,7 +2445,18 @@ static HRESULT StorageImpl_Construct(
*/
if
(
!
(
This
->
smallBlockRootChain
=
BlockChainStream_Construct
(
This
,
NULL
,
This
->
base
.
storageDirEntry
)))
return
STG_E_READFAULT
;
{
hr
=
STG_E_READFAULT
;
}
end:
if
(
FAILED
(
hr
))
{
IStorage_Release
((
IStorage
*
)
This
);
*
result
=
NULL
;
}
else
*
result
=
This
;
return
hr
;
}
...
...
@@ -2447,7 +2474,8 @@ static void StorageImpl_Destroy(StorageBaseImpl* iface)
BlockChainStream_Destroy
(
This
->
rootBlockChain
);
BlockChainStream_Destroy
(
This
->
smallBlockDepotChain
);
BIGBLOCKFILE_Destructor
(
This
->
bigBlockFile
);
if
(
This
->
bigBlockFile
)
BIGBLOCKFILE_Destructor
(
This
->
bigBlockFile
);
HeapFree
(
GetProcessHeap
(),
0
,
This
);
}
...
...
@@ -5663,36 +5691,25 @@ HRESULT WINAPI StgCreateDocfile(
/*
* Allocate and initialize the new IStorage32object.
*/
newStorage
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
StorageImpl
));
if
(
newStorage
==
0
)
{
hr
=
STG_E_INSUFFICIENTMEMORY
;
goto
end
;
}
hr
=
StorageImpl_Construct
(
newStorage
,
hFile
,
pwcsName
,
NULL
,
grfMode
,
TRUE
,
TRUE
);
TRUE
,
&
newStorage
);
if
(
FAILED
(
hr
))
{
HeapFree
(
GetProcessHeap
(),
0
,
newStorage
);
goto
end
;
}
/*
* Get an "out" pointer for the caller.
*/
hr
=
StorageBaseImpl_QueryInterface
(
(
IStorage
*
)
newStorage
,
&
IID_IStorage
,
(
void
**
)
ppstgOpen
);
*
ppstgOpen
=
(
IStorage
*
)
newStorage
;
end:
TRACE
(
"<-- %p r = %08x
\n
"
,
*
ppstgOpen
,
hr
);
...
...
@@ -5947,27 +5964,17 @@ HRESULT WINAPI StgOpenStorage(
/*
* Allocate and initialize the new IStorage32object.
*/
newStorage
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
StorageImpl
));
if
(
newStorage
==
0
)
{
hr
=
STG_E_INSUFFICIENTMEMORY
;
goto
end
;
}
/* Initialize the storage */
hr
=
StorageImpl_Construct
(
newStorage
,
hFile
,
pwcsName
,
NULL
,
grfMode
,
TRUE
,
FALSE
);
FALSE
,
&
newStorage
);
if
(
FAILED
(
hr
))
{
HeapFree
(
GetProcessHeap
(),
0
,
newStorage
);
/*
* According to the docs if the file is not a storage, return STG_E_FILEALREADYEXISTS
*/
...
...
@@ -5984,10 +5991,7 @@ HRESULT WINAPI StgOpenStorage(
/*
* Get an "out" pointer for the caller.
*/
hr
=
StorageBaseImpl_QueryInterface
(
(
IStorage
*
)
newStorage
,
&
IID_IStorage
,
(
void
**
)
ppstgOpen
);
*
ppstgOpen
=
(
IStorage
*
)
newStorage
;
end:
TRACE
(
"<-- %08x, IStorage %p
\n
"
,
hr
,
ppstgOpen
?
*
ppstgOpen
:
NULL
);
...
...
@@ -6012,33 +6016,24 @@ HRESULT WINAPI StgCreateDocfileOnILockBytes(
/*
* Allocate and initialize the new IStorage object.
*/
newStorage
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
StorageImpl
));
if
(
newStorage
==
0
)
return
STG_E_INSUFFICIENTMEMORY
;
hr
=
StorageImpl_Construct
(
newStorage
,
0
,
0
,
plkbyt
,
grfMode
,
FALSE
,
TRUE
);
TRUE
,
&
newStorage
);
if
(
FAILED
(
hr
))
{
HeapFree
(
GetProcessHeap
(),
0
,
newStorage
);
return
hr
;
}
/*
* Get an "out" pointer for the caller.
*/
hr
=
StorageBaseImpl_QueryInterface
(
(
IStorage
*
)
newStorage
,
&
IID_IStorage
,
(
void
**
)
ppstgOpen
);
*
ppstgOpen
=
(
IStorage
*
)
newStorage
;
return
hr
;
}
...
...
@@ -6068,33 +6063,24 @@ HRESULT WINAPI StgOpenStorageOnILockBytes(
/*
* Allocate and initialize the new IStorage object.
*/
newStorage
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
StorageImpl
));
if
(
newStorage
==
0
)
return
STG_E_INSUFFICIENTMEMORY
;
hr
=
StorageImpl_Construct
(
newStorage
,
0
,
0
,
plkbyt
,
grfMode
,
FALSE
,
FALSE
);
FALSE
,
&
newStorage
);
if
(
FAILED
(
hr
))
{
HeapFree
(
GetProcessHeap
(),
0
,
newStorage
);
return
hr
;
}
/*
* Get an "out" pointer for the caller.
*/
hr
=
StorageBaseImpl_QueryInterface
(
(
IStorage
*
)
newStorage
,
&
IID_IStorage
,
(
void
**
)
ppstgOpen
);
*
ppstgOpen
=
(
IStorage
*
)
newStorage
;
return
hr
;
}
...
...
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