| delorie.com/archives/browse.cgi | search |
| X-Authentication-Warning: | delorie.com: mailnull set sender to djgpp-bounces using -f |
| From: | Waldemar Schultz <schultz AT ma DOT tum DOT de> |
| Newsgroups: | comp.os.msdos.djgpp |
| Subject: | Re: gcc bug or am I blind? |
| Date: | Wed, 12 Dec 2001 17:48:47 +0100 |
| Organization: | [posted via] Leibniz-Rechenzentrum, Muenchen (Germany) |
| Lines: | 47 |
| Message-ID: | <3C178A6F.8B8DF9A0@ma.tum.de> |
| 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> |
| NNTP-Posting-Host: | pcritter14.mathematik.tu-muenchen.de |
| Mime-Version: | 1.0 |
| X-Trace: | wsc10.lrz-muenchen.de 1008175723 27894 131.159.68.151 (12 Dec 2001 16:48:43 GMT) |
| X-Complaints-To: | news AT lrz-muenchen DOT de |
| NNTP-Posting-Date: | 12 Dec 2001 16:48:43 GMT |
| X-Mailer: | Mozilla 4.75 [de] (Win98; U) |
| X-Accept-Language: | de,en-US |
| To: | djgpp AT delorie DOT com |
| DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
| Reply-To: | djgpp AT delorie DOT com |
CBFalconer schrieb:
> > dest = realloc (dest, (strlen (dest) + strlen (arg) + 1) * sizeof (char));
> ^^^^ ^^^^
> 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
Example
-------
if (now+new > max)
{
max = now+new;
p = realloc(p, max);
}
to something like
Example
-------
if (now+new > max)
{
max = now+new;
t = realloc(p, max);
if(t==0)
{
free(p);
/*...*/
exit(1);
}
else
p = t;
}
just a thought.
--
Gruss Waldemar Schultz. schultz AT ma DOT tum DOT de
Technische Universität München, Zentrum Mathematik M1, D 80290 München
Tel: +49 (0)89 2892 8226 FAX: +49 (0)89 2892 8228
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |