diff options
author | Dana Robinson <derobins@hdfgroup.org> | 2016-09-30 08:31:59 (GMT) |
---|---|---|
committer | Dana Robinson <derobins@hdfgroup.org> | 2016-09-30 08:31:59 (GMT) |
commit | 77e7c43bf02f2e8f8ec834da7aca0c3e9599c5c0 (patch) | |
tree | 372586d18f4a3355638e6b84b10faded273aff55 /test/theap.c | |
parent | 865553617111c44b036f30bdf5ae51df465572e4 (diff) | |
parent | 30ca70b0969ae0ab63104d7910523818e5385ac6 (diff) | |
download | hdf5-77e7c43bf02f2e8f8ec834da7aca0c3e9599c5c0.zip hdf5-77e7c43bf02f2e8f8ec834da7aca0c3e9599c5c0.tar.gz hdf5-77e7c43bf02f2e8f8ec834da7aca0c3e9599c5c0.tar.bz2 |
Merge branch 'develop' into evict_on_close
Diffstat (limited to 'test/theap.c')
-rw-r--r-- | test/theap.c | 47 |
1 files changed, 38 insertions, 9 deletions
diff --git a/test/theap.c b/test/theap.c index 2d509bf..9c509a1 100644 --- a/test/theap.c +++ b/test/theap.c @@ -44,13 +44,13 @@ typedef struct test_obj { } test_obj; /* Array of random element values */ -static test_obj rand_num[NUM_ELEMS]; +static test_obj *rand_num; /* Array of random elements values, sorted in increasing order */ -static test_obj inc_sort_num[NUM_ELEMS]; +static test_obj *inc_sort_num; /* Array of random elements values, sorted in decreasing order */ -static test_obj dec_sort_num[NUM_ELEMS]; +static test_obj *dec_sort_num; static int tst_dec_sort(const void *_i1, const void *_i2) { @@ -88,21 +88,29 @@ test_heap_init(void) time_t curr_time; /* Current time, for seeding random number generator */ size_t u; /* Local index variables */ + /* Allocate arrays */ + rand_num = (test_obj *)HDmalloc(sizeof(test_obj) * NUM_ELEMS); + CHECK(rand_num, NULL, "HDmalloc"); + inc_sort_num = (test_obj *)HDmalloc(sizeof(test_obj) * NUM_ELEMS); + CHECK(inc_sort_num, NULL, "HDmalloc"); + dec_sort_num = (test_obj *)HDmalloc(sizeof(test_obj) * NUM_ELEMS); + CHECK(dec_sort_num, NULL, "HDmalloc"); + /* Create randomized set of numbers */ - curr_time=time(NULL); + curr_time = HDtime(NULL); HDsrandom((unsigned)curr_time); - for(u=0; u<NUM_ELEMS; u++) + for(u = 0; u < NUM_ELEMS; u++) /* Generate random numbers from -1000 to 1000 */ - rand_num[u].val=(int)(HDrandom()%2001)-1001; + rand_num[u].val = (int)(HDrandom() % 2001) - 1001; /* Sort random numbers into increasing order */ - HDmemcpy(inc_sort_num,rand_num,sizeof(test_obj)*NUM_ELEMS); + HDmemcpy(inc_sort_num, rand_num, sizeof(test_obj) * NUM_ELEMS); HDqsort(inc_sort_num, (size_t)NUM_ELEMS, sizeof(test_obj), tst_inc_sort); /* Sort random numbers into decreasing order */ - HDmemcpy(dec_sort_num,rand_num,sizeof(test_obj)*NUM_ELEMS); + HDmemcpy(dec_sort_num, rand_num, sizeof(test_obj) * NUM_ELEMS); HDqsort(dec_sort_num, (size_t)NUM_ELEMS, sizeof(test_obj), tst_dec_sort); -} /* end test_tst_init() */ +} /* end test_heap_init() */ /**************************************************************** ** @@ -1023,6 +1031,24 @@ test_heap_incdec(void) /**************************************************************** ** +** test_heap_term(): Test H5HP (heap) code. +** Release data for Heap testing +** +****************************************************************/ +static void +test_heap_term(void) +{ + /* Release arrays */ + if(rand_num) + HDfree(rand_num); + if(inc_sort_num) + HDfree(inc_sort_num); + if(dec_sort_num) + HDfree(dec_sort_num); +} /* end test_tst_term() */ + +/**************************************************************** +** ** test_heap(): Main H5HP testing routine. ** ****************************************************************/ @@ -1044,5 +1070,8 @@ test_heap(void) test_heap_change(); /* Test changing priority of objects on Heap */ test_heap_incdec(); /* Test incrementing & decrementing priority of objects on Heap */ + /* Release Heap testing data */ + test_heap_term(); + } /* end test_heap() */ |