Huw Davies : winepulse: Return offsets rather than ptrs to the strings.
Alexandre Julliard
julliard at winehq.org
Thu Apr 21 15:21:38 CDT 2022
Module: wine
Branch: master
Commit: 5199420f4608ffe5036fc34225332f535cf30d19
URL: https://source.winehq.org/git/wine.git/?a=commit;h=5199420f4608ffe5036fc34225332f535cf30d19
Author: Huw Davies <huw at codeweavers.com>
Date: Thu Apr 21 15:51:56 2022 +0100
winepulse: Return offsets rather than ptrs to the strings.
This will make the Wow64 syscall rather simpler.
Signed-off-by: Huw Davies <huw at codeweavers.com>
Signed-off-by: Jacek Caban <jacek at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/winepulse.drv/mmdevdrv.c | 9 ++++++---
dlls/winepulse.drv/pulse.c | 17 ++++++++---------
dlls/winepulse.drv/unixlib.h | 4 ++--
3 files changed, 16 insertions(+), 14 deletions(-)
diff --git a/dlls/winepulse.drv/mmdevdrv.c b/dlls/winepulse.drv/mmdevdrv.c
index 4a0ee70ee92..18009435f1f 100644
--- a/dlls/winepulse.drv/mmdevdrv.c
+++ b/dlls/winepulse.drv/mmdevdrv.c
@@ -457,13 +457,16 @@ HRESULT WINAPI AUDDRV_GetEndpointIDs(EDataFlow flow, WCHAR ***ids_out, GUID **ke
}
for (i = 0; i < params.num; i++) {
- unsigned int size = (wcslen(params.endpoints[i].name) + 1) * sizeof(WCHAR);
+ WCHAR *name = (WCHAR *)((char *)params.endpoints + params.endpoints[i].name);
+ char *pulse_name = (char *)params.endpoints + params.endpoints[i].pulse_name;
+ unsigned int size = (wcslen(name) + 1) * sizeof(WCHAR);
+
if (!(ids[i] = HeapAlloc(GetProcessHeap(), 0, size))) {
params.result = E_OUTOFMEMORY;
break;
}
- memcpy(ids[i], params.endpoints[i].name, size);
- get_device_guid(drv_key, flow, params.endpoints[i].pulse_name, &guids[i]);
+ memcpy(ids[i], name, size);
+ get_device_guid(drv_key, flow, pulse_name, &guids[i]);
}
if (drv_key)
RegCloseKey(drv_key);
diff --git a/dlls/winepulse.drv/pulse.c b/dlls/winepulse.drv/pulse.c
index 6312ac58ebc..06047a21944 100644
--- a/dlls/winepulse.drv/pulse.c
+++ b/dlls/winepulse.drv/pulse.c
@@ -253,12 +253,11 @@ static NTSTATUS pulse_get_endpoint_ids(void *args)
struct list *list = (params->flow == eRender) ? &g_phys_speakers : &g_phys_sources;
struct endpoint *endpoint = params->endpoints;
DWORD len, name_len, needed;
+ unsigned int offset;
PhysDevice *dev;
- char *ptr;
params->num = list_count(list);
- needed = params->num * sizeof(*params->endpoints);
- ptr = (char*)(endpoint + params->num);
+ offset = needed = params->num * sizeof(*params->endpoints);
LIST_FOR_EACH_ENTRY(dev, list, PhysDevice, entry) {
name_len = lstrlenW(dev->name) + 1;
@@ -266,12 +265,12 @@ static NTSTATUS pulse_get_endpoint_ids(void *args)
needed += name_len * sizeof(WCHAR) + ((len + 1) & ~1);
if (needed <= params->size) {
- endpoint->name = (WCHAR*)ptr;
- memcpy(endpoint->name, dev->name, name_len * sizeof(WCHAR));
- ptr += name_len * sizeof(WCHAR);
- endpoint->pulse_name = ptr;
- memcpy(endpoint->pulse_name, dev->pulse_name, len);
- ptr += (len + 1) & ~1;
+ endpoint->name = offset;
+ memcpy((char *)params->endpoints + offset, dev->name, name_len * sizeof(WCHAR));
+ offset += name_len * sizeof(WCHAR);
+ endpoint->pulse_name = offset;
+ memcpy((char *)params->endpoints + offset, dev->pulse_name, len);
+ offset += (len + 1) & ~1;
endpoint++;
}
}
diff --git a/dlls/winepulse.drv/unixlib.h b/dlls/winepulse.drv/unixlib.h
index 4780943c4eb..f224f26c909 100644
--- a/dlls/winepulse.drv/unixlib.h
+++ b/dlls/winepulse.drv/unixlib.h
@@ -41,8 +41,8 @@ struct pulse_config
struct endpoint
{
- WCHAR *name;
- char *pulse_name;
+ unsigned int name;
+ unsigned int pulse_name;
};
struct main_loop_params
More information about the wine-cvs
mailing list