Re: malloc under linux
- From: Keith Thompson <kst-u@xxxxxxx>
- Date: Wed, 03 Oct 2007 11:42:51 -0700
santosh <santosh.k83@xxxxxxxxx> writes:
jacob navia wrote:[...]
[...]This makes any serious usage of malloc completely impossible!
Theoretically, but practically this is not much of a problem for most
programs.
It always return true!
No. It means what it says, i.e., even if malloc returns a non-null pointer,
memory might not actually be allocated. Linux attempts to do so, when the
memory is actually written to.
jacob's statement isn't an unreasonable inference, though. Given the
description, it's plausible that malloc() will always return a
non-null result (which can be interpreted as "true").
An experiment on my own Linux box shows that it doesn't *quite* work
that way; malloc() does return a null pointer for very large arguments
(above about 2.1 gigabytes on a system with 1 gigabyte of physical
memory).
--
Keith Thompson (The_Other_Keith) kst-u@xxxxxxx <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
"We must do something. This is something. Therefore, we must do this."
-- Antony Jay and Jonathan Lynn, "Yes Minister"
.
- Follow-Ups:
- Re: malloc under linux
- From: santosh
- Re: malloc under linux
- References:
- malloc under linux
- From: jacob navia
- Re: malloc under linux
- From: santosh
- malloc under linux
- Prev by Date: What is the meaning of the term open coded in the following extract
- Next by Date: Re: What is the meaning of the term open coded in the following extract
- Previous by thread: Re: malloc under linux
- Next by thread: Re: malloc under linux
- Index(es):
Relevant Pages
|
|