Skip to content

Commit

Permalink
Clean up memory leaks in t_vfd (HDFGroup#4457)
Browse files Browse the repository at this point in the history
  • Loading branch information
qkoziol authored May 3, 2024
1 parent 63fcd58 commit e4f079e
Showing 1 changed file with 48 additions and 39 deletions.
87 changes: 48 additions & 39 deletions testpar/t_vfd.c
Original file line number Diff line number Diff line change
Expand Up @@ -4216,22 +4216,21 @@ static unsigned
vector_write_test_8(int file_name_id, int mpi_rank, int mpi_size, H5FD_mpio_xfer_t xfer_mode,
H5FD_mpio_collective_opt_t coll_opt_mode, const char *vfd_name)
{
const char *fcn_name = "vector_write_test_8()";
char test_title[120];
char filename[512];
haddr_t eoa;
haddr_t base_addr;
bool show_progress = false;
hid_t fapl_id = H5I_INVALID_HID; /* file access property list ID */
hid_t dxpl_id = H5I_INVALID_HID; /* data access property list ID */
H5FD_t *lf = NULL; /* VFD struct ptr */
int cp = 0;
int i;
int base_index;
uint32_t count = 0;
size_t sizes[4];
H5FD_mem_t types[2];

const char *fcn_name = "vector_write_test_8()";
char test_title[120];
char filename[512];
haddr_t eoa;
haddr_t base_addr;
bool show_progress = false;
hid_t fapl_id = H5I_INVALID_HID; /* file access property list ID */
hid_t dxpl_id = H5I_INVALID_HID; /* data access property list ID */
H5FD_t *lf = NULL; /* VFD struct ptr */
int cp = 0;
int i;
int base_index;
uint32_t count = 0;
size_t sizes[4];
H5FD_mem_t types[2];
haddr_t *tt_addrs = NULL; /* For storing addrs */
const void **tt_bufs = NULL; /* For storing buf pointers */

Expand Down Expand Up @@ -4629,6 +4628,9 @@ test_vector_io(int mpi_rank, int mpi_size)
H5FD_SUBFILING_NAME);
#endif

/* discard the file image buffers */
free_file_images();

nerrors += (int)nerrs;

/* return(nerrs);*/
Expand Down Expand Up @@ -5955,15 +5957,14 @@ test_selection_io_types_1d(int mpi_rank, int mpi_size, H5FD_t *lf, hid_t dxpl, H
static void
test_selection_io_real(int mpi_rank, int mpi_size, H5FD_t *lf, hid_t dxpl)
{
hid_t mem_spaces[2] = {H5I_INVALID_HID, H5I_INVALID_HID}; /* memory dataspaces vector */
hid_t file_spaces[2] = {H5I_INVALID_HID, H5I_INVALID_HID}; /* file dataspaces vector */
hsize_t dims1[1]; /* 1d dimension sizes */
hsize_t dims2[2]; /* 2d dimension sizes */

H5FD_mem_t type; /* File type */
haddr_t addrs[2]; /* File allocation address */
size_t element_sizes[2] = {sizeof(int), sizeof(int)}; /* Element size */
size_t bufsize; /* Buffer size */
hid_t mem_spaces[2] = {H5I_INVALID_HID, H5I_INVALID_HID}; /* memory dataspaces vector */
hid_t file_spaces[2] = {H5I_INVALID_HID, H5I_INVALID_HID}; /* file dataspaces vector */
hsize_t dims1[1]; /* 1d dimension sizes */
hsize_t dims2[2]; /* 2d dimension sizes */
H5FD_mem_t type; /* File type */
haddr_t addrs[2]; /* File allocation address */
size_t element_sizes[2] = {sizeof(int), sizeof(int)}; /* Element size */
size_t bufsize; /* Buffer size */
int i;
int j;

Expand Down Expand Up @@ -6059,18 +6060,30 @@ test_selection_io_real(int mpi_rank, int mpi_size, H5FD_t *lf, hid_t dxpl)
}

/* Free the buffers */
if (wbuf1)
if (wbuf1) {
free(wbuf1);
if (wbuf2)
wbuf1 = NULL;
}
if (wbuf2) {
free(wbuf2);
if (fbuf1)
wbuf2 = NULL;
}
if (fbuf1) {
free(fbuf1);
if (fbuf2)
fbuf1 = NULL;
}
if (fbuf2) {
free(fbuf2);
if (erbuf1)
fbuf2 = NULL;
}
if (erbuf1) {
free(erbuf1);
if (erbuf2)
erbuf1 = NULL;
}
if (erbuf2) {
free(erbuf2);
erbuf2 = NULL;
}

CHECK_PASSED();

Expand All @@ -6085,11 +6098,10 @@ test_selection_io_real(int mpi_rank, int mpi_size, H5FD_t *lf, hid_t dxpl)
static void
test_selection_io(int mpi_rank, int mpi_size)
{
H5FD_t *lf = NULL; /* VFD struct ptr */
hid_t fapl = H5I_INVALID_HID; /* File access property list */
char filename[1024]; /* Test file name */
unsigned flags = 0; /* File access flags */

H5FD_t *lf = NULL; /* VFD struct ptr */
hid_t fapl = H5I_INVALID_HID; /* File access property list */
char filename[1024]; /* Test file name */
unsigned flags = 0; /* File access flags */
unsigned collective; /* Types of I/O for testing */
hid_t dxpl = H5I_INVALID_HID; /* Dataset transfer property list */
hid_t def_dxpl = H5I_INVALID_HID; /* dxpl: independent access */
Expand Down Expand Up @@ -6309,9 +6321,6 @@ main(int argc, char **argv)
printf("===================================\n");
}

/* discard the file image buffers */
free_file_images();

/* close HDF5 library */
H5close();

Expand Down

0 comments on commit e4f079e

Please sign in to comment.