I can shorten it using peekb and pokeb.
This post is for those who like me, hoped you could shorten a buffer using ReAllocateMemory.
Code: Select all
*Buffer = AllocateMemory(20)
PokeS(*Buffer, 0, "12345678901234567")
Debug "Buffer size: " + MemorySize(*Buffer)
*NewBuffer = ReAllocateMemory(*Buffer, 18) ; need more memory
If *NewBuffer
Debug "New buffer size: " + MemorySize(*NewBuffer)
Debug "The old content is still here:"
For k = 0 To 17
HexView$ + Hex(PeekB(*newbuffer, k), #PB_Byte) + " "
Next
Debug "Text encoded (hex view): " + HexView$
FreeMemory(*NewBuffer)
EndIf