Ben Collins-Sussman wrote:
> Ben Collins-Sussman <sussman@collab.net> writes:
>
>>Working on #1075, I noticed this:
>>
>>I see code in svn which loops over an apr_hash_t, yet code within the
>>loop potentially removes an item from the hash. Isn't this
>>dangrerous? Can't this mess up the hash iterator (apr_hash_index_t)?
>>
>>In particular, I'm looking at libsvn_wc/adm_ops.c:121.
>
> Hm, I shoulda checked the APR docs. They say:
>
> * @remark There is no restriction on adding or deleting hash entries during
> * an iteration (although the results may be unpredictable unless all you do
> * is delete the current entry) and multiple iterations can be in
> * progress at the same time.
That's a confusing @remark. I would suggest it be changed to one of these if one of these is correct:
* @remark During an iteration it is safe to delete the current hash entry,
* but not to delete any other entry or to add an entry.
* Multiple iterations may be in progress at the same time if none of them
* adds or deletes hash entries.
* @remark During an iteration it is safe to delete the current hash entry,
* and to add entries.
* Multiple iterations may be in progress at the same time if none of them
* deletes hash entries.
I.e. the remark should say what is guaranteed to be safe, not "you may do this but the results may be unpredictable".
- Julian
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@subversion.tigris.org
For additional commands, e-mail: dev-help@subversion.tigris.org
Received on Thu Sep 25 00:38:36 2003