;
; ------------------------------------------------------------
;
;   PureBasic - Memory example file
;
;    (c) 2001 - Fantaisie Software
;
; ------------------------------------------------------------
;

*MemoryID = AllocateMemory(1000) 

*Pointer = *MemoryID
CopyMemoryString("Hello ", @*Pointer)
CopyMemoryString("World")

*NewMemoryID = ReAllocateMemory(*MemoryID, 2000) ; need more memory 
If *NewMemoryID 
  ; work with *NewMemoryID now with size 2000 
  ;
  Debug "The old contents are still here:" 
  Debug PeekS(*NewMemoryID) 
  FreeMemory(*NewMemoryID) 
Else 
  ; resizing failed, keep working with *MemoryID (size 1000) 
  ; 
  FreeMemory(*MemoryID) 
EndIf