delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2000/09/10/18:51:49

Date: Mon, 11 Sep 2000 00:49:53 +0200
From: Egon Eckert <egon AT chance DOT cz>
To: djgpp AT delorie DOT com
Subject: Re: strdup() with delete[]
Message-ID: <20000911004953.B23829@chance.cz>
References: <8pgtns$sja$1 AT info DOT cyf-kr DOT edu DOT pl>
Mime-Version: 1.0
User-Agent: Mutt/1.0.1i
In-Reply-To: <8pgtns$sja$1@info.cyf-kr.edu.pl>; from r_maj@poczta.onet.pl on Sun, Sep 10, 2000 at 11:18:07PM +0200
Reply-To: djgpp AT delorie DOT com
Errors-To: nobody AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> All memory allocated like
>   char* s = new char[100];
> should be deleted using :
>   delete s[];
> right ?

I'd use free (s), as for everything allocated with malloc.  That's what
strdup does, it doesn't call 'operator new'.  It doesn't even know anything
about C++.

-- 
Egon Eckert, Chance, a.s.
E-mail: egon AT chance DOT cz

- Raw text -


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