Page 1 of 1

PB 5.21 FreeMemory() error

Posted: Tue Mar 04, 2014 10:38 pm
by troy
Hi, getting ima error on FreeMemory(*buffer) in this piece of code:

Code: Select all

str.s = "0123456789012345678901234567890123456789"

size.l = StringByteLength(str, #PB_UTF8)
*buffer = AllocateMemory(size)
If *buffer
    
  PokeS(*buffer, str, size, #PB_UTF8)
  str = MD5Fingerprint(*buffer, size)
  Debug str
  FreeMemory(*buffer) <--- IMA error
      
EndIf
Faced with the error only if I had Len(str) = 40. Is this bug on not?

Win 7, PB 5.21 x86

Re: PB 5.21 FreeMemory() error

Posted: Tue Mar 04, 2014 10:42 pm
by luis
No, the bug is in front of the monitor :)

Read PokeS() help, or enable purifier, or do both :wink:

HINT: null
Is this bug on not?
Then why aren't you posting this in coding question :?:

Re: PB 5.21 FreeMemory() error

Posted: Tue Mar 04, 2014 10:48 pm
by STARGĂ…TE
PokeS() write an additional NUL-character at the end.

So you have to allocate size+1:

Code: Select all

size.l = StringByteLength(str, #PB_UTF8)
*buffer = AllocateMemory(size+1)
If *buffer

Re: PB 5.21 FreeMemory() error

Posted: Wed Mar 05, 2014 2:55 am
by Alex777
luis wrote:No, the bug is in front of the monitor :)
:lol: