User`s guide
Memory Management
5-6
If no alignment is necessary, align should be 0. MEM’s implementation aligns
memory on a boundary equal to the number of words required to hold a
MEM_Header structure, even if align has a value of 0. Other values of align
cause the memory to be allocated on an align word boundary, where align is
a power of 2.
5.1.5 Freeing Memory
MEM_free frees memory obtained with a previous call to MEM_alloc,
MEM_calloc, or MEM_valloc. The parameters to MEM_free—segid, ptr, and
size—specify a memory segment, a pointer, and a block size respectively, as
shown in Example 5-5. The values of these parameters must be the same as
those used when allocating the block of storage.
Example 5-5. Using MEM_free to Free Memory
Example 5-6 displays a function call which frees the array of objects allocated
in Example 5-5.
Example 5-6. Freeing an Array of Objects
5.1.6 Getting the Status of a Memory Segment
You can use MEM_stat to obtain the status of a memory segment in the
number of minimum addressable data units (MADUs). In a manner similar to
MEM_alloc, MEM_calloc, and MEM_valloc (refer to Example 5-3), the size
used and length values are returned by MEM_stat.
5.1.7 Reducing Memory Fragmentation
Repeatedly allocating and freeing blocks of memory can lead to memory
fragmentation. When this occurs, calls to MEM_alloc can return
MEM_ILLEGAL if there is no contiguous block of free memory large enough
to satisfy the request. This occurs even if the total amount of memory in free
memory blocks is greater than the amount requested.
Void MEM_free(segid, ptr, size)
Int segid;
Ptr ptr;
Uns size;
MEM_free(SRAM, objArr, sizeof(Obj) * ARRAYLEN);










