quote:
Originally posted by CookieRevised
PS2: Will be done automatically as soon as the function ends since the two are local variables though.
code:
function TraceWin32Error(){
var LastError = Interop.GetLastError();
if(LastError != 0){
var MsgBuffer = Interop.Allocate(1024);
Interop.Call("Kernel32", "FormatMessageW", 0x1000, 0, LastError, 0, MsgBuffer, 1024, 0);
Debug.Trace(MsgBuffer.ReadString(0));
MsgBuffer.Size = 0; //Release the allocated memory now
}
}
Why does Patchou do it in his example if its not needed?
Aside from it being good practise to get used to.