IBM AS/400 manual Managing Dynamically-Allocated Storage, SeeAPI theReference

Models: AS/400

1 489
Download 489 pages 47.95 Kb
Page 144
Image 144

Managing Dynamically-Allocated Storage

procedures in the module DYNARRAY dynamically allocate storage for a pr unbounded packed array. The procedures in the module perform the foll actions on the array:

¹Initialize the array

¹ Add an element to the array

¹ Return the value of an element

¹Release the storage for the array.

DYNARRAY

performs these

actions

using the three ILE bindable storage A

CEECRHP (Create

Heap),

CEEGTST

(Get Storage), and

CEEDSHP

(Discard

Heap),

as

well

as the REALLOC operation codeSystem.

SeeAPI theReference

for

specific

information

about

the storage management bindable APIs.

Figure 54

shows

the

/COPY

file

DYNARRI containing the prototypes for the

dures

in

DYNARRAY.

This

/COPY file is

used by

the

DYNARRAY module as

as

any

other

modules

that

call

the

procedures in

DYNARRAY.

DYNARRAY has been defined for use with a (15,0) packed decimal array easily be converted to handle a character array simply by changing t DYNA_TYPE to a character field.

 

*=================================================================

 

* DYNARRAY :

Handle a (practically) unbounded run-time

 

*

Packed(15,0) array.

The DYNARRAY module contains

 

*

procedures to allocate the array, return or set

 

*

an array value and deallocate the array.

 

*=================================================================

D DYNA_TYPE

S

15P 0

 

D DYNA_INIT

PR

 

 

D DYNA_TERM

PR

 

 

D DYNA_SET

PR

 

 

D

Element

 

 

VALUE LIKE(DYNA_TYPE)

D

Index

 

5I 0

VALUE

D DYNA_GET

PR

 

LIKE(DYNA_TYPE)

D

Index

 

5I 0

VALUE

 

 

Figure

54. /COPY file DYNARRI containing prototypes for DYNARRAY module

Figure 55 on page 121 shows the beginning of module DYNARRAY containing th Control specification, and Definition specifications.

120 ILE RPG for AS/400 Programmer's Guide

Page 144
Image 144
IBM AS/400 manual Managing Dynamically-Allocated Storage, SeeAPI theReference