| www.delorie.com/archives/browse.cgi | search |
| From: | Hans-Bernhard Broeker <broeker AT physik DOT rwth-aachen DOT de> |
| Newsgroups: | comp.os.msdos.djgpp |
| Subject: | Re: Deleting after strdup |
| Date: | 3 May 2001 11:19:16 GMT |
| Organization: | Aachen University of Technology (RWTH) |
| Lines: | 16 |
| Message-ID: | <9crerk$mct$1@nets3.rz.RWTH-Aachen.DE> |
| References: | <9crage$5td$1 AT info DOT cyf-kr DOT edu DOT pl> |
| NNTP-Posting-Host: | acp3bf.physik.rwth-aachen.de |
| X-Trace: | nets3.rz.RWTH-Aachen.DE 988888756 22941 137.226.32.75 (3 May 2001 11:19:16 GMT) |
| X-Complaints-To: | abuse AT rwth-aachen DOT de |
| NNTP-Posting-Date: | 3 May 2001 11:19:16 GMT |
| Originator: | broeker@ |
| To: | djgpp AT delorie DOT com |
| DJ-Gateway: | from newsgroup comp.os.msdos.djgpp |
| Reply-To: | djgpp AT delorie DOT com |
Rafal Maj <maj_rafal AT poczta DOT onet DOT pl> wrote: > Sorry for newbie question... after char* s = strdup(...); I should use > delete[] s; ? No. free(s). strdup() is a C function, not a C++ one, so it uses the C style of memory allocation. > or is it safe to use char *s = strdup(org); ? Read it up in the docs. If they don't say you can pass in a NULL without harm, then you shouldn't. -- Hans-Bernhard Broeker (broeker AT physik DOT rwth-aachen DOT de) Even if all the snow were burnt, ashes would remain.
| webmaster | delorie software privacy |
| Copyright © 2019 by DJ Delorie | Updated Jul 2019 |