delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/12/12/08:02:57

X-Authentication-Warning: delorie.com: mailnull set sender to djgpp-bounces using -f
From: Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: gcc bug or am I blind?
Date: 12 Dec 2001 12:27:02 GMT
Organization: Aachen University of Technology (RWTH)
Lines: 21
Message-ID: <9v7iem$54q$1@nets3.rz.RWTH-Aachen.DE>
References: <3C17418A DOT 85364005 AT ma DOT tum DOT de> <3C174718 DOT EF323B32 AT ma DOT tum DOT de>
NNTP-Posting-Host: acp3bf.physik.rwth-aachen.de
X-Trace: nets3.rz.RWTH-Aachen.DE 1008160022 5274 137.226.32.75 (12 Dec 2001 12:27:02 GMT)
X-Complaints-To: abuse AT rwth-aachen DOT de
NNTP-Posting-Date: 12 Dec 2001 12:27:02 GMT
Originator: broeker@
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:
> Waldemar Schultz schrieb:
>> 
>> Hi,
>> Please have a look on this program
>> 
>> //M_CAT.c
> --snip
>>   dest=realloc(dest,strlen(arg)*sizeof(*dest));

> of course:   dest=realloc(dest,(1+strlen(arg))*sizeof(*dest));
> but the problem persists.

The realloc() call ist still *very* wrong.  You're forgetting the space
that dest already needs.  The second argument would have to be:

	(strlen(dest)+strlen(arg)+1)*(sizeof(*dest) 

-- 
Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de)
Even if all the snow were burnt, ashes would remain.

- Raw text -


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