Hi all

How do I find out the leftover amount of storage memory on
my device? I've tried the following code (on the Emulator)
but the amount returned never changes, despite extensive
"read record data + decompress it + resize record + write
record back" operations. Obviously a bad case of RTFM, or
is the Emulator debug session misleading me?

Thanks in advance
Alex


...
UInt32 freeStorage = GetFreeStorageMem (0);
...

UInt32 GetFreeStorageMem (Int16 cardNo)
{
    Int16   i;
    Int16   nCards;
    UInt16  heapID, flags;
    UInt32  totalStorage = 0;

    // Iterate through each card to support devices with multiple cards.
    if (cardNo == MEM_ALL_CARDS)
        nCards = MemNumCards ();
    else if (cardNo >= 0)
        nCards = cardNo + 1;
    else
        return 0;

    for (cardNo=0; cardNo<nCards; cardNo++)
    {
        // Iterate through the heaps on a card
        for (i=0; i<MemNumHeaps (cardNo); i++)
        {
            // Obtain the ID of the heap.
            heapID = MemHeapID (cardNo, i);
            flags = MemHeapFlags (heapID);
            if (! MemHeapDynamic (heapID) && (flags & 0x0001))
                totalStorage += MemHeapSize (heapID);
        }
    }
    return totalStorage;
}



-- 
For information on using the Palm Developer Forums, or to unsubscribe, please see 
http://www.palmos.com/dev/support/forums/

Reply via email to