使用 LE 例程分配内存

发布于 2024-08-21 07:27:10 字数 273 浏览 6 评论 0原文

可变长度表中的内存分配 NealB 提到了在非 CICS COBOL 程序中分配/释放内存的 LE 例程。

我非常想知道这是如何完成的:如何调用 LE 例程。 (我熟悉链接部分和设置地址。)

由于我目前无法访问 IBM 大型机 - 这意味着无法访问在线文档 - 一些代码片段可以启发我。

At
Allocation of Memory in Variable-Length Tables
NealB mentioned LE routines to allocate/deallocate memory in a non-CICS COBOL program.

I'd very much like to know how this is done: how the LE routine is called. (I'm familiar with the LINKAGE SECTION and with SET ADDRESS.)

Since I have no access to an IBM mainframe at the moment - meaning no access to online documentation - some code snippets could enlighten me.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

┊风居住的梦幻卍 2024-08-28 07:27:10

在 LE 环境中,您可以调用 CEEGTST 和 CEEFRST 来获取并释放存储空间。

它们都采用 12 字节结果标记作为第一个参数——如果您传递 null,LE 将在失败时为您异常终止。

第二个参数是地址。

对于 CEEGTST,您还传递第三个长度参数。

分配示例:

Call 'CEEGTST' using
  omitted
  address of some-linkage-item
  length of some-linkage-item
End-Call

释放示例:

Call 'CEEFRST' using
  omitted
  address of some-linkage-item
End-Call

In an LE environment, you would call CEEGTST and CEEFRST to get and free storage.

They both take a 12-byte result token as the first parameter -- if you pass null, LE will abend for you on a failure.

The second parameter is the address.

In the case of CEEGTST, you also pass a third, length, parameter.

Example to allocate:

Call 'CEEGTST' using
  omitted
  address of some-linkage-item
  length of some-linkage-item
End-Call

Example to free:

Call 'CEEFRST' using
  omitted
  address of some-linkage-item
End-Call
剧终人散尽 2024-08-28 07:27:10

几乎所有 IBM 产品和技术文档都可以在 Internet 上找到。
整理起来可能有点麻烦,但看看
图书管理器

要回答您的具体问题,

语言环境编程参考
告诉您几乎所有内容
曾经需要了解 LE。您可能想要了解的内存管理例程是:CEEGTST
(分配内存)和CEEFRST(空闲内存)。

以下内容有点长,但它是一个完整的 IBM Enterprise COBOL 程序,做了一些简单的操作
使用 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.
  ***************************************************

程序写道:

    0001
    0002
    0003
    0004
    0005
    LIST HAS BEEN FREED.

不是很令人兴奋,但确实演示了如何将一些东西串在一起。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文