String pointers

BlitzMax Forums/BlitzMax Programming/String pointers

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

unfortunatly doing that leaks memory try this

Strict

Type Test
	Field name:String
	Field StringVar:Byte Ptr
	
	Method toString1()
		Print "Name: " + name
		Print "StringVar: " + String.fromCString(StringVar) 
	End Method
	
End Type


Local teststring:Byte Ptr	= "Test Ptr".toCString()
Local aka:test 			= New test
aka.name	 		= "test"
aka.StringVar			= teststring

Print aka.tostring1() 


For Local n:Int=0 To 10000000
	Local ts:Byte Ptr= "Papa".toCString()
	MemCopy(teststring,ts,Len("Papa")+1)
	MemFree ts
	aka.tostring1()
Next 
MemFree teststring



and thry doing the same with your example without the memfree's when your code runs the memory used (as reported by a process explorer continually increases)

using the code I have posted here the mem usage stays stable