FreeMemory crash ...

Just starting out? Need help? Post your questions and find answers here.
User avatar
bingo
Enthusiast
Enthusiast
Posts: 210
Joined: Fri Apr 02, 2004 12:21 pm
Location: germany/thueringen
Contact:

FreeMemory crash ...

Post by bingo »

Code: Select all

membuffer.i = AllocateMemory(500)

For i=0 To 5
any.b = PeekB(membuffer)
membuffer = membuffer + 1
Next

FreeMemory(membuffer)
End
:roll:

no error ...

Code: Select all

membuffer.i = AllocateMemory(500)

For i=0 To 5
any.b = PeekB(membuffer+i)
Next

FreeMemory(membuffer)
End
["1:0>1"]
cxAlex
User
User
Posts: 88
Joined: Fri Oct 24, 2008 11:29 pm
Location: Austria
Contact:

Post by cxAlex »

NO BUG!

Code: Select all

membuffer.i = AllocateMemory(500)

startbuffer.i = membuffer

For i=0 To 5
any.b = PeekB(membuffer)
membuffer = membuffer + 1
Next

FreeMemory(startbuffer)
End
Fred
Administrator
Administrator
Posts: 18253
Joined: Fri May 17, 2002 4:39 pm
Location: France
Contact:

Post by Fred »

Well, the first code is wrong, as you free something else than the allocated pointer.
User avatar
bingo
Enthusiast
Enthusiast
Posts: 210
Joined: Fri Apr 02, 2004 12:21 pm
Location: germany/thueringen
Contact:

Post by bingo »

:oops: ok ... sorry . p :shock: inter
["1:0>1"]
User avatar
Hroudtwolf
Addict
Addict
Posts: 803
Joined: Sat Feb 12, 2005 3:35 am
Location: Germany(Hessen)
Contact:

Post by Hroudtwolf »

Hi,

It isn't a bug.
'Cause it is a incorrect use.
You can just free a memory block with freememory, by using the startaddress of your allocated memory block .

Regards

Wolf
Post Reply