At 10:56 PM +0100 9-01-00, Marc Campbell wrote:
>I have a question about MemPtrResize.  According to the docs, it says "Call
>this routine to resize a locked chunk."  One of the return values is
>memErrChunkLocked.
>
>Does MemPtrResize expect a locked or unlocked chunk?

MemPtrResize expects a pointer.  By definition, a pointer is non-moveable.
That is, it was either created as a pointer (MemPtrNew) or obtained by
locking a handle (MemHandleLock).

Many people forget this, but you *can* resize a non-moveable chunk.  You
can always *shrink* a non-moveable chunk, because shrinking will never
require the chunk to change locations.  (At least, not in any
implementation of the memory manager so far.)

Rarely, you can also grow a non-moveable chunk, but this is only possible
if the next chunk (the one located next in memory at a higher address) is
free and if it has enough space to handle the growing.  Most often, the
next chunk in memory will be allocated.  And so in order to grow the chunk
the memory manager would have to move it.  Because it's non-moveable
(either was never moveable or is currently locked) the MemPtrResize will
fail.  The error code in this case is memErrChunkLocked.

                                        --Bob


Reply via email to