Fix another memory leak with linphone_address_as_string_uri_only

This commit is contained in:
Yann Diorcet 2012-07-23 22:14:46 +02:00
parent 6950283052
commit 88144bc4b1
8 changed files with 35 additions and 15 deletions

View file

@ -209,12 +209,16 @@ static UICompositeViewDescription *compositeDescription = nil;
LinphoneAddress *from = [[[notif userInfo] objectForKey:@"from"] pointerValue];
ChatModel *chat = [[notif userInfo] objectForKey:@"chat"];
if(from != NULL && chat != NULL) {
if([[NSString stringWithUTF8String:linphone_address_as_string_uri_only(from)]
caseInsensitiveCompare:remoteAddress] == NSOrderedSame) {
[chat setRead:[NSNumber numberWithInt:1]];
[chat update];
[[NSNotificationCenter defaultCenter] postNotificationName:@"LinphoneTextReceived" object:self];
[tableController addChatEntry:chat];
char *fromStr = linphone_address_as_string_uri_only(from);
if(fromStr != NULL) {
if([[NSString stringWithUTF8String:fromStr]
caseInsensitiveCompare:remoteAddress] == NSOrderedSame) {
[chat setRead:[NSNumber numberWithInt:1]];
[chat update];
[[NSNotificationCenter defaultCenter] postNotificationName:@"LinphoneTextReceived" object:self];
[tableController addChatEntry:chat];
}
ms_free(fromStr);
}
} else {
[LinphoneLogger logc:LinphoneLoggerWarning format:"Invalid textReceivedEvent"];

View file

@ -157,7 +157,7 @@ static UICompositeViewDescription *compositeDescription = nil;
if(addr != NULL) {
BOOL useLinphoneAddress = true;
// contact name
const char* lAddress = linphone_address_as_string_uri_only(addr);
char* lAddress = linphone_address_as_string_uri_only(addr);
if(lAddress) {
NSString *normalizedSipAddress = [FastAddressBook normalizeSipURI:[NSString stringWithUTF8String:lAddress]];
contact = [[[LinphoneManager instance] fastAddressBook] getContact:normalizedSipAddress];
@ -166,6 +166,7 @@ static UICompositeViewDescription *compositeDescription = nil;
address = [FastAddressBook getContactDisplayName:contact];
useLinphoneAddress = false;
}
ms_free(lAddress);
}
if(useLinphoneAddress) {
const char* lDisplayName = linphone_address_get_display_name(addr);
@ -234,10 +235,11 @@ static UICompositeViewDescription *compositeDescription = nil;
if (addr != NULL) {
// contact name
const char* lAddress = linphone_address_as_string_uri_only(addr);
char* lAddress = linphone_address_as_string_uri_only(addr);
if(lAddress != NULL) {
[addressButton setTitle:[NSString stringWithUTF8String:lAddress] forState:UIControlStateNormal];
[addressButton setHidden:FALSE];
ms_free(lAddress);
} else {
[addressButton setHidden:TRUE];
}
@ -280,7 +282,9 @@ static UICompositeViewDescription *compositeDescription = nil;
addr = callLog->to;
}
const char* lAddress = linphone_address_as_string_uri_only(addr);
char* lAddress = linphone_address_as_string_uri_only(addr);
if(lAddress == NULL)
return;
NSString *displayName = nil;
if(contact != nil) {
@ -303,6 +307,7 @@ static UICompositeViewDescription *compositeDescription = nil;
[controller call:[NSString stringWithUTF8String:lAddress]];
}
}
ms_free(lAddress);
}
@end

View file

@ -137,7 +137,7 @@
if(addr != NULL) {
BOOL useLinphoneAddress = true;
// contact name
const char* lAddress = linphone_address_as_string_uri_only(addr);
char* lAddress = linphone_address_as_string_uri_only(addr);
if(lAddress) {
address = [NSString stringWithUTF8String:lAddress];
NSString *normalizedSipAddress = [FastAddressBook normalizeSipURI:address];
@ -146,6 +146,7 @@
displayName = [FastAddressBook getContactDisplayName:contact];
useLinphoneAddress = false;
}
ms_free(lAddress);
}
if(useLinphoneAddress) {
const char* lDisplayName = linphone_address_get_display_name(addr);

View file

@ -97,7 +97,7 @@
if (addr != NULL) {
BOOL useLinphoneAddress = true;
// contact name
const char* lAddress = linphone_address_as_string_uri_only(addr);
char* lAddress = linphone_address_as_string_uri_only(addr);
if(lAddress) {
NSString *normalizedSipAddress = [FastAddressBook normalizeSipURI:[NSString stringWithUTF8String:lAddress]];
ABRecordRef contact = [[[LinphoneManager instance] fastAddressBook] getContact:normalizedSipAddress];
@ -106,6 +106,7 @@
address = [FastAddressBook getContactDisplayName:contact];
useLinphoneAddress = false;
}
ms_free(lAddress);
}
if(useLinphoneAddress) {
const char* lDisplayName = linphone_address_get_display_name(addr);

View file

@ -330,15 +330,21 @@ static void linphone_iphone_registration_state(LinphoneCore *lc, LinphoneProxyCo
- (void)onTextReceived:(LinphoneCore *)lc room:(LinphoneChatRoom *)room from:(const LinphoneAddress *)from message:(const char *)message {
char *fromStr = linphone_address_as_string_uri_only(from);
if(fromStr == NULL)
return;
// Save message in database
ChatModel *chat = [[ChatModel alloc] init];
[chat setRemoteContact:[NSString stringWithUTF8String:linphone_address_as_string_uri_only(from)]];
[chat setRemoteContact:[NSString stringWithUTF8String:fromStr]];
[chat setMessage:[NSString stringWithUTF8String:message]];
[chat setDirection:[NSNumber numberWithInt:1]];
[chat setTime:[NSDate date]];
[chat setRead:[NSNumber numberWithInt:0]];
[chat create];
ms_free(fromStr);
// Post event
NSDictionary* dict = [[[NSDictionary alloc] initWithObjectsAndKeys:
[NSValue valueWithPointer:room], @"room",

View file

@ -171,7 +171,7 @@
if(addr != NULL) {
BOOL useLinphoneAddress = true;
// contact name
const char* lAddress = linphone_address_as_string_uri_only(addr);
char* lAddress = linphone_address_as_string_uri_only(addr);
if(lAddress) {
NSString *normalizedSipAddress = [FastAddressBook normalizeSipURI:[NSString stringWithUTF8String:lAddress]];
ABRecordRef contact = [[[LinphoneManager instance] fastAddressBook] getContact:normalizedSipAddress];
@ -180,6 +180,7 @@
address = [FastAddressBook getContactDisplayName:contact];
useLinphoneAddress = false;
}
ms_free(lAddress);
}
if(useLinphoneAddress) {
const char* lDisplayName = linphone_address_get_display_name(addr);

View file

@ -118,7 +118,7 @@
if(addr != NULL) {
BOOL useLinphoneAddress = true;
// contact name
const char* lAddress = linphone_address_as_string_uri_only(addr);
char* lAddress = linphone_address_as_string_uri_only(addr);
if(lAddress) {
NSString *normalizedSipAddress = [FastAddressBook normalizeSipURI:[NSString stringWithUTF8String:lAddress]];
ABRecordRef contact = [[[LinphoneManager instance] fastAddressBook] getContact:normalizedSipAddress];
@ -126,6 +126,7 @@
address = [FastAddressBook getContactDisplayName:contact];
useLinphoneAddress = false;
}
ms_free(lAddress);
}
if(useLinphoneAddress) {
const char* lDisplayName = linphone_address_get_display_name(addr);

View file

@ -483,7 +483,7 @@ static PhoneMainView* phoneMainViewInstance=nil;
if(addr != NULL) {
BOOL useLinphoneAddress = true;
// contact name
const char* lAddress = linphone_address_as_string_uri_only(addr);
char* lAddress = linphone_address_as_string_uri_only(addr);
if(lAddress) {
NSString *normalizedSipAddress = [FastAddressBook normalizeSipURI:[NSString stringWithUTF8String:lAddress]];
ABRecordRef contact = [[[LinphoneManager instance] fastAddressBook] getContact:normalizedSipAddress];
@ -491,6 +491,7 @@ static PhoneMainView* phoneMainViewInstance=nil;
address = [FastAddressBook getContactDisplayName:contact];
useLinphoneAddress = false;
}
ms_free(lAddress);
}
if(useLinphoneAddress) {
const char* lDisplayName = linphone_address_get_display_name(addr);