Figure 1D: Example written in COBOL


       PROCESS NOMONOPRC.
       IDENTIFICATION DIVISION.
      * To compile: CRTBNDCBL PGM(EXAMPLE1D) BNDDIR(QC2LE)
       PROGRAM-ID. EXAMPLE1D.
       ENVIRONMENT DIVISION.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  ptr                POINTER.
       01  sz                 PIC S9(9) BINARY.
       LINKAGE SECTION.
       77  based-data PIC X(16).
       PROCEDURE DIVISION.
       MAIN-LINE SECTION.
       001-MAIN-FLOW.
           MOVE 16 TO sz.
      *    allocate 16 bytes of storage from the heap
           CALL LINKAGE PRC "malloc" USING BY VALUE sz
                                     RETURNING ptr.
      *    set the allocated storage
           SET ADDRESS OF based-data TO ptr.
           MOVE "abcdefghijklmnop" TO based-data.
      *    deallocate storage
           CALL LINKAGE PRC "free" USING BY VALUE ptr.
           STOP RUN.