Commit e0ca118f authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

prntvpt: Use CRT allocation functions.

parent d19814cb
......@@ -26,26 +26,15 @@
#include "winspool.h"
#include "objbase.h"
#include "prntvpt.h"
#include "wine/heap.h"
#include "wine/debug.h"
#include "prntvpt_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(prntvpt);
static WCHAR *heap_strdupW(const WCHAR *src)
{
WCHAR *dst;
size_t len;
if (!src) return NULL;
len = (wcslen(src) + 1) * sizeof(WCHAR);
if ((dst = heap_alloc(len))) memcpy(dst, src, len);
return dst;
}
HRESULT WINAPI PTReleaseMemory(PVOID mem)
{
heap_free(mem);
free(mem);
return S_OK;
}
......@@ -65,9 +54,9 @@ HRESULT WINAPI PTCloseProvider(HPTPROVIDER provider)
return E_HANDLE;
prov->owner = 0;
heap_free(prov->name);
free(prov->name);
ClosePrinter(prov->hprn);
heap_free(prov);
free(prov);
return S_OK;
}
......@@ -92,16 +81,16 @@ HRESULT WINAPI PTOpenProviderEx(const WCHAR *printer, DWORD max_version, DWORD p
if (!max_version || !provider || !used_version)
return E_INVALIDARG;
prov = heap_alloc(sizeof(*prov));
prov = malloc(sizeof(*prov));
if (!prov) return E_OUTOFMEMORY;
if (!OpenPrinterW((LPWSTR)printer, &prov->hprn, NULL))
{
heap_free(prov);
free(prov);
return HRESULT_FROM_WIN32(GetLastError());
}
prov->name = heap_strdupW(printer);
prov->name = wcsdup(printer);
prov->owner = GetCurrentThreadId();
*provider = (HPTPROVIDER)prov;
*used_version = 1;
......
......@@ -30,7 +30,6 @@
#include "prntvpt.h"
#include "initguid.h"
#include "msxml2.h"
#include "wine/heap.h"
#include "wine/debug.h"
#include "prntvpt_private.h"
......@@ -709,7 +708,7 @@ static HRESULT initialize_ticket(struct prn_provider *prov, struct ticket *ticke
if (GetLastError() != ERROR_INSUFFICIENT_BUFFER)
return HRESULT_FROM_WIN32(GetLastError());
pi2 = heap_alloc(size);
pi2 = malloc(size);
if (!pi2) return E_OUTOFMEMORY;
if (!GetPrinterW(prov->hprn, 2, (LPBYTE)pi2, size, NULL))
......@@ -717,7 +716,7 @@ static HRESULT initialize_ticket(struct prn_provider *prov, struct ticket *ticke
else
devmode_to_ticket(pi2->pDevMode, ticket);
heap_free(pi2);
free(pi2);
return hr;
}
......@@ -739,7 +738,7 @@ HRESULT WINAPI PTConvertPrintTicketToDevMode(HPTPROVIDER provider, IStream *stre
hr = parse_ticket(stream, scope, &ticket);
if (hr != S_OK) return hr;
*dm = heap_alloc(sizeof(**dm));
*dm = malloc(sizeof(**dm));
if (!*dm) return E_OUTOFMEMORY;
ticket_to_devmode(&ticket, *dm);
......@@ -1279,7 +1278,7 @@ static HRESULT write_PageMediaSize_caps(const WCHAR *device, IXMLDOMElement *roo
if (count <= 0)
return HRESULT_FROM_WIN32(GetLastError());
pt = heap_alloc(count * sizeof(*pt));
pt = calloc(count, sizeof(*pt));
if (!pt) return E_OUTOFMEMORY;
count = DeviceCapabilitiesW(device, NULL, DC_PAPERSIZE, (LPWSTR)pt, NULL);
......@@ -1298,7 +1297,7 @@ static HRESULT write_PageMediaSize_caps(const WCHAR *device, IXMLDOMElement *roo
fail:
if (feature) IXMLDOMElement_Release(feature);
heap_free(pt);
free(pt);
return hr;
}
......@@ -1353,7 +1352,7 @@ static HRESULT write_PageResolution_caps(const WCHAR *device, IXMLDOMElement *ro
if (count <= 0)
return HRESULT_FROM_WIN32(GetLastError());
res = heap_alloc(count * sizeof(*res));
res = calloc(count, sizeof(*res));
if (!res) return E_OUTOFMEMORY;
count = DeviceCapabilitiesW(device, NULL, DC_ENUMRESOLUTIONS, (LPWSTR)res, NULL);
......@@ -1372,7 +1371,7 @@ static HRESULT write_PageResolution_caps(const WCHAR *device, IXMLDOMElement *ro
fail:
if (feature) IXMLDOMElement_Release(feature);
heap_free(res);
free(res);
return hr;
}
......@@ -1427,7 +1426,7 @@ static HRESULT write_JobInputBin_caps(const WCHAR *device, IXMLDOMElement *root)
if (count <= 0)
return HRESULT_FROM_WIN32(GetLastError());
bin = heap_alloc(count * sizeof(*bin));
bin = calloc(count, sizeof(*bin));
if (!bin) return E_OUTOFMEMORY;
count = DeviceCapabilitiesW(device, NULL, DC_BINS, (LPWSTR)bin, NULL);
......@@ -1446,7 +1445,7 @@ static HRESULT write_JobInputBin_caps(const WCHAR *device, IXMLDOMElement *root)
fail:
if (feature) IXMLDOMElement_Release(feature);
heap_free(bin);
free(bin);
return hr;
}
......
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