George Stephanos <gaf.stephanos@gmail.com> writes:You need some sort of free list instead of a linear search.
> @@ -224,13 +248,138 @@ static NTSTATUS open_key( HKEY *retkey, ACCESS_MASK access, OBJECT_ATTRIBUTES *a
>
> }
>
> +static LSTATUS create_hkcr_struct( HKEY *hkey, opened_hkcr_t **hkcr )
> +{
> + UINT_PTR handle = nb_hkcr_handles, i;
> + LSTATUS ret = ERROR_SUCCESS;
> +
> + EnterCriticalSection( &hkcr_handles_cs );
> +
> + for (i = 0; i < nb_hkcr_handles; i++)
> + {
> + if (!hkcr_handles[i])
> + {
> + handle = i;
> + break;
> + }
> + }
Also you can probably avoid one level of pointers and store objects directly.
Returning a pointer to the object outside of the critical section is not
a good idea.
The count needs to be protected by the critical section too.
> +static HKEY resolve_hkcr( HKEY hkey )
> +{
> + HKEY ret;
> + UINT_PTR idx = (UINT_PTR)hkey >> 2;
> + opened_hkcr_t *hkcr;
> + if (idx <= nb_hkcr_handles)
> + {
> + EnterCriticalSection( &hkcr_handles_cs );
Also please write a better subject line for the commit.
--
Alexandre Julliard
julliard@winehq.org