home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!dtix!darwin.sura.net!jvnc.net!rutgers!bagate!cbmvax!cbmehq!cbmger!edohwg!heinz
- From: heinz@edohwg.UUCP (Heinz Wrobel)
- Newsgroups: comp.lang.c++
- Subject: Re: strdup() Was: Re: Renew?
- Message-ID: <heinz.02rw@edohwg.UUCP>
- Date: 29 Jul 92 21:33:36 GMT
- References: <1992Jul27.173054.396@taumet.com> <1992Jul27.201834.13654@Warren.MENTORG.COM> <1992Jul28.163356.3019@taumet.com> <1548ujINN826@agate.berkeley.edu>
- Organization: Edotronik GmbH
- Lines: 24
-
- In article <1548ujINN826@agate.berkeley.edu> jbuck@forney.berkeley.edu (Joe Buck) writes:
- >>Since strdup is a very tiny function, your best bet is to write one
- >>yourself for use with C++, using new rather than malloc if you wish.
- >
- >Like so:
- >
- >#include <string.h>
- >
- >char * strdup_new (const char * input) {
- > return strcpy(new char*[strlen(input)+1],input);
- >}
-
- Where is the error check for not having enough memory, i.e. new giving back
- a NULL pointer? Don't you need an error check?
-
- >Joe Buck jbuck@ohm.berkeley.edu
-
- --
- Heinz Wrobel, Edotronik GmbH (ECG018)
- FAX +49 89 850 51 25 / TEL +49 89 850 25 20 (HOME!&VOICE, sometimes...)
- Path: cbmehq!cbmger!edohwg!heinz@cbmvax.commodore.com
- "It's good to have a mouse, it's faster if you can do without one..."
- "He who doesn't develop with an A2024 doesn't know about font independent
- user interfaces..."
-