Skip to content

Do not call srand before each rand #125

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 23, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions test/malloc_compliance_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,7 @@ using umf_test::test;
// Helpers
//------------------------------------------------------------------------

static inline size_t rand_alloc_size(int max) {
srand(SRAND_INIT_VALUE);
return rand() % max;
}
static inline size_t rand_alloc_size(int max) { return rand() % max; }

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

// ISO/IEC 9899:TC3 7.20.3.3
void malloc_compliance_test(umf_memory_pool_handle_t hPool) {
srand(SRAND_INIT_VALUE);
void *alloc_ptr[ITERATIONS];
size_t alloc_ptr_size[ITERATIONS];

Expand Down Expand Up @@ -80,6 +78,7 @@ void malloc_compliance_test(umf_memory_pool_handle_t hPool) {

// ISO/IEC 9899:TC3 7.20.3.1
void calloc_compliance_test(umf_memory_pool_handle_t hPool) {
srand(SRAND_INIT_VALUE);
void *alloc_ptr[ITERATIONS];
size_t alloc_size;

Expand All @@ -98,6 +97,7 @@ void calloc_compliance_test(umf_memory_pool_handle_t hPool) {

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