Commit 897ab8c6 authored by Piotr Caban's avatar Piotr Caban Committed by Alexandre Julliard

localspl: Use CRT allocation functions.

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