Wine-Devel
By thread
wine-devel@list.winehq.org
By month
Messages by month
- ----- 2026 -----
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2004 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2003 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2002 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2001 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
January 2022
- 86 participants
- 2418 messages
Re: Arbitrary DOS device name
by Stefan Dösinger
Am Dienstag, 25. Jänner 2022, 20:39:55 EAT schrieb Daniel Kucera:
> I was researching this option but I haven't even found a way to load a
> driver.
> Besides, if the original driver doesn't work out-of-the-box (which I
> presume it won't), I am not really able to write/compile wine/Windows
> driver.
I'm hoping that maybe Remi can chime in on this question.
> The software is calling DeviceIoControl() which results in ioctl calls
> in wine server and ends here:
> https://github.com/wine-mirror/wine/blob/master/server/fd.c#L2408
>
> To forward the call to device, I would need to modify this function,
> something in this sense:
One other option to investigate: Write a small Windows/Wine device driver that
registers the character device and forwards it to the Unix device node. If you
get that working you shouldn't need to modify wineserver in a very device
specific way. In theory the API is also stable (Wine just implements the
Windows driver API), so the Windows device driver can live out of tree.
See dlls/*.sys for some examples of existing device drivers; In particular
mountmgr.sys, wineusb.sys are examples of drivers that talk to both the
Windows and Unix side.
Jan. 26, 2022
Re: [PATCH v3 07/13] loader: Don't clobber existing memory mappings when reserving addresses.
by Alexandre Julliard
Jinoh Kang <jinoh.kang.kr(a)gmail.com> writes:
> On 1/26/22 00:48, Alexandre Julliard wrote:
>> Jinoh Kang <jinoh.kang.kr(a)gmail.com> writes:
>>
>>> Today, the preloader makes no attempt to avoid unmapping existing
>>> memory mappings except the initial stack. This results in irrevocably
>>> unmapping some useful preallocated memory areas, such as vDSO.
>>>
>>> Fix this by reading /proc/self/maps for existing VMAs, and splitting
>>> mmap() calls to avoid erasing existing memory mappings.
>>
>> That defeats the purpose of using the preloader.
>
> The intention was to *incrementally* scrape memory areas for the reserved ranges,
> relocating any critical areas (vDSO, stack, ...) along the way.
>
> It's also why this change is useless without the subsequent patches,
> which calls map_reserve_preload_ranges again to actually fill out all
> the gaps previously occupied by vDSO/stack.
I don't see the point. If you want to remap vDSO you can do that first,
and then reserve the full range. You don't need all that complexity.
And as general advice for your patches, please try to avoid changing
things that don't need changing, or adding infrastructure that isn't
needed. It will make it easier to see the actual changes.
--
Alexandre Julliard
julliard(a)winehq.org
Jan. 26, 2022
[PATCH] d3d10/tests: Add a test with fx_4_1 binary.
by Nikolay Sivov
Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com>
---
The only purpose is to show that fx_4_1 binary loading works.
dlls/d3d10/tests/effect.c | 38 ++++++++++++++++++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/dlls/d3d10/tests/effect.c b/dlls/d3d10/tests/effect.c
index b4ea4402a05..9cdbc7fffca 100644
--- a/dlls/d3d10/tests/effect.c
+++ b/dlls/d3d10/tests/effect.c
@@ -8209,6 +8209,43 @@ static void test_effect_value_expression(void)
ok(!refcount, "Device has %u references left.\n", refcount);
}
+#if 0
+technique10 tech0
+{
+ pass pass0 {}
+};
+#endif
+static DWORD fx_test_fx_4_1[] =
+{
+ 0x43425844, 0x228fcf4d, 0x9396b2f5, 0xd817b31f, 0xab6dd460, 0x00000001, 0x000000a0, 0x00000001,
+ 0x00000024, 0x30315846, 0x00000074, 0xfeff1011, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000001, 0x00000010, 0x00000000, 0x00000000, 0x00000000, 0x00000000,
+ 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x00000000, 0x68636574,
+ 0x61700030, 0x00307373, 0x00000004, 0x00000001, 0x00000000, 0x0000000a, 0x00000000, 0x00000000,
+};
+
+static void test_effect_fx_4_1(void)
+{
+ ID3D10Effect *effect;
+ ID3D10Device *device;
+ ULONG refcount;
+ HRESULT hr;
+
+ if (!(device = create_device()))
+ {
+ skip("Failed to create device, skipping tests.\n");
+ return;
+ }
+
+ hr = create_effect(fx_test_fx_4_1, 0, device, NULL, &effect);
+ ok(SUCCEEDED(hr), "Failed to create an effect, hr %#x.\n", hr);
+
+ effect->lpVtbl->Release(effect);
+
+ refcount = ID3D10Device_Release(device);
+ ok(!refcount, "Device has %u references left.\n", refcount);
+}
+
START_TEST(effect)
{
test_effect_constant_buffer_type();
@@ -8235,4 +8272,5 @@ START_TEST(effect)
test_effect_dynamic_numeric_field();
test_effect_index_expression();
test_effect_value_expression();
+ test_effect_fx_4_1();
}
--
2.34.1
Jan. 26, 2022
[PATCH 2/2] ddraw/tests: Don't insist on a different refresh rate if no refresh rate was requested.
by Stefan Dösinger
d4fdb1f62cf5 broke test_cursor_clipping by accident. It added a requirement
that width, height and refresh rate are different from the old mode, but
test_cursor_clipping does not use DDEDM_REFRESHRATES, so all refresh rates
are 0.
Signed-off-by: Stefan Dösinger <stefan(a)codeweavers.com>
---
Possibly the logical AND should be logical OR, i.e. one of the properties
differs and not all of them?
---
dlls/ddraw/tests/ddraw2.c | 2 +-
dlls/ddraw/tests/ddraw4.c | 2 +-
dlls/ddraw/tests/ddraw7.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c
index 8a6c4b41ac1..625776c652c 100644
--- a/dlls/ddraw/tests/ddraw2.c
+++ b/dlls/ddraw/tests/ddraw2.c
@@ -15116,7 +15116,7 @@ static HRESULT CALLBACK find_different_mode_callback(DDSURFACEDESC *surface_desc
/* See comment in ddraw7 about the frequency. */
if (surface_desc->dwWidth != param->old_width && surface_desc->dwHeight != param->old_height &&
- !compare_uint(surface_desc->dwRefreshRate, param->old_frequency, 1))
+ (!compare_uint(surface_desc->dwRefreshRate, param->old_frequency, 1) || !param->old_frequency))
{
param->new_width = surface_desc->dwWidth;
param->new_height = surface_desc->dwHeight;
diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c
index c229ab66341..9b8acb674e3 100644
--- a/dlls/ddraw/tests/ddraw4.c
+++ b/dlls/ddraw/tests/ddraw4.c
@@ -18153,7 +18153,7 @@ static HRESULT CALLBACK find_different_mode_callback(DDSURFACEDESC2 *surface_des
/* See comment in ddraw7 about the frequency. */
if (surface_desc->dwWidth != param->old_width && surface_desc->dwHeight != param->old_height &&
- !compare_uint(surface_desc->dwRefreshRate, param->old_frequency, 1))
+ (!compare_uint(surface_desc->dwRefreshRate, param->old_frequency, 1) || !param->old_frequency))
{
param->new_width = surface_desc->dwWidth;
param->new_height = surface_desc->dwHeight;
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c
index 18ebf849391..84789e8f177 100644
--- a/dlls/ddraw/tests/ddraw7.c
+++ b/dlls/ddraw/tests/ddraw7.c
@@ -18427,7 +18427,7 @@ static HRESULT CALLBACK find_different_mode_callback(DDSURFACEDESC2 *surface_des
* set 60hz in the advanced display properties manually. Usually the restriction to one refresh
* rate applies to laptop panels. */
if (surface_desc->dwWidth != param->old_width && surface_desc->dwHeight != param->old_height &&
- !compare_uint(surface_desc->dwRefreshRate, param->old_frequency, 1))
+ (!compare_uint(surface_desc->dwRefreshRate, param->old_frequency, 1) || !param->old_frequency))
{
param->new_width = surface_desc->dwWidth;
param->new_height = surface_desc->dwHeight;
--
2.34.1
Jan. 26, 2022
[PATCH 1/2] ddraw/tests: Treat refresh rates with 1 hz difference as equal.
by Stefan Dösinger
Signed-off-by: Stefan Dösinger <stefan(a)codeweavers.com>
---
This fixes test failures on Win7, Geforce 9600.
The MS doc I am referring to is https://support.microsoft.com/en-us/topic/screen-refresh-rate-in-windows-do….
---
dlls/ddraw/tests/ddraw2.c | 3 ++-
dlls/ddraw/tests/ddraw4.c | 3 ++-
dlls/ddraw/tests/ddraw7.c | 11 ++++++++++-
3 files changed, 14 insertions(+), 3 deletions(-)
diff --git a/dlls/ddraw/tests/ddraw2.c b/dlls/ddraw/tests/ddraw2.c
index 00c8f820edb..8a6c4b41ac1 100644
--- a/dlls/ddraw/tests/ddraw2.c
+++ b/dlls/ddraw/tests/ddraw2.c
@@ -15114,8 +15114,9 @@ static HRESULT CALLBACK find_different_mode_callback(DDSURFACEDESC *surface_desc
if (U1(U4(*surface_desc).ddpfPixelFormat).dwRGBBitCount != registry_mode.dmBitsPerPel)
return DDENUMRET_OK;
+ /* See comment in ddraw7 about the frequency. */
if (surface_desc->dwWidth != param->old_width && surface_desc->dwHeight != param->old_height &&
- surface_desc->dwRefreshRate != param->old_frequency)
+ !compare_uint(surface_desc->dwRefreshRate, param->old_frequency, 1))
{
param->new_width = surface_desc->dwWidth;
param->new_height = surface_desc->dwHeight;
diff --git a/dlls/ddraw/tests/ddraw4.c b/dlls/ddraw/tests/ddraw4.c
index a8b68b8a20b..c229ab66341 100644
--- a/dlls/ddraw/tests/ddraw4.c
+++ b/dlls/ddraw/tests/ddraw4.c
@@ -18151,8 +18151,9 @@ static HRESULT CALLBACK find_different_mode_callback(DDSURFACEDESC2 *surface_des
if (U1(U4(*surface_desc).ddpfPixelFormat).dwRGBBitCount != registry_mode.dmBitsPerPel)
return DDENUMRET_OK;
+ /* See comment in ddraw7 about the frequency. */
if (surface_desc->dwWidth != param->old_width && surface_desc->dwHeight != param->old_height &&
- surface_desc->dwRefreshRate != param->old_frequency)
+ !compare_uint(surface_desc->dwRefreshRate, param->old_frequency, 1))
{
param->new_width = surface_desc->dwWidth;
param->new_height = surface_desc->dwHeight;
diff --git a/dlls/ddraw/tests/ddraw7.c b/dlls/ddraw/tests/ddraw7.c
index f4388296702..18ebf849391 100644
--- a/dlls/ddraw/tests/ddraw7.c
+++ b/dlls/ddraw/tests/ddraw7.c
@@ -18417,8 +18417,17 @@ static HRESULT CALLBACK find_different_mode_callback(DDSURFACEDESC2 *surface_des
if (U1(U4(*surface_desc).ddpfPixelFormat).dwRGBBitCount != registry_mode.dmBitsPerPel)
return DDENUMRET_OK;
+ /* Windows will advertise 59hz (for 59.94) and 60hz (for proper 60hz) on monitors that support
+ * only one of the two (usually 59.94). If an application requests 60hz windows will apply 59.94.
+ * Thus if we think we found a different refresh rate, we get 59hz instead of the 60hz we
+ * requested.
+ *
+ * The same is true of other 1% slowed-down TV compatible refresh rates according to a Microsoft
+ * support document: 23.976 vs 24, 30, 48, 72 and 120 hz. It can be reproduced by attempting to
+ * set 60hz in the advanced display properties manually. Usually the restriction to one refresh
+ * rate applies to laptop panels. */
if (surface_desc->dwWidth != param->old_width && surface_desc->dwHeight != param->old_height &&
- surface_desc->dwRefreshRate != param->old_frequency)
+ !compare_uint(surface_desc->dwRefreshRate, param->old_frequency, 1))
{
param->new_width = surface_desc->dwWidth;
param->new_height = surface_desc->dwHeight;
--
2.34.1
Jan. 26, 2022
Re: [PATCH] d3dcompiler: Implement D3DWriteBlobToFile().
by Marvin
Hi,
While running your changed tests, I think I found new failures.
Being a bot and all I'm not very good at pattern recognition, so I might be
wrong, but could you please double-check?
Full results can be found at:
https://testbot.winehq.org/JobDetails.pl?Key=106020
Your paranoid android.
=== build (build log) ===
WineRunBuild.pl:error: An error occurred while waiting for the build to complete: network read timed out (wait2:ListSize:0/4)
WineRunBuild.pl:error: BotError: The test VM has crashed, rebooted or lost connectivity (or the TestAgent server died)
Jan. 26, 2022
[PATCH 2/2] scrrun/dictionary: Remove typedef from object data type.
by Nikolay Sivov
Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com>
---
dlls/scrrun/dictionary.c | 175 ++++++++++++++++++++-------------------
1 file changed, 88 insertions(+), 87 deletions(-)
diff --git a/dlls/scrrun/dictionary.c b/dlls/scrrun/dictionary.c
index b946d8ad25b..d1c6eb24e0b 100644
--- a/dlls/scrrun/dictionary.c
+++ b/dlls/scrrun/dictionary.c
@@ -52,7 +52,8 @@ WINE_DEFAULT_DEBUG_CHANNEL(scrrun);
indicates that pairs are not reordered basing on hash value.
*/
-struct keyitem_pair {
+struct keyitem_pair
+{
struct list entry;
struct list bucket;
DWORD hash;
@@ -60,7 +61,7 @@ struct keyitem_pair {
VARIANT item;
};
-typedef struct
+struct dictionary
{
struct provideclassinfo classinfo;
IDictionary IDictionary_iface;
@@ -71,20 +72,21 @@ typedef struct
struct list pairs;
struct list buckets[BUCKET_COUNT];
struct list notifier;
-} dictionary;
+};
-struct dictionary_enum {
+struct dictionary_enum
+{
IEnumVARIANT IEnumVARIANT_iface;
LONG ref;
- dictionary *dict;
+ struct dictionary *dict;
struct list *cur;
struct list notify;
};
-static inline dictionary *impl_from_IDictionary(IDictionary *iface)
+static inline struct dictionary *impl_from_IDictionary(IDictionary *iface)
{
- return CONTAINING_RECORD(iface, dictionary, IDictionary_iface);
+ return CONTAINING_RECORD(iface, struct dictionary, IDictionary_iface);
}
static inline struct dictionary_enum *impl_from_IEnumVARIANT(IEnumVARIANT *iface)
@@ -92,7 +94,7 @@ static inline struct dictionary_enum *impl_from_IEnumVARIANT(IEnumVARIANT *iface
return CONTAINING_RECORD(iface, struct dictionary_enum, IEnumVARIANT_iface);
}
-static inline struct list *get_bucket_head(dictionary *dict, DWORD hash)
+static inline struct list *get_bucket_head(struct dictionary *dict, DWORD hash)
{
return &dict->buckets[hash % BUCKET_COUNT];
}
@@ -115,7 +117,7 @@ static inline WCHAR *get_key_strptr(const VARIANT *key)
}
/* should be used only when both keys are of string type, it's not checked */
-static inline int strcmp_key(const dictionary *dict, const VARIANT *key1, const VARIANT *key2)
+static inline int strcmp_key(const struct dictionary *dict, const VARIANT *key1, const VARIANT *key2)
{
const WCHAR *str1, *str2;
@@ -124,7 +126,7 @@ static inline int strcmp_key(const dictionary *dict, const VARIANT *key1, const
return dict->method == BinaryCompare ? wcscmp(str1, str2) : wcsicmp(str1, str2);
}
-static BOOL is_matching_key(const dictionary *dict, const struct keyitem_pair *pair, const VARIANT *key, DWORD hash)
+static BOOL is_matching_key(const struct dictionary *dict, const struct keyitem_pair *pair, const VARIANT *key, DWORD hash)
{
if (is_string_key(key) && is_string_key(&pair->key)) {
if (hash != pair->hash)
@@ -141,7 +143,7 @@ static BOOL is_matching_key(const dictionary *dict, const struct keyitem_pair *p
return hash == pair->hash;
}
-static struct keyitem_pair *get_keyitem_pair(dictionary *dict, VARIANT *key)
+static struct keyitem_pair *get_keyitem_pair(struct dictionary *dict, VARIANT *key)
{
struct keyitem_pair *pair;
struct list *head, *entry;
@@ -165,7 +167,7 @@ static struct keyitem_pair *get_keyitem_pair(dictionary *dict, VARIANT *key)
return NULL;
}
-static HRESULT add_keyitem_pair(dictionary *dict, VARIANT *key, VARIANT *item)
+static HRESULT add_keyitem_pair(struct dictionary *dict, VARIANT *key, VARIANT *item)
{
struct keyitem_pair *pair;
struct list *head;
@@ -316,7 +318,7 @@ static HRESULT WINAPI dict_enum_Reset(IEnumVARIANT *iface)
return S_OK;
}
-static HRESULT create_dict_enum(dictionary*, IUnknown**);
+static HRESULT create_dict_enum(struct dictionary *, IUnknown**);
static HRESULT WINAPI dict_enum_Clone(IEnumVARIANT *iface, IEnumVARIANT **cloned)
{
@@ -335,7 +337,7 @@ static const IEnumVARIANTVtbl dictenumvtbl = {
dict_enum_Clone
};
-static HRESULT create_dict_enum(dictionary *dict, IUnknown **ret)
+static HRESULT create_dict_enum(struct dictionary *dict, IUnknown **ret)
{
struct dictionary_enum *object;
@@ -373,8 +375,9 @@ static void notify_remove_pair(struct list *notifier, struct list *pair)
static HRESULT WINAPI dictionary_QueryInterface(IDictionary *iface, REFIID riid, void **obj)
{
- dictionary *This = impl_from_IDictionary(iface);
- TRACE("(%p)->(%s, %p)\n", This, debugstr_guid(riid), obj);
+ struct dictionary *dictionary = impl_from_IDictionary(iface);
+
+ TRACE("%p, %s, %p.\n", iface, debugstr_guid(riid), obj);
*obj = NULL;
@@ -382,11 +385,11 @@ static HRESULT WINAPI dictionary_QueryInterface(IDictionary *iface, REFIID riid,
IsEqualIID(riid, &IID_IDispatch) ||
IsEqualIID(riid, &IID_IDictionary))
{
- *obj = &This->IDictionary_iface;
+ *obj = &dictionary->IDictionary_iface;
}
else if (IsEqualIID(riid, &IID_IProvideClassInfo))
{
- *obj = &This->classinfo.IProvideClassInfo_iface;
+ *obj = &dictionary->classinfo.IProvideClassInfo_iface;
}
else if ( IsEqualGUID( riid, &IID_IDispatchEx ))
{
@@ -412,17 +415,17 @@ static HRESULT WINAPI dictionary_QueryInterface(IDictionary *iface, REFIID riid,
static ULONG WINAPI dictionary_AddRef(IDictionary *iface)
{
- dictionary *This = impl_from_IDictionary(iface);
- ULONG ref = InterlockedIncrement(&This->ref);
+ struct dictionary *dictionary = impl_from_IDictionary(iface);
+ ULONG ref = InterlockedIncrement(&dictionary->ref);
- TRACE("(%p)->(%u)\n", This, ref);
+ TRACE("%p, refcount %u.\n", iface, ref);
return ref;
}
static ULONG WINAPI dictionary_Release(IDictionary *iface)
{
- dictionary *dictionary = impl_from_IDictionary(iface);
+ struct dictionary *dictionary = impl_from_IDictionary(iface);
ULONG ref = InterlockedDecrement(&dictionary->ref);
TRACE("%p, refcount %u.\n", iface, ref);
@@ -438,9 +441,7 @@ static ULONG WINAPI dictionary_Release(IDictionary *iface)
static HRESULT WINAPI dictionary_GetTypeInfoCount(IDictionary *iface, UINT *pctinfo)
{
- dictionary *This = impl_from_IDictionary(iface);
-
- TRACE("(%p)->(%p)\n", This, pctinfo);
+ TRACE("%p, %p.\n", iface, pctinfo);
*pctinfo = 1;
return S_OK;
@@ -448,20 +449,18 @@ static HRESULT WINAPI dictionary_GetTypeInfoCount(IDictionary *iface, UINT *pcti
static HRESULT WINAPI dictionary_GetTypeInfo(IDictionary *iface, UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
{
- dictionary *This = impl_from_IDictionary(iface);
+ TRACE("%p, %u, %u, %p.\n", iface, iTInfo, lcid, ppTInfo);
- TRACE("(%p)->(%u %u %p)\n", This, iTInfo, lcid, ppTInfo);
return get_typeinfo(IDictionary_tid, ppTInfo);
}
static HRESULT WINAPI dictionary_GetIDsOfNames(IDictionary *iface, REFIID riid, LPOLESTR *rgszNames,
UINT cNames, LCID lcid, DISPID *rgDispId)
{
- dictionary *This = impl_from_IDictionary(iface);
ITypeInfo *typeinfo;
HRESULT hr;
- TRACE("(%p)->(%s %p %u %u %p)\n", This, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
+ TRACE("%p, %s, %p, %u, %u, %p.\n", iface, debugstr_guid(riid), rgszNames, cNames, lcid, rgDispId);
hr = get_typeinfo(IDictionary_tid, &typeinfo);
if(SUCCEEDED(hr))
@@ -477,17 +476,17 @@ static HRESULT WINAPI dictionary_Invoke(IDictionary *iface, DISPID dispIdMember,
LCID lcid, WORD wFlags, DISPPARAMS *pDispParams, VARIANT *pVarResult,
EXCEPINFO *pExcepInfo, UINT *puArgErr)
{
- dictionary *This = impl_from_IDictionary(iface);
+ struct dictionary *dictionary = impl_from_IDictionary(iface);
ITypeInfo *typeinfo;
HRESULT hr;
- TRACE("(%p)->(%d %s %d %d %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
+ TRACE("%p, %d, %s, %d, %d, %p, %p, %p, %p.\n", iface, dispIdMember, debugstr_guid(riid),
lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
hr = get_typeinfo(IDictionary_tid, &typeinfo);
if(SUCCEEDED(hr))
{
- hr = ITypeInfo_Invoke(typeinfo, &This->IDictionary_iface, dispIdMember, wFlags,
+ hr = ITypeInfo_Invoke(typeinfo, &dictionary->IDictionary_iface, dispIdMember, wFlags,
pDispParams, pVarResult, pExcepInfo, puArgErr);
ITypeInfo_Release(typeinfo);
}
@@ -497,21 +496,19 @@ static HRESULT WINAPI dictionary_Invoke(IDictionary *iface, DISPID dispIdMember,
static HRESULT WINAPI dictionary_putref_Item(IDictionary *iface, VARIANT *Key, VARIANT *pRetItem)
{
- dictionary *This = impl_from_IDictionary(iface);
-
- FIXME("(%p)->(%p %p)\n", This, Key, pRetItem);
+ FIXME("%p, %p, %p stub\n", iface, Key, pRetItem);
return E_NOTIMPL;
}
static HRESULT WINAPI dictionary_put_Item(IDictionary *iface, VARIANT *key, VARIANT *item)
{
- dictionary *This = impl_from_IDictionary(iface);
+ struct dictionary *dictionary = impl_from_IDictionary(iface);
struct keyitem_pair *pair;
- TRACE("(%p)->(%s %s)\n", This, debugstr_variant(key), debugstr_variant(item));
+ TRACE("%p, %s, %s.\n", iface, debugstr_variant(key), debugstr_variant(item));
- if ((pair = get_keyitem_pair(This, key)))
+ if ((pair = get_keyitem_pair(dictionary, key)))
return VariantCopyInd(&pair->item, item);
return IDictionary_Add(iface, key, item);
@@ -519,12 +516,12 @@ static HRESULT WINAPI dictionary_put_Item(IDictionary *iface, VARIANT *key, VARI
static HRESULT WINAPI dictionary_get_Item(IDictionary *iface, VARIANT *key, VARIANT *item)
{
- dictionary *This = impl_from_IDictionary(iface);
+ struct dictionary *dictionary = impl_from_IDictionary(iface);
struct keyitem_pair *pair;
- TRACE("(%p)->(%s %p)\n", This, debugstr_variant(key), item);
+ TRACE("%p, %s, %p.\n", iface, debugstr_variant(key), item);
- if ((pair = get_keyitem_pair(This, key)))
+ if ((pair = get_keyitem_pair(dictionary, key)))
VariantCopy(item, &pair->item);
else {
VariantInit(item);
@@ -536,42 +533,42 @@ static HRESULT WINAPI dictionary_get_Item(IDictionary *iface, VARIANT *key, VARI
static HRESULT WINAPI dictionary_Add(IDictionary *iface, VARIANT *key, VARIANT *item)
{
- dictionary *This = impl_from_IDictionary(iface);
+ struct dictionary *dictionary = impl_from_IDictionary(iface);
- TRACE("(%p)->(%s %s)\n", This, debugstr_variant(key), debugstr_variant(item));
+ TRACE("%p, %s, %s.\n", iface, debugstr_variant(key), debugstr_variant(item));
- if (get_keyitem_pair(This, key))
+ if (get_keyitem_pair(dictionary, key))
return CTL_E_KEY_ALREADY_EXISTS;
- return add_keyitem_pair(This, key, item);
+ return add_keyitem_pair(dictionary, key, item);
}
static HRESULT WINAPI dictionary_get_Count(IDictionary *iface, LONG *count)
{
- dictionary *This = impl_from_IDictionary(iface);
+ struct dictionary *dictionary = impl_from_IDictionary(iface);
- TRACE("(%p)->(%p)\n", This, count);
+ TRACE("%p, %p.\n", iface, count);
- *count = This->count;
+ *count = dictionary->count;
return S_OK;
}
static HRESULT WINAPI dictionary_Exists(IDictionary *iface, VARIANT *key, VARIANT_BOOL *exists)
{
- dictionary *This = impl_from_IDictionary(iface);
+ struct dictionary *dictionary = impl_from_IDictionary(iface);
- TRACE("(%p)->(%s %p)\n", This, debugstr_variant(key), exists);
+ TRACE("%p, %s, %p.\n", iface, debugstr_variant(key), exists);
if (!exists)
return CTL_E_ILLEGALFUNCTIONCALL;
- *exists = get_keyitem_pair(This, key) != NULL ? VARIANT_TRUE : VARIANT_FALSE;
+ *exists = get_keyitem_pair(dictionary, key) != NULL ? VARIANT_TRUE : VARIANT_FALSE;
return S_OK;
}
static HRESULT WINAPI dictionary_Items(IDictionary *iface, VARIANT *items)
{
- dictionary *This = impl_from_IDictionary(iface);
+ struct dictionary *dictionary = impl_from_IDictionary(iface);
struct keyitem_pair *pair;
SAFEARRAYBOUND bound;
SAFEARRAY *sa;
@@ -579,13 +576,13 @@ static HRESULT WINAPI dictionary_Items(IDictionary *iface, VARIANT *items)
HRESULT hr;
LONG i;
- TRACE("(%p)->(%p)\n", This, items);
+ TRACE("%p, %p.\n", iface, items);
if (!items)
return S_OK;
bound.lLbound = 0;
- bound.cElements = This->count;
+ bound.cElements = dictionary->count;
sa = SafeArrayCreate(VT_VARIANT, 1, &bound);
if (!sa)
return E_OUTOFMEMORY;
@@ -597,7 +594,8 @@ static HRESULT WINAPI dictionary_Items(IDictionary *iface, VARIANT *items)
}
i = 0;
- LIST_FOR_EACH_ENTRY(pair, &This->pairs, struct keyitem_pair, entry) {
+ LIST_FOR_EACH_ENTRY(pair, &dictionary->pairs, struct keyitem_pair, entry)
+ {
VariantCopy(&v[i], &pair->item);
i++;
}
@@ -610,14 +608,15 @@ static HRESULT WINAPI dictionary_Items(IDictionary *iface, VARIANT *items)
static HRESULT WINAPI dictionary_put_Key(IDictionary *iface, VARIANT *key, VARIANT *newkey)
{
- dictionary *This = impl_from_IDictionary(iface);
+ struct dictionary *dictionary = impl_from_IDictionary(iface);
struct keyitem_pair *pair;
VARIANT empty;
HRESULT hr;
- TRACE("(%p)->(%s %s)\n", This, debugstr_variant(key), debugstr_variant(newkey));
+ TRACE("%p, %s, %s.\n", iface, debugstr_variant(key), debugstr_variant(newkey));
- if ((pair = get_keyitem_pair(This, key))) {
+ if ((pair = get_keyitem_pair(dictionary, key)))
+ {
/* found existing pair for a key, add new pair with new key
and old item and remove old pair after that */
@@ -634,7 +633,7 @@ static HRESULT WINAPI dictionary_put_Key(IDictionary *iface, VARIANT *key, VARIA
static HRESULT WINAPI dictionary_Keys(IDictionary *iface, VARIANT *keys)
{
- dictionary *This = impl_from_IDictionary(iface);
+ struct dictionary *dictionary = impl_from_IDictionary(iface);
struct keyitem_pair *pair;
SAFEARRAYBOUND bound;
SAFEARRAY *sa;
@@ -642,13 +641,13 @@ static HRESULT WINAPI dictionary_Keys(IDictionary *iface, VARIANT *keys)
HRESULT hr;
LONG i;
- TRACE("(%p)->(%p)\n", This, keys);
+ TRACE("%p, %p.\n", iface, keys);
if (!keys)
return S_OK;
bound.lLbound = 0;
- bound.cElements = This->count;
+ bound.cElements = dictionary->count;
sa = SafeArrayCreate(VT_VARIANT, 1, &bound);
if (!sa)
return E_OUTOFMEMORY;
@@ -660,7 +659,8 @@ static HRESULT WINAPI dictionary_Keys(IDictionary *iface, VARIANT *keys)
}
i = 0;
- LIST_FOR_EACH_ENTRY(pair, &This->pairs, struct keyitem_pair, entry) {
+ LIST_FOR_EACH_ENTRY(pair, &dictionary->pairs, struct keyitem_pair, entry)
+ {
VariantCopy(&v[i], &pair->key);
i++;
}
@@ -673,18 +673,18 @@ static HRESULT WINAPI dictionary_Keys(IDictionary *iface, VARIANT *keys)
static HRESULT WINAPI dictionary_Remove(IDictionary *iface, VARIANT *key)
{
- dictionary *This = impl_from_IDictionary(iface);
+ struct dictionary *dictionary = impl_from_IDictionary(iface);
struct keyitem_pair *pair;
- TRACE("(%p)->(%s)\n", This, debugstr_variant(key));
+ TRACE("%p, %s.\n", iface, debugstr_variant(key));
- if (!(pair = get_keyitem_pair(This, key)))
+ if (!(pair = get_keyitem_pair(dictionary, key)))
return CTL_E_ELEMENT_NOT_FOUND;
- notify_remove_pair(&This->notifier, &pair->entry);
+ notify_remove_pair(&dictionary->notifier, &pair->entry);
list_remove(&pair->entry);
list_remove(&pair->bucket);
- This->count--;
+ dictionary->count--;
free_keyitem_pair(pair);
return S_OK;
@@ -692,55 +692,56 @@ static HRESULT WINAPI dictionary_Remove(IDictionary *iface, VARIANT *key)
static HRESULT WINAPI dictionary_RemoveAll(IDictionary *iface)
{
- dictionary *This = impl_from_IDictionary(iface);
+ struct dictionary *dictionary = impl_from_IDictionary(iface);
struct keyitem_pair *pair, *pair2;
- TRACE("(%p)\n", This);
+ TRACE("%p.\n", iface);
- if (This->count == 0)
+ if (!dictionary->count)
return S_OK;
- notify_remove_pair(&This->notifier, NULL);
- LIST_FOR_EACH_ENTRY_SAFE(pair, pair2, &This->pairs, struct keyitem_pair, entry) {
+ notify_remove_pair(&dictionary->notifier, NULL);
+ LIST_FOR_EACH_ENTRY_SAFE(pair, pair2, &dictionary->pairs, struct keyitem_pair, entry)
+ {
list_remove(&pair->entry);
list_remove(&pair->bucket);
free_keyitem_pair(pair);
}
- This->count = 0;
+ dictionary->count = 0;
return S_OK;
}
static HRESULT WINAPI dictionary_put_CompareMode(IDictionary *iface, CompareMethod method)
{
- dictionary *This = impl_from_IDictionary(iface);
+ struct dictionary *dictionary = impl_from_IDictionary(iface);
- TRACE("(%p)->(%d)\n", This, method);
+ TRACE("%p, %d.\n", iface, method);
- if (This->count)
+ if (dictionary->count)
return CTL_E_ILLEGALFUNCTIONCALL;
- This->method = method;
+ dictionary->method = method;
return S_OK;
}
static HRESULT WINAPI dictionary_get_CompareMode(IDictionary *iface, CompareMethod *method)
{
- dictionary *This = impl_from_IDictionary(iface);
+ struct dictionary *dictionary = impl_from_IDictionary(iface);
- TRACE("(%p)->(%p)\n", This, method);
+ TRACE("%p, %p.\n", iface, method);
- *method = This->method;
+ *method = dictionary->method;
return S_OK;
}
static HRESULT WINAPI dictionary__NewEnum(IDictionary *iface, IUnknown **ret)
{
- dictionary *This = impl_from_IDictionary(iface);
+ struct dictionary *dictionary = impl_from_IDictionary(iface);
- TRACE("(%p)->(%p)\n", This, ret);
+ TRACE("%p, %p.\n", iface, ret);
- return create_dict_enum(This, ret);
+ return create_dict_enum(dictionary, ret);
}
static DWORD get_str_hash(const WCHAR *str, CompareMethod method)
@@ -789,16 +790,16 @@ static DWORD get_ptr_hash(void *ptr)
static HRESULT WINAPI dictionary_get_HashVal(IDictionary *iface, VARIANT *key, VARIANT *hash)
{
- dictionary *This = impl_from_IDictionary(iface);
+ struct dictionary *dictionary = impl_from_IDictionary(iface);
- TRACE("(%p)->(%s %p)\n", This, debugstr_variant(key), hash);
+ TRACE("%p, %s, %p.\n", iface, debugstr_variant(key), hash);
V_VT(hash) = VT_I4;
switch (V_VT(key))
{
case VT_BSTR|VT_BYREF:
case VT_BSTR:
- V_I4(hash) = get_str_hash(get_key_strptr(key), This->method);
+ V_I4(hash) = get_str_hash(get_key_strptr(key), dictionary->method);
break;
case VT_UI1|VT_BYREF:
case VT_UI1:
@@ -887,7 +888,7 @@ static const struct IDictionaryVtbl dictionary_vtbl =
HRESULT WINAPI Dictionary_CreateInstance(IClassFactory *factory, IUnknown *outer, REFIID riid, void **ret)
{
- dictionary *object;
+ struct dictionary *object;
TRACE("(%p, %p, %s, %p)\n", factory, outer, debugstr_guid(riid), ret);
--
2.34.1
Jan. 26, 2022
[PATCH 1/2] scrrun: Use CRT allocation functions.
by Nikolay Sivov
Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com>
---
dlls/scrrun/dictionary.c | 71 ++++++++++---------
dlls/scrrun/filesystem.c | 143 ++++++++++++++++++++-------------------
2 files changed, 107 insertions(+), 107 deletions(-)
diff --git a/dlls/scrrun/dictionary.c b/dlls/scrrun/dictionary.c
index 477943f6579..b946d8ad25b 100644
--- a/dlls/scrrun/dictionary.c
+++ b/dlls/scrrun/dictionary.c
@@ -30,7 +30,6 @@
#include "scrrun_private.h"
#include "wine/debug.h"
-#include "wine/heap.h"
#include "wine/list.h"
WINE_DEFAULT_DEBUG_CHANNEL(scrrun);
@@ -177,8 +176,7 @@ static HRESULT add_keyitem_pair(dictionary *dict, VARIANT *key, VARIANT *item)
if (FAILED(hr))
return hr;
- pair = heap_alloc(sizeof(*pair));
- if (!pair)
+ if (!(pair = malloc(sizeof(*pair))))
return E_OUTOFMEMORY;
pair->hash = V_I4(&hash);
@@ -207,7 +205,7 @@ static HRESULT add_keyitem_pair(dictionary *dict, VARIANT *key, VARIANT *item)
failed:
VariantClear(&pair->key);
VariantClear(&pair->item);
- heap_free(pair);
+ free(pair);
return hr;
}
@@ -215,7 +213,7 @@ static void free_keyitem_pair(struct keyitem_pair *pair)
{
VariantClear(&pair->key);
VariantClear(&pair->item);
- heap_free(pair);
+ free(pair);
}
static HRESULT WINAPI dict_enum_QueryInterface(IEnumVARIANT *iface, REFIID riid, void **obj)
@@ -251,10 +249,11 @@ static ULONG WINAPI dict_enum_Release(IEnumVARIANT *iface)
TRACE("(%p)->(%u)\n", This, ref);
- if (!ref) {
+ if (!ref)
+ {
list_remove(&This->notify);
IDictionary_Release(&This->dict->IDictionary_iface);
- heap_free(This);
+ free(This);
}
return ref;
@@ -338,22 +337,22 @@ static const IEnumVARIANTVtbl dictenumvtbl = {
static HRESULT create_dict_enum(dictionary *dict, IUnknown **ret)
{
- struct dictionary_enum *This;
+ struct dictionary_enum *object;
*ret = NULL;
- This = heap_alloc(sizeof(*This));
- if (!This)
+ if (!(object = calloc(1, sizeof(*object))))
return E_OUTOFMEMORY;
- This->IEnumVARIANT_iface.lpVtbl = &dictenumvtbl;
- This->ref = 1;
- This->cur = list_head(&dict->pairs);
- list_add_tail(&dict->notifier, &This->notify);
- This->dict = dict;
+ object->IEnumVARIANT_iface.lpVtbl = &dictenumvtbl;
+ object->ref = 1;
+ object->cur = list_head(&dict->pairs);
+ list_add_tail(&dict->notifier, &object->notify);
+ object->dict = dict;
IDictionary_AddRef(&dict->IDictionary_iface);
- *ret = (IUnknown*)&This->IEnumVARIANT_iface;
+ *ret = (IUnknown *)&object->IEnumVARIANT_iface;
+
return S_OK;
}
@@ -423,14 +422,15 @@ static ULONG WINAPI dictionary_AddRef(IDictionary *iface)
static ULONG WINAPI dictionary_Release(IDictionary *iface)
{
- dictionary *This = impl_from_IDictionary(iface);
- ULONG ref = InterlockedDecrement(&This->ref);
+ dictionary *dictionary = impl_from_IDictionary(iface);
+ ULONG ref = InterlockedDecrement(&dictionary->ref);
- TRACE("(%p)->(%u)\n", This, ref);
+ TRACE("%p, refcount %u.\n", iface, ref);
- if (!ref) {
+ if (!ref)
+ {
IDictionary_RemoveAll(iface);
- heap_free(This);
+ free(dictionary);
}
return ref;
@@ -885,27 +885,26 @@ static const struct IDictionaryVtbl dictionary_vtbl =
dictionary_get_HashVal
};
-HRESULT WINAPI Dictionary_CreateInstance(IClassFactory *factory,IUnknown *outer,REFIID riid, void **obj)
+HRESULT WINAPI Dictionary_CreateInstance(IClassFactory *factory, IUnknown *outer, REFIID riid, void **ret)
{
- dictionary *This;
+ dictionary *object;
- TRACE("(%p, %p, %s, %p)\n", factory, outer, debugstr_guid(riid), obj);
+ TRACE("(%p, %p, %s, %p)\n", factory, outer, debugstr_guid(riid), ret);
- *obj = NULL;
+ *ret = NULL;
- This = heap_alloc(sizeof(*This));
- if(!This) return E_OUTOFMEMORY;
+ if (!(object = calloc(1, sizeof(*object))))
+ return E_OUTOFMEMORY;
- This->IDictionary_iface.lpVtbl = &dictionary_vtbl;
- This->ref = 1;
- This->method = BinaryCompare;
- This->count = 0;
- list_init(&This->pairs);
- list_init(&This->notifier);
- memset(This->buckets, 0, sizeof(This->buckets));
+ object->IDictionary_iface.lpVtbl = &dictionary_vtbl;
+ object->ref = 1;
+ object->method = BinaryCompare;
+ list_init(&object->pairs);
+ list_init(&object->notifier);
+
+ init_classinfo(&CLSID_Dictionary, (IUnknown *)&object->IDictionary_iface, &object->classinfo);
- init_classinfo(&CLSID_Dictionary, (IUnknown *)&This->IDictionary_iface, &This->classinfo);
- *obj = &This->IDictionary_iface;
+ *ret = &object->IDictionary_iface;
return S_OK;
}
diff --git a/dlls/scrrun/filesystem.c b/dlls/scrrun/filesystem.c
index 5d7d42850ab..e525b9db8da 100644
--- a/dlls/scrrun/filesystem.c
+++ b/dlls/scrrun/filesystem.c
@@ -33,7 +33,6 @@
#include "scrrun_private.h"
#include "wine/debug.h"
-#include "wine/heap.h"
WINE_DEFAULT_DEBUG_CHANNEL(scrrun);
@@ -317,15 +316,16 @@ static ULONG WINAPI textstream_AddRef(ITextStream *iface)
static ULONG WINAPI textstream_Release(ITextStream *iface)
{
- struct textstream *This = impl_from_ITextStream(iface);
- ULONG ref = InterlockedDecrement(&This->ref);
- TRACE("(%p)->(%d)\n", This, ref);
+ struct textstream *stream = impl_from_ITextStream(iface);
+ ULONG ref = InterlockedDecrement(&stream->ref);
+
+ TRACE("%p, refcount %d.\n", iface, ref);
if (!ref)
{
- if (This->read_buf_size) heap_free(This->read_buf);
- CloseHandle(This->file);
- heap_free(This);
+ if (stream->read_buf_size) free(stream->read_buf);
+ CloseHandle(stream->file);
+ free(stream);
}
return ref;
@@ -462,9 +462,9 @@ static HRESULT append_read_data(struct textstream *stream, const char *buf, size
SetFilePointerEx(stream->file, revert, NULL, FILE_CURRENT);
if (!stream->read_buf_size)
- new_buf = heap_alloc(len * sizeof(WCHAR));
+ new_buf = malloc(len * sizeof(WCHAR));
else
- new_buf = heap_realloc(stream->read_buf, (len + stream->read_buf_size) * sizeof(WCHAR));
+ new_buf = realloc(stream->read_buf, (len + stream->read_buf_size) * sizeof(WCHAR));
if (!new_buf) return E_OUTOFMEMORY;
if (stream->unicode)
@@ -504,7 +504,7 @@ static BOOL read_from_buffer(struct textstream *stream, size_t len, BSTR *ret, s
if (stream->read_buf_size)
memmove(stream->read_buf, stream->read_buf + len, stream->read_buf_size * sizeof(WCHAR));
else
- heap_free(stream->read_buf);
+ free(stream->read_buf);
return TRUE;
}
@@ -622,14 +622,14 @@ static HRESULT textstream_writestr(struct textstream *stream, BSTR text)
char *buffA;
HRESULT hr;
- buffA = heap_alloc(len);
+ buffA = malloc(len);
if (!buffA)
return E_OUTOFMEMORY;
WideCharToMultiByte(CP_ACP, 0, text, SysStringLen(text), buffA, len, NULL, NULL);
ret = WriteFile(stream->file, buffA, len, &written, NULL);
hr = (ret && written == len) ? S_OK : create_error(GetLastError());
- heap_free(buffA);
+ free(buffA);
return hr;
}
}
@@ -765,21 +765,18 @@ static HRESULT create_textstream(const WCHAR *filename, DWORD disposition, IOMod
return E_INVALIDARG;
}
- stream = heap_alloc(sizeof(struct textstream));
- if (!stream) return E_OUTOFMEMORY;
+ if (!(stream = calloc(1, sizeof(*stream))))
+ return E_OUTOFMEMORY;
stream->ITextStream_iface.lpVtbl = &textstreamvtbl;
stream->ref = 1;
stream->mode = mode;
- stream->eof = FALSE;
- stream->read_buf = NULL;
- stream->read_buf_size = 0;
stream->file = CreateFileW(filename, access, 0, NULL, disposition, FILE_ATTRIBUTE_NORMAL, NULL);
if (stream->file == INVALID_HANDLE_VALUE)
{
HRESULT hr = create_error(GetLastError());
- heap_free(stream);
+ free(stream);
return hr;
}
@@ -877,12 +874,13 @@ static ULONG WINAPI drive_AddRef(IDrive *iface)
static ULONG WINAPI drive_Release(IDrive *iface)
{
- struct drive *This = impl_from_IDrive(iface);
- ULONG ref = InterlockedDecrement(&This->ref);
- TRACE("(%p)->(%d)\n", This, ref);
+ struct drive *drive = impl_from_IDrive(iface);
+ ULONG ref = InterlockedDecrement(&drive->ref);
+
+ TRACE("%p, refcount %d.\n", iface, ref);
if (!ref)
- heap_free(This);
+ free(drive);
return ref;
}
@@ -1182,7 +1180,7 @@ static HRESULT create_drive(WCHAR letter, IDrive **drive)
*drive = NULL;
- object = heap_alloc(sizeof(*object));
+ object = malloc(sizeof(*object));
if (!object) return E_OUTOFMEMORY;
object->IDrive_iface.lpVtbl = &drivevtbl;
@@ -1235,7 +1233,7 @@ static ULONG WINAPI foldercoll_enumvariant_Release(IEnumVARIANT *iface)
{
IFolderCollection_Release(&This->data.u.foldercoll.coll->IFolderCollection_iface);
FindClose(This->data.u.foldercoll.find);
- heap_free(This);
+ free(This);
}
return ref;
@@ -1392,7 +1390,7 @@ static HRESULT create_foldercoll_enum(struct foldercollection *collection, IUnkn
*newenum = NULL;
- This = heap_alloc(sizeof(*This));
+ This = malloc(sizeof(*This));
if (!This) return E_OUTOFMEMORY;
This->IEnumVARIANT_iface.lpVtbl = &foldercollenumvariantvtbl;
@@ -1417,7 +1415,7 @@ static ULONG WINAPI filecoll_enumvariant_Release(IEnumVARIANT *iface)
{
IFileCollection_Release(&This->data.u.filecoll.coll->IFileCollection_iface);
FindClose(This->data.u.filecoll.find);
- heap_free(This);
+ free(This);
}
return ref;
@@ -1534,7 +1532,7 @@ static HRESULT create_filecoll_enum(struct filecollection *collection, IUnknown
*newenum = NULL;
- This = heap_alloc(sizeof(*This));
+ This = malloc(sizeof(*This));
if (!This) return E_OUTOFMEMORY;
This->IEnumVARIANT_iface.lpVtbl = &filecollenumvariantvtbl;
@@ -1558,7 +1556,7 @@ static ULONG WINAPI drivecoll_enumvariant_Release(IEnumVARIANT *iface)
if (!ref)
{
IDriveCollection_Release(&This->data.u.drivecoll.coll->IDriveCollection_iface);
- heap_free(This);
+ free(This);
}
return ref;
@@ -1657,7 +1655,7 @@ static HRESULT create_drivecoll_enum(struct drivecollection *collection, IUnknow
*newenum = NULL;
- This = heap_alloc(sizeof(*This));
+ This = malloc(sizeof(*This));
if (!This) return E_OUTOFMEMORY;
This->IEnumVARIANT_iface.lpVtbl = &drivecollenumvariantvtbl;
@@ -1713,7 +1711,7 @@ static ULONG WINAPI foldercoll_Release(IFolderCollection *iface)
if (!ref)
{
SysFreeString(This->path);
- heap_free(This);
+ free(This);
}
return ref;
@@ -1854,7 +1852,7 @@ static HRESULT create_foldercoll(BSTR path, IFolderCollection **folders)
*folders = NULL;
- This = heap_alloc(sizeof(struct foldercollection));
+ This = malloc(sizeof(*This));
if (!This) return E_OUTOFMEMORY;
This->IFolderCollection_iface.lpVtbl = &foldercollvtbl;
@@ -1862,7 +1860,7 @@ static HRESULT create_foldercoll(BSTR path, IFolderCollection **folders)
This->path = SysAllocString(path);
if (!This->path)
{
- heap_free(This);
+ free(This);
return E_OUTOFMEMORY;
}
@@ -1914,7 +1912,7 @@ static ULONG WINAPI filecoll_Release(IFileCollection *iface)
if (!ref)
{
SysFreeString(This->path);
- heap_free(This);
+ free(This);
}
return ref;
@@ -2047,7 +2045,7 @@ static HRESULT create_filecoll(BSTR path, IFileCollection **files)
*files = NULL;
- This = heap_alloc(sizeof(*This));
+ This = malloc(sizeof(*This));
if (!This) return E_OUTOFMEMORY;
This->IFileCollection_iface.lpVtbl = &filecollectionvtbl;
@@ -2055,7 +2053,7 @@ static HRESULT create_filecoll(BSTR path, IFileCollection **files)
This->path = SysAllocString(path);
if (!This->path)
{
- heap_free(This);
+ free(This);
return E_OUTOFMEMORY;
}
@@ -2104,7 +2102,7 @@ static ULONG WINAPI drivecoll_Release(IDriveCollection *iface)
TRACE("(%p)->(%d)\n", This, ref);
if (!ref)
- heap_free(This);
+ free(This);
return ref;
}
@@ -2219,7 +2217,7 @@ static HRESULT create_drivecoll(IDriveCollection **drives)
*drives = NULL;
- This = heap_alloc(sizeof(*This));
+ This = malloc(sizeof(*This));
if (!This) return E_OUTOFMEMORY;
This->IDriveCollection_iface.lpVtbl = &drivecollectionvtbl;
@@ -2276,7 +2274,7 @@ static ULONG WINAPI folder_Release(IFolder *iface)
if (!ref)
{
SysFreeString(This->path);
- heap_free(This);
+ free(This);
}
return ref;
@@ -2568,26 +2566,26 @@ static const IFolderVtbl foldervtbl = {
HRESULT create_folder(const WCHAR *path, IFolder **folder)
{
- struct folder *This;
+ struct folder *object;
*folder = NULL;
TRACE("%s\n", debugstr_w(path));
- This = heap_alloc(sizeof(struct folder));
- if (!This) return E_OUTOFMEMORY;
+ if (!(object = malloc(sizeof(*object))))
+ return E_OUTOFMEMORY;
- This->IFolder_iface.lpVtbl = &foldervtbl;
- This->ref = 1;
- This->path = SysAllocString(path);
- if (!This->path)
+ object->IFolder_iface.lpVtbl = &foldervtbl;
+ object->ref = 1;
+ object->path = SysAllocString(path);
+ if (!object->path)
{
- heap_free(This);
+ free(object);
return E_OUTOFMEMORY;
}
- init_classinfo(&CLSID_Folder, (IUnknown *)&This->IFolder_iface, &This->classinfo);
- *folder = &This->IFolder_iface;
+ init_classinfo(&CLSID_Folder, (IUnknown *)&object->IFolder_iface, &object->classinfo);
+ *folder = &object->IFolder_iface;
return S_OK;
}
@@ -2629,15 +2627,15 @@ static ULONG WINAPI file_AddRef(IFile *iface)
static ULONG WINAPI file_Release(IFile *iface)
{
- struct file *This = impl_from_IFile(iface);
- LONG ref = InterlockedDecrement(&This->ref);
+ struct file *file = impl_from_IFile(iface);
+ LONG ref = InterlockedDecrement(&file->ref);
- TRACE("(%p) ref=%d\n", This, ref);
+ TRACE("%p, refcount %d.\n", iface, ref);
- if(!ref)
+ if (!ref)
{
- heap_free(This->path);
- heap_free(This);
+ free(file->path);
+ free(file);
}
return ref;
@@ -2942,7 +2940,7 @@ static HRESULT create_file(BSTR path, IFile **file)
*file = NULL;
- f = heap_alloc(sizeof(struct file));
+ f = malloc(sizeof(struct file));
if(!f)
return E_OUTOFMEMORY;
@@ -2950,28 +2948,31 @@ static HRESULT create_file(BSTR path, IFile **file)
f->ref = 1;
len = GetFullPathNameW(path, 0, NULL, NULL);
- if(!len) {
- heap_free(f);
+ if (!len)
+ {
+ free(f);
return E_FAIL;
}
- f->path = heap_alloc(len*sizeof(WCHAR));
- if(!f->path) {
- heap_free(f);
+ f->path = malloc(len*sizeof(WCHAR));
+ if(!f->path)
+ {
+ free(f);
return E_OUTOFMEMORY;
}
- if(!GetFullPathNameW(path, len, f->path, NULL)) {
- heap_free(f->path);
- heap_free(f);
+ if (!GetFullPathNameW(path, len, f->path, NULL))
+ {
+ free(f->path);
+ free(f);
return E_FAIL;
}
attrs = GetFileAttributesW(f->path);
- if(attrs==INVALID_FILE_ATTRIBUTES ||
- (attrs&(FILE_ATTRIBUTE_DIRECTORY|FILE_ATTRIBUTE_DEVICE))) {
- heap_free(f->path);
- heap_free(f);
+ if (attrs == INVALID_FILE_ATTRIBUTES || (attrs & (FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_DEVICE)))
+ {
+ free(f->path);
+ free(f);
return create_error(GetLastError());
}
@@ -3931,22 +3932,22 @@ static HRESULT WINAPI filesys_GetFileVersion(IFileSystem3 *iface, BSTR name, BST
if (!len)
return HRESULT_FROM_WIN32(GetLastError());
- ptr = heap_alloc(len);
+ ptr = malloc(len);
if (!GetFileVersionInfoW(name, 0, len, ptr))
{
- heap_free(ptr);
+ free(ptr);
return HRESULT_FROM_WIN32(GetLastError());
}
ret = VerQueryValueW(ptr, L"\\", (void **)&info, &len);
if (!ret)
{
- heap_free(ptr);
+ free(ptr);
return HRESULT_FROM_WIN32(GetLastError());
}
get_versionstring(info, ver);
- heap_free(ptr);
+ free(ptr);
*version = SysAllocString(ver);
TRACE("version=%s\n", debugstr_w(ver));
--
2.34.1
Jan. 26, 2022
[PATCH] d3dcompiler: Implement D3DWriteBlobToFile().
by Nikolay Sivov
Signed-off-by: Nikolay Sivov <nsivov(a)codeweavers.com>
---
dlls/d3dcompiler_43/blob.c | 25 ++++++++++++++++++++---
dlls/d3dcompiler_43/tests/blob.c | 35 ++++++++++++++++++++++++++++++++
2 files changed, 57 insertions(+), 3 deletions(-)
diff --git a/dlls/d3dcompiler_43/blob.c b/dlls/d3dcompiler_43/blob.c
index 5cc49fe5699..f220eeb6962 100644
--- a/dlls/d3dcompiler_43/blob.c
+++ b/dlls/d3dcompiler_43/blob.c
@@ -514,9 +514,28 @@ HRESULT WINAPI D3DReadFileToBlob(const WCHAR *filename, ID3DBlob **contents)
return S_OK;
}
-HRESULT WINAPI D3DWriteBlobToFile(ID3DBlob* blob, const WCHAR *filename, BOOL overwrite)
+HRESULT WINAPI D3DWriteBlobToFile(ID3DBlob *blob, const WCHAR *filename, BOOL overwrite)
{
- FIXME("blob %p, filename %s, overwrite %d\n", blob, debugstr_w(filename), overwrite);
+ DWORD written_size;
+ SIZE_T data_size;
+ HANDLE file;
+ BOOL ret;
+
+ TRACE("blob %p, filename %s, overwrite %d.\n", blob, debugstr_w(filename), overwrite);
+
+ file = CreateFileW(filename, GENERIC_WRITE, FILE_SHARE_READ, NULL, overwrite ? CREATE_ALWAYS : CREATE_NEW,
+ FILE_ATTRIBUTE_NORMAL, NULL);
+ if (file == INVALID_HANDLE_VALUE)
+ return HRESULT_FROM_WIN32(GetLastError());
- return E_NOTIMPL;
+ data_size = ID3D10Blob_GetBufferSize(blob);
+ ret = WriteFile(file, ID3D10Blob_GetBufferPointer(blob), data_size, &written_size, NULL);
+ CloseHandle(file);
+ if (!ret || data_size != written_size)
+ {
+ WARN("Failed to write blob contents.\n");
+ return E_FAIL;
+ }
+
+ return S_OK;
}
diff --git a/dlls/d3dcompiler_43/tests/blob.c b/dlls/d3dcompiler_43/tests/blob.c
index 3e1a3aa3da3..b59611f7eb6 100644
--- a/dlls/d3dcompiler_43/tests/blob.c
+++ b/dlls/d3dcompiler_43/tests/blob.c
@@ -36,6 +36,7 @@
static HRESULT (WINAPI *pD3DCreateBlob)(SIZE_T, ID3DBlob **);
static HRESULT (WINAPI *pD3DGetBlobPart)(const void *, SIZE_T, D3D_BLOB_PART, UINT, ID3DBlob **);
static HRESULT (WINAPI *pD3DReadFileToBlob)(const WCHAR *, ID3DBlob **);
+static HRESULT (WINAPI *pD3DWriteBlobToFile)(ID3DBlob *blob, const WCHAR *filename, BOOL overwrite);
static HRESULT (WINAPI *pD3DStripShader)(const void *, SIZE_T, UINT, ID3DBlob **);
#define MAKE_TAG(ch0, ch1, ch2, ch3) \
@@ -761,6 +762,8 @@ static BOOL load_d3dcompiler_47(void)
return FALSE;
pD3DReadFileToBlob = (void *)GetProcAddress(module, "D3DReadFileToBlob");
+ pD3DWriteBlobToFile = (void *)GetProcAddress(module, "D3DWriteBlobToFile");
+ pD3DCreateBlob = (void *)GetProcAddress(module, "D3DCreateBlob");
return TRUE;
}
@@ -862,6 +865,37 @@ static void test_D3DReadFileToBlob(void)
ID3D10Blob_Release(blob);
}
+static void test_D3DWriteBlobToFile(void)
+{
+ WCHAR temp_dir[MAX_PATH], filename[MAX_PATH];
+ ID3DBlob *blob;
+ HRESULT hr;
+
+ GetTempPathW(ARRAY_SIZE(temp_dir), temp_dir);
+ GetTempFileNameW(temp_dir, NULL, 0, filename);
+
+ hr = pD3DCreateBlob(16, &blob);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+
+ hr = pD3DWriteBlobToFile(blob, filename, FALSE);
+ ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_EXISTS), "Unexpected hr %#x.\n", hr);
+
+ hr = pD3DWriteBlobToFile(blob, filename, TRUE);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+
+ DeleteFileW(filename);
+
+ hr = pD3DWriteBlobToFile(blob, filename, FALSE);
+ ok(hr == S_OK, "Unexpected hr %#x.\n", hr);
+
+ hr = pD3DWriteBlobToFile(blob, filename, FALSE);
+ ok(hr == HRESULT_FROM_WIN32(ERROR_FILE_EXISTS), "Unexpected hr %#x.\n", hr);
+
+ DeleteFileW(filename);
+
+ ID3D10Blob_Release(blob);
+}
+
START_TEST(blob)
{
if (load_d3dcompiler_43())
@@ -878,6 +912,7 @@ START_TEST(blob)
if (load_d3dcompiler_47())
{
test_D3DReadFileToBlob();
+ test_D3DWriteBlobToFile();
}
else
{
--
2.34.1
Jan. 26, 2022
Re: [PATCH vkd3d 3/6] vkd3d-shader/hlsl: Write SM4 unsigned multiplication instructions.
by Giovanni Mascellani
Hi,
Il 25/01/22 20:06, Zebediah Figura (she/her) ha scritto:
> I'd also suggest specifying both dsts as optional hlsl_ir_node pointers,
> where NULL translates to SM4_RT_NULL. That would allow you to use this
> helper even if both dsts are used.
Actually, a difficulty with this approach is that then, if both
destinations are specified, we don't know which one is to be used to map
the sources' writemasks. The ways out I see are to add another argument
to specify it, to assume that they are identical so either can be used
or to keep the current interface with which exactly one destination is
non-NULL (it's true that it is more constraining, but my, admittedly
probably poor, understanding of Matteo's intentions is that
optimizations like the one you say are going to happen at a lower level,
so I wouldn't bother for the time being).
Which one do you prefer?
Giovanni.
Jan. 26, 2022