home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / lang / cplus / 12653 < prev    next >
Encoding:
Text File  |  1992-08-20  |  1.6 KB  |  40 lines

  1. Newsgroups: comp.lang.c++
  2. 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
  3. From: pjl@sparc10.cs.uiuc.edu (Paul Lucas)
  4. Subject: Re: Return value for the constructors.
  5. Message-ID: <1992Aug20.170239.3322@sunb10.cs.uiuc.edu>
  6. Sender: news@sunb10.cs.uiuc.edu
  7. Organization: University of Illinois at Urbana-Champaign
  8. References: <3462@unisql.UUCP> <1992Aug18.210426.19494@sunb10.cs.uiuc.edu> <H575V1E@netmbx.netmbx.de> <1992Aug20.122656.15072@aruba.uucp>
  9. Distribution: usa
  10. Date: Thu, 20 Aug 1992 17:02:39 GMT
  11. Lines: 27
  12.  
  13. In <1992Aug20.122656.15072@aruba.uucp> philc@ruby.aruba.UUCP (Phil Calvin) writes:
  14.  
  15. >In article <H575V1E@netmbx.netmbx.de>, jrobie@netmbx.netmbx.de (Jonathan Robie) writes:
  16.  
  17. >|> But note this example from the ARM, page 62:
  18. >|> 
  19. >|>     complex* p = new complex(i++);
  20. >|>     if (p == 0)  // allocation failed!
  21. >|> 
  22. >|> On page 61 he also states that initialization will only be done if the
  23. >|> return from the new is nonzero.
  24. >|> 
  25. >|> So I think that it is safe to check the pointer to see if it is zero.
  26.  
  27. >Isn't a more secure method provided by implementing a _new_handler function
  28. >that deals with allocation failures??
  29.  
  30. >That way, such pointer checks are unnecessary..
  31.  
  32.     Yes....but.  All the _new_handler knows is that somebody ran out
  33.     of memory somewhere.  It knows nothing about the object that was
  34.     trying to be constructed at the time; hence, it may only be able
  35.     to do "dumb" or "panic" actions.
  36. -- 
  37.     - Paul J. Lucas                University of Illinois    
  38.       AT&T Bell Laboratories        at Urbana-Champaign
  39.       Naperville, IL            pjl@cs.uiuc.edu
  40.