View previous topic :: View next topic
|
Author |
Message |
shashi1026
New User
Joined: 18 Nov 2008 Posts: 3 Location: Chennai
|
|
|
|
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 |
|
|
Bill Dennis
Active Member
Joined: 17 Aug 2007 Posts: 562 Location: Iowa, USA
|
|
|
|
1. Program 'A' should allocate the space for the structure and pass the address to 'B' for updating. |
|
Back to top |
|
|
MBabu
Active User
Joined: 03 Aug 2008 Posts: 400 Location: Mumbai
|
|
|
|
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 |
|
|
enrico-sorichetti
Superior Member
Joined: 14 Mar 2007 Posts: 10873 Location: italy
|
|
|
|
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 |
|
|
|