You need to free the ToCString().
Read this topic: http://www.blitzbasic.com/Community/posts.php?topic=53269
Read this topic: http://www.blitzbasic.com/Community/posts.php?topic=53269
Hi,
Here's the story:
String.ToCString() and String.ToWString() return pointers that you must manually free yourself using MemFree.
The $Z data type can only be used with function parameters, and automagically handles the ToCString/MemFree stuff for you - it does not actually use GC at all.
The $Z setup assumes that the receiving c function does NOT 'hold onto' or otherwise use the c string after the function returns. In other words, $Z can be thought of as 'const char *'.
I did briefly consider getting rid of $Z altogether (and forcing everyone to use ToCString/MemFree) but realized it would require quite a module overhaul to achieve.
I'll probably add $W at a later date too.
Bye,
Mark Sibly
WinXP, DX9.0b, P4/3G, 512M, Radeon 9800
MacOS10.3, G5/1.8G, 768M, GeForce 6800 Ultra
Here's the story:
String.ToCString() and String.ToWString() return pointers that you must manually free yourself using MemFree.
The $Z data type can only be used with function parameters, and automagically handles the ToCString/MemFree stuff for you - it does not actually use GC at all.
The $Z setup assumes that the receiving c function does NOT 'hold onto' or otherwise use the c string after the function returns. In other words, $Z can be thought of as 'const char *'.
I did briefly consider getting rid of $Z altogether (and forcing everyone to use ToCString/MemFree) but realized it would require quite a module overhaul to achieve.
I'll probably add $W at a later date too.
Bye,
Mark Sibly
WinXP, DX9.0b, P4/3G, 512M, Radeon 9800
MacOS10.3, G5/1.8G, 768M, GeForce 6800 Ultra