Guardian Programmer's Guide

Table Of Contents
Managing Memory
Guardian Programmer’s Guide 421922-014
17 - 45
Defining a Memory Pool
The following example sets up the memory pool shown in Figure 17-9. The example
allocates an extended data segment, makes that segment current, and defines a pool
within that segment:
INT ERROR;
INT OPTIONS;
INT SEGMENT^ID;
INT OLD^SEGMENT^ID;
INT(32) SEGMENT^SIZE;
INT ERROR^DETAIL;
INT(32) BASE^ADDRESS;
INT .EXT BASE^PTR := BASE^ADDRESS;
INT .EXT POOL^START;
INT(32) MAX^POOLSIZE;
.
.
!Allocate a flat segment of 4000 bytes.
OPTIONS.<14> := 1;
SEGMENT^ID := 0;
SEGMENT^SIZE := 4000D;
ERROR := SEGMENT_ALLOCATE_(SEGMENT^ID,
SEGMENT^SIZE,
!swap^file:length!,
ERROR^DETAIL,
!pin!,
!segment^type!,
BASE^ADDRESS,
!max^size!,
OPTIONS);
IF ERROR <> 0 THEN CALL ERROR^HANDLER;
!Make the segment current (if a selectable segment).
SEGMENT^ID := 0;
ERROR := SEGMENT_USE_(SEGMENT^ID,
OLD^SEGMENT^ID,
@BASE^PTR,
ERROR^DETAIL);
IF ERROR <> 0 THEN CALL ERROR^HANDLER;
!Define a 1536-byte memory pool starting 1024 words into the
!extended data segment.
@POOL^START := @BASE^PTR[1024];
MAX^POOLSIZE := 1536D;
ERROR := POOL_DEFINE_(POOL^START,MAX^POOLSIZE);
IF ERROR <> 0 THEN CALL ERROR^HANDLER;
.
.