I discovered that String Ptr somehow maintains it's string length in the provided handle.
How can this be?
Where is it stored?
Should i make precautions because i make different uses of the same heapalloc.
I can't imagne that PB somewhere keeps a reference.
A copy of 2 heapallocs 'copies' this same length indicator!
------------------
[email protected]
How can this be?
Where is it stored?
Should i make precautions because i make different uses of the same heapalloc.
I can't imagne that PB somewhere keeps a reference.
A copy of 2 heapallocs 'copies' this same length indicator!
Code:
#Compile Exe #Include "win32api.inc" Function PbMain Dim h1 As Long Dim h2 As Long Dim h3 As Long Dim T1 As String Ptr Dim T2 As String Ptr Dim T3 As String Ptr h1 = HeapAlloc( GetProcessHeap(), %HEAP_ZERO_MEMORY, 1000 ) h2 = HeapAlloc( GetProcessHeap(), %HEAP_ZERO_MEMORY, 1000 ) h3 = HeapAlloc( GetProcessHeap(), %HEAP_ZERO_MEMORY, 1000 ) T1 = h1 MsgBox "1> " & Str$( Len( @T1 ) ) @T1 = Space$( 500 ) MsgBox "2> " & Str$( Len( @T1 ) ) T2 = h1 MsgBox "3> " & Str$( Len( @T2 ) ) MoveMemory h3, h1, 1000 T3 = h3 MsgBox "4> " & Str$( Len( @T3 ) ) If h1 Then Call HeapFree( GetProcessHeap(), 0, ByVal h1 ) If h2 Then Call HeapFree( GetProcessHeap(), 0, ByVal h2 ) If h3 Then Call HeapFree( GetProcessHeap(), 0, ByVal h3 ) End Function
[email protected]
Comment