AllocateStructure() / FreeStructure()
Posted: Fri Sep 17, 2010 2:23 pm
Some convenience functions would be nice to have:
If not, a simpler change, is to make InitializeStructure() return the pointer address it was given. We can then make our own macro:
Code: Select all
AllocateStructure(Typename) =
*P = AllocateMemory(SizeOf(TypeName))
InitializeStructure(*P, TypeName)
Return P
Code: Select all
FreeStructure(*P, Typename) =
ClearStructure(*P, TypeName)
FreeMemory(*P)
Code: Select all
Macro AllocateStructure(Typename)
InitializeStructure(AllocateMemory(SizeOf(Typename)), Typename)
EndMacro