RString no longer allows NULL. (I have no idea how it took me so long to catch this.)

This commit is contained in:
Steve Checkoway
2007-02-16 07:28:43 +00:00
parent 46ca7f526a
commit 92fd82b630
2 changed files with 9 additions and 3 deletions
@@ -172,7 +172,8 @@ RString ArchHooks_darwin::GetMachineId() const
if( serial ) if( serial )
{ {
ret = CFStringGetCStringPtr( (CFStringRef)serial, kCFStringEncodingMacRoman ); const char *str = CFStringGetCStringPtr( (CFStringRef)serial, CFStringGetSystemEncoding() );
ret = str? str:"";
CFRelease( serial ); CFRelease( serial );
} }
IOObjectRelease( service ); IOObjectRelease( service );
@@ -339,7 +340,9 @@ RString ArchHooks::GetPreferredLanguage()
(lang = (CFStringRef)CFArrayGetValueAtIndex(languages, 0)) != NULL ) (lang = (CFStringRef)CFArrayGetValueAtIndex(languages, 0)) != NULL )
{ {
// MacRoman agrees with ASCII in the low-order 7 bits. // MacRoman agrees with ASCII in the low-order 7 bits.
ret = RString( CFStringGetCStringPtr(lang, kCFStringEncodingMacRoman), 2 ); const char *str = CFStringGetCStringPtr( lang, kCFStringEncodingMacRoman );
ASSERT( str );
ret = RString( str, 2 );
} }
CFRelease( languages ); CFRelease( languages );
+4 -1
View File
@@ -62,7 +62,10 @@ bool HIDDevice::Open( io_object_t device )
} }
if( object && CFGetTypeID(object) == CFStringGetTypeID() ) if( object && CFGetTypeID(object) == CFStringGetTypeID() )
m_sDescription = CFStringGetCStringPtr( CFStringRef(object), CFStringGetSystemEncoding() ); {
const char *str = CFStringGetCStringPtr( CFStringRef(object), CFStringGetSystemEncoding() );
m_sDescription = str? str:"";
}
if( m_sDescription == "" ) if( m_sDescription == "" )
m_sDescription = ssprintf( "%04x:%04x", vid, pid ); m_sDescription = ssprintf( "%04x:%04x", vid, pid );