Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove HD/hbool_t from fortran #3182

Merged
merged 1 commit into from
Jun 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions fortran/src/H5Af.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ h5adelete_c(hid_t_f *obj_id, _fcd name, size_t_f *namelen)

done:
if (c_name)
HDfree(c_name);
free(c_name);

return ret_value;
}
Expand Down Expand Up @@ -135,7 +135,7 @@ h5aget_name_c(hid_t_f *attr_id, size_t_f *bufsize, _fcd buf)
/*
* Allocate buffer to hold name of an attribute
*/
if (NULL == (c_buf = (char *)HDmalloc(c_bufsize)))
if (NULL == (c_buf = (char *)malloc(c_bufsize)))
HGOTO_DONE(FAIL);

/*
Expand All @@ -151,7 +151,7 @@ h5aget_name_c(hid_t_f *attr_id, size_t_f *bufsize, _fcd buf)

done:
if (c_buf)
HDfree(c_buf);
free(c_buf);
return ret_value;
}

Expand Down Expand Up @@ -204,9 +204,9 @@ h5adelete_by_name_c(hid_t_f *loc_id, _fcd obj_name, size_t_f *obj_namelen, _fcd

done:
if (c_attr_name)
HDfree(c_attr_name);
free(c_attr_name);
if (c_obj_name)
HDfree(c_obj_name);
free(c_obj_name);
return ret_value;
}
/****if* H5Af/h5adelete_by_idx_c
Expand Down Expand Up @@ -256,7 +256,7 @@ h5adelete_by_idx_c(hid_t_f *loc_id, _fcd obj_name, size_t_f *obj_namelen, int_f

done:
if (c_obj_name)
HDfree(c_obj_name);
free(c_obj_name);

return ret_value;
}
Expand Down Expand Up @@ -325,7 +325,7 @@ h5aget_name_by_idx_c(hid_t_f *loc_id, _fcd obj_name, size_t_f *obj_namelen, int_
* Allocate buffer to hold name of an attribute
*/
c_buf_size = (size_t)*size + 1;
if (NULL == (c_buf = (char *)HDmalloc(c_buf_size)))
if (NULL == (c_buf = (char *)malloc(c_buf_size)))
HGOTO_DONE(FAIL)

/*
Expand All @@ -344,9 +344,9 @@ h5aget_name_by_idx_c(hid_t_f *loc_id, _fcd obj_name, size_t_f *obj_namelen, int_

done:
if (c_obj_name)
HDfree(c_obj_name);
free(c_obj_name);
if (c_buf)
HDfree(c_buf);
free(c_buf);
return ret_value;
}

Expand Down Expand Up @@ -474,7 +474,7 @@ h5aget_info_by_idx_c(hid_t_f *loc_id, _fcd obj_name, size_t_f *obj_namelen, int_

done:
if (c_obj_name)
HDfree(c_obj_name);
free(c_obj_name);

return ret_value;
}
Expand Down Expand Up @@ -542,9 +542,9 @@ h5aget_info_by_name_c(hid_t_f *loc_id, _fcd obj_name, size_t_f *obj_namelen, _fc

done:
if (c_obj_name)
HDfree(c_obj_name);
free(c_obj_name);
if (c_attr_name)
HDfree(c_attr_name);
free(c_attr_name);

return ret_value;
}
Expand Down
52 changes: 26 additions & 26 deletions fortran/src/H5Df.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,10 +67,10 @@ h5dwrite_ref_reg_c(hid_t_f *dset_id, hid_t_f *mem_type_id, hid_t_f *mem_space_id
/*
* Allocate temporary buffer and copy references from Fortran.
*/
buf_c = (hdset_reg_ref_t *)HDmalloc(sizeof(hdset_reg_ref_t) * n);
buf_c = (hdset_reg_ref_t *)malloc(sizeof(hdset_reg_ref_t) * n);
if (buf_c != NULL) {
for (i = 0; i < n; i++) {
HDmemcpy(&buf_c[i], buf, H5R_DSET_REG_REF_BUF_SIZE);
memcpy(&buf_c[i], buf, H5R_DSET_REG_REF_BUF_SIZE);
buf = buf + REF_REG_BUF_LEN_F;
}
}
Expand All @@ -85,7 +85,7 @@ h5dwrite_ref_reg_c(hid_t_f *dset_id, hid_t_f *mem_type_id, hid_t_f *mem_space_id
c_mem_space_id = (hid_t)*mem_space_id;
c_file_space_id = (hid_t)*file_space_id;
ret = H5Dwrite(c_dset_id, c_mem_type_id, c_mem_space_id, c_file_space_id, c_xfer_prp, buf_c);
HDfree(buf_c);
free(buf_c);
if (ret < 0)
return ret_value;
ret_value = 0;
Expand Down Expand Up @@ -138,7 +138,7 @@ h5dread_ref_reg_c(hid_t_f *dset_id, hid_t_f *mem_type_id, hid_t_f *mem_space_id,
/*
* Allocate temporary buffer.
*/
buf_c = (hdset_reg_ref_t *)HDmalloc(sizeof(hdset_reg_ref_t) * (size_t)n);
buf_c = (hdset_reg_ref_t *)malloc(sizeof(hdset_reg_ref_t) * (size_t)n);
if (buf_c != NULL) {
/*
* Call H5Dread function.
Expand All @@ -150,12 +150,12 @@ h5dread_ref_reg_c(hid_t_f *dset_id, hid_t_f *mem_type_id, hid_t_f *mem_space_id,
ret = H5Dread(c_dset_id, c_mem_type_id, c_mem_space_id, c_file_space_id, c_xfer_prp, buf_c);
if (ret >= 0) {
for (i = 0; i < n; i++) {
HDmemcpy(buf, &buf_c[i], H5R_DSET_REG_REF_BUF_SIZE);
memcpy(buf, &buf_c[i], H5R_DSET_REG_REF_BUF_SIZE);
buf = buf + REF_REG_BUF_LEN_F;
}
}
if (buf_c != NULL)
HDfree(buf_c);
free(buf_c);
}
if (ret < 0)
return ret_value;
Expand Down Expand Up @@ -320,7 +320,7 @@ h5dvlen_get_max_len_c(hid_t_f *dset_id, hid_t_f *type_id, hid_t_f *space_id, siz
if (num_elem < 0)
return ret_value;

c_buf = (hvl_t *)HDmalloc(sizeof(hvl_t) * (size_t)num_elem);
c_buf = (hvl_t *)malloc(sizeof(hvl_t) * (size_t)num_elem);
if (c_buf == NULL)
return ret_value;
status = H5Dread(c_dset_id, c_type_id, H5S_ALL, c_space_id, H5P_DEFAULT, c_buf);
Expand All @@ -336,7 +336,7 @@ h5dvlen_get_max_len_c(hid_t_f *dset_id, hid_t_f *type_id, hid_t_f *space_id, siz

DONE:

HDfree(c_buf);
free(c_buf);
return ret_value;
}
/****if* H5Df/h5dwrite_vl_integer_c
Expand Down Expand Up @@ -393,7 +393,7 @@ h5dwrite_vl_integer_c(hid_t_f *dset_id, hid_t_f *mem_type_id, hid_t_f *mem_space
c_file_space_id = (hid_t)*file_space_id;
c_xfer_prp = (hid_t)*xfer_prp;

c_buf = (hvl_t *)HDmalloc((size_t)num_elem * sizeof(hvl_t));
c_buf = (hvl_t *)malloc((size_t)num_elem * sizeof(hvl_t));
if (c_buf == NULL)
return ret_value;
tmp = (int_f *)buf;
Expand All @@ -411,7 +411,7 @@ h5dwrite_vl_integer_c(hid_t_f *dset_id, hid_t_f *mem_type_id, hid_t_f *mem_space
goto DONE;
ret_value = 0;
DONE:
HDfree(c_buf);
free(c_buf);
return ret_value;
}

Expand Down Expand Up @@ -471,7 +471,7 @@ h5dread_vl_integer_c(hid_t_f *dset_id, hid_t_f *mem_type_id, hid_t_f *mem_space_
if (num_elem != (hssize_t)dims[1])
return ret_value;

c_buf = (hvl_t *)HDmalloc((size_t)num_elem * sizeof(hvl_t));
c_buf = (hvl_t *)malloc((size_t)num_elem * sizeof(hvl_t));
if (c_buf == NULL)
return ret_value;
/*
Expand All @@ -487,7 +487,7 @@ h5dread_vl_integer_c(hid_t_f *dset_id, hid_t_f *mem_type_id, hid_t_f *mem_space_
H5Treclaim(c_mem_type_id, c_mem_space_id, H5P_DEFAULT, c_buf);
ret_value = 0;
DONE:
HDfree(c_buf);
free(c_buf);
return ret_value;
}

Expand Down Expand Up @@ -547,22 +547,22 @@ h5dwrite_vl_string_c(hid_t_f *dset_id, hid_t_f *mem_type_id, hid_t_f *mem_space_
/*
* Allocate arra of character pointers
*/
c_buf = (char **)HDmalloc((size_t)num_elem * sizeof(char *));
c_buf = (char **)malloc((size_t)num_elem * sizeof(char *));
if (c_buf == NULL)
return ret_value;

/* Copy data to long C string */
tmp = (char *)HD5f2cstring(buf, (size_t)(max_len * num_elem));
if (tmp == NULL) {
HDfree(c_buf);
free(c_buf);
return ret_value;
}
/*
* Move data from temporary buffer
*/
tmp_p = tmp;
for (i = 0; i < num_elem; i++) {
c_buf[i] = (char *)HDmalloc((size_t)len[i] + 1);
c_buf[i] = (char *)malloc((size_t)len[i] + 1);
memcpy(c_buf[i], tmp_p, (size_t)len[i]);
c_buf[i][len[i]] = '\0';
tmp_p = tmp_p + max_len;
Expand All @@ -578,8 +578,8 @@ h5dwrite_vl_string_c(hid_t_f *dset_id, hid_t_f *mem_type_id, hid_t_f *mem_space_
ret_value = 0;
DONE:
H5Treclaim(c_mem_type_id, c_mem_space_id, H5P_DEFAULT, c_buf);
HDfree(c_buf);
HDfree(tmp);
free(c_buf);
free(tmp);
return ret_value;
}
/****if* H5Df/h5dread_vl_string_c
Expand Down Expand Up @@ -638,7 +638,7 @@ h5dread_vl_string_c(hid_t_f *dset_id, hid_t_f *mem_type_id, hid_t_f *mem_space_i
/*
* Allocate array of character pointers
*/
c_buf = (char **)HDmalloc((size_t)num_elem * sizeof(char *));
c_buf = (char **)malloc((size_t)num_elem * sizeof(char *));
if (c_buf == NULL)
return ret_value;

Expand All @@ -647,11 +647,11 @@ h5dread_vl_string_c(hid_t_f *dset_id, hid_t_f *mem_type_id, hid_t_f *mem_space_i
*/
status = H5Dread(c_dset_id, c_mem_type_id, c_mem_space_id, c_file_space_id, c_xfer_prp, c_buf);
if (status < 0) {
HDfree(c_buf);
free(c_buf);
return ret_value;
}
/* Copy data to long C string */
tmp = (char *)HDmalloc((size_t)(max_len * num_elem) + 1);
tmp = (char *)malloc((size_t)(max_len * num_elem) + 1);
tmp_p = tmp;
for (i = 0; i < max_len * num_elem; i++)
tmp[i] = ' ';
Expand All @@ -664,8 +664,8 @@ h5dread_vl_string_c(hid_t_f *dset_id, hid_t_f *mem_type_id, hid_t_f *mem_space_i
HD5packFstring(tmp, _fcdtocp(buf), (size_t)(max_len * num_elem));
ret_value = 0;
H5Treclaim(c_mem_type_id, c_mem_space_id, H5P_DEFAULT, c_buf);
HDfree(c_buf);
HDfree(tmp);
free(c_buf);
free(tmp);
return ret_value;
}

Expand Down Expand Up @@ -723,7 +723,7 @@ h5dwrite_vl_real_c(hid_t_f *dset_id, hid_t_f *mem_type_id, hid_t_f *mem_space_id
c_file_space_id = (hid_t)*file_space_id;
c_xfer_prp = (hid_t)*xfer_prp;

c_buf = (hvl_t *)HDmalloc((size_t)num_elem * sizeof(hvl_t));
c_buf = (hvl_t *)malloc((size_t)num_elem * sizeof(hvl_t));
if (c_buf == NULL)
return ret_value;
tmp = (real_f *)buf;
Expand All @@ -741,7 +741,7 @@ h5dwrite_vl_real_c(hid_t_f *dset_id, hid_t_f *mem_type_id, hid_t_f *mem_space_id
goto DONE;
ret_value = 0;
DONE:
HDfree(c_buf);
free(c_buf);
return ret_value;
}

Expand Down Expand Up @@ -801,7 +801,7 @@ h5dread_vl_real_c(hid_t_f *dset_id, hid_t_f *mem_type_id, hid_t_f *mem_space_id,
if (num_elem != (hssize_t)dims[1])
return ret_value;

c_buf = (hvl_t *)HDmalloc((size_t)num_elem * sizeof(hvl_t));
c_buf = (hvl_t *)malloc((size_t)num_elem * sizeof(hvl_t));
if (c_buf == NULL)
return ret_value;
/*
Expand All @@ -818,7 +818,7 @@ h5dread_vl_real_c(hid_t_f *dset_id, hid_t_f *mem_type_id, hid_t_f *mem_space_id,
H5Treclaim(c_mem_type_id, c_mem_space_id, H5P_DEFAULT, c_buf);
ret_value = 0;
DONE:
HDfree(c_buf);
free(c_buf);
return ret_value;
}

Expand Down
18 changes: 9 additions & 9 deletions fortran/src/H5Ef.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ h5eprint_c1(_fcd name, int_f *namelen)

if (NULL == (c_name = (char *)HD5f2cstring(name, (size_t)*namelen)))
HGOTO_DONE(FAIL)
if (NULL == (file = HDfopen(c_name, "a")))
if (NULL == (file = fopen(c_name, "a")))
HGOTO_DONE(FAIL)

/*
Expand All @@ -95,9 +95,9 @@ h5eprint_c1(_fcd name, int_f *namelen)

done:
if (file)
HDfclose(file);
fclose(file);
if (c_name)
HDfree(c_name);
free(c_name);

return ret_value;
}
Expand Down Expand Up @@ -164,7 +164,7 @@ h5eget_major_c(int_f *error_no, _fcd name, size_t_f *namelen)
int_f ret_value = 0;

if (c_namelen > 0)
c_name = (char *)HDmalloc(c_namelen + 1);
c_name = (char *)malloc(c_namelen + 1);

if (!c_name)
HGOTO_DONE(FAIL)
Expand All @@ -174,12 +174,12 @@ h5eget_major_c(int_f *error_no, _fcd name, size_t_f *namelen)
*/
H5Eget_msg((hid_t)*error_no, NULL, c_name, c_namelen);
HD5packFstring((char *)c_name, _fcdtocp(name), c_namelen);
if (!HDstrcmp(c_name, "Invalid major error number"))
if (!strcmp(c_name, "Invalid major error number"))
HGOTO_DONE(FAIL)

done:
if (c_name)
HDfree(c_name);
free(c_name);

return ret_value;
}
Expand Down Expand Up @@ -212,7 +212,7 @@ h5eget_minor_c(int_f *error_no, _fcd name, size_t_f *namelen)
int_f ret_value = 0;

if (c_namelen > 0)
c_name = (char *)HDmalloc(c_namelen + 1);
c_name = (char *)malloc(c_namelen + 1);

if (!c_name)
HGOTO_DONE(FAIL)
Expand All @@ -222,12 +222,12 @@ h5eget_minor_c(int_f *error_no, _fcd name, size_t_f *namelen)
*/
H5Eget_msg((hid_t)*error_no, NULL, c_name, c_namelen);
HD5packFstring((char *)c_name, _fcdtocp(name), c_namelen);
if (!HDstrcmp(c_name, "Invalid minor error number"))
if (!strcmp(c_name, "Invalid minor error number"))
HGOTO_DONE(FAIL)

done:
if (c_name)
HDfree(c_name);
free(c_name);

return ret_value;
}
Expand Down
Loading