From 6efa8215552705c9076079f5368cd64582f93918 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Wed, 29 Nov 2000 10:49:38 -0500 Subject: [svn-r3017] Purpose: Code cleanup/bug fix Description: Variable length datatypes were leaking memory when being dumped. Solution: Reclaim the VL data after each element has been dumped out. Platforms tested: FreeBSD 4.2 (hawkwind) & Solaris 2.6 (baldric) --- tools/h5tools.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tools/h5tools.c b/tools/h5tools.c index 41532b6..3244025 100644 --- a/tools/h5tools.c +++ b/tools/h5tools.c @@ -105,11 +105,6 @@ extern int get_tableflag(table_t*, int); extern int set_tableflag(table_t*, int); extern char *get_objectname(table_t*, int); -/* local functions */ -static void h5dump_simple_data(FILE *stream, const h5dump_t *info, - hid_t container, h5dump_context_t *ctx/*in,out*/, unsigned flags, - hsize_t nelmts, hid_t type, void *_mem); - /*------------------------------------------------------------------------- * Function: h5tools_init * @@ -1086,6 +1081,7 @@ h5dump_sprint(h5dump_str_t *str/*in,out*/, const h5dump_t *info, H5Tclose(memb); } else if (H5T_VLEN==H5Tget_class(type)) { unsigned int i; + hid_t space; /* Get the VL sequences's base datatype for each element */ memb=H5Tget_super(type); @@ -1129,6 +1125,15 @@ h5dump_sprint(h5dump_str_t *str/*in,out*/, const h5dump_t *info, h5dump_str_append(str, "%s", OPT(info->vlen_suf, ")")); H5Tclose(memb); + + /* Create a datatype for reclaiming the memory */ + space=H5Screate(H5S_SCALAR); + + /* Reclaim the VL memory */ + H5Dvlen_reclaim(type,space,H5P_DEFAULT,cp_vp); + + /* Let the dataspace go */ + H5Sclose(space); } else { /* All other types get printed as hexadecimal */ unsigned int i; -- cgit v0.12