Newsgroups: comp.os.msdos.djgpp Date: Tue, 3 Jul 2001 01:34:46 +0100 (BST) From: Daniel Barker To: Subject: Re: malloc() problem, DJDEV 203 In-Reply-To: <200107022351.TAA05124@envy.delorie.com> Message-ID: References: <200107022219 DOT SAA04299 AT envy DOT delorie DOT com> <200107022351 DOT TAA05124 AT envy DOT delorie DOT com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk There seems to be another problem as well. Some significantly smaller requests that are still large enough that they must fail, e.g., 4294378000U bytes, also cause malloc() to return non-NULL. I was experimenting to find the exact size at which the problem sets in, but my computer spontaneously rebooted before I got the answer. I became nervous and didn't press on. The operating system is Windows 98 SP1. On Mon, 2 Jul 2001, DJ Delorie wrote: > > > Alternatively, DJGPP malloc() could be changed to return NULL for > > zero-byte allocations. This is a significant change of behaviour but is > > allowed by the C standard. > > No, there are far too many programs that expect malloc(0) to succeed, > even if the standard allows it to fail. -- Daniel Barker.