mirror of
https://gitlab.winehq.org/wine/vkd3d.git
synced 2024-11-21 16:46:41 -08:00
libs/vkd3d: Re-use vkd3d_array_reserve() in d3d12_fence_SetEventOnCompletion().
This commit is contained in:
parent
b224b6372c
commit
c558118f70
@ -179,23 +179,14 @@ static HRESULT STDMETHODCALLTYPE d3d12_fence_SetEventOnCompletion(ID3D12Fence *i
|
||||
}
|
||||
}
|
||||
|
||||
if (fence->event_array_size == fence->event_count)
|
||||
{
|
||||
unsigned int new_size = 2 * fence->event_array_size;
|
||||
struct vkd3d_waiting_event *new_events;
|
||||
|
||||
TRACE("Resizing waiting events array from %u to %u.\n", fence->event_array_size, new_size);
|
||||
|
||||
if (!(new_events = vkd3d_realloc(fence->events, new_size * sizeof(*fence->events))))
|
||||
if (!vkd3d_array_reserve((void **)&fence->events, &fence->events_size,
|
||||
fence->event_count + 1, sizeof(*fence->events)))
|
||||
{
|
||||
WARN("Failed to add event.\n");
|
||||
pthread_mutex_unlock(&fence->mutex);
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
|
||||
fence->event_array_size = new_size;
|
||||
fence->events = new_events;
|
||||
}
|
||||
|
||||
fence->events[fence->event_count].value = value;
|
||||
fence->events[fence->event_count].event = event;
|
||||
++fence->event_count;
|
||||
@ -280,12 +271,8 @@ static HRESULT d3d12_fence_init(struct d3d12_fence *fence, struct d3d12_device *
|
||||
if (flags)
|
||||
FIXME("Ignoring flags %#x.\n", flags);
|
||||
|
||||
fence->event_array_size = 2;
|
||||
if (!(fence->events = vkd3d_calloc(fence->event_array_size, sizeof(*fence->events))))
|
||||
{
|
||||
pthread_mutex_destroy(&fence->mutex);
|
||||
return E_OUTOFMEMORY;
|
||||
}
|
||||
fence->events = NULL;
|
||||
fence->events_size = 0;
|
||||
fence->event_count = 0;
|
||||
|
||||
fence->device = device;
|
||||
|
@ -69,9 +69,9 @@ struct d3d12_fence
|
||||
UINT64 value;
|
||||
pthread_mutex_t mutex;
|
||||
|
||||
unsigned int event_array_size;
|
||||
unsigned int event_count;
|
||||
struct vkd3d_waiting_event *events;
|
||||
size_t events_size;
|
||||
size_t event_count;
|
||||
|
||||
struct d3d12_device *device;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user