IBM AS/400 Frozen Dessert Maker User Manual


 
Managing Dynamically-Allocated Storage
procedures in the module DYNARRAY dynamically allocate storage for a practically
unbounded packed array. The procedures in the module perform the following
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 APIs,
CEECRHP (Create Heap), CEEGTST (Get Storage), and CEEDSHP (Discard
Heap), as well as the REALLOC operation code. See the
System API Reference
for specific information about the storage management bindable APIs.
Figure 54 shows the /COPY file DYNARRI containing the prototypes for the proce-
dures in DYNARRAY. This /COPY file is used by the DYNARRAY module as well
as any other modules that call the procedures in DYNARRAY.
DYNARRAY has been defined for use with a (15,0) packed decimal array. It could
easily be converted to handle a character array simply by changing the definition of
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 the
Control specification, and Definition specifications.
120 ILE RPG for AS/400 Programmer's Guide