1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/* SI 413 Fall 2012
 * Keeps allocating blocks of the specified size until something stops it.
 */
 
#include <iostream>
#include <cstdlib>
#include <cstring>
 
using namespace std;
 
int main(int argc, char** argv) {
  if (argc != 2) {
    cout << "Usage: " << argv[0] << " size" << endl;
    return 1;
  }
 
  int size = atoi(argv[1]);
  int* arr;
 
  for (int i=0; ; ++i) { // infinite loop!
    cout << i << endl;
    arr = new int[size];
    if (arr == NULL) {
      cout << "FAIL" << endl;
      return 1;
    }
    memset(arr, 0, size*sizeof(int));
    //delete [] arr;
  }
 
  return 0;
}