Subject: Re: Possible bug relating to malloc()/realloc(), popen(), and read()
To: None <port-i386@NetBSD.org>
From: Vincent Stemen <netbsd@crel.us>
List: port-i386
Date: 12/02/2004 12:58:41
On Thu, Dec 02, 2004 at 03:25:35PM +0100, Martin Husemann wrote:
> On Wed, Dec 01, 2004 at 07:05:40PM -0600, Vincent Stemen wrote:
> > but the pointer I get back from realloc() does
> > not point to the beginning of the data allocated by the first malloc()
> > as it should.
> 
> Why do you think it should?

Because the manual on realloc() says it should and it would not be
very useful otherwise.  Either way, as pointed out by other replies, I
was misinterpreting the result.  That was not the problem.


> Your program does not properly handle return values from read(). You need
> to check -1 and errno == EAGAIN at least, if you don't read from straight
> disk files.
> 
> Martin

It does check for -1.  According to the manual, EAGAIN is only for
non-blocking I/O which I did not think applied in this case.


-- 
Vincent Stemen
Avoid the VeriSign/Network Solutions domain registration trap!
Read how Network Solutions (NSI) was involved in stealing our domain name.
http://www.InetAddresses.net