Skip to content

Commit a87fa0d

Browse files
authored
Merge pull request #125 from igchor/fix_compliance
Do not call srand before each rand
2 parents 97ee67e + 6ecc931 commit a87fa0d

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

test/malloc_compliance_tests.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,7 @@ using umf_test::test;
3232
// Helpers
3333
//------------------------------------------------------------------------
3434

35-
static inline size_t rand_alloc_size(int max) {
36-
srand(SRAND_INIT_VALUE);
37-
return rand() % max;
38-
}
35+
static inline size_t rand_alloc_size(int max) { return rand() % max; }
3936

4037
static inline void free_memory(umf_memory_pool_handle_t hPool,
4138
void *ptr[ITERATIONS]) {
@@ -50,6 +47,7 @@ static inline void free_memory(umf_memory_pool_handle_t hPool,
5047

5148
// ISO/IEC 9899:TC3 7.20.3.3
5249
void malloc_compliance_test(umf_memory_pool_handle_t hPool) {
50+
srand(SRAND_INIT_VALUE);
5351
void *alloc_ptr[ITERATIONS];
5452
size_t alloc_ptr_size[ITERATIONS];
5553

@@ -80,6 +78,7 @@ void malloc_compliance_test(umf_memory_pool_handle_t hPool) {
8078

8179
// ISO/IEC 9899:TC3 7.20.3.1
8280
void calloc_compliance_test(umf_memory_pool_handle_t hPool) {
81+
srand(SRAND_INIT_VALUE);
8382
void *alloc_ptr[ITERATIONS];
8483
size_t alloc_size;
8584

@@ -99,6 +98,7 @@ void calloc_compliance_test(umf_memory_pool_handle_t hPool) {
9998

10099
// ISO/IEC 9899:TC3 7.20.3.4
101100
void realloc_compliance_test(umf_memory_pool_handle_t hPool) {
101+
srand(SRAND_INIT_VALUE);
102102
// If ptr is a null pointer, the realloc function behaves
103103
// like the malloc function for the specified size
104104
void *ret = umfPoolRealloc(hPool, NULL, 10);

0 commit comments

Comments
 (0)