@@ -89,11 +89,12 @@ } return self; } -- initWithDictionary: (OFDictionary*)dictionary +- _initWithDictionary: (OFDictionary*)dictionary + copyKeys: (BOOL)copyKeys { self = [super init]; @try { uint32_t i; @@ -110,19 +111,21 @@ size = dictionary->size; count = dictionary->count; for (i = 0; i < size; i++) { - id key; + id key; struct of_dictionary_bucket *bucket; if (dictionary->data[i] == NULL || dictionary->data[i] == DELETED) continue; bucket = [self allocMemoryWithSize: sizeof(*bucket)]; - key = [dictionary->data[i]->key copy]; + key = (copyKeys + ? [dictionary->data[i]->key copy] + : [dictionary->data[i]->key retain]); @try { [dictionary->data[i]->object retain]; } @catch (id e) { [key release]; @@ -140,10 +143,16 @@ @throw e; } return self; } + +- initWithDictionary: (OFDictionary*)dictionary +{ + return [self _initWithDictionary: dictionary + copyKeys: YES]; +} - initWithObject: (id)object forKey: (id )key { self = [super init]; @@ -781,11 +790,11 @@ OFEnumerator *keyEnumerator, *objectEnumerator; id key, object; size_t i; if (count == 0) - return @"{}"; + return @"{()}"; ret = [OFMutableString stringWithString: @"{\n"]; pool = [[OFAutoreleasePool alloc] init]; keyEnumerator = [self keyEnumerator]; objectEnumerator = [self objectEnumerator];