home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!sdl!adk
- From: adk@Warren.MENTORG.COM (Ajay Kamdar)
- Subject: strdup() Was: Re: Renew?
- Message-ID: <1992Jul27.201834.13654@Warren.MENTORG.COM>
- Organization: Mentor Graphics Corp. - IC Group
- References: <23315@alice.att.com> <1992Jul25.151227.8156@hemlock.cray.com> <1992Jul27.173054.396@taumet.com>
- Date: Mon, 27 Jul 1992 20:18:34 GMT
- Lines: 24
-
- In article <1992Jul27.173054.396@taumet.com> steve@taumet.com (Steve Clamage) writes:
- >There is no requirement that 'new', for example, have any relationship
- >whatever to 'malloc' or 'realloc'. Either might be implemented in
- >terms of the other, or they might be independent implementations. They
- >might even manage different address spaces.
-
- Given that new and malloc are not necessarily related, deleteing memory
- returned from strdup() [STRINGS(3)] could be a recipe for disaster since the
- returned memory is malloced and not newed. It is onerous to keep track of
- which memory is newed, and which is malloced. C++ code written using strdup()
- might work with one compiler but not with another if care is not exercised
- in freeing the returned memory.
-
- Is there any move towards providing C++ified versions of functions like
- strdup() as part of some standard library? Right now the only solution
- I know is to implement my own version of such functions.
-
- - Ajay
-
- --
- I speak for none but myself.
-
- Ajay Kamdar Email : ajay_kamdar@mentorg.com
- Mentor Graphics, IC Group (Warren, NJ) Phone : (908) 580-0102
-