delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2004/06/01/17:21:11

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
Date: Tue, 1 Jun 2004 23:08:18 +0200
From: Egon Eckert <egon AT heaven DOT industries DOT cz>
To: djgpp AT delorie DOT com
Subject: Re: "delete" crash
Message-ID: <20040601210818.GC9423@chance.cz>
References: <a716df2e DOT 0406010443 DOT 581cf241 AT posting DOT google DOT com>
Mime-Version: 1.0
In-Reply-To: <a716df2e.0406010443.581cf241@posting.google.com>
User-Agent: Mutt/1.5.5.1+cvs20040105i
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

> "new". If anyone is eager to help me, here is the source

I doubt the problem lies in DJGPP, but I see more of them in your
GString class.  So we are off-topic here...  I would suggest at least:

- add a copy constructor, ie. "GString::GString(const GString& other)"

- be careful to avoid calling strcpy() on overlapping strings, the
good practice is to check "if (this != &strFrom) ..." in the
assignment operator

- the assignment operator itself should IMHO take "const GString&"
instead of "const GString"

- check bounds in "operator[]" to prevent overwriting memory past the
pString

etc.  In short, "back to the drawing table". :-)

-- 
Egon Eckert, Heaven Industries, s.r.o.
E-mail: egon AT heaven DOT industries DOT cz

Never be afraid to try something new. Remember, amateurs built the
ark; professionals built the Titanic. -- Anonymous

- Raw text -


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