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

From: Damian Yerrick <Bullcr_pd_yerrick AT hotmail DOT comRemoveBullcr_p>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: strdup() with delete[]
Organization: Pin Eight Software http://pineight.8m.com/
Message-ID: <u92ors0c83laria5qtffqcrni94l89p0t0@4ax.com>
References: <8pgtns$sja$1 AT info DOT cyf-kr DOT edu DOT pl>
X-Newsreader: Forte Agent 1.7/32.534
MIME-Version: 1.0
Lines: 25
X-Trace: /Kw5eC5oHnU5/zdYZUbmtskSAW2ToWjTzHgEcejMaQPH24OTkluduAqhjCW0MAXzu8Hcl2a3OKnd!ii3AExXZjGX5NHClkvxtzHjALA2mRoIZKf7OjDWbI88ZJ1fHeAJAOIBoESVndoSMLnmmdUa6KrEM!Tyc=
X-Complaints-To: abuse AT gte DOT net
X-Abuse-Info: Please be sure to forward a copy of ALL headers
X-Abuse-Info: Otherwise we will be unable to process your complaint properly
NNTP-Posting-Date: Sun, 10 Sep 2000 22:21:22 GMT
Distribution: world
Date: Sun, 10 Sep 2000 22:21:22 GMT
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

On Sun, 10 Sep 2000 23:18:07 +0200, "Rafał Maj" <r_maj AT poczta DOT onet DOT pl>
wrote:

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

delete[] s;

>And what about allocation done with strdup() :
>  char* s = strdup("test");
>should I use then delete s[];  OR  delete s;  ?

Neither.  strdup() is part of the C library, so you use the C function
  free(s);

-- 
MS (n)  1. A debilitating and surprisingly widespread affliction
  that renders the sufferer barely able to perform the simplest
  task.  2. A disease, multiple sclerosis (see).

This is McAfee VirusScan. Add these two lines to your signature to
prevent the spread of signature viruses.  http://www.mcafee.com/

- Raw text -


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