[PATCH 1/2] xmllite: Use CRT allocation functions.
Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com> --- dlls/xmllite/reader.c | 16 ++++------------ dlls/xmllite/writer.c | 21 +++++---------------- dlls/xmllite/xmllite_private.h | 8 +++----- 3 files changed, 12 insertions(+), 33 deletions(-) diff --git a/dlls/xmllite/reader.c b/dlls/xmllite/reader.c index ccdc1ae2c1b..8d893b51f04 100644 --- a/dlls/xmllite/reader.c +++ b/dlls/xmllite/reader.c @@ -3632,11 +3632,7 @@ HRESULT WINAPI CreateXmlReader(REFIID riid, void **obj, IMalloc *imalloc) TRACE("(%s, %p, %p)\n", wine_dbgstr_guid(riid), obj, imalloc); - if (imalloc) - reader = IMalloc_Alloc(imalloc, sizeof(*reader)); - else - reader = heap_alloc(sizeof(*reader)); - if (!reader) + if (!(reader = m_alloc(imalloc, sizeof(*reader)))) return E_OUTOFMEMORY; memset(reader, 0, sizeof(*reader)); @@ -3682,21 +3678,17 @@ HRESULT WINAPI CreateXmlReaderInputWithEncodingName(IUnknown *stream, if (!stream || !ppInput) return E_INVALIDARG; - if (imalloc) - readerinput = IMalloc_Alloc(imalloc, sizeof(*readerinput)); - else - readerinput = heap_alloc(sizeof(*readerinput)); - if(!readerinput) return E_OUTOFMEMORY; + if (!(readerinput = m_alloc(imalloc, sizeof(*readerinput)))) + return E_OUTOFMEMORY; + memset(readerinput, 0, sizeof(*readerinput)); readerinput->IXmlReaderInput_iface.lpVtbl = &xmlreaderinputvtbl; readerinput->ref = 1; readerinput->imalloc = imalloc; - readerinput->stream = NULL; if (imalloc) IMalloc_AddRef(imalloc); readerinput->encoding = parse_encoding_name(encoding, -1); readerinput->hint = hint; readerinput->baseuri = readerinput_strdupW(readerinput, base_uri); - readerinput->pending = 0; hr = alloc_input_buffer(readerinput); if (hr != S_OK) diff --git a/dlls/xmllite/writer.c b/dlls/xmllite/writer.c index ac02bd4c200..58d9edea059 100644 --- a/dlls/xmllite/writer.c +++ b/dlls/xmllite/writer.c @@ -1865,13 +1865,8 @@ HRESULT WINAPI CreateXmlWriter(REFIID riid, void **obj, IMalloc *imalloc) TRACE("(%s, %p, %p)\n", wine_dbgstr_guid(riid), obj, imalloc); - if (imalloc) - writer = IMalloc_Alloc(imalloc, sizeof(*writer)); - else - writer = heap_alloc(sizeof(*writer)); - if (!writer) + if (!(writer = m_alloc(imalloc, sizeof(*writer)))) return E_OUTOFMEMORY; - memset(writer, 0, sizeof(*writer)); writer->IXmlWriter_iface.lpVtbl = &xmlwriter_vtbl; @@ -1899,12 +1894,9 @@ static HRESULT create_writer_output(IUnknown *stream, IMalloc *imalloc, xml_enco *out = NULL; - if (imalloc) - writeroutput = IMalloc_Alloc(imalloc, sizeof(*writeroutput)); - else - writeroutput = heap_alloc(sizeof(*writeroutput)); - if (!writeroutput) + if (!(writeroutput = m_alloc(imalloc, sizeof(*writeroutput)))) return E_OUTOFMEMORY; + memset(writeroutput, 0, sizeof(*writeroutput)); writeroutput->IXmlWriterOutput_iface.lpVtbl = &xmlwriteroutputvtbl; writeroutput->ref = 1; @@ -1912,21 +1904,18 @@ static HRESULT create_writer_output(IUnknown *stream, IMalloc *imalloc, xml_enco if (imalloc) IMalloc_AddRef(imalloc); writeroutput->encoding = encoding; - writeroutput->stream = NULL; hr = init_output_buffer(writeroutput); if (FAILED(hr)) { IUnknown_Release(&writeroutput->IXmlWriterOutput_iface); return hr; } - if (encoding_name) { + if (encoding_name) + { unsigned int size = (lstrlenW(encoding_name) + 1) * sizeof(WCHAR); writeroutput->encoding_name = writeroutput_alloc(writeroutput, size); memcpy(writeroutput->encoding_name, encoding_name, size); } - else - writeroutput->encoding_name = NULL; - writeroutput->written = 0; IUnknown_QueryInterface(stream, &IID_IUnknown, (void**)&writeroutput->output); diff --git a/dlls/xmllite/xmllite_private.h b/dlls/xmllite/xmllite_private.h index 10f43760b41..03653bbe371 100644 --- a/dlls/xmllite/xmllite_private.h +++ b/dlls/xmllite/xmllite_private.h @@ -21,14 +21,12 @@ #ifndef __XMLLITE_PRIVATE__ #define __XMLLITE_PRIVATE__ -#include "wine/heap.h" - static inline void *m_alloc(IMalloc *imalloc, size_t len) { if (imalloc) return IMalloc_Alloc(imalloc, len); else - return heap_alloc(len); + return malloc(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) if (imalloc) return IMalloc_Realloc(imalloc, mem, len); else - return heap_realloc(mem, len); + return realloc(mem, len); } static inline void m_free(IMalloc *imalloc, void *mem) @@ -44,7 +42,7 @@ static inline void m_free(IMalloc *imalloc, void *mem) if (imalloc) IMalloc_Free(imalloc, mem); else - heap_free(mem); + free(mem); } typedef enum -- 2.35.1
Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com> --- dlls/xmllite/tests/reader.c | 9 ++++----- dlls/xmllite/tests/writer.c | 35 +++++++++++++++++------------------ 2 files changed, 21 insertions(+), 23 deletions(-) diff --git a/dlls/xmllite/tests/reader.c b/dlls/xmllite/tests/reader.c index d0d2373aaf1..d9c831fb52d 100644 --- a/dlls/xmllite/tests/reader.c +++ b/dlls/xmllite/tests/reader.c @@ -30,7 +30,6 @@ #include "ole2.h" #include "xmllite.h" #include "wine/test.h" -#include "wine/heap.h" DEFINE_GUID(IID_IXmlReaderInput, 0x0b3ccc9b, 0x9214, 0x428b, 0xa2, 0xae, 0xef, 0x3a, 0xa8, 0x71, 0xaf, 0xda); @@ -383,12 +382,12 @@ static ULONG WINAPI testinput_AddRef(IUnknown *iface) static ULONG WINAPI testinput_Release(IUnknown *iface) { - testinput *This = impl_from_IUnknown(iface); + testinput *input = impl_from_IUnknown(iface); LONG ref; - ref = InterlockedDecrement(&This->ref); + ref = InterlockedDecrement(&input->ref); if (ref == 0) - heap_free(This); + free(input); return ref; } @@ -404,7 +403,7 @@ static HRESULT testinput_createinstance(void **ppObj) { testinput *input; - input = heap_alloc(sizeof(*input)); + input = malloc(sizeof(*input)); if(!input) return E_OUTOFMEMORY; input->IUnknown_iface.lpVtbl = &testinput_vtbl; diff --git a/dlls/xmllite/tests/writer.c b/dlls/xmllite/tests/writer.c index 8d096b0d632..2f6edb26d16 100644 --- a/dlls/xmllite/tests/writer.c +++ b/dlls/xmllite/tests/writer.c @@ -27,7 +27,6 @@ #include "ole2.h" #include "xmllite.h" -#include "wine/heap.h" #include "wine/test.h" #include "initguid.h" @@ -100,7 +99,7 @@ static WCHAR *strdupAtoW(const char *str) if (!str) return ret; len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0); - ret = heap_alloc(len * sizeof(WCHAR)); + ret = malloc(len * sizeof(WCHAR)); if (ret) MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len); return ret; @@ -843,9 +842,9 @@ static HRESULT write_start_element(IXmlWriter *writer, const char *prefix, const hr = IXmlWriter_WriteStartElement(writer, prefixW, localW, uriW); - heap_free(prefixW); - heap_free(localW); - heap_free(uriW); + free(prefixW); + free(localW); + free(uriW); return hr; } @@ -863,10 +862,10 @@ static HRESULT write_element_string(IXmlWriter *writer, const char *prefix, cons hr = IXmlWriter_WriteElementString(writer, prefixW, localW, uriW, valueW); - heap_free(prefixW); - heap_free(localW); - heap_free(uriW); - heap_free(valueW); + free(prefixW); + free(localW); + free(uriW); + free(valueW); return hr; } @@ -880,7 +879,7 @@ static HRESULT write_string(IXmlWriter *writer, const char *str) hr = IXmlWriter_WriteString(writer, strW); - heap_free(strW); + free(strW); return hr; } @@ -1589,10 +1588,10 @@ static HRESULT write_attribute_string(IXmlWriter *writer, const char *prefix, co hr = IXmlWriter_WriteAttributeString(writer, prefixW, localW, uriW, valueW); - heap_free(prefixW); - heap_free(localW); - heap_free(uriW); - heap_free(valueW); + free(prefixW); + free(localW); + free(uriW); + free(valueW); return hr; } @@ -2116,10 +2115,10 @@ static HRESULT write_doctype(IXmlWriter *writer, const char *name, const char *p hr = IXmlWriter_WriteDocType(writer, nameW, pubidW, sysidW, subsetW); - heap_free(nameW); - heap_free(pubidW); - heap_free(sysidW); - heap_free(subsetW); + free(nameW); + free(pubidW); + free(sysidW); + free(subsetW); return hr; } -- 2.35.1
participants (1)
-
Nikolay Sivov