IBM AS/400 manual Managing Dynamically-Allocated Storage, Part, Running a Program121

Models: AS/400

1 489
Download 489 pages 47.95 Kb
Page 145
Image 145
of 2). Global variables and local prototypes for DYNARRAY

Managing Dynamically-Allocated Storage

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

* DYNARRAY :

Handle a

(practically)

unbounded run-time

*

Packed(15,0) array.

This

module

contains

*

procedures to allocate

the

array,

return or set

*

an array

value and deallocate the

array.

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

H NOMAIN *-----------------------------------------------------------------

* Prototypes for the procedures in this module.

*-----------------------------------------------------------------

/COPY DYNARRI

*-----------------------------------------------------------------

*Interface to the CEEGTST API (Get Heap Storage).

*1) HeapId = Id of the heap.

* 2) Size

= Number of bytes to allocate

*3) RetAddr= Return address of the allocated storage

*4) *OMIT = The feedback parameter. Specifying *OMIT here

*

 

means that we will receive an exception from

*

 

the

API if it cannot satisfy our request.

*

 

Since we do not monitor for it, the calling

*

 

procedure will receive the exception.

*

-----------------------------------------------------------------

 

 

 

D CEEGTST

PR

 

 

 

D

HeapId

 

10I

0

CONST

D

Size

 

10I

0

CONST

D

RetAddr

 

*

 

 

D

Feedback

 

12A

 

OPTIONS(*OMIT)

*

-----------------------------------------------------------------

 

 

 

* Interface to the

CEECRHP API (Create Heap).

*

1) HeapId

=

Id of the heap.

 

 

*

2) InitSize

=

Initial size of

the heap.

*

3) Incr

=

Number of bytes

to increment if heap must be

*

 

 

enlarged.

 

 

*4) AllocStrat = Allocation strategy for this heap. We will

*

 

specify a value

of 0 which allows the system

*

 

to choose the optimal strategy.

*

5) *OMIT

= The feedback parameter.

Specifying *OMIT here

*

 

means that we will receive an exception from

*

 

the API if it cannot satisfy our request.

*

 

Since we do not

monitor for it, the calling

*

 

procedure will receive the exception.

*-----------------------------------------------------------------

 

 

 

 

D CEECRHP

PR

 

 

 

D

HeapId

10I

0

 

 

D

InitSize

10I

0

CONST

D

Incr

10I

0

CONST

D

AllocStrat

10I

0

CONST

D

Feedback

12A

 

OPTIONS(*OMIT)

 

 

 

 

Figure 55

(Part 1

of 2). Global variables and local prototypes for DYNARRAY

Chapter 9. Running a Program121

Page 145
Image 145
IBM AS/400 manual Managing Dynamically-Allocated Storage, Part, of 2. Global variables and local prototypes for DYNARRAY