> Hi,
> 
> i study the cases of pointers and i found at this page
> http://www.yolinux.com/TUTORIALS/C++MemoryCorruptionAndMemoryLeaks.html
> 
> cases of program crashes from bad usage of pointers.
> 
> i made a test for
> Attempting to write to memory already freed.
> 
> ---------------------------
> ' Gambas module file
> 
> Public Sub Main()
> 
> Dim pPointer As Pointer
> Dim hMemory As Stream
> 
> pPointer = Alloc(SizeOf(gb.Integer))
> hMemory = Memory pPointer For Read Write
> 
> Print pPointer
> 
> Free(pPointer)
> 
> Write #hMemory, 10 As Integer
> 
> Print pPointer
> Print Int@(pPointer)
> Print pPointer
> 
> End
> ---------------------------
> 
> in this example i free the pointer and then try to write to it.
> The result is that i can write and read normally after Free(pPointer)
> 
> Is this ok?

Yes.

Freed memory is not made forbidden automatically (it will be too slow). The C 
library decides when freed memory is given back to the system.

I didn't think that Gambas will make somebody learn C and system programming 
;-)

Regards,

-- 
Benoît Minisini


------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand 
malware threats, the impact they can have on your business, and how you 
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
Gambas-user mailing list
Gambas-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gambas-user

Reply via email to