From: Rémi Bernon rbernon@codeweavers.com
Wine-Bug: https://bugs.winehq.org/show_bug.cgi?id=55773 --- dlls/wined3d/resource.c | 14 ++++---------- dlls/wined3d/wined3d_private.h | 3 ++- 2 files changed, 6 insertions(+), 11 deletions(-)
diff --git a/dlls/wined3d/resource.c b/dlls/wined3d/resource.c index 9d3fd0a426d..c7bf989286c 100644 --- a/dlls/wined3d/resource.c +++ b/dlls/wined3d/resource.c @@ -331,8 +331,7 @@ void CDECL wined3d_resource_preload(struct wined3d_resource *resource)
static BOOL wined3d_resource_allocate_sysmem(struct wined3d_resource *resource) { - void **p; - SIZE_T align = RESOURCE_ALIGNMENT - 1 + sizeof(*p); + static const SIZE_T align = RESOURCE_ALIGNMENT - 1; void *mem;
if (!(mem = heap_alloc_zero(resource->size + align))) @@ -341,10 +340,7 @@ static BOOL wined3d_resource_allocate_sysmem(struct wined3d_resource *resource) return FALSE; }
- p = (void **)(((ULONG_PTR)mem + align) & ~(RESOURCE_ALIGNMENT - 1)) - 1; - *p = mem; - - resource->heap_memory = ++p; + resource->heap_memory = mem;
return TRUE; } @@ -359,12 +355,10 @@ BOOL wined3d_resource_prepare_sysmem(struct wined3d_resource *resource)
void wined3d_resource_free_sysmem(struct wined3d_resource *resource) { - void **p = resource->heap_memory; - - if (!p) + if (!resource->heap_memory) return;
- heap_free(*(--p)); + heap_free(resource->heap_memory); resource->heap_memory = NULL; }
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 9fc5b9b2f16..031e3d7abd6 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -3266,7 +3266,8 @@ void wined3d_resource_memory_colour_fill(struct wined3d_resource *resource,
static inline void *wined3d_resource_get_sysmem(const struct wined3d_resource *resource) { - return resource->heap_memory; + static const SIZE_T align = RESOURCE_ALIGNMENT - 1; + return (void *)(((ULONG_PTR)resource->heap_memory + align) & ~align); }
#define WINED3D_LOCATION_DISCARDED 0x00000001