可变长度表中的内存分配 [英] Allocation of Memory in Variable-Length Tables
问题描述
说我在工作存储
...
01 SOAP-RECORD.
05 SOAP-INPUT PIC X(8) VALUE SPACES.
05 SOAP-STATUS PIC 9 VALUE ZERO.
05 SOAP-MESSAGE PIC X(50) VALUE SPACES.
05 SOAP-ITEMS OCCURS 0 TO 500 TIMES
DEPENDING ON ITEM-COUNT
INDEXED BY ITEM-X.
10 SI-SUB-ITEMS OCCURS 0 TO 100 TIMES
DEPENDING ON SUB-COUNT
INDEXED BY SUB-X.
15 SS-KEY PIC X(8) VALUE SPACES.
15 SS-AMOUNT PIC -9(7).99 VALUE ZEROS.
15 SS-DESCR PIC x(100) VALUE SPACES.
此程序运行时是否会最初分配该表可能需要的空间,或者分配内存更动态吗?我猜想 DEPENDING ON
子句会使其更动态,因为它会分配更多的内存作为 ITEM-COUNT
变量递增。一位同事告诉我否则,但他不确定100%。所以我真的很想知道它是如何工作的,以便尽可能高效地构建程序。
When this program runs, will it initially allocate as much space as this table could possibly need, or is it more dynamic about allocating memory? I would guess that the DEPENDING ON
clause would make it more dynamic in the sense that it would allocate more memory as the ITEM-COUNT
variable is incremented. A co-worker tells me otherwise, but he is not 100% sure. So I would really like to know how this works in order to structure my program as efficiently as possible.
PS:是的,我 am 在写作一个新的COBOL程序!它实际上是CICS网络服务。我认为这种语言不会消失:(
PS: Yes, I am writing a new COBOL program! It's actually a CICS web service. I don't think this language will ever die :(
推荐答案
您没有提到正在使用哪个编译器,但是,至少直到当前的2002年COBOL标准为止,分配给OCCURS ... DEPENDING ON(ODO)数据项的空间都不需要是动态的。(实际上,它的出现次数,而不是长度)尽管您的编译器供应商可能已经实现了对该标准的扩展,但是我不知道在这一领域有任何供应商这样做。
You don't mention which compiler you're using, but, at least up through the current, 2002, COBOL standard, the space allocated for an OCCURS...DEPENDING ON (ODO) data item is not required to be dynamic. (It's really only the number of occurrences, not the length, of the data item that varies.) Although your compiler vendor may've implemented an extension to the standard, I'm not aware of any vendor that has done so in this area.
该标准的下一个但尚未批准的修订版包括对具有新的OCCURS DYNAMIC格式的动态容量表的支持。
The next, but not yet approved, revision of the standard includes support for dynamic-capacity tables with a new OCCURS DYNAMIC format.
这篇关于可变长度表中的内存分配的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!