[Contents] [index] [Help] [Retrace] [browse <] [Browse >]

The following examples free the memory chunks shown in the previous calls
to allocmem().

    FreeMem(apointer, 100);
    FreeMem(anotherptr, 1000);

A memory block allocated with allocvec() must be returned to the system
pool with the freevec().  this function uses the stored size in the
allocation to free the memory block, so there is no need to specify the
size of the memory block to free.

    FreeVec(yap);

freemem() and freevec() return no status.  however, if you attempt to free
a memory block in the middle of a chunk that the system believes is
already free, you will cause a system crash. Applications must free the
same size memory blocks that they allocated.  An allocated block may not
be deallocated as smaller pieces.  Due to the internal way the system
rounds up and aligns allocations.  Partial deallocations can corrupt the
system memory list.

    Leave Memory Allocations Out Of Interrupt Code.
    -----------------------------------------------
    Do not allocate or deallocate system memory from within interrupt
    code.  The "exec interrupts" chapter explains that an interrupt may
    occur at any time, even during a memory allocation process.  As a
    result, system data structures may not be internally consistent at
    this time.