@@ -18,10 +18,12 @@ #include #import "OFMutableDictionary_hashtable.h" +#import "autorelease.h" + static struct { Class isa; } placeholder; @interface OFMutableDictionary_placeholder: OFDictionary @@ -187,10 +189,23 @@ - (void)removeObjectForKey: (id)key { [self doesNotRecognizeSelector: _cmd]; abort(); } + +- (void)removeAllObjects +{ + void *pool = objc_autoreleasePoolPush(); + OFArray *keys = [self allKeys]; + OFEnumerator *enumerator = [keys objectEnumerator]; + id key; + + while ((key = [enumerator nextObject]) != nil) + [self removeObjectForKey: key]; + + objc_autoreleasePoolPop(pool); +} - copy { return [[OFDictionary alloc] initWithDictionary: self]; }