Guardian Programmer's Guide

Table Of Contents
Managing Memory
Guardian Programmer’s Guide 421922-014
17 - 43
Defining a Memory Pool
For information on segment allocation and specifying a current segment, see Read-
only segments cannot be extensible. and Making a Selectable Segment Current,
earlier in this section. The following paragraphs describe how to define a memory pool
and how to obtain storage from a memory pool.
Defining a Memory Pool
Use the POOL_DEFINE_ procedure to define a memory pool. You must supply the
POOL_DEFINE_ procedure with the address in the current extended data segment or
user data area where the pool is to begin and with the size in bytes of the pool.
A header is automatically allocated at the beginning of every memory pool. The
header, which may vary in length, contains information used by the operating system to
manage the pool; it is not intended to be accessed by user programs. In addition, a
small portion of the memory pool is used for system overhead. Thus, the total size of
the pool available to user programs is somewhat less than the defined size of the pool.
The POOL_DEFINE_ procedure allows you to specify the alignment of the memory
pool. Possible alignments are 4-byte, 8-byte, or 16-byte alignment. The default is
16-byte alignment, but you may want to specify a different alignment for efficiency or
performance reasons.
The POOL_DEFINE_ procedure returns an error status value that indicates whether
the operation was successful. A status value of 0 is returned for a successful
operation.
Figure 17-9 shows how a memory pool is allocated from an extended data segment.