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

xmllite: Use CRT allocation functions.

parent f859e8b2
...@@ -3632,11 +3632,7 @@ HRESULT WINAPI CreateXmlReader(REFIID riid, void **obj, IMalloc *imalloc) ...@@ -3632,11 +3632,7 @@ HRESULT WINAPI CreateXmlReader(REFIID riid, void **obj, IMalloc *imalloc)
TRACE("(%s, %p, %p)\n", wine_dbgstr_guid(riid), obj, imalloc); TRACE("(%s, %p, %p)\n", wine_dbgstr_guid(riid), obj, imalloc);
if (imalloc) if (!(reader = m_alloc(imalloc, sizeof(*reader))))
reader = IMalloc_Alloc(imalloc, sizeof(*reader));
else
reader = heap_alloc(sizeof(*reader));
if (!reader)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
memset(reader, 0, sizeof(*reader)); memset(reader, 0, sizeof(*reader));
...@@ -3682,21 +3678,17 @@ HRESULT WINAPI CreateXmlReaderInputWithEncodingName(IUnknown *stream, ...@@ -3682,21 +3678,17 @@ HRESULT WINAPI CreateXmlReaderInputWithEncodingName(IUnknown *stream,
if (!stream || !ppInput) return E_INVALIDARG; if (!stream || !ppInput) return E_INVALIDARG;
if (imalloc) if (!(readerinput = m_alloc(imalloc, sizeof(*readerinput))))
readerinput = IMalloc_Alloc(imalloc, sizeof(*readerinput)); return E_OUTOFMEMORY;
else memset(readerinput, 0, sizeof(*readerinput));
readerinput = heap_alloc(sizeof(*readerinput));
if(!readerinput) return E_OUTOFMEMORY;
readerinput->IXmlReaderInput_iface.lpVtbl = &xmlreaderinputvtbl; readerinput->IXmlReaderInput_iface.lpVtbl = &xmlreaderinputvtbl;
readerinput->ref = 1; readerinput->ref = 1;
readerinput->imalloc = imalloc; readerinput->imalloc = imalloc;
readerinput->stream = NULL;
if (imalloc) IMalloc_AddRef(imalloc); if (imalloc) IMalloc_AddRef(imalloc);
readerinput->encoding = parse_encoding_name(encoding, -1); readerinput->encoding = parse_encoding_name(encoding, -1);
readerinput->hint = hint; readerinput->hint = hint;
readerinput->baseuri = readerinput_strdupW(readerinput, base_uri); readerinput->baseuri = readerinput_strdupW(readerinput, base_uri);
readerinput->pending = 0;
hr = alloc_input_buffer(readerinput); hr = alloc_input_buffer(readerinput);
if (hr != S_OK) if (hr != S_OK)
......
...@@ -1865,13 +1865,8 @@ HRESULT WINAPI CreateXmlWriter(REFIID riid, void **obj, IMalloc *imalloc) ...@@ -1865,13 +1865,8 @@ HRESULT WINAPI CreateXmlWriter(REFIID riid, void **obj, IMalloc *imalloc)
TRACE("(%s, %p, %p)\n", wine_dbgstr_guid(riid), obj, imalloc); TRACE("(%s, %p, %p)\n", wine_dbgstr_guid(riid), obj, imalloc);
if (imalloc) if (!(writer = m_alloc(imalloc, sizeof(*writer))))
writer = IMalloc_Alloc(imalloc, sizeof(*writer));
else
writer = heap_alloc(sizeof(*writer));
if (!writer)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
memset(writer, 0, sizeof(*writer)); memset(writer, 0, sizeof(*writer));
writer->IXmlWriter_iface.lpVtbl = &xmlwriter_vtbl; writer->IXmlWriter_iface.lpVtbl = &xmlwriter_vtbl;
...@@ -1899,12 +1894,9 @@ static HRESULT create_writer_output(IUnknown *stream, IMalloc *imalloc, xml_enco ...@@ -1899,12 +1894,9 @@ static HRESULT create_writer_output(IUnknown *stream, IMalloc *imalloc, xml_enco
*out = NULL; *out = NULL;
if (imalloc) if (!(writeroutput = m_alloc(imalloc, sizeof(*writeroutput))))
writeroutput = IMalloc_Alloc(imalloc, sizeof(*writeroutput));
else
writeroutput = heap_alloc(sizeof(*writeroutput));
if (!writeroutput)
return E_OUTOFMEMORY; return E_OUTOFMEMORY;
memset(writeroutput, 0, sizeof(*writeroutput));
writeroutput->IXmlWriterOutput_iface.lpVtbl = &xmlwriteroutputvtbl; writeroutput->IXmlWriterOutput_iface.lpVtbl = &xmlwriteroutputvtbl;
writeroutput->ref = 1; writeroutput->ref = 1;
...@@ -1912,21 +1904,18 @@ static HRESULT create_writer_output(IUnknown *stream, IMalloc *imalloc, xml_enco ...@@ -1912,21 +1904,18 @@ static HRESULT create_writer_output(IUnknown *stream, IMalloc *imalloc, xml_enco
if (imalloc) if (imalloc)
IMalloc_AddRef(imalloc); IMalloc_AddRef(imalloc);
writeroutput->encoding = encoding; writeroutput->encoding = encoding;
writeroutput->stream = NULL;
hr = init_output_buffer(writeroutput); hr = init_output_buffer(writeroutput);
if (FAILED(hr)) { if (FAILED(hr)) {
IUnknown_Release(&writeroutput->IXmlWriterOutput_iface); IUnknown_Release(&writeroutput->IXmlWriterOutput_iface);
return hr; return hr;
} }
if (encoding_name) { if (encoding_name)
{
unsigned int size = (lstrlenW(encoding_name) + 1) * sizeof(WCHAR); unsigned int size = (lstrlenW(encoding_name) + 1) * sizeof(WCHAR);
writeroutput->encoding_name = writeroutput_alloc(writeroutput, size); writeroutput->encoding_name = writeroutput_alloc(writeroutput, size);
memcpy(writeroutput->encoding_name, encoding_name, size); memcpy(writeroutput->encoding_name, encoding_name, size);
} }
else
writeroutput->encoding_name = NULL;
writeroutput->written = 0;
IUnknown_QueryInterface(stream, &IID_IUnknown, (void**)&writeroutput->output); IUnknown_QueryInterface(stream, &IID_IUnknown, (void**)&writeroutput->output);
......
...@@ -21,14 +21,12 @@ ...@@ -21,14 +21,12 @@
#ifndef __XMLLITE_PRIVATE__ #ifndef __XMLLITE_PRIVATE__
#define __XMLLITE_PRIVATE__ #define __XMLLITE_PRIVATE__
#include "wine/heap.h"
static inline void *m_alloc(IMalloc *imalloc, size_t len) static inline void *m_alloc(IMalloc *imalloc, size_t len)
{ {
if (imalloc) if (imalloc)
return IMalloc_Alloc(imalloc, len); return IMalloc_Alloc(imalloc, len);
else else
return heap_alloc(len); return malloc(len);
} }
static inline void *m_realloc(IMalloc *imalloc, void *mem, size_t len) static inline void *m_realloc(IMalloc *imalloc, void *mem, size_t len)
...@@ -36,7 +34,7 @@ static inline void *m_realloc(IMalloc *imalloc, void *mem, size_t len) ...@@ -36,7 +34,7 @@ static inline void *m_realloc(IMalloc *imalloc, void *mem, size_t len)
if (imalloc) if (imalloc)
return IMalloc_Realloc(imalloc, mem, len); return IMalloc_Realloc(imalloc, mem, len);
else else
return heap_realloc(mem, len); return realloc(mem, len);
} }
static inline void m_free(IMalloc *imalloc, void *mem) static inline void m_free(IMalloc *imalloc, void *mem)
...@@ -44,7 +42,7 @@ static inline void m_free(IMalloc *imalloc, void *mem) ...@@ -44,7 +42,7 @@ static inline void m_free(IMalloc *imalloc, void *mem)
if (imalloc) if (imalloc)
IMalloc_Free(imalloc, mem); IMalloc_Free(imalloc, mem);
else else
heap_free(mem); free(mem);
} }
typedef enum typedef enum
......
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