IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Dynamic memory allocation


IBM Mainframe Forums -> PL/I & Assembler
Post new topic   Reply to topic
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
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
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: 400
Location: Mumbai

PostPosted: Wed Apr 01, 2009 9:55 pm
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

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Apr 01, 2009 10:07 pm
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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> PL/I & Assembler

 


Similar Topics
Topic Forum Replies
No new posts CLIST - Virtual storage allocation error CLIST & REXX 5
No new posts Using Dynamic file handler in the Fil... COBOL Programming 2
No new posts JCL Dynamic System Symbols JCL & VSAM 3
No new posts Synctool-dynamic split job for varyin... JCL & VSAM 7
No new posts Dynamic file allocation using JCL JCL & VSAM 8
Search our Forums:

Back to Top