int main() {
  int length = __VERIFIER_nondet_int();
  int n = __VERIFIER_nondet_int();
  int c = __VERIFIER_nondet_int();
  if (length < 1) {
      length = 1;
  }
  if (n < 1) {
      n = 1;
  }
  char* nondetArea = (char*) alloca(n * sizeof(char));
  cmemset(nondetArea, c, n);
  return 0;
}
Example #2
0
GC_USER_FUNC void
lex_read_file (GC_CAP const char * name)
{
  lex_state.num_tokens = 0;
  FILE * file = fopen((const char *) name, "rb");
  if (!file)
  {
    fprintf(stderr, "could not open file %s\n", (const char *) name);
    exit(1);
  }
  
  // A very inefficient way of reading a file, designed to stress the collector.
  lex_state.max = 0;
  lex_state.file = GC_INVALID_PTR();
  lex_state.index = 0;
  char c;
  while (fread(&c, 1, 1, file) == 1)
  {
    lex_state.max++;
    GC_CAP char * tmp = GC_INVALID_PTR();
    GC_STORE_CAP(tmp, ml_malloc(lex_state.max));
    if (!PTR_VALID(tmp))
    {
      fprintf(stderr, "out of memory reading file %s\n", (const char *) name);
      exit(1);
    }
    cmemset(tmp, 0, lex_state.max);
    if (PTR_VALID(lex_state.file))
    {
      cmemcpy(tmp, lex_state.file, lex_state.max-1);
    }
    GC_STORE_CAP(lex_state.file, tmp);
    lex_state.file[lex_state.max-1] = c;
  }

  fclose(file);
}