Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fixed a leak

  • Loading branch information...
commit fb43e4bdf92157751682dfb4002f443b304593aa 1 parent 7fc9013
@Soph Soph authored committed
Showing with 5 additions and 7 deletions.
  1. +5 −7 source/madvertise/MadvertiseUtilities.m
View
12 source/madvertise/MadvertiseUtilities.m
@@ -20,7 +20,6 @@ @implementation MadvertiseUtilities
+ (NSString *) getIP {
- NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init];
NSString *result = nil;
struct ifaddrs* addrs;
@@ -36,7 +35,7 @@ + (NSString *) getIP {
{
const struct sockaddr_in* dlAddr = (const struct sockaddr_in*) cursor->ifa_addr;
const uint8_t* base = (const uint8_t*)&dlAddr->sin_addr;
- ip = [[NSMutableString new] autorelease];
+ ip = [NSMutableString new];
for (int i = 0; i < 4; i++)
{
if (i != 0)
@@ -45,22 +44,21 @@ + (NSString *) getIP {
}
interface = [NSString stringWithFormat:@"%s", cursor->ifa_name];
if([interface isEqualToString:@"en0"] && result == nil) {
- result = ip;
+ result = [ip copy];
}
if(![interface isEqualToString:@"lo0"] && ![interface isEqualToString:@"en0"] && ![interface isEqualToString:@"fw0"] && ![interface isEqualToString:@"en1"] ) {
// NSLog(@"Interface %@", interface);
- result = ip;
+ result = [ip copy];
}
+ [ip release];
}
cursor = cursor->ifa_next;
}
freeifaddrs(addrs);
}
- [result retain];
- [pool release];
if(result == nil)
result = @"127.0.0.1";
- return result;
+ return [result autorelease];
}
static char base64[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_";
Please sign in to comment.
Something went wrong with that request. Please try again.