From d29e59a145c5d0b6138e7de297ab697e97810199 Mon Sep 17 00:00:00 2001 From: Jacek Caban Date: Mon, 12 Sep 2016 13:44:09 +0200 Subject: [PATCH] rbtree.h: Take wine_rb_entry as wine_rb_remove argument type and add new wine_rb_remove_key helper using key. Signed-off-by: Jacek Caban Signed-off-by: Henri Verbeet Signed-off-by: Matteo Bruni Signed-off-by: Alexandre Julliard --- dlls/d3d11/state.c | 8 ++++---- dlls/d3dcompiler_43/utils.c | 2 +- dlls/ntoskrnl.exe/ntoskrnl.c | 2 +- dlls/wined3d/glsl_shader.c | 2 +- include/wine/rbtree.h | 12 ++++++++---- programs/winedevice/device.c | 4 ++-- 6 files changed, 17 insertions(+), 13 deletions(-) diff --git a/dlls/d3d11/state.c b/dlls/d3d11/state.c index d702d98c35a..1aa9af5e437 100644 --- a/dlls/d3d11/state.c +++ b/dlls/d3d11/state.c @@ -78,7 +78,7 @@ static ULONG STDMETHODCALLTYPE d3d11_blend_state_Release(ID3D11BlendState *iface { struct d3d_device *device = impl_from_ID3D11Device(state->device); wined3d_mutex_lock(); - wine_rb_remove(&device->blend_states, &state->desc); + wine_rb_remove_key(&device->blend_states, &state->desc); ID3D11Device_Release(state->device); wined3d_private_store_cleanup(&state->private_store); wined3d_mutex_unlock(); @@ -379,7 +379,7 @@ static ULONG STDMETHODCALLTYPE d3d11_depthstencil_state_Release(ID3D11DepthStenc { struct d3d_device *device = impl_from_ID3D11Device(state->device); wined3d_mutex_lock(); - wine_rb_remove(&device->depthstencil_states, &state->desc); + wine_rb_remove_key(&device->depthstencil_states, &state->desc); ID3D11Device_Release(state->device); wined3d_private_store_cleanup(&state->private_store); wined3d_mutex_unlock(); @@ -663,7 +663,7 @@ static ULONG STDMETHODCALLTYPE d3d11_rasterizer_state_Release(ID3D11RasterizerSt { struct d3d_device *device = impl_from_ID3D11Device(state->device); wined3d_mutex_lock(); - wine_rb_remove(&device->rasterizer_states, &state->desc); + wine_rb_remove_key(&device->rasterizer_states, &state->desc); wined3d_rasterizer_state_decref(state->wined3d_state); wined3d_private_store_cleanup(&state->private_store); wined3d_mutex_unlock(); @@ -963,7 +963,7 @@ static ULONG STDMETHODCALLTYPE d3d11_sampler_state_Release(ID3D11SamplerState *i wined3d_mutex_lock(); wined3d_sampler_decref(state->wined3d_sampler); - wine_rb_remove(&device->sampler_states, &state->desc); + wine_rb_remove_key(&device->sampler_states, &state->desc); ID3D11Device_Release(state->device); wined3d_private_store_cleanup(&state->private_store); wined3d_mutex_unlock(); diff --git a/dlls/d3dcompiler_43/utils.c b/dlls/d3dcompiler_43/utils.c index 54f359ea16a..79f3be8840d 100644 --- a/dlls/d3dcompiler_43/utils.c +++ b/dlls/d3dcompiler_43/utils.c @@ -2483,7 +2483,7 @@ void add_function_decl(struct wine_rb_tree *funcs, char *name, struct hlsl_ir_fu d3dcompiler_free(name); return; } - wine_rb_remove(&func->overloads, decl->parameters); + wine_rb_remove(&func->overloads, old_entry); free_function_decl(old_decl); } wine_rb_put(&func->overloads, decl->parameters, &decl->entry); diff --git a/dlls/ntoskrnl.exe/ntoskrnl.c b/dlls/ntoskrnl.exe/ntoskrnl.c index 91e08d923cd..d5236e6c4e0 100644 --- a/dlls/ntoskrnl.exe/ntoskrnl.c +++ b/dlls/ntoskrnl.exe/ntoskrnl.c @@ -933,7 +933,7 @@ void WINAPI IoDeleteDriver( DRIVER_OBJECT *driver_object ) TRACE( "(%p)\n", driver_object ); EnterCriticalSection( &drivers_cs ); - wine_rb_remove( &wine_drivers, &driver_object->DriverName ); + wine_rb_remove_key( &wine_drivers, &driver_object->DriverName ); LeaveCriticalSection( &drivers_cs ); RtlFreeUnicodeString( &driver_object->DriverName ); diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index 863f17f4043..e605cb9f1cc 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -5389,7 +5389,7 @@ static void delete_glsl_program_entry(struct shader_glsl_priv *priv, const struc key.vs_id = entry->vs.id; key.gs_id = entry->gs.id; key.ps_id = entry->ps.id; - wine_rb_remove(&priv->program_lookup, &key); + wine_rb_remove_key(&priv->program_lookup, &key); GL_EXTCALL(glDeleteProgram(entry->id)); if (entry->vs.id) diff --git a/include/wine/rbtree.h b/include/wine/rbtree.h index bdf1a85a7f1..634893dfcac 100644 --- a/include/wine/rbtree.h +++ b/include/wine/rbtree.h @@ -226,13 +226,11 @@ static inline int wine_rb_put(struct wine_rb_tree *tree, const void *key, struct return 0; } -static inline void wine_rb_remove(struct wine_rb_tree *tree, const void *key) +static inline void wine_rb_remove(struct wine_rb_tree *tree, struct wine_rb_entry *entry) { - struct wine_rb_entry *entry, *iter, *child, *parent, *w; + struct wine_rb_entry *iter, *child, *parent, *w; int need_fixup; - if (!(entry = wine_rb_get(tree, key))) return; - if (entry->right && entry->left) for(iter = entry->right; iter->left; iter = iter->left); else @@ -337,4 +335,10 @@ static inline void wine_rb_remove(struct wine_rb_tree *tree, const void *key) if (tree->root) tree->root->flags &= ~WINE_RB_FLAG_RED; } +static inline void wine_rb_remove_key(struct wine_rb_tree *tree, const void *key) +{ + struct wine_rb_entry *entry = wine_rb_get(tree, key); + if (entry) wine_rb_remove(tree, entry); +} + #endif /* __WINE_WINE_RBTREE_H */ diff --git a/programs/winedevice/device.c b/programs/winedevice/device.c index b261a4a78b6..44aa1a0f16a 100644 --- a/programs/winedevice/device.c +++ b/programs/winedevice/device.c @@ -350,7 +350,7 @@ static NTSTATUS unload_driver( struct wine_rb_entry *entry, BOOL destroy ) return STATUS_SUCCESS; } - wine_rb_remove( &wine_drivers, driver->name ); + wine_rb_remove( &wine_drivers, &driver->entry ); memset( &environment, 0, sizeof(environment) ); environment.Version = 1; @@ -405,7 +405,7 @@ static void WINAPI async_create_driver( PTP_CALLBACK_INSTANCE instance, void *co error: EnterCriticalSection( &drivers_cs ); - wine_rb_remove( &wine_drivers, driver->name ); + wine_rb_remove( &wine_drivers, &driver->entry ); LeaveCriticalSection( &drivers_cs ); set_service_status( driver->handle, SERVICE_STOPPED, 0 );