bool random_stress(void) {
  void *ptr_array[256];
  size_t i;
  int idx;

  corruption_cnt = 0;

  printf("Size of umm_heap is %u\n", (unsigned int) sizeof(test_umm_heap));

  umm_init();

  umm_info(NULL, 1);

  for (idx = 0; idx < 256; ++idx) ptr_array[idx] = (void *) NULL;

  for (idx = 0; idx < 100000; ++idx) {
    i = rand() % 256;

    /* try to realloc some pointer to deliberately too large value */
    {
      void *tmp = wrap_realloc(ptr_array[i], UMM_MALLOC_CFG__HEAP_SIZE);
      if (tmp != NULL) {
        printf("realloc to too large buffer should return NULL");
        return false;
      }
    }

    switch (rand() % 16) {
      case 0:
      case 1:
      case 2:
      case 3:
      case 4:
      case 5:
      case 6: {
        ptr_array[i] = wrap_realloc(ptr_array[i], 0);
        break;
      }
      case 7:
      case 8: {
        size_t size = rand() % 40;
        ptr_array[i] = wrap_realloc(ptr_array[i], size);
        memset(ptr_array[i], 0xfe, size);
        break;
      }

      case 9:
      case 10:
      case 11:
      case 12: {
        size_t size = rand() % 100;
        ptr_array[i] = wrap_realloc(ptr_array[i], size);
        memset(ptr_array[i], 0xfe, size);
        break;
      }

      case 13:
      case 14: {
        size_t size = rand() % 200;
        wrap_free(ptr_array[i]);
        ptr_array[i] = wrap_calloc(1, size);
        if (ptr_array[i] != NULL) {
          int a;
          for (a = 0; a < size; a++) {
            if (((char *) ptr_array[i])[a] != 0x00) {
              printf("calloc returned non-zeroed memory\n");
              return false;
            }
          }
        }
        memset(ptr_array[i], 0xfe, size);
        break;
      }

      default: {
        size_t size = rand() % 400;
        wrap_free(ptr_array[i]);
        ptr_array[i] = wrap_malloc(size);
        memset(ptr_array[i], 0xfe, size);
        break;
      }
    }
  }

  return (corruption_cnt == 0);
}
bool random_stress(void) {
  void *ptr_array[256];
  size_t i;
  int idx;

  corruption_cnt = 0;

  printf("Size of umm_heap is %u\n", (unsigned int) sizeof(test_umm_heap));

  umm_init();

  umm_info(NULL, 1);

  for (idx = 0; idx < 256; ++idx) ptr_array[idx] = (void *) NULL;

  for (idx = 0; idx < 100000; ++idx) {
    i = rand() % 256;

     
    {
      void *tmp = wrap_realloc(ptr_array[i], UMM_MALLOC_CFG__HEAP_SIZE);
      if (tmp != NULL) {
        printf("realloc to too large buffer should return NULL");
        return false;
      }
    }

    switch (rand() % 16) {
      case 0:
      case 1:
      case 2:
      case 3:
      case 4:
      case 5:
      case 6: {
        ptr_array[i] = wrap_realloc(ptr_array[i], 0);
        break;
      }
      case 7:
      case 8: {
        size_t size = rand() % 40;
        ptr_array[i] = wrap_realloc(ptr_array[i], size);
        memset(ptr_array[i], 0xfe, size);
        break;
      }

      case 9:
      case 10:
      case 11:
      case 12: {
        size_t size = rand() % 100;
        ptr_array[i] = wrap_realloc(ptr_array[i], size);
        memset(ptr_array[i], 0xfe, size);
        break;
      }

      case 13:
      case 14: {
        size_t size = rand() % 200;
        wrap_free(ptr_array[i]);
        ptr_array[i] = wrap_calloc(1, size);
        if (ptr_array[i] != NULL) {
          int a;
          for (a = 0; a < size; a++) {
            if (((char *) ptr_array[i])[a] != 0x00) {
              printf("calloc returned non-zeroed memory\n");
              return false;
            }
          }
        }
        memset(ptr_array[i], 0xfe, size);
        break;
      }

      default: {
        size_t size = rand() % 400;
        wrap_free(ptr_array[i]);
        ptr_array[i] = wrap_malloc(size);
        memset(ptr_array[i], 0xfe, size);
        break;
      }
    }
  }

  return (corruption_cnt == 0);
}