From: George Bassili [mailto:[EMAIL PROTECTED]]
> x = MemPtrNew(1);
> error = MemPtrResize(x, 29);
> I get a memErrChunkLocked error.  How?  MemPtrResize is supposed
> to only work on a locked chunk.  The docs say this too, but they
> ALSO say that it can return memErrChunkLocked as an error which
> doesn't make sense given that it should be locked before it executes.
> Am I missing something here?

Yes -- MemPtrResize does work only on locked chunks, but it isn't guaranteed
to always work.  Specifically, if you are trying to grow a chunk (as you are
doing here) but there don't happen to be enough free bytes past the tail end
of the chunk in the dynamic heap, then it will fail as you are seeing.  If
there *are* enough free bytes, then it does succeed.  Shrinking always
succeeds.  Unfortunately the amount of free space past the end of any given
chunk is essentially random.

So basically growing a chunk with MemPtrResize is just not reliable.  If
possible, allocate a movable chunk with a handle, unlock the chunk before
resizing, and use MemHandleResize instead.  This function will almost always
work since (because the chunk is unlocked) it can move (reallocate) the
chunk in order to find enough space if needed.

-slj-



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

Reply via email to