Dynamic Memory Allocation in Cobol

2

How do you allocate dynamic memory in Cobol without using external C libraries?

I'm not interested in using some kind of *alloc() coming from C. In any Cobol flavor does it exist? It should exist, because if now some compilers have access to database, internet and OOP, then it may have. The English search did not help me much.

    
asked by anonymous 02.09.2015 / 06:24

1 answer

4

The verb in COBOL that does this is ALLOCATE . Only assignment can be used with a data item defined as BASED (which indicates that the compiler does not allocate the usual storage for the data item). FREE free the storage obtained by allocating.

ALLOCATE / BASE / FREE exist since the 2002 Standard which was replaced by the 2014 Standard. The implementation is down to the compiler vendor and not all compilers support this.

All COBOLs will have additional ways to allocate storage assigned to a POINTER value through a system call of some kind.

There is also a way to load, but not execute, "a program" that contains the storage (usually for reference), using a PROCEDURE- POINTER (or a FUNCTION-POINTER ).

CALL is used in many ways to do many things, including allowing access to storage outside of the currently active program. If something does not exist, you can always write a program and CALL it.

    
02.09.2015 / 09:41