<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Fri, Sep 27, 2013 at 11:13 AM, Alexandre Julliard <span dir="ltr"><<a href="mailto:julliard@winehq.org" target="_blank" onclick="window.open('https://mail.google.com/mail/?view=cm&tf=1&to=julliard@winehq.org&cc=&bcc=&su=&body=','_blank');return false;">julliard@winehq.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">George Stephanos <<a href="mailto:gaf.stephanos@gmail.com" onclick="window.open('https://mail.google.com/mail/?view=cm&tf=1&to=gaf.stephanos@gmail.com&cc=&bcc=&su=&body=','_blank');return false;">gaf.stephanos@gmail.com</a>> writes:<br>

<br>
> @@ -224,13 +248,138 @@ static NTSTATUS open_key( HKEY *retkey, ACCESS_MASK access, OBJECT_ATTRIBUTES *a<br>
><br>
> �}<br>
><br>
> +static LSTATUS create_hkcr_struct( HKEY *hkey, opened_hkcr_t **hkcr )<br>
> +{<br>
> + � �UINT_PTR handle = nb_hkcr_handles, i;<br>
> + � �LSTATUS ret = ERROR_SUCCESS;<br>
> +<br>
> + � �EnterCriticalSection( &hkcr_handles_cs );<br>
> +<br>
> + � �for (i = 0; i < nb_hkcr_handles; i++)<br>
> + � �{<br>
> + � � � �if (!hkcr_handles[i])<br>
> + � � � �{<br>
> + � � � � � �handle = i;<br>
> + � � � � � �break;<br>
> + � � � �}<br>
> + � �}<br>
<br>
</div>You need some sort of free list instead of a linear search.</blockquote><div>�</div><div>Alright.�</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Also you can�probably avoid one level of pointers and store objects directly.<br></blockquote><div><br></div><div>I thought about this. If I store objects directly, accessing any would require a lock on the whole table so I guarantee it's not moved or reallocated elsewhere. This would obviously be pretty slow.</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<br>
Returning a pointer to the object outside of the critical section is not<br>
a good idea.�</blockquote><div><br></div><div>The critical section just protects the table and not the handles/structs themselves.</div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div class="im"><br>
> +static HKEY resolve_hkcr( HKEY hkey )<br>
> +{<br>
> + � �HKEY ret;<br>
> + � �UINT_PTR idx = (UINT_PTR)hkey >> 2;<br>
> + � �opened_hkcr_t *hkcr;<br>
> + � �if (idx <= nb_hkcr_handles)<br>
> + � �{<br>
> + � � � �EnterCriticalSection( &hkcr_handles_cs );<br>
<br>
</div>The count needs to be protected by the critical section too.<br>
<br>
Also please write a better subject line for the commit.<br>
<span class="HOEnZb"><font color="#888888"><br>
--<br>
Alexandre Julliard<br>
<a href="mailto:julliard@winehq.org" onclick="window.open('https://mail.google.com/mail/?view=cm&tf=1&to=julliard@winehq.org&cc=&bcc=&su=&body=','_blank');return false;">julliard@winehq.org</a><br>

</font></span></blockquote></div><br></div></div>