From: fredex AT fcshome DOT stoneham DOT ma DOT us Message-Id: <199608061025.GAA00551@fcshome.stoneham.ma.us> Subject: Re: Malloc and realloc pains.. To: djgpp AT delorie DOT com Date: Tue, 6 Aug 1996 06:25:21 -0400 (EDT) In-Reply-To: <9608051653.aa11550@ailin.inti.edu.ar> from "Salvador Eduardo Tropea" at Aug 5, 96 04:52:51 pm Content-Type: text > >>Borland returns a NULL pointer on a malloc( (size_t)(0) ); > >>Microsoft does not deallocate the passed memory block on a failed realloc. > >>Perhaps someone can come up with a way to neatly fix the problem? Sorry I'm getting into this thread a bit late. Certainly the comment: > >>Borland returns a NULL pointer on a malloc( (size_t)(0) ); represents a non-conforming implementation, but it IS the way malloc used to commonly work in pre-ANSI days, so it's always good defensive programming to ASSUME this behavior when you're writing code, on the off-chance you'll hit an old (or broken) compiler some day. > >>Microsoft does not deallocate the passed memory block on a failed realloc. This, on the other hand, seems to me to be exactly the behavior you WANT in realloc, and what the standard specifies. What's the complaint here? Here's an excerpt from the standard: If the space cannot be allocated, the object pointed to by ptr is unchanged. It says nothing about deallocating ptr in case of failure, in fact it says (above) that it WON'T be. Fred -- ------------------------------------------------------------------------------- .---- Fred Smith / Office: fred AT computrition DOT com ( /__ ,__. __ __ / __ : / 508-663-2524 / / / /__) / / /__) .+' Home: fredex AT fcshome DOT stoneham DOT ma DOT us / / (__ (___ (__(_ (___ / :__ 617-438-5471 -------------------------------- Jude 1:24,25 ---------------------------------