diff options
author | Quincey Koziol <koziol@lbl.gov> | 2016-09-29 20:19:35 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@lbl.gov> | 2016-09-29 20:19:35 (GMT) |
commit | 30ca70b0969ae0ab63104d7910523818e5385ac6 (patch) | |
tree | 471b06e9f95379c79b350ec435c49ec525b9e786 /test/theap.c | |
parent | a7fb4ede8601e135433ef2d23bf4bbb466d9f58d (diff) | |
parent | 5a7880183025f56421cf6f2274d9f1ac36f59641 (diff) | |
download | hdf5-30ca70b0969ae0ab63104d7910523818e5385ac6.zip hdf5-30ca70b0969ae0ab63104d7910523818e5385ac6.tar.gz hdf5-30ca70b0969ae0ab63104d7910523818e5385ac6.tar.bz2 |
Merge pull request #46 in HDFFV/hdf5 from ~KOZIOL/hdf5:features/warning_cleanups to develop
* commit '5a7880183025f56421cf6f2274d9f1ac36f59641':
Clean up hardcoded constants and check return values better. (Comments from group code review)
Description: Cleanups from Dana's review.
Description: Further warning cleanups: from 667 warnings to 503.
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() */ |