[futurebasic] Re: [FB] MySQL - query with CFArrayMutableRef - works great!

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

From: Robert Purves <listrp@...>
Date: Wed, 3 Aug 2011 17:46:00 +1200
Thomas Peters wrote:

> The interesting bridge is apple's CoreFoundation.  I am thinking that the mysql libraries could also be implemented in FB, but that would be a big task.  In the mean time, I am going to continue working on a generic set of functions that use CoreFoundation as the bridge.

Sounds interesting.

Your demo currently leaks memory, because it creates many CF objects but releases none. One leak is fixed here:
...
aCol = CFStringCreateWithCString( NULL, row[i], kCFStringEncodingUTF8 );
CFArrayAppendValue( cols, aCol );
CFRelease( aCol ); // ***release after using what we created***
...

Recommended reading
<developer.apple.com/library/mac/#documentation/CoreFoundation/Conceptual/CFMemoryMgmt/CFMemoryMgmt.html>

A useful aid to correct CF memory management is to choose clang (analysis) as the compiler in FBtoC or project preferences.

Robert P.