summaryrefslogtreecommitdiff
path: root/src/inspircd.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-03-16 18:09:04 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-03-16 18:09:04 +0000
commit5c3dd954465e8e3db3ac44183d230e1b77f78134 (patch)
tree4920fcc9bcc9c8b1bb171295dc26610d9e6c3927 /src/inspircd.cpp
parent99c2964bca779f2bae8d6e9e04d4d31ca37ea1e1 (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
Diffstat (limited to 'src/inspircd.cpp')
-rw-r--r--src/inspircd.cpp20
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;
}