-/*
- * malloc/free are reusing memory areas too quickly, which does not let us
- * test races appropriately. Use a large circular array for allocations.
- * ARRAY_SIZE is larger than nr_writers, and we keep the mutex across
- * both alloc and free, which insures we never run over our tail.
- */
-#define ARRAY_SIZE (1048576 * nr_writers)
-#define ARRAY_POISON 0xDEADBEEF
-static int array_index;
-static struct test_array *test_array;
-
-static struct test_array *test_array_alloc(void)
-{
- struct test_array *ret;
- int index;
-
- index = array_index % ARRAY_SIZE;
- assert(test_array[index].a == ARRAY_POISON ||
- test_array[index].a == 0);
- ret = &test_array[index];
- array_index++;
- if (array_index == ARRAY_SIZE)
- array_index = 0;
- return ret;
-}
-
-static void test_array_free(struct test_array *ptr)
-{
- if (!ptr)
- return;
- ptr->a = ARRAY_POISON;
-}
-