Previous Topic Next topic Print topic


CBL_ALLOC_DYN_MEM

Dynamically allocates memory, and can associate it with the calling program.

Syntax:

call "CBL_ALLOC_DYN_MEM" using     mem-pointer
                         by value  mem-size
                                   flags
                         returning status-code

Parameters:

  Using call prototype (see Key) Picture
mem-pointer cblt-pointer usage pointer. Must be level 01.
mem-size cblt-os-size pic x(4) comp-5

or

pic x(8) comp-5 (64-bit native programs only)

flags cblt-os-flags pic x(4) comp-5

or

pic x(8) comp-5 (64-bit native programs only)

status-code See Library Routines - Key  

On Entry:

mem-size
The number of bytes of memory to allocate.
flags
The type of memory required. You can set the following bits:
Bits 0-1 Reserved. Must be set to 0.
Bit 2 Allocate this memory independently from any calling program.
Remaining bits Reserved. Must be set to 0.

On Exit:

mem-pointer
A pointer to the memory allocated. The allocated memory is not initialized.
status-code
0 Successful allocation
157 Unable to allocate memory
181 Contradictory flags specification

Comments:

The memory allocated is not initialized to any value.

The maximum size of this allocated memory is restricted only by your operating system (unless the -l run-time switch is set).

If bit 2 is not set the memory allocated by CBL_ALLOC_DYN_MEM is freed when the program that allocated it is canceled (logically or physically), if there is a COBOL program that is directly or indirectly the caller. If bit 2 is set, this memory is freed when the run unit terminates, if it has not been previously freed by CBL_FREE_DYN_MEM.

Previous Topic Next topic Print topic