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
294be173
Commit
294be173
authored
Sep 01, 2023
by
Alex Henrie
Committed by
Alexandre Julliard
Sep 04, 2023
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
shcore: Use CRT allocation functions.
parent
161f1b7b
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
30 additions
and
31 deletions
+30
-31
main.c
dlls/shcore/main.c
+30
-31
No files found.
dlls/shcore/main.c
View file @
294be173
...
...
@@ -33,7 +33,6 @@
#include "shlwapi.h"
#include "wine/debug.h"
#include "wine/heap.h"
WINE_DEFAULT_DEBUG_CHANNEL
(
shcore
);
...
...
@@ -588,8 +587,8 @@ static ULONG WINAPI memstream_Release(IStream *iface)
if
(
!
refcount
)
{
heap_
free
(
stream
->
u
.
mem
.
buffer
);
heap_
free
(
stream
);
free
(
stream
->
u
.
mem
.
buffer
);
free
(
stream
);
}
return
refcount
;
...
...
@@ -634,7 +633,7 @@ static HRESULT WINAPI memstream_Write(IStream *iface, const void *buff, ULONG bu
if
(
length
>
stream
->
u
.
mem
.
length
)
{
BYTE
*
buffer
=
HeapReAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
stream
->
u
.
mem
.
buffer
,
length
);
BYTE
*
buffer
=
_recalloc
(
stream
->
u
.
mem
.
buffer
,
1
,
length
);
if
(
!
buffer
)
return
STG_E_INSUFFICIENTMEMORY
;
...
...
@@ -687,7 +686,7 @@ static HRESULT WINAPI memstream_SetSize(IStream *iface, ULARGE_INTEGER new_size)
/* we cut off the high part here */
length
=
new_size
.
u
.
LowPart
;
buffer
=
HeapReAlloc
(
GetProcessHeap
(),
HEAP_ZERO_MEMORY
,
stream
->
u
.
mem
.
buffer
,
length
);
buffer
=
_recalloc
(
stream
->
u
.
mem
.
buffer
,
1
,
length
);
if
(
!
buffer
)
return
STG_E_INSUFFICIENTMEMORY
;
...
...
@@ -836,13 +835,13 @@ static struct shstream *shstream_create(const IStreamVtbl *vtbl, const BYTE *dat
if
(
!
data
)
data_len
=
0
;
stream
=
heap_
alloc
(
sizeof
(
*
stream
));
stream
=
m
alloc
(
sizeof
(
*
stream
));
stream
->
IStream_iface
.
lpVtbl
=
vtbl
;
stream
->
refcount
=
1
;
stream
->
u
.
mem
.
buffer
=
heap_
alloc
(
data_len
);
stream
->
u
.
mem
.
buffer
=
m
alloc
(
data_len
);
if
(
!
stream
->
u
.
mem
.
buffer
)
{
heap_
free
(
stream
);
free
(
stream
);
return
NULL
;
}
memcpy
(
stream
->
u
.
mem
.
buffer
,
data
,
data_len
);
...
...
@@ -888,8 +887,8 @@ static ULONG WINAPI filestream_Release(IStream *iface)
if
(
!
refcount
)
{
CloseHandle
(
stream
->
u
.
file
.
handle
);
heap_
free
(
stream
->
u
.
file
.
path
);
heap_
free
(
stream
);
free
(
stream
->
u
.
file
.
path
);
free
(
stream
);
}
return
refcount
;
...
...
@@ -1157,14 +1156,14 @@ HRESULT WINAPI SHCreateStreamOnFileEx(const WCHAR *path, DWORD mode, DWORD attri
if
(
hFile
==
INVALID_HANDLE_VALUE
)
return
HRESULT_FROM_WIN32
(
GetLastError
());
stream
=
heap_
alloc
(
sizeof
(
*
stream
));
stream
=
m
alloc
(
sizeof
(
*
stream
));
stream
->
IStream_iface
.
lpVtbl
=
&
filestreamvtbl
;
stream
->
refcount
=
1
;
stream
->
u
.
file
.
handle
=
hFile
;
stream
->
u
.
file
.
mode
=
mode
;
len
=
lstrlenW
(
path
);
stream
->
u
.
file
.
path
=
heap_
alloc
((
len
+
1
)
*
sizeof
(
WCHAR
));
stream
->
u
.
file
.
path
=
m
alloc
((
len
+
1
)
*
sizeof
(
WCHAR
));
memcpy
(
stream
->
u
.
file
.
path
,
path
,
(
len
+
1
)
*
sizeof
(
WCHAR
));
*
ret
=
&
stream
->
IStream_iface
;
...
...
@@ -1203,13 +1202,13 @@ HRESULT WINAPI SHCreateStreamOnFileA(const char *path, DWORD mode, IStream **str
return
HRESULT_FROM_WIN32
(
ERROR_PATH_NOT_FOUND
);
len
=
MultiByteToWideChar
(
CP_ACP
,
0
,
path
,
-
1
,
NULL
,
0
);
pathW
=
heap_
alloc
(
len
*
sizeof
(
WCHAR
));
pathW
=
m
alloc
(
len
*
sizeof
(
WCHAR
));
if
(
!
pathW
)
return
E_OUTOFMEMORY
;
MultiByteToWideChar
(
CP_ACP
,
0
,
path
,
-
1
,
pathW
,
len
);
hr
=
SHCreateStreamOnFileW
(
pathW
,
mode
,
stream
);
heap_
free
(
pathW
);
free
(
pathW
);
return
hr
;
}
...
...
@@ -1233,8 +1232,8 @@ static ULONG WINAPI regstream_Release(IStream *iface)
RegCloseKey
(
stream
->
u
.
mem
.
hkey
);
}
CoTaskMemFree
(
stream
->
u
.
mem
.
valuename
);
heap_
free
(
stream
->
u
.
mem
.
buffer
);
heap_
free
(
stream
);
free
(
stream
->
u
.
mem
.
buffer
);
free
(
stream
);
}
return
refcount
;
...
...
@@ -1284,16 +1283,16 @@ IStream * WINAPI SHOpenRegStream2W(HKEY hKey, const WCHAR *subkey, const WCHAR *
ret
=
RegQueryValueExW
(
hStrKey
,
value
,
0
,
0
,
0
,
&
length
);
if
(
ret
==
ERROR_SUCCESS
&&
length
)
{
buff
=
heap_
alloc
(
length
);
buff
=
m
alloc
(
length
);
RegQueryValueExW
(
hStrKey
,
value
,
0
,
0
,
buff
,
&
length
);
}
}
if
(
!
length
)
buff
=
heap_
alloc
(
length
);
buff
=
m
alloc
(
length
);
stream
=
shstream_create
(
&
regstreamvtbl
,
buff
,
length
);
heap_
free
(
buff
);
free
(
buff
);
if
(
stream
)
{
stream
->
u
.
mem
.
hkey
=
hStrKey
;
...
...
@@ -1458,7 +1457,7 @@ static ULONG WINAPI threadref_Release(IUnknown *iface)
TRACE
(
"%p, refcount %ld.
\n
"
,
threadref
,
refcount
);
if
(
!
refcount
)
heap_
free
(
threadref
);
free
(
threadref
);
return
refcount
;
}
...
...
@@ -1484,7 +1483,7 @@ HRESULT WINAPI SHCreateThreadRef(LONG *refcount, IUnknown **out)
*
out
=
NULL
;
threadref
=
heap_
alloc
(
sizeof
(
*
threadref
));
threadref
=
m
alloc
(
sizeof
(
*
threadref
));
if
(
!
threadref
)
return
E_OUTOFMEMORY
;
threadref
->
IUnknown_iface
.
lpVtbl
=
&
threadrefvtbl
;
...
...
@@ -1993,10 +1992,10 @@ DWORD WINAPI SHCopyKeyW(HKEY hkey_src, const WCHAR *subkey, HKEY hkey_dst, DWORD
max_key_len
=
max
(
max_key_len
,
max_value_len
);
if
(
max_key_len
++
>
MAX_PATH
-
1
)
ptr_name
=
heap_
alloc
(
max_key_len
*
sizeof
(
WCHAR
));
ptr_name
=
m
alloc
(
max_key_len
*
sizeof
(
WCHAR
));
if
(
max_data_len
>
sizeof
(
buff
))
ptr
=
heap_
alloc
(
max_data_len
);
ptr
=
m
alloc
(
max_data_len
);
if
(
!
ptr_name
||
!
ptr
)
ret
=
ERROR_NOT_ENOUGH_MEMORY
;
...
...
@@ -2040,9 +2039,9 @@ DWORD WINAPI SHCopyKeyW(HKEY hkey_src, const WCHAR *subkey, HKEY hkey_dst, DWORD
/* Free buffers if allocated */
if
(
ptr_name
!=
name
)
heap_
free
(
ptr_name
);
free
(
ptr_name
);
if
(
ptr
!=
buff
)
heap_
free
(
ptr
);
free
(
ptr
);
if
(
subkey
&&
hkey_src
)
RegCloseKey
(
hkey_src
);
...
...
@@ -2118,20 +2117,20 @@ DWORD WINAPI SHQueryValueExW(HKEY hkey, const WCHAR *name, DWORD *reserved, DWOR
if
(
!
buff
||
ret
==
ERROR_MORE_DATA
)
{
length
=
data_len
;
value
=
heap_
alloc
(
length
);
value
=
m
alloc
(
length
);
RegQueryValueExW
(
hkey
,
name
,
reserved
,
NULL
,
(
BYTE
*
)
value
,
&
length
);
length
=
ExpandEnvironmentStringsW
(
value
,
NULL
,
0
);
}
else
{
length
=
(
lstrlenW
(
buff
)
+
1
)
*
sizeof
(
WCHAR
);
value
=
heap_
alloc
(
length
);
value
=
m
alloc
(
length
);
memcpy
(
value
,
buff
,
length
);
length
=
ExpandEnvironmentStringsW
(
value
,
buff
,
*
buff_len
/
sizeof
(
WCHAR
));
if
(
length
>
*
buff_len
)
ret
=
ERROR_MORE_DATA
;
}
data_len
=
max
(
data_len
,
length
);
heap_
free
(
value
);
free
(
value
);
}
if
(
type
)
...
...
@@ -2166,20 +2165,20 @@ DWORD WINAPI SHQueryValueExA(HKEY hkey, const char *name, DWORD *reserved, DWORD
if
(
!
buff
||
ret
==
ERROR_MORE_DATA
)
{
length
=
data_len
;
value
=
heap_
alloc
(
length
);
value
=
m
alloc
(
length
);
RegQueryValueExA
(
hkey
,
name
,
reserved
,
NULL
,
(
BYTE
*
)
value
,
&
length
);
length
=
ExpandEnvironmentStringsA
(
value
,
NULL
,
0
);
}
else
{
length
=
strlen
(
buff
)
+
1
;
value
=
heap_
alloc
(
length
);
value
=
m
alloc
(
length
);
memcpy
(
value
,
buff
,
length
);
length
=
ExpandEnvironmentStringsA
(
value
,
buff
,
*
buff_len
);
if
(
length
>
*
buff_len
)
ret
=
ERROR_MORE_DATA
;
}
data_len
=
max
(
data_len
,
length
);
heap_
free
(
value
);
free
(
value
);
}
if
(
type
)
...
...
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