Store under additional key.

git-svn-id: svn+ssh://svn.gna.org/svn/gnustep/libs/base/trunk@5519 72102866-910b-0410-8b05-ffd578937521
This commit is contained in:
Richard Frith-MacDonald 1999-12-15 13:03:40 +00:00
parent bf32e9366a
commit 5837aeb214

View file

@ -53,12 +53,12 @@ static BOOL _hostCacheEnabled = YES;
static NSMutableDictionary *_hostCache = nil;
@interface NSHost (Private)
- (id) _initWithHostEntry: (struct hostent*)entry;
- (id) _initWithHostEntry: (struct hostent*)entry key: (NSString*)key;
@end
@implementation NSHost (Private)
- (id) _initWithHostEntry: (struct hostent*)entry
- (id) _initWithHostEntry: (struct hostent*)entry key: (NSString*)name
{
int i;
char *ptr;
@ -112,6 +112,13 @@ static NSMutableDictionary *_hostCache = nil;
{
[_hostCache setObject: self forKey: key];
}
/*
* In addition to official names, use the name we were called with.
*/
if (name != nil)
{
[_hostCache setObject: self forKey: name];
}
}
return self;
@ -176,7 +183,7 @@ static NSMutableDictionary *_hostCache = nil;
h = gethostbyname((char*)[name cString]);
host = [[self alloc] _initWithHostEntry: h];
host = [[self alloc] _initWithHostEntry: h key: name];
AUTORELEASE(host);
}
[_hostCacheLock unlock];
@ -220,7 +227,7 @@ static NSMutableDictionary *_hostCache = nil;
if (addrOk == YES)
{
h = gethostbyaddr((char*)&hostaddr, sizeof(hostaddr), AF_INET);
host = [[self alloc] _initWithHostEntry: h];
host = [[self alloc] _initWithHostEntry: h key: address];
AUTORELEASE(host);
}
}