[webkit-dev] about WTF::HashMap::iterator

Darin Adler darin at apple.com
Thu Apr 9 08:31:51 PDT 2009

On Apr 8, 2009, at 9:02 PM, ZHOU Xiao-bo wrote:

> it's not about memory reallocation or element shift, but it's  
> because the
> member variable 'm_table' in WTF::HashTable::iterator may become NULL
> if there is only one entry in the HashMap before you call  
> remove( olditer ).

This is a misunderstanding.

The m_value data member in HashTable::iterator is a debugging  
mechanism, to make debug versions of the software immediately drop  
into the debugger in cases where a release version would usually work,  
but occasionally fail. It turns hard-to-find subtle bugs with  
incorrect use of hash table iterators into bugs you can easily  
immediately find.

m_table becomes 0 any time the hash table changes in a way that  
invalidates iterators; it has nothing to do with the number of entries  
in the table.

     -- Darin

More information about the webkit-dev mailing list