[prev in list] [next in list] [prev in thread] [next in thread]
List: wine-devel
Subject: Re: [PATCH 1/2] advapi32: HKCR merge: foundation
From: Alexandre Julliard <julliard () winehq ! org>
Date: 2013-09-27 9:13:19
Message-ID: 87had6630w.fsf () wine ! dyndns ! org
[Download RAW message or body]
George Stephanos <gaf.stephanos@gmail.com> writes:
> @@ -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;
> + }
> + }
You need some sort of free list instead of a linear search. 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.
> +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 );
The count needs to be protected by the critical section too.
Also please write a better subject line for the commit.
--
Alexandre Julliard
julliard@winehq.org
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic