[Gambas-user] Tests against pointers in Gambas3
Demosthenes Koptsis
demosthenesk at ...626...
Tue Jan 11 18:32:35 CET 2011
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?
--
Regards,
Demosthenes Koptsis.
More information about the User
mailing list