Guardian Programmer's Guide

Table Of Contents
Managing Memory
Guardian Programmer’s Guide 421922-014
17 - 46
Getting Space in a Memory Pool
Getting Space in a Memory Pool
After defining a pool, your process can obtain blocks of space from that pool by calling
the POOL_GETSPACE_ procedure. You must specify the pool from which you want to
obtain blocks by indicating the starting address of the pool. You must also specify the
size of the block you require in bytes.
The POOL_GETSPACE_ procedure allocates the first block of contiguously available
memory of the size requested that lies within the memory pool. The
POOL_GETSPACE_ procedure then returns the address of the block of memory
allocated. You can assign this address to an extended pointer so that you can use it to
refer to locations in the block. If an error (such as insufficient space left in the memory
pool) occurs, then the procedure returns NIL_ instead of an address.
Figure 17-10 shows how a block of storage is obtained from a memory pool.
In the following example, the POOL_GETSPACE_ procedure obtains a 64-byte block
of memory from the memory pool defined in the example under Defining a Memory
Pool; the address of that block is stored in BLK^PTR (as shown in Figure 17-8), which
is then used to refer to locations in the block.
.
.
!Obtain a 64-byte storage block from the memory pool.
BLK^SIZE := 64D;
Figure 17-10. Getting Space in a Memory Pool
VST092.VSD