Welcome to Pauls PureProject
 Home Online Reference Guide duplicated from http://cvs.purebasic.com  
 Online Resources
   · Reference

 Libraries
     2DDrawing
     Billboard
     Camera
     CDAudio
     Cipher
     Clipboard
     Console
     Database
     Date
     Desktop
     Engine3D
     Entity
     File
     FileSystem
     Font
     Gadget
     Help
     Image
     ImagePlugin
     Joystick
     Keyboard
     Library
     Light
     LinkedList
     Material
     Math
     Memory
     Menu
     Mesh
     Misc
     Module
     Mouse
     Movie
     Network
     OnError
     Packer
     Palette
     Particle
     Preference
     Printer
     Requester
     Sort
     Sound
     SoundPlugin
     Sprite
     Sprite3D
     StatusBar
     String
     SysTray
     Terrain
     Texture
     Thread
     Toolbar
     Window

 ReAllocateMemory

Syntax

*MemoryID = ReAllocateMemory(*MemoryID, Size)
Description
Allocates (when parameter *MemoryID is 0) a new or re-allocates (with a valid *MemoryID as parameter) an existing contiguous memory area according to the specified size (in bytes). If the needed memory is available, the return value *MemoryID will get the start address of the memory area, else it will be 0 (the existing memory area will remain then, as well its previous *MemoryID stay valid).

The content of the previous memory area '*MemoryID' is kept. If the new 'size' of the memory area is smaller than the previous one, the end is cutted. If the new 'size' is larger than the previous one, the memory area will be filled up with Null.

Note: All the allocated memory areas are automatically freed when the programs ends.

Example:
  *MemoryID = AllocateMemory(1000)
  PokeS(*MemoryID, "Store this string")
  ; do something more with it here...
  ;
  *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

Supported OS

Windows, AmigaOS, Linux

<- PokeW() - Memory Index



Hosted by Reel Media Productions Copyright©2001-2004 All Rights Reserved