Page 1 of 1

(Solved) short program dies on AllocateMemory (5.73 x64)

Posted: Wed Jul 28, 2021 4:28 am
by Cyllceaux

Code: Select all

EnableExplicit

Define text1.s=~"Hällo Welt #@€ß\nHöLLo Würldz"
Define size=StringByteLength(text1)
Define *mem=AllocateMemory(size)
CopyMemoryString(text1,@*mem):*mem-size		
Define *res1=AllocateMemory(size) ; Here it dies

Win10 x64 21H1

Re: short program dies on AllocateMemory (5.73 x64)

Posted: Wed Jul 28, 2021 5:56 am
by GPI
I can't test it here, but the *mem-Buffer is to small, StringByteLength return the length without the zero-end-byte, CopyMemoryString DOES copy the zero-byte. You should add a "SizeOf(Character)".

Re: short program dies on AllocateMemory (5.73 x64)

Posted: Wed Jul 28, 2021 5:58 am
by wilbert
GPI is right.
You have to allocate room for one additional character.

Code: Select all

Define *mem=AllocateMemory(size + SizeOf(Character))

(Solved) Re: short program dies on AllocateMemory (5.73 x64)

Posted: Wed Jul 28, 2021 6:06 am
by Cyllceaux
OOOOOHHH.... I forgot...

Thx GPI and wilbert :)