ADMB Documentation  11.5.3197
 All Classes Files Functions Variables Typedefs Friends Defines
newhand.cpp
Go to the documentation of this file.
00001 /*
00002  * $Id$
00003  *
00004  * Author: David Fournier
00005  * Copyright (c) 2008-2012 Regents of the University of California
00006  */
00011 #include <admodel.h>
00012 #if !defined(__GNUG__)
00013 #  include <new.h>
00014 #else
00015 #  if __GNUG__>=3
00016 #    include <iostream>
00017      using namespace std;
00018 
00019 #     if __GNUG__<4
00020 #       include <new.h>
00021 #     endif
00022 #  endif
00023 #endif
00024 
00025 #if !defined(__GNUG__) ||   (defined(__GNUG__) && __GNUG__>=3)
00026 extern "C"  {
00027 #if defined(_MSC_VER)   // will need to deal with different VC versions
00028 int adnewhandler(size_t i)
00029 #else
00030 void adnewhandler(void)
00031 #endif
00032 {
00033    cout << "Memory allocation error -- Perhaps you are trying to allocate too"
00034      " much memory in your program "<< endl;
00035    ad_exit(1);
00036 #if defined(_MSC_VER)   // will need to deal with different VC versions
00037    return 0;
00038 #endif
00039 }
00040 } // extern "C"
00041 
00046 void ad_set_new_handler (void)
00047 {
00048 #if defined(_MSC_VER)   // will need to deal with different VC versions
00049   _set_new_handler (adnewhandler);
00050 #else
00051   set_new_handler (adnewhandler);
00052 #endif
00053 }
00054 #endif