MemoryAllocation

Everything else that doesn't fall into one of the other PB categories.
Andras
User
User
Posts: 34
Joined: Wed Oct 27, 2004 6:58 am
Location: Germany

MemoryAllocation

Post by Andras »

Hi, I use the following code to indirectly be able to pass a structure as a ProcedureReturn:


Structure MYSTRUC
x.f
y.f
EndStructure

Procedure.l Something()
*out.mystruc=AllocateMemory(SizeOf(mystruc))
*out\x=0.5
*out\y=1.25
ProcedureReturn *out
EndProcedure

CopyMemory(something(),test.mystruc,SizeOf(mystruc))

Debug test\x
Debug test\y


I'm wondering, if the allocated memory will be discarded by PureBasic (since it is now linked with 'test'), or if I have to do a "FreeMemory()".
Manolo
User
User
Posts: 75
Joined: Fri Apr 25, 2003 7:06 pm
Location: Spain

Post by Manolo »

This is more apropiate:

Code: Select all

Structure MYSTRUC 
x.f 
y.f 
EndStructure 

Procedure.l Something(*MYSTRUC.mystruc) 
*mystruc\x=0.5 
*mystruc\y=1.25 
ProcedureReturn  
EndProcedure 

Something(@test.MYSTRUC) 

Debug test\x 
Debug test\y 

Manolo
Return to the forum
Post Reply