Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Dynamic memory allocation

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler
View previous topic :: :: View next topic  
Author Message
shashi1026

New User


Joined: 18 Nov 2008
Posts: 3
Location: Chennai

PostPosted: Wed Apr 01, 2009 5:16 pm    Post subject: Dynamic memory allocation
Reply with quote

Hi,

1. Consider a program 'A' calls program 'B' dynamically. Program 'B' allocates a structure and fills data in it and returns a pointer of the allocated structure to the calling program 'A'.
Now, can the structure allocated in program 'B' , be used in program 'A', as the allocating program ie 'B' has already ended.

2. What is the difference between builtin function ALLOCATE and the service CEEGTST
Back to top
View user's profile Send private message

Bill Dennis

Active Member


Joined: 17 Aug 2007
Posts: 562
Location: Iowa, USA

PostPosted: Wed Apr 01, 2009 7:02 pm    Post subject:
Reply with quote

1. Program 'A' should allocate the space for the structure and pass the address to 'B' for updating.
Back to top
View user's profile Send private message
MBabu

Active User


Joined: 03 Aug 2008
Posts: 401
Location: Mumbai

PostPosted: Wed Apr 01, 2009 9:55 pm    Post subject:
Reply with quote

It doesn't matter which program allocates the storage as long as they are running in the same task. What does matter is that the storage must be explicitly allocated (getmain'ed) as opposed to being part of the 'local' storage the program uses for local variables, which goes away when the called program ends. Storage you explicitly allocate stays allocated until the task ends but you should explicitly free it too because your program may not be able to count on task termination to clean up.
Back to top
View user's profile Send private message
enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10327
Location: italy

PostPosted: Wed Apr 01, 2009 10:07 pm    Post subject: Reply to: Dynamic memory allocation
Reply with quote

Quote:
It doesn't matter which program allocates the storage as long as they are running in the same task


not true for pl/i ( block structured language )

- a variable declared inside a block is not known outside the block itself

in a dynamically invoked pli program the SCOPE of a variable is the called program
the storage used for the variables will be freed at program exit/return

the only correct solution is as per Bill Dennis answer
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> PL/I & Assembler All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts REXX - Dynamic file Creation d_sarlie CLIST & REXX 7 Tue Jun 27, 2017 7:30 pm
No new posts Dynamic output file creation in cobol... smileheal COBOL Programming 7 Thu Jun 15, 2017 10:53 pm
No new posts VSAM Space Allocation mrgnndhmk JCL & VSAM 7 Sat Apr 22, 2017 12:42 am
No new posts Dynamic split of files under groups sril.krishy DFSORT/ICETOOL 4 Mon Apr 17, 2017 1:09 pm
No new posts Dynamic array request/response contai... Suja.Sai CICS 2 Tue Jan 24, 2017 11:37 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us