size *= 2; if (realloc(arr, size * sizeof(int)) == NULL) { fprintf(stderr, "Not enough memory\n"); exit(EXIT_FAILURE); }