James Sutherland wrote:
> >> >BUT "when I use up the resources given to me" - If the resources
> >> >weren't available, why did the system give them to me?
> >> It didn't.
> >If he did a [mc]alloc to ALLOCate the the memory and got a non-null
> >return, it certainly said it did.
> No - malloc() doesn't allocate MEMORY, it allocates ADDRESS SPACE to
> put memory in later. This may not be what you wanted, but that's what
> it does.
Both 'man malloc' and 'info malloc' on my SuSE 6.3 system say it
"allocates memory". At the very least, these pages need some text in
the BUGS section explaining what they actually do.
Also, you describe what malloc() currently does on Linux, but it is by
no means clear that that's what it should do.
Checking the C standard at:
7.20.3 Memory management functions
... The pointer returned if the allocation succeeds ...
may be ... used to
access such an object or an array of such objects in the
space allocated (until the space is explicitly freed or
The calloc function allocates space for an array of
nmemb objects, ...
The malloc function allocates space for an object ...
Notice that the standard makes no distinction between calloc() and
malloc(). Both "allocate space".
Earlier in this thread, though, someone suggested replacing malloc()
with calloc() to ensure that space actually gets allocated. That should
not be necessary.
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to email@example.com
Please read the FAQ at http://www.tux.org/lkml/
This archive was generated by hypermail 2b29 : Fri Mar 31 2000 - 21:00:15 EST