Heap Support
Heap Support
Heap Support
By default, the dynamic storage provided by malloc, calloc, realloc and new is
the same type of storage as the storage model of the root program
in the activation group. However, when the single-level storage model
is in use, then teraspace storage is provided by these interfaces
if the TERASPACE(*YES *TSIFC) compiler option was specified. Similarly,
a single-level storage model program can explicitly use bindable APIs
to work with teraspace, such as _C_TS_malloc, _C_TS_free, _C_TS_realloc and _C_TS_calloc.
For details about how you can use teraspace storage, see Teraspace and Single-Level Storage.
If you choose to use both the CEExxxx storage management bindable APIs and the ILE C
malloc(), calloc(), realloc(), and
free() functions, the following rules apply:
- Dynamic storage allocated through the C functions malloc(), calloc(), and realloc(), cannot be freed or reallocated with the CEEFRST and the CEECZST bindable APIs.
- Dynamic storage allocated by the CEEGTST bindable API can be freed with the free() function.
- Dynamic storage initially allocated with the CEEGTST bindable API can be reallocated with the realloc() function.
Other languages, such as COBOL, have no heap storage model. These languages can access the ILE dynamic storage model through the bindable APIs for dynamic storage.
RPG has operation codes ALLOC, REALLOC and DEALLOC, and builtin
functions %ALLOC and %REALLOC for accessing heap storage. An RPG
module can use either single-level heap storage or teraspace heap
storage. For modules with teraspace storage model, the default type
of heap storage is teraspace. For modules with inherit or single-level
storage model, the default type of heap storage is single-level.
However, you can explicitly set the type of heap storage using the
ALLOC keyword on the Control specification. The RPG support uses
the CEEGTST, CEECZST, and CEEFRST bindable APIs for single-level heap
storage operations and it uses the _C_TS_malloc(), _C_TS_realloc(),
and _C_TS_free() functions for teraspace heap storage operations.