Almost all IBM product and technical documentation is available on the internet.
It can be a bit of a chore to sort out but have a look at
Book Manger
To answer your specific question, the
Language Environment Programming Reference tells you just about everything you will
ever need to know about LE. The memory management routines you may want to expore are: CEEGTST
(allocate memory) and CEEFRST (free memory).
The following is a bit long but it is a complete IBM Enterprise COBOL program that does some simple
memory management stuff using LE.
***************************************************
** **
** DEMONSTRATION FOR LINKED LIST HANDLING **
** **
***************************************************
IDENTIFICATION DIVISION.
PROGRAM-ID. LINKLST.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 RET-CDE PIC 9(3).
01 HEAD-OF-LIST POINTER.
LINKAGE SECTION.
01 LINK GLOBAL.
02 DATA-PART PIC 9(4).
02 NEXT-PTR POINTER.
PROCEDURE DIVISION.
CALL "BULDLST" USING HEAD-OF-LIST,
RET-CDE
IF RET-CDE = ZERO THEN
CALL "SHOWLST" USING HEAD-OF-LIST
CALL "FREELST" USING HEAD-OF-LIST
IF HEAD-OF-LIST = NULL THEN
DISPLAY "LIST HAS BEEN FREED."
END-IF
END-IF
GOBACK
.
***************************************************
IDENTIFICATION DIVISION.
PROGRAM-ID BULDLST.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 I PIC 9(4).
LINKAGE SECTION.
01 HEAD-OF-LIST POINTER.
01 RET-CDE PIC 9(3).
PROCEDURE DIVISION USING HEAD-OF-LIST, RET-CDE.
MAINLINE SECTION.
CALL "MEMALOC" USING BY REFERENCE HEAD-OF-LIST,
BY CONTENT LENGTH OF LINK,
BY REFERENCE RET-CDE
IF RET-CDE = ZERO THEN
SET ADDRESS OF LINK TO HEAD-OF-LIST
PERFORM VARYING I FROM 1 BY 1
UNTIL I > 4
OR RET-CDE > ZERO
MOVE I TO DATA-PART OF LINK
CALL "MEMALOC" USING BY REFERENCE NEXT-PTR OF LINK,
BY CONTENT LENGTH OF LINK,
BY REFERENCE RET-CDE
IF RET-CDE = ZERO THEN
SET ADDRESS OF LINK TO NEXT-PTR OF LINK
END-IF
END-PERFORM
IF RET-CDE = ZERO THEN
MOVE I TO DATA-PART OF LINK
SET NEXT-PTR OF LINK TO NULL
END-IF
END-IF
GOBACK
.
END PROGRAM BULDLST.
***************************************************
IDENTIFICATION DIVISION.
PROGRAM-ID SHOWLST.
DATA DIVISION.
LINKAGE SECTION.
01 HEAD-OF-LIST POINTER.
PROCEDURE DIVISION USING HEAD-OF-LIST.
MAINLINE SECTION.
SET ADDRESS OF LINK TO HEAD-OF-LIST
PERFORM UNTIL ADDRESS OF LINK = NULL
DISPLAY DATA-PART
SET ADDRESS OF LINK TO NEXT-PTR OF LINK
END-PERFORM
GOBACK
.
END PROGRAM SHOWLST.
***************************************************
IDENTIFICATION DIVISION.
PROGRAM-ID FREELST.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 NXT-PTR POINTER.
01 RET-CDE PIC 9(3).
LINKAGE SECTION.
01 HEAD-OF-LIST POINTER.
PROCEDURE DIVISION USING HEAD-OF-LIST.
MAINLINE SECTION.
MOVE ZERO TO RET-CDE
PERFORM UNTIL HEAD-OF-LIST = NULL OR
RET-CDE NOT = ZERO
SET ADDRESS OF LINK TO HEAD-OF-LIST
SET NXT-PTR TO NEXT-PTR OF LINK
CALL "MEMFREE" USING HEAD-OF-LIST, RET-CDE
SET HEAD-OF-LIST TO NXT-PTR
END-PERFORM
GOBACK
.
END PROGRAM FREELST.
***************************************************
IDENTIFICATION DIVISION.
PROGRAM-ID MEMALOC COMMON PROGRAM.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 HEAPID PIC S9(9) BINARY.
01 FC.
02 CONDITION-TOKEN-VALUE.
COPY CEEIGZCT.
03 CASE-1-CONDITION-ID.
04 SEVERITY PIC S9(4) BINARY.
04 MSG-NO PIC S9(4) BINARY.
03 CASE-2-CONDITION-ID
REDEFINES CASE-1-CONDITION-ID.
04 CLASS-CODE PIC S9(4) BINARY.
04 CAUSE-CODE PIC S9(4) BINARY.
03 CASE-SEV-CTL PIC X.
03 FACILITY-ID PIC XXX.
02 I-S-INFO PIC S9(9) BINARY.
LINKAGE SECTION.
01 PTR-TO-MEM POINTER.
01 NBR-OF-BYTES PIC S9(9) BINARY.
01 RET-CDE PIC 9(3).
PROCEDURE DIVISION USING PTR-TO-MEM, NBR-OF-BYTES, RET-CDE.
MOVE 0 TO HEAPID
CALL "CEEGTST" USING HEAPID,
NBR-OF-BYTES,
PTR-TO-MEM,
FC
IF CEE000 OF FC THEN
MOVE ZERO TO RET-CDE
ELSE
DISPLAY "CEEGTST FAILED WITH: " MSG-NO OF FC
MOVE 1 TO RET-CDE
SET PTR-TO-MEM TO NULL
END-IF
GOBACK.
END PROGRAM MEMALOC.
***************************************************
IDENTIFICATION DIVISION.
PROGRAM-ID MEMFREE COMMON PROGRAM.
DATA DIVISION.
WORKING-STORAGE SECTION.
01 HEAPID PIC S9(9) BINARY.
01 FC.
02 CONDITION-TOKEN-VALUE.
COPY CEEIGZCT.
03 CASE-1-CONDITION-ID.
04 SEVERITY PIC S9(4) BINARY.
04 MSG-NO PIC S9(4) BINARY.
03 CASE-2-CONDITION-ID
REDEFINES CASE-1-CONDITION-ID.
04 CLASS-CODE PIC S9(4) BINARY.
04 CAUSE-CODE PIC S9(4) BINARY.
03 CASE-SEV-CTL PIC X.
03 FACILITY-ID PIC XXX.
02 I-S-INFO PIC S9(9) BINARY.
LINKAGE SECTION.
01 PTR-TO-MEM POINTER.
01 RET-CDE PIC 9(3).
PROCEDURE DIVISION USING PTR-TO-MEM, RET-CDE.
MOVE 0 TO HEAPID
CALL "CEEFRST" USING PTR-TO-MEM,
FC
IF CEE000 OF FC THEN
MOVE ZERO TO RET-CDE
ELSE
DISPLAY "CEEFRST FAILED WITH: " MSG-NO OF FC
MOVE 1 TO RET-CDE
END-IF
GOBACK.
END PROGRAM MEMFREE.
END PROGRAM LINKLST.
***************************************************
The program writes:
0001
0002
0003
0004
0005
LIST HAS BEEN FREED.
Not terribly exciting but does demonstrate how to string a few things together.