delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/12/12/13:18:26

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f
From: "A. Sinan Unur" <asu1 AT cornell DOT edu>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: gcc bug or am I blind?
Date: 12 Dec 2001 17:59:52 GMT
Organization: Cornell University
Lines: 32
Sender: asu1 AT cornell DOT invalid (on 128.253.251.163)
Message-ID: <Xns91758435F416FASINANUNUR@132.236.56.8>
References: <3C17418A DOT 85364005 AT ma DOT tum DOT de> <3C174718 DOT EF323B32 AT ma DOT tum DOT de> <3c175119 AT news DOT starhub DOT net DOT sg> <3C17652A DOT C898D48F AT yahoo DOT com> <3C178A6F DOT 8B8DF9A0 AT ma DOT tum DOT de>
NNTP-Posting-Host: 128.253.251.163
X-Trace: news01.cit.cornell.edu 1008179992 9320 128.253.251.163 (12 Dec 2001 17:59:52 GMT)
X-Complaints-To: usenet AT news01 DOT cit DOT cornell DOT edu
NNTP-Posting-Date: 12 Dec 2001 17:59:52 GMT
User-Agent: Xnews/4.06.22
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Waldemar Schultz <schultz AT ma DOT tum DOT de> wrote in
news:3C178A6F DOT 8B8DF9A0 AT ma DOT tum DOT de: 

> CBFalconer schrieb:
>> > dest = realloc (dest, (strlen (dest) + strlen (arg) + 1) * sizeof
>> > (char)); 
>>   ^^^^            ^^^^

by the way, sizeof char is always 1.

>> automatically creates a memory leak on any realloc failure.  You want:
>> 
>>   if (NULL == (temp = realloc(dest, /* whatever */))) {
>>      /* failure recovery */ } else dest = temp;
> 
> Right. So shouldn't we modify the info libc realloc 

no we shouldn't. library routines are not supposed to exit on a whim. you 
don't want some library routine to dump your user out of the program when 
you could have handled the problem in many ways.

incidentally, this whole topic belongs not here but comp.lang.c or 
comp.lang.c.moderated. you might want to consult the FAQ before you post to 
those groups. for example, see

http://www.eskimo.com/~scs/C-faq/q7.8.html

Sinan.
-- 
--------------------------------
A. Sinan Unur
http://www.unur.com/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019