View previous topic :: View next topic
|
Author |
Message |
Duncan Sharppe
New User
Joined: 13 Dec 2013 Posts: 20 Location: USA
|
|
|
|
Hello people of the forum!
The following text is from the PL/I Language Reference (SC14-7285-02)
page 450.
AVAILABLEAREA returns a FIXED BINARY(31,0) value.
The value returned by AVAILABLEAREA is the size of the largest
single allocation that can be obtained from the area x.
The example cited in the book on page 450 is:
{Note that I've added the line numbers for ease of reference.)
1 ... dcl Uarea area(1000);
2 ... dcl Pz ptr;
3 ... dcl C99z char(99) varyingz based(Pz);
4 ... dcl (SizeBefore, SizeAfter) fixed bin(31);
5 ... SizeBefore = availablearea(Uarea); /* returns 1000 */
6 ... Alloc C99z in(Uarea);
7 ... SizeAfter = availablearea(Uarea); /* returns 896 */
8 ... dcl C9 char(896) based(Pz);
9 ... Alloc C9 in(Uarea);
From my understanding the allocate in statement number (6) allocated 100
bytes in area (Uarea) qualified by the based variable (C99z).
The returned value from availablearea in statement (7) is said to be
896; I believe this is incorrect it should be 900 as the varible (C99z)
has been the only thing allocate in area (Uarea).
It appears that the writer has assumed the pointer(Pz) been allocated
in the area as well. Or has mistakenly added the additional 4-bytes
of the pointer to the allocation and thus cites the number 896 in
the comments of line 8 as the remaining free space.
Is my understanding correct or I am missing something obvious.
TIA for any clirafications.
friarDuncan |
|
Back to top |
|
 |
prino
Senior Member

Joined: 07 Feb 2009 Posts: 1318 Location: Vilnius, Lithuania
|
|
|
|
The example is correct, the size of variables allocated inside an area is rounded up to the next multiple of 8 bytes. |
|
Back to top |
|
 |
Duncan Sharppe
New User
Joined: 13 Dec 2013 Posts: 20 Location: USA
|
|
|
|
Thank you!
I think I'll write ASM some code to examine the area and the "allocated data" within it or if I feel bolder I will TEST the proc and ASM code in TSO.
Whew!
friarDuncan |
|
Back to top |
|
 |
prino
Senior Member

Joined: 07 Feb 2009 Posts: 1318 Location: Vilnius, Lithuania
|
|
|
|
This should get you started, no assembler required:
Code: |
dcl 1 * union,
2 area(1000),
2 ar_ea, /* Overlay on area */
3 use_list bit (1), /* Free list in use */
3 filler char (3),
3 nab fixed bin (31), /* Next available byte */
3 ffree fixed bin (31), /* Offset of first free byte */
3 eol fixed bin (31), /* Always 0, end of free list */
3 contents char (1000); /* Contents */ |
|
|
Back to top |
|
 |
Duncan Sharppe
New User
Joined: 13 Dec 2013 Posts: 20 Location: USA
|
|
|
|
Hehehe...
Sorry for not getting back to you sooner...
That is some code!!!
I really like your knowledge set and I love learning about internals.
Much Thanks.
friarDuncan |
|
Back to top |
|
 |
|