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
897ab8c6
Commit
897ab8c6
authored
Nov 10, 2022
by
Piotr Caban
Committed by
Alexandre Julliard
Nov 14, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
localspl: Use CRT allocation functions.
parent
685e2fda
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
37 additions
and
38 deletions
+37
-38
localmon.c
dlls/localspl/localmon.c
+9
-10
provider.c
dlls/localspl/provider.c
+28
-28
No files found.
dlls/localspl/localmon.c
View file @
897ab8c6
...
...
@@ -34,7 +34,6 @@
#include "localspl_private.h"
#include "wine/debug.h"
#include "wine/heap.h"
#include "wine/list.h"
...
...
@@ -117,7 +116,7 @@ static BOOL does_port_exist(LPCWSTR myname)
TRACE
(
"(%s)
\n
"
,
debugstr_w
(
myname
));
id
=
EnumPortsW
(
NULL
,
1
,
NULL
,
0
,
&
needed
,
&
returned
);
pi
=
heap_
alloc
(
needed
);
pi
=
m
alloc
(
needed
);
returned
=
0
;
if
(
pi
)
id
=
EnumPortsW
(
NULL
,
1
,
(
LPBYTE
)
pi
,
needed
,
&
needed
,
&
returned
);
...
...
@@ -128,13 +127,13 @@ static BOOL does_port_exist(LPCWSTR myname)
{
if
(
lstrcmpiW
(
myname
,
pi
[
id
].
pName
)
==
0
)
{
TRACE
(
"(%lu) found %s
\n
"
,
id
,
debugstr_w
(
pi
[
id
].
pName
));
heap_
free
(
pi
);
free
(
pi
);
return
TRUE
;
}
}
}
heap_
free
(
pi
);
free
(
pi
);
return
FALSE
;
}
...
...
@@ -306,7 +305,7 @@ static DWORD get_type_from_local_name(LPCWSTR nameW)
TRACE
(
"(%s)
\n
"
,
debugstr_w
(
myname
));
needed
=
get_ports_from_reg
(
1
,
NULL
,
0
,
&
numentries
);
pi
=
heap_
alloc
(
needed
);
pi
=
m
alloc
(
needed
);
if
(
pi
)
needed
=
get_ports_from_reg
(
1
,
(
LPBYTE
)
pi
,
needed
,
&
numentries
);
...
...
@@ -325,7 +324,7 @@ static DWORD get_type_from_local_name(LPCWSTR nameW)
id
=
(
myname
)
?
get_type_from_name
(
myname
)
:
PORT_IS_UNKNOWN
;
heap_
free
(
pi
);
free
(
pi
);
return
id
;
}
...
...
@@ -407,7 +406,7 @@ static BOOL WINAPI localmon_ClosePort(HANDLE hPort)
EnterCriticalSection
(
&
port_handles_cs
);
list_remove
(
&
port
->
entry
);
LeaveCriticalSection
(
&
port_handles_cs
);
heap_
free
(
port
);
free
(
port
);
return
TRUE
;
}
...
...
@@ -498,7 +497,7 @@ static BOOL WINAPI localmon_OpenPortW(LPWSTR pName, PHANDLE phPort)
type
=
get_type_from_local_name
(
pName
);
if
(
!
type
)
return
FALSE
;
port
=
heap_
alloc
(
FIELD_OFFSET
(
port_t
,
nameW
[
wcslen
(
pName
)
+
1
]));
port
=
m
alloc
(
FIELD_OFFSET
(
port_t
,
nameW
[
wcslen
(
pName
)
+
1
]));
if
(
!
port
)
return
FALSE
;
port
->
type
=
type
;
...
...
@@ -535,7 +534,7 @@ static BOOL WINAPI localmon_XcvClosePort(HANDLE hXcv)
EnterCriticalSection
(
&
xcv_handles_cs
);
list_remove
(
&
xcv
->
entry
);
LeaveCriticalSection
(
&
xcv_handles_cs
);
heap_
free
(
xcv
);
free
(
xcv
);
return
TRUE
;
}
...
...
@@ -710,7 +709,7 @@ static BOOL WINAPI localmon_XcvOpenPort(LPCWSTR pName, ACCESS_MASK GrantedAccess
TRACE
(
"%s, 0x%lx, %p)
\n
"
,
debugstr_w
(
pName
),
GrantedAccess
,
phXcv
);
/* No checks for any field is done in Windows */
xcv
=
heap_
alloc
(
FIELD_OFFSET
(
xcv_t
,
nameW
[
wcslen
(
pName
)
+
1
]));
xcv
=
m
alloc
(
FIELD_OFFSET
(
xcv_t
,
nameW
[
wcslen
(
pName
)
+
1
]));
if
(
xcv
)
{
xcv
->
GrantedAccess
=
GrantedAccess
;
lstrcpyW
(
xcv
->
nameW
,
pName
);
...
...
dlls/localspl/provider.c
View file @
897ab8c6
...
...
@@ -19,6 +19,7 @@
*/
#include <stdarg.h>
#include <stdlib.h>
#define COBJMACROS
...
...
@@ -33,7 +34,6 @@
#include "ddk/winsplp.h"
#include "wine/debug.h"
#include "wine/heap.h"
#include "wine/list.h"
#include "localspl_private.h"
...
...
@@ -288,7 +288,7 @@ static LPWSTR strdupW(LPCWSTR p)
if
(
!
p
)
return
NULL
;
len
=
(
wcslen
(
p
)
+
1
)
*
sizeof
(
WCHAR
);
ret
=
heap_
alloc
(
len
);
ret
=
m
alloc
(
len
);
if
(
ret
)
memcpy
(
ret
,
p
,
len
);
return
ret
;
}
...
...
@@ -432,9 +432,9 @@ static void monitor_unload(monitor_t * pm)
pm
->
monitor
.
pfnShutdown
(
pm
->
hmon
);
FreeLibrary
(
pm
->
hdll
);
heap_
free
(
pm
->
name
);
heap_
free
(
pm
->
dllname
);
heap_
free
(
pm
);
free
(
pm
->
name
);
free
(
pm
->
dllname
);
free
(
pm
);
}
LeaveCriticalSection
(
&
monitor_handles_cs
);
}
...
...
@@ -585,7 +585,7 @@ static monitor_t * monitor_load(LPCWSTR name, LPWSTR dllname)
}
if
(
pm
==
NULL
)
{
pm
=
heap_alloc_zero
(
sizeof
(
monitor_t
));
pm
=
calloc
(
1
,
sizeof
(
monitor_t
));
if
(
pm
==
NULL
)
goto
cleanup
;
list_add_tail
(
&
monitor_handles
,
&
pm
->
entry
);
}
...
...
@@ -597,7 +597,7 @@ static monitor_t * monitor_load(LPCWSTR name, LPWSTR dllname)
if
(
name
)
{
len
=
wcslen
(
monitorsW
)
+
wcslen
(
name
)
+
2
;
regroot
=
heap_
alloc
(
len
*
sizeof
(
WCHAR
));
regroot
=
m
alloc
(
len
*
sizeof
(
WCHAR
));
}
if
(
regroot
)
{
...
...
@@ -609,7 +609,7 @@ static monitor_t * monitor_load(LPCWSTR name, LPWSTR dllname)
DWORD
namesize
;
if
(
RegQueryValueExW
(
hroot
,
L"Driver"
,
NULL
,
NULL
,
NULL
,
&
namesize
)
==
ERROR_SUCCESS
)
{
driver
=
heap_
alloc
(
namesize
);
driver
=
m
alloc
(
namesize
);
RegQueryValueExW
(
hroot
,
L"Driver"
,
NULL
,
NULL
,
(
BYTE
*
)
driver
,
&
namesize
);
}
}
...
...
@@ -734,9 +734,9 @@ cleanup:
pm_localport
=
pm
;
}
LeaveCriticalSection
(
&
monitor_handles_cs
);
if
(
driver
!=
dllname
)
heap_
free
(
driver
);
if
(
driver
!=
dllname
)
free
(
driver
);
if
(
hroot
)
RegCloseKey
(
hroot
);
heap_
free
(
regroot
);
free
(
regroot
);
TRACE
(
"=> %p
\n
"
,
pm
);
return
pm
;
}
...
...
@@ -848,7 +848,7 @@ static monitor_t * monitor_load_by_port(LPCWSTR portname)
}
len
=
MAX_PATH
+
wcslen
(
L"
\\
Ports
\\
"
)
+
wcslen
(
portname
)
+
1
;
buffer
=
heap_
alloc
(
len
*
sizeof
(
WCHAR
));
buffer
=
m
alloc
(
len
*
sizeof
(
WCHAR
));
if
(
buffer
==
NULL
)
return
NULL
;
if
(
RegOpenKeyW
(
HKEY_LOCAL_MACHINE
,
monitorsW
,
&
hroot
)
==
ERROR_SUCCESS
)
{
...
...
@@ -872,7 +872,7 @@ static monitor_t * monitor_load_by_port(LPCWSTR portname)
LeaveCriticalSection
(
&
monitor_handles_cs
);
RegCloseKey
(
hroot
);
}
heap_
free
(
buffer
);
free
(
buffer
);
return
pm
;
}
...
...
@@ -1177,9 +1177,9 @@ static DWORD get_ports_from_all_monitors(DWORD level, LPBYTE pPorts, DWORD cbBuf
pi_returned
=
0
;
res
=
wrap_EnumPorts
(
pm
,
NULL
,
level
,
pi_buffer
,
pi_allocated
,
&
pi_needed
,
&
pi_returned
);
if
(
!
res
&&
(
GetLastError
()
==
ERROR_INSUFFICIENT_BUFFER
))
{
/* Do not use
heap_
realloc (we do not need the old data in the buffer) */
heap_
free
(
pi_buffer
);
pi_buffer
=
heap_
alloc
(
pi_needed
);
/* Do not use realloc (we do not need the old data in the buffer) */
free
(
pi_buffer
);
pi_buffer
=
m
alloc
(
pi_needed
);
pi_allocated
=
(
pi_buffer
)
?
pi_needed
:
0
;
res
=
wrap_EnumPorts
(
pm
,
NULL
,
level
,
pi_buffer
,
pi_allocated
,
&
pi_needed
,
&
pi_returned
);
}
...
...
@@ -1216,7 +1216,7 @@ static DWORD get_ports_from_all_monitors(DWORD level, LPBYTE pPorts, DWORD cbBuf
}
}
/* the temporary portinfo-buffer is no longer needed */
heap_
free
(
pi_buffer
);
free
(
pi_buffer
);
*
lpreturned
=
numentries
;
TRACE
(
"need %ld byte for %ld entries
\n
"
,
needed
,
numentries
);
...
...
@@ -1245,13 +1245,13 @@ static HKEY open_driver_reg(LPCWSTR pEnvironment)
env
=
validate_envW
(
pEnvironment
);
if
(
!
env
)
return
NULL
;
buffer
=
HeapAlloc
(
GetProcessHeap
(),
0
,
sizeof
(
fmt_driversW
)
+
(
wcslen
(
env
->
envname
)
+
wcslen
(
env
->
versionregpath
))
*
sizeof
(
WCHAR
));
buffer
=
malloc
(
sizeof
(
fmt_driversW
)
+
(
wcslen
(
env
->
envname
)
+
wcslen
(
env
->
versionregpath
))
*
sizeof
(
WCHAR
));
if
(
buffer
)
{
wsprintfW
(
buffer
,
fmt_driversW
,
env
->
envname
,
env
->
versionregpath
);
RegCreateKeyW
(
HKEY_LOCAL_MACHINE
,
buffer
,
&
retval
);
HeapFree
(
GetProcessHeap
(),
0
,
buffer
);
free
(
buffer
);
}
return
retval
;
}
...
...
@@ -1389,9 +1389,9 @@ static VOID printer_free(printer_t * printer)
monitor_unload
(
printer
->
pm
);
heap_
free
(
printer
->
printername
);
heap_
free
(
printer
->
name
);
heap_
free
(
printer
);
free
(
printer
->
printername
);
free
(
printer
->
name
);
free
(
printer
);
}
/******************************************************************
...
...
@@ -1423,7 +1423,7 @@ static HANDLE printer_alloc_handle(LPCWSTR name, LPPRINTER_DEFAULTSW pDefault)
return
NULL
;
}
printer
=
heap_alloc_zero
(
sizeof
(
printer_t
));
printer
=
calloc
(
1
,
sizeof
(
printer_t
));
if
(
!
printer
)
goto
end
;
/* clone the base name. This is NULL for the printserver */
...
...
@@ -1631,7 +1631,7 @@ static BOOL myAddPrinterDriverEx(DWORD level, LPBYTE pDriverInfo, DWORD dwFileCo
if
(
di
.
pDependentFiles
&&
*
di
.
pDependentFiles
)
{
WCHAR
*
reg
,
*
reg_ptr
,
*
in_ptr
;
reg
=
reg_ptr
=
HeapAlloc
(
GetProcessHeap
(),
0
,
multi_sz_lenW
(
di
.
pDependentFiles
)
);
reg
=
reg_ptr
=
malloc
(
multi_sz_lenW
(
di
.
pDependentFiles
)
);
for
(
in_ptr
=
di
.
pDependentFiles
;
*
in_ptr
;
in_ptr
+=
wcslen
(
in_ptr
)
+
1
)
{
...
...
@@ -1644,7 +1644,7 @@ static BOOL myAddPrinterDriverEx(DWORD level, LPBYTE pDriverInfo, DWORD dwFileCo
*
reg_ptr
=
0
;
RegSetValueExW
(
hdrv
,
L"Dependent Files"
,
0
,
REG_MULTI_SZ
,
(
BYTE
*
)
reg
,
(
reg_ptr
-
reg
+
1
)
*
sizeof
(
WCHAR
)
);
HeapFree
(
GetProcessHeap
(),
0
,
reg
);
free
(
reg
);
}
else
RegSetValueExW
(
hdrv
,
L"Dependent Files"
,
0
,
REG_MULTI_SZ
,
(
const
BYTE
*
)
L""
,
sizeof
(
L""
));
...
...
@@ -2446,8 +2446,8 @@ static BOOL WINAPI fpEnumPrintProcessors(LPWSTR pName, LPWSTR pEnvironment, DWOR
if
(
!
env
)
goto
epp_cleanup
;
/* ERROR_INVALID_ENVIRONMENT */
regpathW
=
heap_
alloc
(
sizeof
(
fmt_printprocessorsW
)
+
(
wcslen
(
env
->
envname
)
*
sizeof
(
WCHAR
)));
regpathW
=
m
alloc
(
sizeof
(
fmt_printprocessorsW
)
+
(
wcslen
(
env
->
envname
)
*
sizeof
(
WCHAR
)));
if
(
!
regpathW
)
goto
epp_cleanup
;
...
...
@@ -2469,7 +2469,7 @@ static BOOL WINAPI fpEnumPrintProcessors(LPWSTR pName, LPWSTR pEnvironment, DWOR
res
=
TRUE
;
epp_cleanup:
heap_
free
(
regpathW
);
free
(
regpathW
);
if
(
pcbNeeded
)
*
pcbNeeded
=
needed
;
if
(
pcReturned
)
*
pcReturned
=
numentries
;
...
...
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