Page 1 of 1

copymemory bug ???

Posted: Thu Jul 07, 2016 10:09 am
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...

Re: copymemory bug ???

Posted: Thu Jul 07, 2016 10:22 am
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))