copymemory bug ???

Just starting out? Need help? Post your questions and find answers here.
drgolf
Enthusiast
Enthusiast
Posts: 114
Joined: Tue Mar 03, 2009 3:40 pm
Location: france

copymemory bug ???

Post by drgolf »

on win 10 X64 pro with pure basic 5.42 LTS X86

this :

Code: Select all

string.s="a"
For i=1 To 255
string=string+"a"
*mem=AllocateMemory(StringByteLength(string))
CopyMemory(@string,*mem,StringByteLength(string))
Debug MemorySize(*mem)
Debug PeekS(*mem)
FreeMemory(*mem)
Next

Each 8 the end of string is missing...
User avatar
mhs
Enthusiast
Enthusiast
Posts: 101
Joined: Thu Jul 02, 2015 4:53 pm
Location: Germany
Contact:

Re: copymemory bug ???

Post by mhs »

drgolf wrote:

Code: Select all

*mem=AllocateMemory(StringByteLength(string))
No bug, the size for the null terminating character is missing...

Code: Select all

*mem=AllocateMemory(StringByteLength(string) + SizeOf(Character))
Post Reply