Guardian Programmer's Guide

Table Of Contents
Managing Memory
Guardian Programmer’s Guide 421922-014
17 - 34
Checking the Size of an Extended Data Segment
Checking the Size of an Extended Data Segment
To determine the size of a flat segment or a selectable segment (regardless of whether
or not the selectable segment is currently in use), supply the SEGMENT_GETINFO_
procedure with the appropriate segment ID.
The following statement returns the size of extended data segment 3 in the variable
SEGMENT^SIZE:
SEGMENT^ID := 3;
ERROR := SEGMENT_GETINFO_(SEGMENT^ID,SEGMENT^SIZE);
IF ERROR <> 0 THEN CALL ERROR^HANDLER;
The variable to contain the returned segment size value must be a 32-bit integer. The
size of the segment is expressed in bytes.
Changing the Size of an Extended Data Segment
You can alter the size of an extended data segment by calling the RESIZESEGMENT
procedure. You supply the procedure with the segment ID and the new segment size.
The following example allocates a selectable segment and enlarges it from 8000 bytes
to 20000 bytes:
SEGMENT^ID := 1;
SIZE := 8000D;
ERROR := SEGMENT_ALLOCATE_(SEGMENT^ID,
SIZE,
!swap^file:length!,
ERROR^DETAIL,
!pin!,
!segment^type!,
BASE^ADDRESS
MAX^SIZE);
IF ERROR <> 0 THEN CALL ERROR^HANDLER;
.
.
NEW^SEGMENT^SIZE := 20000D;
ERROR := RESIZESEGMENT(SEGMENT^ID, NEW^SEGMENT^SIZE);
IF ERROR <> 0 THEN ...
If a flat segment will be resized, the maximum segment size (1120 megabytes in the
TNS/R environment and 1536 megabytes in the TNS/E environment) should be
declared in the SEGMENT_ALLOCATE_ procedure call that allocates the segment.
This prevents other flat segments from allocating the same space before the resizing is
performed. To reserve the maximum segment size, use the max-size parameter in
the SEGMENT_ALLOCATE_ procedure call. The max-size parameter defines the
upper limit of the new-segment-size parameter of the RESIZESEGMENT
procedure. The following example allocates an 8000-byte flat segment and specifies a
maximum segment size of 64000 bytes. Later in the program, the segment is resized
to its maximum size.