bad_alloc.cc
changeset 13 2640a7fd96ca
parent 9 c3fecc82ade6
child 28 54addf5893ef
equal deleted inserted replaced
12:9f0ce4eaa1ce 13:2640a7fd96ca
    17 
    17 
    18     rlim.rlim_cur = megs;
    18     rlim.rlim_cur = megs;
    19     rlim.rlim_max = 1.25 * megs;
    19     rlim.rlim_max = 1.25 * megs;
    20     if (megs > (4 * 1024 * 1024))
    20     if (megs > (4 * 1024 * 1024))
    21         return setrlimit (RLIMIT_AS, &rlim);
    21         return setrlimit (RLIMIT_AS, &rlim);
       
    22 
    22     return EXIT_FAILURE;
    23     return EXIT_FAILURE;
    23 }
    24 }
    24 
    25 
    25 int main (int argc, char **argv)
    26 int main (int argc, char **argv)
    26 {
    27 {
    39         }
    40         }
    40     } catch (exception & e) {
    41     } catch (exception & e) {
    41         cout << e.what () << " after " << i << " iterations" << endl << endl;
    42         cout << e.what () << " after " << i << " iterations" << endl << endl;
    42         cout << "Would you like to see the full error message? (y/n) ";
    43         cout << "Would you like to see the full error message? (y/n) ";
    43         cin >> action;
    44         cin >> action;
    44 		v.resize(0);
    45         v.clear();
    45         switch (action) {
    46         switch (action) {
    46         case 'y':
    47         case 'y':
    47             throw;
    48             throw;
    48             break;
    49             break;
    49         }
    50         }