Using callbacks in a DLL

BlitzMax Forums/BlitzMax Programming/Using callbacks in a DLL

Interesting...

Here is the section in the dll that calls the callback:
	If AppLogCallback<>Null
		'If RETURNSTRING<>Null MemFree RETURNSTRING
		RETURNSTRING=s.tocstring()
		GCSuspend()
		AppLogCallback(RETURNSTRING,flags)
		GCResume()
		Return
	EndIf


RETURNSTRING is a global byte ptr. It is used to return a string value from the dll.

A crash occurs when I use MemFree on the variable RETURNSTRING. Actually, a crash occurs in a different unrelated function, indicating that this probably screws up memory somewhere.

What is the proper procedure to use a string this way? Does the byte ptr need to be freed if I am assigning it to a new CString?