/* SI 413 Fall 2018
 * 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;
}