X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=sope-core%2FNGExtensions%2FNGHashMap.m;h=18a02b27f91e6e74b3cca410ed67a0af50f6e776;hb=da4fee939ad67e8da731714f06358d6bdd3ee617;hp=9767611fffa654a96556cd60cef499d58fb4bf59;hpb=4d91b8d73b64594d7d5c49ba480cfbadd44852c3;p=sope diff --git a/sope-core/NGExtensions/NGHashMap.m b/sope-core/NGExtensions/NGHashMap.m index 9767611f..18a02b27 100644 --- a/sope-core/NGExtensions/NGHashMap.m +++ b/sope-core/NGExtensions/NGHashMap.m @@ -49,32 +49,33 @@ static inline void checkForAddErrorMessage(id _self, id _object, id _key) { NSString *r; if (_key == nil) { - r = [NSString stringWithFormat:@"nil key to be added in HashMap with object %@", - _object ? _object : @""]; - ui = [NSDictionary dictionaryWithObjectsAndKeys: - _self, @"map", - _key ? _key : @"", - @"key", - _object ? _object : @"", - @"object", - nil]; + r = [[NSString alloc] initWithFormat: + @"nil key to be added in HashMap with object %@", + (_object != nil ? _object : (id)@"")]; + ui = [[NSDictionary alloc] initWithObjectsAndKeys: + _self, @"map", + _key ? _key : (id)@"", @"key", + _object ? _object : (id)@"", @"object", + nil]; exc = [NSException exceptionWithName:NSInvalidArgumentException reason:r userInfo:ui]; + [r release]; r = nil; + [ui release]; ui = nil; [exc raise]; } if (_object == nil) { - r = [NSString stringWithFormat: - @"nil object to be added in HashMap for key %@", - _key ? _key : @""]; - ui = [NSDictionary dictionaryWithObjectsAndKeys: - _self, @"map", - _key ? _key : @"", - @"key", - _object ? _object : @"", - @"object", - nil]; + r = [[NSString alloc] initWithFormat: + @"nil object to be added in HashMap for key %@", + _key ? _key : (id)@""]; + ui = [[NSDictionary alloc] initWithObjectsAndKeys: + _self, @"map", + _key ? _key : (id)@"", @"key", + _object ? _object : (id)@"", @"object", + nil]; exc = [NSException exceptionWithName:NSInvalidArgumentException reason:r userInfo:ui]; + [r release]; r = nil; + [ui release]; ui = nil; [exc raise]; } } @@ -87,18 +88,18 @@ static inline void checkForRemoveErrorMessage(id _self, id _object, id _key) { if (_object != nil && _key != nil) return; - r = [NSString stringWithFormat: - @"nil object to be removed in HashMap for key %@", - _key ? _key : @""]; - ui = [NSDictionary dictionaryWithObjectsAndKeys: - _self, @"map", - _key ? _key : @"", - @"key", - _object ? _object : @"", - @"object", - nil]; + r = [[NSString alloc] initWithFormat: + @"nil object to be removed in HashMap for key %@", + _key ? _key : (id)@""]; + ui = [[NSDictionary alloc] initWithObjectsAndKeys: + _self, @"map", + _key ? _key : (id)@"", @"key", + _object ? _object : (id)@"", @"object", + nil]; exc = [NSException exceptionWithName:NSInvalidArgumentException reason:r userInfo:ui]; + [ui release]; ui = nil; + [r release]; r = nil; [exc raise]; } @@ -720,7 +721,7 @@ static inline unsigned __countObjectsForKey(NGHashMap *self, id _key) { if ((root = [self __structForKey:_key]) == NULL) { if (_index > 0) { [NSException raise:NSRangeException - format:@"index %d out of range in map 0x%08X", + format:@"index %d out of range in map 0x%p", _index, self]; return; } @@ -732,7 +733,7 @@ static inline unsigned __countObjectsForKey(NGHashMap *self, id _key) { else { if (!(_index < root->count)) { [NSException raise:NSRangeException - format:@"index %d out of range in map 0x%08X length %d", + format:@"index %d out of range in map 0x%p length %d", _index, self, root->count]; return; }