Re: Freeing memory - will it be available immediately
- From: Ben Bacarisse <ben.usenet@xxxxxxxxx>
- Date: Mon, 03 Mar 2008 14:52:08 +0000
Kelsey Bjarnason <kbjarnason@xxxxxxxxx> writes:
[snips]
On Fri, 29 Feb 2008 11:39:26 +0000, Ben Bacarisse wrote:
I have been sitting on my hands with this thread, but I can't any
longer. Your basis for this is that the standard only considers one
program, that there is no "OS" so how else can one interpret "being
available"?
No, that's not my basis; check the thread.
Earlier you did seem to stress the fact that the standard does nothing
but define the behaviour of one program -- that any discussion of
other entities was reading more into the words than could be there.
But I am very happy if you are not saying this. The word "allocate"
suggests exactly this: the presence of multiple entities that own the
memory -- initially something other than the program, and then the
program, once malloc has succeeded.
You miss the fact that there *is* another entity here, but only by
implication. It seems reasonable to me to interpret "available for
further allocation" as returning the memory to the place it came from.
And nobody said anything about "to the place it came from".
malloc does not create the memory, it "allocates" it.
Yes, and?
It can't be a debate if you do this sort of thing. The "and" comes in
the conclusion I draw in the very next sentence.
This implies a
sort of change of ownership from some other entity (the OS, of course)
to the program.
Assuming there is an OS; there need not be.
I said "entity". I apologise for the parenthetical OS reference. The
word "allocate" can be taken to be a change of ownership. That is the
point. "To assign" and "to allot" are similar.
An allocation is an assignment, from one entity to
another. Making memory "available for further allocation" could be
taken to mean the memory reverts to the state (of ownership) that it had
before.
it could be, except that the standard forbids it. The defined behaviour
of free is the defined behaviour of a C standard library function as
relied upon by a C program. The definition of that function, upon which
the program relies, says that the memory *is* made available for further
allocation. Not "may be, if the OS hasn't handed it off somewhere else",
and there is *no* clause for such implementation-defined behaviour
anywhere in the definition.
Was the memory "available for allocation" before malloc allocated it
to the program? I see that as a perfectly reasonable meaning for
those words. For free to do no more than re-create that state of
affairs seems equally reasonable. It withdraws the ownership
previously granted.
I can accept that you don't, but I am finding it hard to see why you
think it is unambiguous.
--
Ben.
.
- References:
- Re: Freeing memory - will it be available immediately
- From: Kelsey Bjarnason
- Re: Freeing memory - will it be available immediately
- Prev by Date: Re: guess the output
- Next by Date: Re: hw does printf(),scanf() nd all work??
- Previous by thread: Re: Freeing memory - will it be available immediately
- Next by thread: Re: Freeing memory - will it be available immediately
- Index(es):
Relevant Pages
|