diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-03-16 18:09:04 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-03-16 18:09:04 +0000 |
commit | 5c3dd954465e8e3db3ac44183d230e1b77f78134 (patch) | |
tree | 4920fcc9bcc9c8b1bb171295dc26610d9e6c3927 | |
parent | 99c2964bca779f2bae8d6e9e04d4d31ca37ea1e1 (diff) |
Catch std::bad_alloc program wide (to catch out nazi sysadmins who restrict machines to small memory sizes, and expect things to still run fine :p)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3722 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r-- | src/inspircd.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 1df6ee293..aed513737 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -26,6 +26,9 @@ using namespace std; #include <sys/ioctl.h> #include <time.h> #include <string> +#include <exception> +#include <stdexcept> +#include <new> #ifdef GCC3 #include <ext/hash_map> #else @@ -829,9 +832,18 @@ int InspIRCd::Run() int main(int argc, char** argv) { - ServerInstance = new InspIRCd(argc, argv); - ServerInstance->Run(); - delete ServerInstance; - return 0; + try + { + ServerInstance = new InspIRCd(argc, argv); + ServerInstance->Run(); + delete ServerInstance; + } + catch (std::bad_alloc) + { + log(DEFAULT,"You are out of memory! (got exception std::bad_alloc!)"); + send_error("**** OUT OF MEMORY **** We're gonna need a bigger boat!"); + printf("Out of memory! (got exception std::bad_alloc!"); + } + return 0; } |