[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-devel
Subject:    Re: About memory allocation failures....
From:       "Schmidt, John" <John_Schmidt () compuware ! com>
Date:       2002-03-23 14:14:52
[Download RAW message or body]

On Saturday 23 March 2002 09:25, Laurent, Guillaume wrote:
> > The "standard" as set by Bjarne indicates
> > bad_alloc
> > is the default, but that does not seem to be the case for all compilers.

> You don't say. Welcome to C++.

So I finally got you to admit that the "default" action of failed memory 
acquisition is not ALWAYS throwing bad_alloc which implies it returns NULL
which cannot be "never," ergo you were wrong!  :))

> No. The latter is an extremely common idiom, applying the RAII "Ressource 
> Acquisition Is Initialisation" principle.

You didn't understand my analogy so I'll use an example right from the book 
you espouse:

void out_of_store() {
    cerr << "operator new failed: out of storage\n";
    throw bad_alloc();  // I'd recommend causing a SIGSEGV to get core
}

int main() {
    set_new_handler(out_of_store);
.
.
}

Wow, I've never seen anything so "advanced"...  :) 


John Schmidt
ServerVantage Development
Compuware Corporation
http://www.compuware.com/products/vantage
john.schmidt@compuware.com
 



The contents of this e-mail are intended for the named addressee only. It
contains information that may be confidential. Unless you are the named
addressee or an authorized designee, you may not copy or use it, or disclose
it to anyone else. If you received it in error please notify us immediately
and then destroy it. 

 
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic