diff options
author | Quincey Koziol <koziol@koziol.gov> | 2020-03-20 21:39:55 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@koziol.gov> | 2020-03-23 23:05:37 (GMT) |
commit | 5144eedd2e03716a3fa9a293ecafa8c26c43937b (patch) | |
tree | 1ce0d4741df16c15eefc02d816f3209234842462 /src | |
parent | 4065a506bc479ffc4c0cd46d2aa8ef47005e7f67 (diff) | |
download | hdf5-5144eedd2e03716a3fa9a293ecafa8c26c43937b.zip hdf5-5144eedd2e03716a3fa9a293ecafa8c26c43937b.tar.gz hdf5-5144eedd2e03716a3fa9a293ecafa8c26c43937b.tar.bz2 |
Revise API for H5get_alloc_stats() to take a struct instead of separate values.
Diffstat (limited to 'src')
-rw-r--r-- | src/H5.c | 20 | ||||
-rw-r--r-- | src/H5MM.c | 53 | ||||
-rw-r--r-- | src/H5MMprivate.h | 4 | ||||
-rw-r--r-- | src/H5public.h | 17 |
4 files changed, 33 insertions, 61 deletions
@@ -609,13 +609,7 @@ done: * filters or non-native VOL connectors. * * Parameters: - * unsigned long long *total_alloc_bytes; OUT: Running count of total # of bytes allocated - * size_t *curr_alloc_bytes; OUT: Current # of bytes allocated - * size_t *peak_alloc_bytes; OUT: Peak # of bytes allocated - * size_t *max_block_size; OUT: Largest block allocated - * size_t *total_alloc_blocks_count; OUT: Running count of total # of blocks allocated - * size_t *curr_alloc_blocks_count; OUT: Current # of blocks allocated - * size_t *peak_alloc_blocks_count; OUT: Peak # of blocks allocated + * H5_alloc_stats_t *stats; OUT: Memory allocation statistics * * Return: Success: non-negative * Failure: negative @@ -626,21 +620,15 @@ done: *------------------------------------------------------------------------- */ herr_t -H5get_alloc_stats(unsigned long long *total_alloc_bytes, size_t *curr_alloc_bytes, - size_t *peak_alloc_bytes, size_t *max_block_size, size_t *total_alloc_blocks_count, - size_t *curr_alloc_blocks_count, size_t *peak_alloc_blocks_count) +H5get_alloc_stats(H5_alloc_stats_t *stats) { herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE7("e", "*UL*z*z*z*z*z*z", total_alloc_bytes, curr_alloc_bytes, - peak_alloc_bytes, max_block_size, total_alloc_blocks_count, - curr_alloc_blocks_count, peak_alloc_blocks_count); + H5TRACE1("e", "*x", stats); /* Call the internal allocation stat routine to get the values */ - if(H5MM_get_alloc_stats(total_alloc_bytes, curr_alloc_bytes, peak_alloc_bytes, - max_block_size, total_alloc_blocks_count, curr_alloc_blocks_count, - peak_alloc_blocks_count) < 0) + if(H5MM_get_alloc_stats(stats) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_CANTGET, FAIL, "can't get allocation stats") done: @@ -610,13 +610,7 @@ H5MM_memcpy(void *dest, const void *src, size_t n) * entire library. * * Parameters: - * unsigned long long *total_alloc_bytes; OUT: Running count of total # of bytes allocated - * size_t *curr_alloc_bytes; OUT: Current # of bytes allocated - * size_t *peak_alloc_bytes; OUT: Peak # of bytes allocated - * size_t *max_block_size; OUT: Largest block allocated - * size_t *total_alloc_blocks_count; OUT: Running count of total # of blocks allocated - * size_t *curr_alloc_blocks_count; OUT: Current # of blocks allocated - * size_t *peak_alloc_blocks_count; OUT: Peak # of blocks allocated + * H5_alloc_stats_t *stats; OUT: Memory allocation statistics * * Return: Success: non-negative * Failure: negative @@ -627,44 +621,25 @@ H5MM_memcpy(void *dest, const void *src, size_t n) *------------------------------------------------------------------------- */ herr_t -H5MM_get_alloc_stats(unsigned long long *total_alloc_bytes, size_t *curr_alloc_bytes, - size_t *peak_alloc_bytes, size_t *max_block_size, size_t *total_alloc_blocks_count, - size_t *curr_alloc_blocks_count, size_t *peak_alloc_blocks_count) +H5MM_get_alloc_stats(H5_alloc_stats_t *stats) { FUNC_ENTER_NOAPI_NOERR #if defined H5_MEMORY_ALLOC_SANITY_CHECK - if(total_alloc_bytes) - *total_alloc_bytes = H5MM_total_alloc_bytes_s; - if(curr_alloc_bytes) - *curr_alloc_bytes = H5MM_curr_alloc_bytes_s; - if(peak_alloc_bytes) - *peak_alloc_bytes = H5MM_peak_alloc_bytes_s; - if(max_block_size) - *max_block_size = H5MM_max_block_size_s; - if(total_alloc_blocks_count) - *total_alloc_blocks_count = H5MM_total_alloc_blocks_count_s; - if(curr_alloc_blocks_count) - *curr_alloc_blocks_count = H5MM_curr_alloc_blocks_count_s; - if(peak_alloc_blocks_count) - *peak_alloc_blocks_count = H5MM_peak_alloc_blocks_count_s; + if(stats) { + stats->total_alloc_bytes = H5MM_total_alloc_bytes_s; + stats->curr_alloc_bytes = H5MM_curr_alloc_bytes_s; + stats->peak_alloc_bytes = H5MM_peak_alloc_bytes_s; + stats->max_block_size = H5MM_max_block_size_s; + stats->total_alloc_blocks_count = H5MM_total_alloc_blocks_count_s; + stats->curr_alloc_blocks_count = H5MM_curr_alloc_blocks_count_s; + stats->peak_alloc_blocks_count = H5MM_peak_alloc_blocks_count_s; + } /* end if */ #else /* H5_MEMORY_ALLOC_SANITY_CHECK */ - if(total_alloc_bytes) - *total_alloc_bytes = 0; - if(curr_alloc_bytes) - *curr_alloc_bytes = 0; - if(peak_alloc_bytes) - *peak_alloc_bytes = 0; - if(max_block_size) - *max_block_size = 0; - if(total_alloc_blocks_count) - *total_alloc_blocks_count = 0; - if(curr_alloc_blocks_count) - *curr_alloc_blocks_count = 0; - if(peak_alloc_blocks_count) - *peak_alloc_blocks_count = 0; + if(stats) + HDmemset(stats, 0, sizeof(H5_alloc_stats_t)); #endif /* H5_MEMORY_ALLOC_SANITY_CHECK */ FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5get_alloc_stats() */ +} /* end H5MM_get_alloc_stats() */ diff --git a/src/H5MMprivate.h b/src/H5MMprivate.h index 8dafc65..ea87db6 100644 --- a/src/H5MMprivate.h +++ b/src/H5MMprivate.h @@ -46,9 +46,7 @@ H5_DLL char *H5MM_xstrdup(const char *s); H5_DLL char *H5MM_strdup(const char *s); H5_DLL void *H5MM_xfree(void *mem); H5_DLL void *H5MM_memcpy(void *dest, const void *src, size_t n); -H5_DLL herr_t H5MM_get_alloc_stats(unsigned long long *total_alloc_bytes, size_t *curr_alloc_bytes, - size_t *peak_alloc_bytes, size_t *max_block_size, size_t *total_alloc_blocks_count, - size_t *curr_alloc_blocks_count, size_t *peak_alloc_blocks_count); +H5_DLL herr_t H5MM_get_alloc_stats(H5_alloc_stats_t *stats); #if defined H5_MEMORY_ALLOC_SANITY_CHECK H5_DLL void H5MM_sanity_check_all(void); H5_DLL void H5MM_final_sanity_check(void); diff --git a/src/H5public.h b/src/H5public.h index f8a9d58..4ad975c 100644 --- a/src/H5public.h +++ b/src/H5public.h @@ -340,6 +340,19 @@ typedef struct H5O_token_t { uint8_t __data[H5O_MAX_TOKEN_SIZE]; } H5O_token_t; +/* + * Allocation statistics info struct + */ +typedef struct H5_alloc_stats_t { + unsigned long long total_alloc_bytes; /* Running count of total # of bytes allocated */ + size_t curr_alloc_bytes; /* Current # of bytes allocated */ + size_t peak_alloc_bytes; /* Peak # of bytes allocated */ + size_t max_block_size; /* Largest block allocated */ + size_t total_alloc_blocks_count; /* Running count of total # of blocks allocated */ + size_t curr_alloc_blocks_count; /* Current # of blocks allocated */ + size_t peak_alloc_blocks_count; /* Peak # of blocks allocated */ +} H5_alloc_stats_t; + /* Functions in H5.c */ H5_DLL herr_t H5open(void); H5_DLL herr_t H5close(void); @@ -350,9 +363,7 @@ H5_DLL herr_t H5set_free_list_limits (int reg_global_lim, int reg_list_lim, int blk_list_lim); H5_DLL herr_t H5get_free_list_sizes(size_t *reg_size, size_t *arr_size, size_t *blk_size, size_t *fac_size); -H5_DLL herr_t H5get_alloc_stats(unsigned long long *total_alloc_bytes, size_t *curr_alloc_bytes, - size_t *peak_alloc_bytes, size_t *max_block_size, size_t *total_alloc_blocks_count, - size_t *curr_alloc_blocks_count, size_t *peak_alloc_blocks_count); +H5_DLL herr_t H5get_alloc_stats(H5_alloc_stats_t *stats); H5_DLL herr_t H5get_libversion(unsigned *majnum, unsigned *minnum, unsigned *relnum); H5_DLL herr_t H5check_version(unsigned majnum, unsigned minnum, |