@@ -585,21 +585,23 @@ } - (OFEnumerator*)objectEnumerator { return [[[OFDictionaryObjectEnumerator alloc] - initWithData: data - size: size - mutationsPointer: NULL] autorelease]; + initWithDictionary: self + data: data + size: size + mutationsPointer: NULL] autorelease]; } - (OFEnumerator*)keyEnumerator { return [[[OFDictionaryKeyEnumerator alloc] - initWithData: data - size: size - mutationsPointer: NULL] autorelease]; + initWithDictionary: self + data: data + size: size + mutationsPointer: NULL] autorelease]; } #ifdef OF_HAVE_BLOCKS - (void)enumerateKeysAndObjectsUsingBlock: (of_dictionary_enumeration_block_t)block @@ -735,38 +737,51 @@ return ret; } @end @implementation OFDictionaryEnumerator -- initWithData: (struct of_dictionary_bucket**)data_ - size: (uint32_t)size_ - mutationsPointer: (unsigned long*)mutationsPtr_ +- initWithDictionary: (OFDictionary*)dictionary_ + data: (struct of_dictionary_bucket**)data_ + size: (uint32_t)size_ + mutationsPointer: (unsigned long*)mutationsPtr_ { self = [super init]; + dictionary = [dictionary_ retain]; data = data_; size = size_; mutations = (mutationsPtr_ != NULL ? *mutationsPtr_ : 0); mutationsPtr = mutationsPtr_; return self; } + +- (void)dealloc +{ + [dictionary release]; + + [super dealloc]; +} - (void)reset { if (mutationsPtr != NULL && *mutationsPtr != mutations) - @throw [OFEnumerationMutationException newWithClass: isa]; + @throw [OFEnumerationMutationException + newWithClass: isa + object: dictionary]; pos = 0; } @end @implementation OFDictionaryObjectEnumerator - (id)nextObject { if (mutationsPtr != NULL && *mutationsPtr != mutations) - @throw [OFEnumerationMutationException newWithClass: isa]; + @throw [OFEnumerationMutationException + newWithClass: isa + object: dictionary]; for (; pos < size && (data[pos] == NULL || data[pos] == DELETED); pos++); if (pos < size) @@ -778,11 +793,13 @@ @implementation OFDictionaryKeyEnumerator - (id)nextObject { if (mutationsPtr != NULL && *mutationsPtr != mutations) - @throw [OFEnumerationMutationException newWithClass: isa]; + @throw [OFEnumerationMutationException + newWithClass: isa + object: dictionary]; for (; pos < size && (data[pos] == NULL || data[pos] == DELETED); pos++); if (pos < size)