[futurebasic] Re: [FB] Function Return Values. What if?

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : December 2011 : Group Archive : Group : All Groups

From: Brian S <fblistserve@...>
Date: Wed, 7 Dec 2011 10:00:49 -0700
On Dec 7, 2011, at 3:10 AM, Bernie wrote:

> 
>> However, something like this would be bad:
>> 	local fn CopyMyString( string as CFStringRef ) as CFStringRef
>> 	end fn = fn CFStringCreateCopy( _kCFAllocatorDefault, string )
>> 	fn CopyMyString( @"alpha" )
> 
> Really bad:
> 	local fn GetMyString( string as CFStringRef ) as CFStringRef
> 	end fn = fn CFStringCreateCopy( _kCFAllocatorDefault, string )
> 	fn GetMyString( @"alpha" )
> 
> bw
> 

Bad = memory leaks in these cases shown by Bernie. There is no way to release the CFStringRef if the returned ref is ignored.


Brian S