Guardian Programmer's Guide

Table Of Contents
Managing Memory
Guardian Programmer’s Guide 421922-014
17 - 47
Returning Memory Pool Space
@BLK^PTR := POOL_GETSPACE_ (POOL^START,
BLK^SIZE,
ERROR);
IF ERROR <> 0 THEN CALL ERROR^HANDLER;
.
.
BLK^PTR[4] := 12;
Returning Memory Pool Space
When your process no longer needs a block of space it obtained from a memory pool,
your process can return the block to the memory pool by calling the
POOL_PUTSPACE_ procedure. Once a block of data is returned to the memory pool,
that storage space becomes available for assignment to other storage blocks.
You must supply the POOL_PUTSPACE_ procedure with the starting address of the
pool from which the block of memory was obtained. You must also supply the starting
address of the block you are returning.
In the following example, the POOL_PUTSPACE_ procedure returns the block pointed
to by BLK^PTR to the memory pool:
ERROR := POOL_PUTSPACE_ (POOL^START,BLK^PTR);
Changing the Size of a Memory Pool
When you define a memory pool, you specify the size of that memory pool. You can
later change the size of a pool by calling the POOL_RESIZE_ procedure.
To change the size of a memory pool, you must supply the POOL_RESIZE_ procedure
with the starting address of the pool. You must also specify the new size of the
memory pool in bytes.
The POOL_RESIZE_ procedure returns an error status. If the error status is zero, then
the operation was successful. If a nonzero value is returned, then the operation failed.
Some reasons for failure are that the requested size would shrink the pool so much
that allocated storage blocks would no longer remain within the pool (error 4), or that
the new size would cause a bounds error, such as expanding the pool beyond the end
of the extended data segment (error 3).
The following example changes the size of the pool identified by POOL^START. After
the change, the memory pool size is 2048 bytes.
INT(32) NEW^POOLSIZE;
INT .EXT POOL^START;
.
.
NEW^POOLSIZE := 2048D;
ERROR := POOL_RESIZE_ (POOL^START,NEW^POOLSIZE);
IF ERROR <> 0 THEN CALL ERROR^HANDLER;
Note that the POOL_RESIZE_ procedure does not move the pool; it only adds
neighboring addresses to the pool. The preceding example assumes that the