opcservices: Use CRT allocation functions.
Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
6549f1f3d2
commit
ea15c212e3
|
@ -28,7 +28,6 @@
|
|||
#include "opc_private.h"
|
||||
|
||||
#include "wine/debug.h"
|
||||
#include "wine/heap.h"
|
||||
|
||||
WINE_DEFAULT_DEBUG_CHANNEL(msopc);
|
||||
|
||||
|
@ -120,7 +119,7 @@ HRESULT compress_create_archive(IStream *output, struct zip_archive **out)
|
|||
WORD date, time;
|
||||
FILETIME ft;
|
||||
|
||||
if (!(archive = heap_alloc(sizeof(*archive))))
|
||||
if (!(archive = malloc(sizeof(*archive))))
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
archive->files = NULL;
|
||||
|
@ -180,9 +179,9 @@ void compress_finalize_archive(struct zip_archive *archive)
|
|||
IStream_Release(archive->output);
|
||||
|
||||
for (i = 0; i < archive->file_count; i++)
|
||||
heap_free(archive->files[i]);
|
||||
heap_free(archive->files);
|
||||
heap_free(archive);
|
||||
free(archive->files[i]);
|
||||
free(archive->files);
|
||||
free(archive);
|
||||
}
|
||||
|
||||
static void compress_write_content(struct zip_archive *archive, IStream *content,
|
||||
|
@ -270,7 +269,7 @@ HRESULT compress_add_file(struct zip_archive *archive, const WCHAR *path,
|
|||
DWORD len;
|
||||
|
||||
len = WideCharToMultiByte(CP_ACP, 0, path, -1, NULL, 0, NULL, NULL);
|
||||
if (!(name = heap_alloc(len)))
|
||||
if (!(name = malloc(len)))
|
||||
return E_OUTOFMEMORY;
|
||||
WideCharToMultiByte(CP_ACP, 0, path, -1, name, len, NULL, NULL);
|
||||
|
||||
|
@ -302,9 +301,9 @@ HRESULT compress_add_file(struct zip_archive *archive, const WCHAR *path,
|
|||
return archive->write_result;
|
||||
|
||||
/* Set directory entry */
|
||||
if (!(entry = heap_alloc_zero(sizeof(*entry) + local_header.name_length)))
|
||||
if (!(entry = calloc(1, sizeof(*entry) + local_header.name_length)))
|
||||
{
|
||||
heap_free(name);
|
||||
free(name);
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
|
@ -320,12 +319,12 @@ HRESULT compress_add_file(struct zip_archive *archive, const WCHAR *path,
|
|||
entry->name_length = local_header.name_length;
|
||||
entry->local_file_offset = local_header_pos;
|
||||
memcpy(entry + 1, name, entry->name_length);
|
||||
heap_free(name);
|
||||
free(name);
|
||||
|
||||
if (!opc_array_reserve((void **)&archive->files, &archive->file_size, archive->file_count + 1,
|
||||
sizeof(*archive->files)))
|
||||
{
|
||||
heap_free(entry);
|
||||
free(entry);
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
|
|
|
@ -85,7 +85,7 @@ static ULONG WINAPI opc_filestream_Release(IStream *iface)
|
|||
if (!refcount)
|
||||
{
|
||||
CloseHandle(stream->hfile);
|
||||
heap_free(stream);
|
||||
free(stream);
|
||||
}
|
||||
|
||||
return refcount;
|
||||
|
@ -263,14 +263,14 @@ static HRESULT opc_filestream_create(const WCHAR *filename, OPC_STREAM_IO_MODE i
|
|||
return E_INVALIDARG;
|
||||
}
|
||||
|
||||
if (!(stream = heap_alloc_zero(sizeof(*stream))))
|
||||
if (!(stream = calloc(1, sizeof(*stream))))
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
stream->hfile = CreateFileW(filename, access, 0, sa, creation, flags, NULL);
|
||||
if (stream->hfile == INVALID_HANDLE_VALUE)
|
||||
{
|
||||
HRESULT hr = HRESULT_FROM_WIN32(GetLastError());
|
||||
heap_free(stream);
|
||||
free(stream);
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
|
|
@ -17,7 +17,6 @@
|
|||
*/
|
||||
|
||||
#include "msopc.h"
|
||||
#include "wine/heap.h"
|
||||
|
||||
static inline BOOL opc_array_reserve(void **elements, size_t *capacity, size_t count, size_t size)
|
||||
{
|
||||
|
@ -37,7 +36,7 @@ static inline BOOL opc_array_reserve(void **elements, size_t *capacity, size_t c
|
|||
if (new_capacity < count)
|
||||
new_capacity = max_capacity;
|
||||
|
||||
if (!(new_elements = heap_realloc(*elements, new_capacity * size)))
|
||||
if (!(new_elements = realloc(*elements, new_capacity * size)))
|
||||
return FALSE;
|
||||
|
||||
*elements = new_elements;
|
||||
|
|
|
@ -170,8 +170,8 @@ static void opc_content_release(struct opc_content *content)
|
|||
|
||||
if (!refcount)
|
||||
{
|
||||
heap_free(content->data);
|
||||
heap_free(content);
|
||||
free(content->data);
|
||||
free(content);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -214,7 +214,7 @@ static ULONG WINAPI opc_part_enum_Release(IOpcPartEnumerator *iface)
|
|||
if (!refcount)
|
||||
{
|
||||
IOpcPartSet_Release(&part_enum->part_set->IOpcPartSet_iface);
|
||||
heap_free(part_enum);
|
||||
free(part_enum);
|
||||
}
|
||||
|
||||
return refcount;
|
||||
|
@ -321,7 +321,7 @@ static HRESULT opc_part_enum_create(struct opc_part_set *part_set, IOpcPartEnume
|
|||
{
|
||||
struct opc_part_enum *part_enum;
|
||||
|
||||
if (!(part_enum = heap_alloc_zero(sizeof(*part_enum))))
|
||||
if (!(part_enum = calloc(1, sizeof(*part_enum))))
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
part_enum->IOpcPartEnumerator_iface.lpVtbl = &opc_part_enum_vtbl;
|
||||
|
@ -375,7 +375,7 @@ static ULONG WINAPI opc_rel_enum_Release(IOpcRelationshipEnumerator *iface)
|
|||
if (!refcount)
|
||||
{
|
||||
IOpcRelationshipSet_Release(&rel_enum->rel_set->IOpcRelationshipSet_iface);
|
||||
heap_free(rel_enum);
|
||||
free(rel_enum);
|
||||
}
|
||||
|
||||
return refcount;
|
||||
|
@ -482,7 +482,7 @@ static HRESULT opc_rel_enum_create(struct opc_relationship_set *rel_set, IOpcRel
|
|||
{
|
||||
struct opc_rel_enum *rel_enum;
|
||||
|
||||
if (!(rel_enum = heap_alloc_zero(sizeof(*rel_enum))))
|
||||
if (!(rel_enum = calloc(1, sizeof(*rel_enum))))
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
rel_enum->IOpcRelationshipEnumerator_iface.lpVtbl = &opc_rel_enum_vtbl;
|
||||
|
@ -535,7 +535,7 @@ static ULONG WINAPI opc_content_stream_Release(IStream *iface)
|
|||
if (!refcount)
|
||||
{
|
||||
opc_content_release(stream->content);
|
||||
heap_free(stream);
|
||||
free(stream);
|
||||
}
|
||||
|
||||
return refcount;
|
||||
|
@ -578,7 +578,7 @@ static HRESULT WINAPI opc_content_stream_Write(IStream *iface, const void *data,
|
|||
|
||||
if (size > stream->content->size.QuadPart - stream->pos.QuadPart)
|
||||
{
|
||||
void *ptr = heap_realloc(stream->content->data, stream->pos.QuadPart + size);
|
||||
void *ptr = realloc(stream->content->data, stream->pos.QuadPart + size);
|
||||
if (!ptr)
|
||||
return E_OUTOFMEMORY;
|
||||
stream->content->data = ptr;
|
||||
|
@ -707,7 +707,7 @@ static HRESULT opc_content_stream_create(struct opc_content *content, IStream **
|
|||
{
|
||||
struct opc_content_stream *stream;
|
||||
|
||||
if (!(stream = heap_alloc_zero(sizeof(*stream))))
|
||||
if (!(stream = calloc(1, sizeof(*stream))))
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
stream->IStream_iface.lpVtbl = &opc_content_stream_vtbl;
|
||||
|
@ -780,7 +780,7 @@ static ULONG WINAPI opc_part_Release(IOpcPart *iface)
|
|||
IOpcPartUri_Release(part->name);
|
||||
CoTaskMemFree(part->content_type);
|
||||
opc_content_release(part->content);
|
||||
heap_free(part);
|
||||
free(part);
|
||||
}
|
||||
|
||||
return refcount;
|
||||
|
@ -866,7 +866,7 @@ static HRESULT opc_part_create(struct opc_part_set *set, IOpcPartUri *name, cons
|
|||
if (!opc_array_reserve((void **)&set->parts, &set->size, set->count + 1, sizeof(*set->parts)))
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
if (!(part = heap_alloc_zero(sizeof(*part))))
|
||||
if (!(part = calloc(1, sizeof(*part))))
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
part->IOpcPart_iface.lpVtbl = &opc_part_vtbl;
|
||||
|
@ -880,7 +880,7 @@ static HRESULT opc_part_create(struct opc_part_set *set, IOpcPartUri *name, cons
|
|||
return E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
part->content = heap_alloc_zero(sizeof(*part->content));
|
||||
part->content = calloc(1, sizeof(*part->content));
|
||||
if (!part->content)
|
||||
{
|
||||
IOpcPart_Release(&part->IOpcPart_iface);
|
||||
|
@ -951,8 +951,8 @@ static ULONG WINAPI opc_part_set_Release(IOpcPartSet *iface)
|
|||
|
||||
for (i = 0; i < part_set->count; ++i)
|
||||
IOpcPart_Release(&part_set->parts[i]->IOpcPart_iface);
|
||||
heap_free(part_set->parts);
|
||||
heap_free(part_set);
|
||||
free(part_set->parts);
|
||||
free(part_set);
|
||||
}
|
||||
|
||||
return refcount;
|
||||
|
@ -1088,7 +1088,7 @@ static ULONG WINAPI opc_relationship_Release(IOpcRelationship *iface)
|
|||
CoTaskMemFree(relationship->type);
|
||||
IOpcUri_Release(relationship->source_uri);
|
||||
IUri_Release(relationship->target);
|
||||
heap_free(relationship);
|
||||
free(relationship);
|
||||
}
|
||||
|
||||
return refcount;
|
||||
|
@ -1183,7 +1183,7 @@ static HRESULT opc_relationship_create(struct opc_relationship_set *set, const W
|
|||
if (!opc_array_reserve((void **)&set->relationships, &set->size, set->count + 1, sizeof(*set->relationships)))
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
if (!(relationship = heap_alloc_zero(sizeof(*relationship))))
|
||||
if (!(relationship = calloc(1, sizeof(*relationship))))
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
relationship->IOpcRelationship_iface.lpVtbl = &opc_relationship_vtbl;
|
||||
|
@ -1272,8 +1272,8 @@ static ULONG WINAPI opc_relationship_set_Release(IOpcRelationshipSet *iface)
|
|||
for (i = 0; i < relationship_set->count; ++i)
|
||||
IOpcRelationship_Release(&relationship_set->relationships[i]->IOpcRelationship_iface);
|
||||
IOpcUri_Release(relationship_set->source_uri);
|
||||
heap_free(relationship_set->relationships);
|
||||
heap_free(relationship_set);
|
||||
free(relationship_set->relationships);
|
||||
free(relationship_set);
|
||||
}
|
||||
|
||||
return refcount;
|
||||
|
@ -1398,7 +1398,7 @@ static HRESULT opc_relationship_set_create(IOpcUri *source_uri, IOpcRelationship
|
|||
{
|
||||
struct opc_relationship_set *relationship_set;
|
||||
|
||||
if (!(relationship_set = heap_alloc_zero(sizeof(*relationship_set))))
|
||||
if (!(relationship_set = calloc(1, sizeof(*relationship_set))))
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
relationship_set->IOpcRelationshipSet_iface.lpVtbl = &opc_relationship_set_vtbl;
|
||||
|
@ -1452,7 +1452,7 @@ static ULONG WINAPI opc_package_Release(IOpcPackage *iface)
|
|||
IOpcRelationshipSet_Release(package->relationship_set);
|
||||
if (package->source_uri)
|
||||
IOpcUri_Release(package->source_uri);
|
||||
heap_free(package);
|
||||
free(package);
|
||||
}
|
||||
|
||||
return refcount;
|
||||
|
@ -1466,7 +1466,7 @@ static HRESULT WINAPI opc_package_GetPartSet(IOpcPackage *iface, IOpcPartSet **p
|
|||
|
||||
if (!package->part_set)
|
||||
{
|
||||
struct opc_part_set *part_set = heap_alloc_zero(sizeof(*part_set));
|
||||
struct opc_part_set *part_set = calloc(1, sizeof(*part_set));
|
||||
if (!part_set)
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
|
@ -1515,7 +1515,7 @@ HRESULT opc_package_create(IOpcFactory *factory, IOpcPackage **out)
|
|||
struct opc_package *package;
|
||||
HRESULT hr;
|
||||
|
||||
if (!(package = heap_alloc_zero(sizeof(*package))))
|
||||
if (!(package = calloc(1, sizeof(*package))))
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
package->IOpcPackage_iface.lpVtbl = &opc_package_vtbl;
|
||||
|
@ -1523,7 +1523,7 @@ HRESULT opc_package_create(IOpcFactory *factory, IOpcPackage **out)
|
|||
|
||||
if (FAILED(hr = IOpcFactory_CreatePackageRootUri(factory, &package->source_uri)))
|
||||
{
|
||||
heap_free(package);
|
||||
free(package);
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
@ -1566,7 +1566,7 @@ static HRESULT opc_package_add_override_content_type(struct content_types *types
|
|||
{
|
||||
struct content_type *type;
|
||||
|
||||
if (!(type = heap_alloc(sizeof(*type))))
|
||||
if (!(type = malloc(sizeof(*type))))
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
type->element = CONTENT_TYPE_OVERRIDE;
|
||||
|
@ -1583,7 +1583,7 @@ static HRESULT opc_package_add_default_content_type(struct content_types *types,
|
|||
{
|
||||
struct content_type *type;
|
||||
|
||||
if (!(type = heap_alloc(sizeof(*type))))
|
||||
if (!(type = malloc(sizeof(*type))))
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
type->element = CONTENT_TYPE_DEFAULT;
|
||||
|
@ -1593,7 +1593,7 @@ static HRESULT opc_package_add_default_content_type(struct content_types *types,
|
|||
{
|
||||
CoTaskMemFree(type->u.def.ext);
|
||||
CoTaskMemFree(type->u.def.type);
|
||||
heap_free(type);
|
||||
free(type);
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
|
@ -1810,7 +1810,7 @@ static HRESULT opc_package_write_contenttypes(IOpcPackage *package, struct zip_a
|
|||
hr = IXmlWriter_WriteEndElement(writer);
|
||||
|
||||
list_remove(&content_type->entry);
|
||||
heap_free(content_type);
|
||||
free(content_type);
|
||||
}
|
||||
|
||||
if (SUCCEEDED(hr))
|
||||
|
|
|
@ -79,7 +79,7 @@ static ULONG WINAPI opc_uri_Release(IOpcPartUri *iface)
|
|||
if (uri->source_uri)
|
||||
IOpcPartUri_Release(&uri->source_uri->IOpcPartUri_iface);
|
||||
IUri_Release(uri->uri);
|
||||
heap_free(uri);
|
||||
free(uri);
|
||||
}
|
||||
|
||||
return refcount;
|
||||
|
@ -485,7 +485,7 @@ static IUri *opc_part_uri_get_rels_uri(IUri *uri)
|
|||
}
|
||||
}
|
||||
|
||||
ret = heap_alloc((len + ARRAY_SIZE(relsextW) + ARRAY_SIZE(relsdirW)) * sizeof(WCHAR));
|
||||
ret = malloc((len + ARRAY_SIZE(relsextW) + ARRAY_SIZE(relsdirW)) * sizeof(WCHAR));
|
||||
if (!ret)
|
||||
{
|
||||
SysFreeString(path);
|
||||
|
@ -505,7 +505,7 @@ static IUri *opc_part_uri_get_rels_uri(IUri *uri)
|
|||
|
||||
if (FAILED(hr = CreateUri(ret, Uri_CREATE_ALLOW_RELATIVE, 0, &rels_uri)))
|
||||
WARN("Failed to create rels uri, hr %#lx.\n", hr);
|
||||
heap_free(ret);
|
||||
free(ret);
|
||||
SysFreeString(path);
|
||||
|
||||
return rels_uri;
|
||||
|
@ -539,13 +539,13 @@ static HRESULT opc_source_uri_create(struct opc_uri *uri, IOpcUri **out)
|
|||
if (!uri->source_uri)
|
||||
return OPC_E_RELATIONSHIP_URI_REQUIRED;
|
||||
|
||||
if (!(obj = heap_alloc_zero(sizeof(*obj))))
|
||||
if (!(obj = calloc(1, sizeof(*obj))))
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
if (FAILED(hr = opc_part_uri_init(obj, NULL, uri->source_uri->is_part_uri, uri->source_uri->uri)))
|
||||
{
|
||||
WARN("Failed to init part uri, hr %#lx.\n", hr);
|
||||
heap_free(obj);
|
||||
free(obj);
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
@ -561,13 +561,13 @@ HRESULT opc_part_uri_create(IUri *uri, struct opc_uri *source_uri, IOpcPartUri *
|
|||
struct opc_uri *obj;
|
||||
HRESULT hr;
|
||||
|
||||
if (!(obj = heap_alloc_zero(sizeof(*obj))))
|
||||
if (!(obj = calloc(1, sizeof(*obj))))
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
if (FAILED(hr = opc_part_uri_init(obj, source_uri, TRUE, uri)))
|
||||
{
|
||||
WARN("Failed to init part uri, hr %#lx.\n", hr);
|
||||
heap_free(obj);
|
||||
free(obj);
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
@ -584,13 +584,13 @@ HRESULT opc_root_uri_create(IOpcUri **out)
|
|||
|
||||
*out = NULL;
|
||||
|
||||
if (!(obj = heap_alloc_zero(sizeof(*obj))))
|
||||
if (!(obj = calloc(1, sizeof(*obj))))
|
||||
return E_OUTOFMEMORY;
|
||||
|
||||
if (FAILED(hr = CreateUri(L"/", Uri_CREATE_ALLOW_RELATIVE, 0, &uri)))
|
||||
{
|
||||
WARN("Failed to create rels uri, hr %#lx.\n", hr);
|
||||
heap_free(obj);
|
||||
free(obj);
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
@ -599,7 +599,7 @@ HRESULT opc_root_uri_create(IOpcUri **out)
|
|||
if (FAILED(hr))
|
||||
{
|
||||
WARN("Failed to init uri, hr %#lx.\n", hr);
|
||||
heap_free(uri);
|
||||
free(uri);
|
||||
return hr;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue