HP3000-L Archives

January 2007, Week 4

HP3000-L@RAVEN.UTC.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Randy Schleicher <[log in to unmask]>
Reply To:
Randy Schleicher <[log in to unmask]>
Date:
Wed, 24 Jan 2007 18:14:07 -0500
Content-Type:
text/plain
Parts/Attachments:
text/plain (48 lines)
I am looking to dynamically reduce memory usage for a calling program and a 
sub-program.  The calling program reads in an HTTP message from a socket 
and it reads, and sets the MESSAGE-LENGTH value based upon the length of 
the received transaction.  

Here's the calling program specifics:

 01  MESSAGE-LENGTH              PIC S9(9) COMP VALUE 0.
 01  SOCKET-BUFFER.
      05  FILLER                   PIC X OCCURS 1 TO 5000000 TIMES
                                       DEPENDING ON MESSAGE-LENGTH.
...

     CALL "SUBPRG" USING MESSAGE-LENGTH, SOCKET-BUFFER.


Here's the sub-program specifics:

 LINKAGE SECTION.                                                 
                                                                  
 01  MESSAGE-LENGTH            PIC S9(9) COMP.                    
 01  READ-SOCKET-BUFFER.                                          
      05  FILLER                   PIC X OCCURS 1 TO 5000000 TIMES 
                                       DEPENDING ON MESSAGE-LENGTH.    

 PROCEDURE DIVISION USING
           MESSAGE-LENGTH, READ-SOCKET-BUFFER.           

Questions:

Does COBOL pass the buffer to the sub-program by memory reference?  In 
other words, all that is passed is a memory reference to the buffer that both 
the calling program and sub-program access.  I am thinking yes.

Does the DEPENDING clause and value in MESSAGE-LENGTH determine the 
actual allocation of memory?

Or is memory allocated to the maxium in the OCCURS no matter what the value 
of MESSAGE-LENGTH?

Perhaps there's another more efficent way to dynamically allocate the 
memory.  Any advice would be much appreciated.

TIA.

* To join/leave the list, search archives, change list settings, *
* etc., please visit http://raven.utc.edu/archives/hp3000-l.html *

ATOM RSS1 RSS2