For Programmers: Free Programming Magazines  


Home > Archive > Cobol > June 2006 > ALLOCATE questions









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author ALLOCATE questions
Roger While

2006-06-27, 7:55 am

Standard says -
"2) If arithmetic-expression-1 evaluates to 0 or a negative value, the data
item referenced by data-name-2 is set to
the predefined address NULL."

No exception condition set ?


What is supposed to happen if a second ALLOCATE is done
for the same item (Without an intervening FREE) ?
(Implicit FREE/ReALLOCATE ?)

Roger


Roger While

2006-06-27, 7:55 am

Further, why is there no [NOT] ON EXCEPTION for ALLOCATE ?
Seems like a thing you need to know about.

Roger

"Roger While" <simrw@sim-basis.de> schrieb im Newsbeitrag
news:e7r18m$4bf$01$1@news.t-online.com...
> Standard says -
> "2) If arithmetic-expression-1 evaluates to 0 or a negative value, the
> data item referenced by data-name-2 is set to
> the predefined address NULL."
>
> No exception condition set ?
>
>
> What is supposed to happen if a second ALLOCATE is done
> for the same item (Without an intervening FREE) ?
> (Implicit FREE/ReALLOCATE ?)
>
> Roger
>



Rick Smith

2006-06-27, 7:55 am


"Roger While" <simrw@sim-basis.de> wrote in message
news:e7r18m$4bf$01$1@news.t-online.com...
> Standard says -
> "2) If arithmetic-expression-1 evaluates to 0 or a negative value, the

data
> item referenced by data-name-2 is set to
> the predefined address NULL."
>
> No exception condition set ?


Apparently not. Why should NULL be an exception?
If the programmer wishes to treat NULL as an exception,
why not
if address of data-name-2 equal null
*> handle progammer-defined exception
end-if
?


> What is supposed to happen if a second ALLOCATE is done
> for the same item (Without an intervening FREE) ?
> (Implicit FREE/ReALLOCATE ?)


14.8.3.3 [ALLOCATE statement] General rules,
"10) The allocated storage persists until explicitly released
with a FREE statement or the run unit is terminated,
whichever occurs first."

It is possible that the address of a based item could be
assigned to a data-pointer before the next allocation to
the same based item; in fact, I would think it likely if one
is using linked lists, trees, or the like.

This is not to say that an implementor could not maintain
reference counts for memory allocations and automatically
free them when there are no outstanding references
(garbage collection).



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com