home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!wupost!zaphod.mps.ohio-state.edu!moe.ksu.ksu.edu!ux1.cso.uiuc.edu!m.cs.uiuc.edu!sunb10.cs.uiuc.edu!sparc10.cs.uiuc.edu!pjl
- From: pjl@sparc10.cs.uiuc.edu (Paul Lucas)
- Subject: Re: Return value for the constructors.
- Message-ID: <1992Aug20.170239.3322@sunb10.cs.uiuc.edu>
- Sender: news@sunb10.cs.uiuc.edu
- Organization: University of Illinois at Urbana-Champaign
- References: <3462@unisql.UUCP> <1992Aug18.210426.19494@sunb10.cs.uiuc.edu> <H575V1E@netmbx.netmbx.de> <1992Aug20.122656.15072@aruba.uucp>
- Distribution: usa
- Date: Thu, 20 Aug 1992 17:02:39 GMT
- Lines: 27
-
- In <1992Aug20.122656.15072@aruba.uucp> philc@ruby.aruba.UUCP (Phil Calvin) writes:
-
- >In article <H575V1E@netmbx.netmbx.de>, jrobie@netmbx.netmbx.de (Jonathan Robie) writes:
-
- >|> But note this example from the ARM, page 62:
- >|>
- >|> complex* p = new complex(i++);
- >|> if (p == 0) // allocation failed!
- >|>
- >|> On page 61 he also states that initialization will only be done if the
- >|> return from the new is nonzero.
- >|>
- >|> So I think that it is safe to check the pointer to see if it is zero.
-
- >Isn't a more secure method provided by implementing a _new_handler function
- >that deals with allocation failures??
-
- >That way, such pointer checks are unnecessary..
-
- Yes....but. All the _new_handler knows is that somebody ran out
- of memory somewhere. It knows nothing about the object that was
- trying to be constructed at the time; hence, it may only be able
- to do "dumb" or "panic" actions.
- --
- - Paul J. Lucas University of Illinois
- AT&T Bell Laboratories at Urbana-Champaign
- Naperville, IL pjl@cs.uiuc.edu
-