🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.std.c++
Article #1441

Re: initialized 'global' (extern) char arrays

#1441
From: Steve Clamage
Date: Sat, 09 Jan 1993 17:22
17 lines
1048 bytes
mbb@litwin.com (Mark Beyleveld) writes:

>char * x = strdup("abcde");
>char * y = new char[6];
>(void) strcpy(y, "abcde");

>Further down the road, I want to dispose of the data (which is legal,
>since both are dynamically allocated). Do I use free or delete?

Is it not a good idea to use a C library version of strdup (which is
not part of the C Standard anyway) in a C++ program, for exactly this
reason.  If you need strdup, you would be better off writing your own
as a C++ function, possibly giving it another name to reduce confusion
for the readers of the program.
-- 

Steve Clamage, TauMetric Corp, steve@taumet.com
Technical Details
Message-ID: <1993Jan9.172228.13126@taumet.com>
Path: arc1-ca.pugleaf.net!sparky!uunet!taumet!steve
References: <1993Jan7.032458.21941@netcom.com> <9300812.4657@mulga.cs.mu.OZ.AU> <1993Jan8.135547.26553@litwin.com>

Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c++
Path: arc1-ca.pugleaf.net!sparky!uunet!taumet!steve
From: steve@taumet.com (Steve Clamage)
Subject: Re: initialized 'global' (extern) char arrays
Message-ID: <1993Jan9.172228.13126@taumet.com>
Organization: TauMetric Corporation
References: <1993Jan7.032458.21941@netcom.com> <9300812.4657@mulga.cs.mu.OZ.AU> <1993Jan8.135547.26553@litwin.com>
Date: Sat, 9 Jan 1993 17:22:28 GMT
Lines: 17