"wax wacky" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> but i am facing a problem . I want to allocate a memory of 99KB. and
MemGlueNewPtr() is failing.
> the pointer is getting a null value.
>
> Why this is happening??
> Any advice please ...

Obtain the maximum free chunk size using MemHeapFreeBytes first.

Example: (not tested)

// Find the heap ID
UInt16 cardNo = 0;
UInt16 heapIndex = 0;
UInt16 heapID = MemHeapID(cardNo, heapIndex);
// Find out the number of free bytes and the max. chunk size
UInt32 freeBytes;
UInt32 freeChunk;
MemHeapFreeBytes(heapID, &freeBytes, &freeChunk);

// Now allocate the chunk
MemPtr p = MemGluePtrNew(freeChunk);
ErrFatalDisplayIf((p == NULL), "Could not allocate chunk");
MemPtrFree(p);

Optionally, you may want to call MemHeapCompact prior to MemHeapFreeBytes.
This way you get an accurate measurement of free memory. I don't know if
compacting the memory affects the maximum free chunk size, though.


Regards
-Laurens



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

Reply via email to