Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/opcservices/compress.c | 19 ++++++------ dlls/opcservices/factory.c | 6 ++-- dlls/opcservices/opc_private.h | 3 +- dlls/opcservices/package.c | 54 +++++++++++++++++----------------- dlls/opcservices/uri.c | 20 ++++++------- 5 files changed, 50 insertions(+), 52 deletions(-)
diff --git a/dlls/opcservices/compress.c b/dlls/opcservices/compress.c index cb4fabcc477..37a90716a74 100644 --- a/dlls/opcservices/compress.c +++ b/dlls/opcservices/compress.c @@ -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; }
diff --git a/dlls/opcservices/factory.c b/dlls/opcservices/factory.c index 4c465f653f8..fcebb977c1d 100644 --- a/dlls/opcservices/factory.c +++ b/dlls/opcservices/factory.c @@ -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; }
diff --git a/dlls/opcservices/opc_private.h b/dlls/opcservices/opc_private.h index c7b1d0cab3d..b1163fe1215 100644 --- a/dlls/opcservices/opc_private.h +++ b/dlls/opcservices/opc_private.h @@ -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; diff --git a/dlls/opcservices/package.c b/dlls/opcservices/package.c index 64d34d4b853..e080b386c61 100644 --- a/dlls/opcservices/package.c +++ b/dlls/opcservices/package.c @@ -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)) diff --git a/dlls/opcservices/uri.c b/dlls/opcservices/uri.c index 0a7e2ef3660..556aaae354d 100644 --- a/dlls/opcservices/uri.c +++ b/dlls/opcservices/uri.c @@ -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; }
Signed-off-by: Nikolay Sivov nsivov@codeweavers.com --- dlls/opcservices/tests/opcservices.c | 187 ++++++++++----------------- 1 file changed, 69 insertions(+), 118 deletions(-)
diff --git a/dlls/opcservices/tests/opcservices.c b/dlls/opcservices/tests/opcservices.c index 871619430d4..3fa9c732e42 100644 --- a/dlls/opcservices/tests/opcservices.c +++ b/dlls/opcservices/tests/opcservices.c @@ -25,7 +25,6 @@ #include "msopc.h" #include "urlmon.h"
-#include "wine/heap.h" #include "wine/test.h"
static IOpcFactory *create_factory(void) @@ -494,61 +493,47 @@ static void test_relationship(void) IOpcFactory_Release(factory); }
-static WCHAR *strdupAtoW(const char *str) -{ - WCHAR *ret = NULL; - DWORD len; - - if (!str) return ret; - len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0); - ret = heap_alloc(len * sizeof(WCHAR)); - if (ret) - MultiByteToWideChar(CP_ACP, 0, str, -1, ret, len); - return ret; -} - static void test_rel_part_uri(void) { static const struct { - const char *uri; - const char *rel_uri; + const WCHAR *uri; + const WCHAR *rel_uri; HRESULT hr; } rel_part_uri_tests[] = { - { "/uri", "/_rels/uri.rels" }, - { "/path/uri", "/path/_rels/uri.rels" }, - { "path/uri", "/path/_rels/uri.rels" }, - { "../path/uri", "/path/_rels/uri.rels" }, - { "../../path/uri", "/path/_rels/uri.rels" }, - { "/uri.ext", "/_rels/uri.ext.rels" }, - { "/", "/_rels/.rels" }, - { "uri", "/_rels/uri.rels" }, - { "/path/../uri", "/_rels/uri.rels" }, - { "/path/path/../../uri", "/_rels/uri.rels" }, - { "/_rels/uri.ext.rels", "", OPC_E_NONCONFORMING_URI }, + { L"/uri", L"/_rels/uri.rels" }, + { L"/path/uri", L"/path/_rels/uri.rels" }, + { L"path/uri", L"/path/_rels/uri.rels" }, + { L"../path/uri", L"/path/_rels/uri.rels" }, + { L"../../path/uri", L"/path/_rels/uri.rels" }, + { L"/uri.ext", L"/_rels/uri.ext.rels" }, + { L"/", L"/_rels/.rels" }, + { L"uri", L"/_rels/uri.rels" }, + { L"/path/../uri", L"/_rels/uri.rels" }, + { L"/path/path/../../uri", L"/_rels/uri.rels" }, + { L"/_rels/uri.ext.rels", L"", OPC_E_NONCONFORMING_URI }, }; static const struct { - const char *uri; + const WCHAR *uri; BOOL ret; } is_rel_part_tests[] = { - { "/uri", FALSE }, - { "uri", FALSE }, - { "/_rels/uri", FALSE }, - { "/_rels/uri/uri", FALSE }, - { "/_rels/uri/uri.rels", FALSE }, - { "/uri/uri.rels", FALSE }, - { "/uri/_rels/uri.rels", TRUE }, - { "/_rels/.rels", TRUE }, + { L"/uri", FALSE }, + { L"uri", FALSE }, + { L"/_rels/uri", FALSE }, + { L"/_rels/uri/uri", FALSE }, + { L"/_rels/uri/uri.rels", FALSE }, + { L"/uri/uri.rels", FALSE }, + { L"/uri/_rels/uri.rels", TRUE }, + { L"/_rels/.rels", TRUE }, }; static const WCHAR testuriW[] = {'/','u','r','i',0}; IOpcPartUri *part_uri; IOpcFactory *factory; IOpcUri *source_uri; unsigned int i; - WCHAR *uriW; HRESULT hr;
factory = create_factory(); @@ -577,18 +562,14 @@ static void test_rel_part_uri(void) BOOL is_root = FALSE; IOpcPartUri *rel_uri; IOpcUri *part_uri; - WCHAR *rel_uriW;
- uriW = strdupAtoW(rel_part_uri_tests[i].uri); - rel_uriW = strdupAtoW(rel_part_uri_tests[i].rel_uri); - - if (!strcmp(rel_part_uri_tests[i].uri, "/")) + if (!wcscmp(rel_part_uri_tests[i].uri, L"/")) { hr = IOpcFactory_CreatePackageRootUri(factory, &part_uri); is_root = TRUE; } else - hr = IOpcFactory_CreatePartUri(factory, uriW, (IOpcPartUri **)&part_uri); + hr = IOpcFactory_CreatePartUri(factory, rel_part_uri_tests[i].uri, (IOpcPartUri **)&part_uri); ok(SUCCEEDED(hr), "Failed to create part uri, hr %#lx.\n", hr);
rel_uri = (void *)0xdeadbeef; @@ -621,7 +602,7 @@ static void test_rel_part_uri(void) ok(ret, "Expected equal uris.\n");
hr = IOpcUri_QueryInterface(source_uri, &IID_IOpcPartUri, (void **)&unk); - ok(hr == (is_root ? E_NOINTERFACE : S_OK), "Unexpected hr %#lx, %s.\n", hr, rel_part_uri_tests[i].uri); + ok(hr == (is_root ? E_NOINTERFACE : S_OK), "Unexpected hr %#lx, %s.\n", hr, wine_dbgstr_w(rel_part_uri_tests[i].uri)); if (unk) IUnknown_Release(unk);
@@ -636,8 +617,8 @@ static void test_rel_part_uri(void) hr = IOpcPartUri_GetRawUri(rel_uri, &str); ok(SUCCEEDED(hr), "Failed to get rel uri, hr %#lx.\n", hr); todo_wine_if(i == 3 || i == 4 || i == 8 || i == 9) - ok(!lstrcmpW(str, rel_uriW), "%u: unexpected rel uri %s, expected %s.\n", i, wine_dbgstr_w(str), - wine_dbgstr_w(rel_uriW)); + ok(!lstrcmpW(str, rel_part_uri_tests[i].rel_uri), "%u: unexpected rel uri %s, expected %s.\n", + i, wine_dbgstr_w(str), wine_dbgstr_w(rel_part_uri_tests[i].rel_uri)); SysFreeString(str);
IOpcPartUri_Release(rel_uri); @@ -648,9 +629,6 @@ static void test_rel_part_uri(void) ok(rel_uri == NULL, "%u: unexpected out pointer.\n", i); }
- heap_free(uriW); - heap_free(rel_uriW); - IOpcUri_Release(part_uri); }
@@ -659,9 +637,7 @@ static void test_rel_part_uri(void) IOpcPartUri *part_uri; BOOL ret;
- uriW = strdupAtoW(is_rel_part_tests[i].uri); - - hr = IOpcFactory_CreatePartUri(factory, uriW, &part_uri); + hr = IOpcFactory_CreatePartUri(factory, is_rel_part_tests[i].uri, &part_uri); ok(SUCCEEDED(hr), "Failed to create part uri, hr %#lx.\n", hr);
ret = 123; @@ -669,8 +645,6 @@ static void test_rel_part_uri(void) ok(SUCCEEDED(hr), "Unexpected hr %#lx.\n", hr); ok(ret == is_rel_part_tests[i].ret, "%u: unexpected result %d.\n", i, ret);
- heap_free(uriW); - IOpcPartUri_Release(part_uri); }
@@ -1006,22 +980,22 @@ static void test_relative_uri(void) { static const struct { - const char *part; - const char *combined; - const char *relative; - const char *relative_broken; + const WCHAR *part; + const WCHAR *combined; + const WCHAR *relative; + const WCHAR *relative_broken; } relative_uri_tests[] = { - { "/", "/path/path2", "path/path2", "/path/path2" }, - { "/", "/path", "path", "/path" }, - { "/path/path2", "/path/path2/path3", "path2/path3" }, - { "/path/path2", "/path3", "../path3" }, - { "/path", "/path", "" }, - { "/path", "../path", "" }, - { "/path2", "/path", "path" }, - { "../path", "/path", "" }, - { "../../path", "/path", "" }, + { L"/", L"/path/path2", L"path/path2", L"/path/path2" }, + { L"/", L"/path", L"path", L"/path" }, + { L"/path/path2", L"/path/path2/path3", L"path2/path3" }, + { L"/path/path2", L"/path3", L"../path3" }, + { L"/path", L"/path", L"" }, + { L"/path", L"../path", L"" }, + { L"/path2", L"/path", L"path" }, + { L"../path", L"/path", L"" }, + { L"../../path", L"/path", L"" }, }; IOpcFactory *factory; unsigned int i; @@ -1030,7 +1004,7 @@ static void test_relative_uri(void)
for (i = 0; i < ARRAY_SIZE(relative_uri_tests); ++i) { - WCHAR *uriW, *combinedW, *relativeW, *relative_broken_W; + const WCHAR *relative_broken; IOpcPartUri *combined_uri; IUri *relative_uri; IOpcUri *part_uri; @@ -1038,18 +1012,15 @@ static void test_relative_uri(void) HRESULT hr; BSTR str;
- uriW = strdupAtoW(relative_uri_tests[i].part); - combinedW = strdupAtoW(relative_uri_tests[i].combined); - relativeW = strdupAtoW(relative_uri_tests[i].relative); - relative_broken_W = strdupAtoW(relative_uri_tests[i].relative_broken); + relative_broken = relative_uri_tests[i].relative_broken;
- if (!strcmp(relative_uri_tests[i].part, "/")) + if (!wcscmp(relative_uri_tests[i].part, L"/")) hr = IOpcFactory_CreatePackageRootUri(factory, &part_uri); else - hr = IOpcFactory_CreatePartUri(factory, uriW, (IOpcPartUri **)&part_uri); + hr = IOpcFactory_CreatePartUri(factory, relative_uri_tests[i].part, (IOpcPartUri **)&part_uri); ok(SUCCEEDED(hr), "%u: failed to create part uri, hr %#lx.\n", i, hr);
- hr = IOpcFactory_CreatePartUri(factory, combinedW, &combined_uri); + hr = IOpcFactory_CreatePartUri(factory, relative_uri_tests[i].combined, &combined_uri); ok(SUCCEEDED(hr), "%u: failed to create part uri, hr %#lx.\n", i, hr);
hr = IOpcUri_GetRelativeUri(part_uri, combined_uri, &relative_uri); @@ -1063,7 +1034,7 @@ static void test_relative_uri(void)
hr = IUri_GetRawUri(relative_uri, &str); ok(SUCCEEDED(hr), "%u: failed to get raw uri, hr %#lx.\n", i, hr); - ok(!lstrcmpW(str, relativeW) || broken(relative_broken_W && !lstrcmpW(str, relative_broken_W)), + ok(!lstrcmpW(str, relative_uri_tests[i].relative) || broken(relative_broken && !lstrcmpW(str, relative_broken)), "%u: unexpected relative uri %s.\n", i, wine_dbgstr_w(str)); SysFreeString(str);
@@ -1071,11 +1042,6 @@ static void test_relative_uri(void) } IOpcUri_Release(part_uri); IOpcPartUri_Release(combined_uri); - - heap_free(uriW); - heap_free(combinedW); - heap_free(relativeW); - heap_free(relative_broken_W); }
IOpcFactory_Release(factory); @@ -1085,16 +1051,16 @@ static void test_combine_uri(void) { static const struct { - const char *uri; - const char *relative; - const char *combined; + const WCHAR *uri; + const WCHAR *relative; + const WCHAR *combined; } combine_tests[] = { - { "/", "path", "/path" }, - { "/path1", "path2", "/path2" }, - { "/path1", "../path2", "/path2" }, - { "/path1/../path2", "path3", "/path3" }, + { L"/", L"path", L"/path" }, + { L"/path1", L"path2", L"/path2" }, + { L"/path1", L"../path2", L"/path2" }, + { L"/path1/../path2", L"path3", L"/path3" }, }; IOpcFactory *factory; unsigned int i; @@ -1103,24 +1069,19 @@ static void test_combine_uri(void)
for (i = 0; i < ARRAY_SIZE(combine_tests); ++i) { - WCHAR *uriW, *relativeW, *combinedW; IOpcPartUri *combined_uri; IUri *relative_uri; IOpcUri *uri; HRESULT hr; BSTR str;
- uriW = strdupAtoW(combine_tests[i].uri); - relativeW = strdupAtoW(combine_tests[i].relative); - combinedW = strdupAtoW(combine_tests[i].combined); - - if (!strcmp(combine_tests[i].uri, "/")) + if (!wcscmp(combine_tests[i].uri, L"/")) hr = IOpcFactory_CreatePackageRootUri(factory, &uri); else - hr = IOpcFactory_CreatePartUri(factory, uriW, (IOpcPartUri **)&uri); + hr = IOpcFactory_CreatePartUri(factory, combine_tests[i].uri, (IOpcPartUri **)&uri); ok(SUCCEEDED(hr), "%u: failed to create uri, hr %#lx.\n", i, hr);
- hr = CreateUri(relativeW, Uri_CREATE_ALLOW_RELATIVE, 0, &relative_uri); + hr = CreateUri(combine_tests[i].relative, Uri_CREATE_ALLOW_RELATIVE, 0, &relative_uri); ok(SUCCEEDED(hr), "%u: failed to create relative uri, hr %#lx.\n", i, hr);
combined_uri = (void *)0xdeadbeef; @@ -1137,15 +1098,11 @@ static void test_combine_uri(void) hr = IOpcPartUri_GetRawUri(combined_uri, &str); ok(SUCCEEDED(hr), "%u: failed to get raw uri, hr %#lx.\n", i, hr); todo_wine_if(i == 2 || i == 3) - ok(!lstrcmpW(str, combinedW), "%u: unexpected uri %s.\n", i, wine_dbgstr_w(str)); + ok(!lstrcmpW(str, combine_tests[i].combined), "%u: unexpected uri %s.\n", i, wine_dbgstr_w(str)); SysFreeString(str);
IOpcPartUri_Release(combined_uri);
- heap_free(uriW); - heap_free(relativeW); - heap_free(combinedW); - IOpcUri_Release(uri); IUri_Release(relative_uri); } @@ -1157,16 +1114,16 @@ static void test_create_part_uri(void) { static const struct { - const char *input; - const char *raw_uri; + const WCHAR *input; + const WCHAR *raw_uri; } create_part_uri_tests[] = { - { "path", "/path" }, - { "../path", "/path" }, - { "../../path", "/path" }, - { "/path", "/path" }, - { "/path1/path2/path3/../path4", "/path1/path2/path4" }, + { L"path", L"/path" }, + { L"../path", L"/path" }, + { L"../../path", L"/path" }, + { L"/path", L"/path" }, + { L"/path1/path2/path3/../path4", L"/path1/path2/path4" }, }; IOpcFactory *factory; unsigned int i; @@ -1176,25 +1133,22 @@ static void test_create_part_uri(void)
for (i = 0; i < ARRAY_SIZE(create_part_uri_tests); ++i) { + const WCHAR *raw_uri = create_part_uri_tests[i].raw_uri; IOpcPartUri *part_uri; - WCHAR *inputW, *rawW; IUri *uri; BSTR str; BOOL ret;
- inputW = strdupAtoW(create_part_uri_tests[i].input); - rawW = strdupAtoW(create_part_uri_tests[i].raw_uri); - - hr = IOpcFactory_CreatePartUri(factory, inputW, &part_uri); + hr = IOpcFactory_CreatePartUri(factory, create_part_uri_tests[i].input, &part_uri); ok(SUCCEEDED(hr), "%u: failed to create part uri, hr %#lx.\n", i, hr);
hr = IOpcPartUri_GetRawUri(part_uri, &str); ok(SUCCEEDED(hr), "Failed to get raw uri, hr %#lx.\n", hr); todo_wine_if(i == 1 || i == 2 || i == 4) - ok(!lstrcmpW(str, rawW), "%u: unexpected raw uri %s.\n", i, wine_dbgstr_w(str)); + ok(!lstrcmpW(str, raw_uri), "%u: unexpected raw uri %s.\n", i, wine_dbgstr_w(str)); SysFreeString(str);
- hr = CreateUri(rawW, Uri_CREATE_ALLOW_RELATIVE, 0, &uri); + hr = CreateUri(raw_uri, Uri_CREATE_ALLOW_RELATIVE, 0, &uri); ok(SUCCEEDED(hr), "Failed to create uri, hr %#lx.\n", hr);
ret = FALSE; @@ -1205,9 +1159,6 @@ static void test_create_part_uri(void)
IOpcPartUri_Release(part_uri); IUri_Release(uri); - - heap_free(inputW); - heap_free(rawW); }
IOpcFactory_Release(factory);