home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / lang / cplus / 11820 < prev    next >
Encoding:
Internet Message Format  |  1992-07-30  |  1.3 KB

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