mirror of
https://github.com/gnustep/libs-base.git
synced 2025-04-23 09:04:13 +00:00
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:
parent
bf32e9366a
commit
5837aeb214
1 changed files with 11 additions and 4 deletions
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue