Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups 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: 10211
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 DB2: Dynamic allocation of DB2.D... BHAS CLIST & REXX 3 Mon Dec 19, 2016 8:26 pm
No new posts Not enough virtual memory is availabl... Vinay Pushpala IBM Tools 16 Tue Sep 13, 2016 4:37 pm
No new posts Creating a dynamic sort card in JCL u... ChitraChhabra DFSORT/ICETOOL 4 Wed Aug 03, 2016 6:15 pm
No new posts Need help on SQL Dynamic WHERE Clause subratarec DB2 12 Sat Jul 16, 2016 3:11 pm
No new posts Need to create file with Dynamic Name... kapil27 JCL & VSAM 4 Wed May 25, 2016 9:45 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us