|  |  |  |  | 
 35
 Memory Manager
  
35
 Memory ManagerMemoryMgr.h. 
 
Err MemCardInfo (UInt16 cardNo, Char* cardNameP, Char* manufNameP, UInt16* versionP, UInt32* crDateP, UInt32* romSizeP, UInt32* ramSizeP, UInt32* freeBytesP)
|   |  | Card number. | 
|   |  | Pointer to character array (32 bytes), or 0. | 
|   |  | Pointer to character array (32 bytes), or 0. | 
|   |  | Pointer to version variable, or 0. | 
|   |  | Pointer to creation date variable, or 0. | 
|   |  | Pointer to ROM size variable, or 0. | 
|   |  | Pointer to RAM size variable, or 0. | 
|   |  | Pointer to free byte-count variable, or 0. | 
NOTE:  Blocks are compared as unsigned bytes.
Int16 MemCmp (const void* s1, const void* s2, Int32 numBytes)
s1 > s2 
 
s1 < s2 
MemCmp can be used to test the equality of blocks in memory on all versions that support MemCmp; however, testing the sort ordering of blocks in memory works reliably only on Palm OS® versions 3.5 and higher. On versions earlier than 3.2, MemCmp always returns a positive value if the blocks are unequal. On versions 3.2 and 3.3, MemCmp reliably returns positive to indicate s1 > s2 and negative to indicate s1 < s2 only if the characters that differ are less than 128 apart. If the difference is greater than that, MemCmp may return positive when it should return negative and vice versa. 
UInt16 MemDebugMode(void)
UInt16 MemHandleCardNo (MemHandle h)
true if the given handle is part of a data storage heap. If not, it's a handle in the dynamic heap.
Boolean MemHandleDataStorage (MemHandle h) 
true if the handle is part of a data storage heap.
Err MemHandleFree (MemHandle h)
UInt16 MemHandleHeapID (MemHandle h)
MemPtr MemHandleLock (MemHandle h)
MemHandleLock and MemHandleUnlock should be used in pairs.
MemHandle MemHandleNew (UInt32 size)
MemHandleNew allocates, you must call Err MemHandleResize (MemHandle h, UInt32 newSize)
|   | 0 | No error. | 
|   | memErrInvalidParam | Invalid parameter passed. | 
|   | memErrNotEnoughSpace | Not enough free space in heap to grow chunk. | 
|   | memErrChunkLocked | Can't grow chunk because it's locked. | 
MemHandleResize function tries to resize the chunk only within the same heap, whereas Err MemHandleSetOwner (MemHandle h, UInt16 owner)
|   | ->  | Chunk handle. | 
|   | ->  | New owner ID of the chunk. Specify 0 to set the owner to the operating system. | 
MemHandleSetOwner to grant ownership of those blocks to the OS. If you don't change the ownership of these chunks, they will get freed before the application you're launching has a chance to use them.
UInt32 MemHandleSize (MemHandle h)
LocalID MemHandleToLocalID (MemHandle h)
Err MemHandleUnlock (MemHandle h)
MemHandleLock and MemHandleUnlock should be used in pairs.
Err MemHeapCheck (UInt16 heapID)
Err MemHeapCompact (UInt16 heapID)
true if the given heap is a dynamic heap.
Boolean MemHeapDynamic (UInt16 heapID) 
true if dynamic, false if not.
NOTE:  In Palm OS 3.5, the dynamic heap is sized based on the amount of memory available, and is generally larger than before.
UInt16 MemHeapFlags (UInt16 heapID)
Err MemHeapFreeBytes (UInt16 heapID, UInt32* freeP, UInt32* maxP)
|   | ->  | ID of heap. | 
|   | <->  | Pointer to a variable of type UInt32for free bytes. | 
|   | <->  | Pointer to a variable of type UInt32for max free chunk size. | 
maxP to determine whether enough free space to fulfill your allocation request exists. If not, you may make more space available by calling the  function. An alternative approach is to just call the  function as necessary when an error is returned by the UInt16 MemHeapID (UInt16 cardNo, UInt16 heapIndex)
|   | ->  | The card number, either 0 or 1. | 
|   | ->  | The heap index, anywhere from 0 to MemNumHeaps- 1. | 
Err MemHeapScramble (UInt16 heapID)
UInt32 MemHeapSize (UInt16 heapID)
LocalIDKind MemLocalIDKind (LocalID local)
MemPtr MemLocalIDToGlobal (LocalID local, UInt16 cardNo)
|   | ->  | The local ID to convert. | 
|   | ->  | Memory card the chunk resides in. | 
MemPtr MemLocalIDToLockedPtr (LocalID local, UInt16 cardNo)
MemPtr MemLocalIDToPtr (LocalID local, UInt16 cardNo)
Err MemMove (void* dstP, const void* sP, Int32 numBytes)
|   |  | Pointer to destination. | 
|   |  | Pointer to source. | 
|   |  | Number of bytes to move. | 
UInt16 MemNumCards (void)
UInt16 MemNumHeaps (UInt16 cardNo)
MemNumHeaps.
UInt16 MemNumRAMHeaps (UInt16 cardNo)
UInt16 MemPtrCardNo (MemPtr p)
true if the given pointer is part of a data storage heap; if not, it is a pointer in the dynamic heap.
Boolean MemPtrDataStorage (MemPtr p)
true if the chunk is part of a data storage heap.
Err MemPtrFree (MemPtr p)
UInt16 MemPtrHeapID (MemPtr p)
MemPtr MemPtrNew (UInt32 size)
NOTE:  You cannot allocate a zero-size reference block.
MemHandle MemPtrRecoverHandle (MemPtr p)
Err MemPtrResize (MemPtr p, UInt32 newSize)
Err MemPtrSetOwner (MemPtr p, UInt16 owner)
|   | ->  | Pointer to the chunk. | 
|   | ->  | New owner ID of the chunk. Specify 0 to set the owner to the operating system. | 
MemPtrSetOwner or UInt32 MemPtrSize (MemPtr p)
LocalID MemPtrToLocalID (MemPtr p)
Err MemPtrUnlock (MemPtr p)
Err MemSet (void* dstP, Int32 numBytes, UInt8 value)
|   |  | Pointer to the destination. | 
|   |  | Number of bytes to set. | 
|   |  | Value to set. | 
Err MemSetDebugMode (UInt16 flags)
|) to provide any combination of one, more, or none of the following flags:
 
memDebugModeCheckOnChange
memDebugModeCheckOnAll
memDebugModeScrambleOnChange
memDebugModeScrambleOnAll
memDebugModeFillFree
memDebugModeAllHeaps
memDebugModeRecordMinDynHeapFree
Err MemStoreInfo (UInt16 cardNo, UInt16 storeNumber, UInt16* versionP, UInt16* flagsP, Char* nameP, UInt32* crDateP, UInt32* bckUpDateP, UInt32* heapListOffsetP, UInt32* initCodeOffset1P, UInt32* initCodeOffset2P, LocalID* databaseDirIDP)
|   | ->  | Card number, either 0 or 1. | 
|   | ->  | Store number; 0 for ROM, 1 for RAM. | 
|   | <->  | Pointer to version variable, or 0. | 
|   | <->  | Pointer to flags variable, or 0. | 
|   | <->  | Pointer to character array (32 bytes), or 0. | 
|   | <->  | Pointer to creation date variable, or 0. | 
|   | <->  | Pointer to backup date variable, or 0. | 
|   | <->  | Pointer to heapListOffsetvariable, or 0. | 
|   | <->  | Pointer to initCodeOffset1variable, or 0. | 
|   | <->  | Pointer to initCodeOffset2 variable, or 0. | 
|   | <->  | Pointer to database directory chunk ID variable, or 0. | 
|   |  |  |  |  |   |