summaryrefslogtreecommitdiffstats
path: root/src/H5MF.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5MF.c')
-rw-r--r--src/H5MF.c37
1 files changed, 20 insertions, 17 deletions
diff --git a/src/H5MF.c b/src/H5MF.c
index 91b8553..660f849 100644
--- a/src/H5MF.c
+++ b/src/H5MF.c
@@ -59,7 +59,7 @@ static int interface_initialize_g = 0;
haddr_t
H5MF_alloc(H5F_t *f, H5FD_mem_t type, hsize_t size)
{
- haddr_t ret_value=HADDR_UNDEF;
+ haddr_t ret_value;
FUNC_ENTER_NOAPI(H5MF_alloc, HADDR_UNDEF);
@@ -68,20 +68,20 @@ H5MF_alloc(H5F_t *f, H5FD_mem_t type, hsize_t size)
assert(size > 0);
/* Fail if we don't have write access */
- if (0==(f->intent & H5F_ACC_RDWR)) {
- HRETURN_ERROR(H5E_RESOURCE, H5E_CANTINIT, HADDR_UNDEF, "file is read-only");
- }
+ if (0==(f->intent & H5F_ACC_RDWR))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_CANTINIT, HADDR_UNDEF, "file is read-only");
/* Allocate space from the virtual file layer */
- if (HADDR_UNDEF==(ret_value=H5FD_alloc(f->shared->lf, type, size))) {
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, HADDR_UNDEF,
- "file allocation failed");
- }
+ if (HADDR_UNDEF==(ret_value=H5FD_alloc(f->shared->lf, type, size)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, HADDR_UNDEF, "file allocation failed");
/* Convert absolute file address to relative file address */
assert(ret_value>=f->shared->base_addr);
+
+ /* Set return value */
ret_value -= f->shared->base_addr;
+done:
FUNC_LEAVE(ret_value);
}
@@ -109,13 +109,14 @@ H5MF_alloc(H5F_t *f, H5FD_mem_t type, hsize_t size)
herr_t
H5MF_xfree(H5F_t *f, H5FD_mem_t type, haddr_t addr, hsize_t size)
{
+ herr_t ret_value=SUCCEED; /* Return value */
+
FUNC_ENTER_NOAPI(H5MF_xfree, FAIL);
/* check arguments */
assert(f);
- if (!H5F_addr_defined(addr) || 0 == size) {
- HRETURN(SUCCEED);
- }
+ if (!H5F_addr_defined(addr) || 0 == size)
+ HGOTO_DONE(SUCCEED);
assert(addr!=0);
/* Convert relative address to absolute address */
@@ -132,7 +133,8 @@ H5MF_xfree(H5F_t *f, H5FD_mem_t type, haddr_t addr, hsize_t size)
#endif
}
- FUNC_LEAVE(SUCCEED);
+done:
+ FUNC_LEAVE(ret_value);
}
@@ -175,7 +177,7 @@ haddr_t
H5MF_realloc(H5F_t *f, H5FD_mem_t type, haddr_t old_addr, hsize_t old_size,
hsize_t new_size)
{
- haddr_t ret_value=HADDR_UNDEF;
+ haddr_t ret_value;
FUNC_ENTER_NOAPI(H5MF_realloc, HADDR_UNDEF);
@@ -185,14 +187,15 @@ H5MF_realloc(H5F_t *f, H5FD_mem_t type, haddr_t old_addr, hsize_t old_size,
/* Reallocate memory from the virtual file layer */
ret_value = H5FD_realloc(f->shared->lf, type, old_addr, old_size,
new_size);
- if (HADDR_UNDEF==ret_value) {
- HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, HADDR_UNDEF,
- "unable to allocate new file memory");
- }
+ if (HADDR_UNDEF==ret_value)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, HADDR_UNDEF, "unable to allocate new file memory");
/* Convert return value to relative address */
assert(ret_value>=f->shared->base_addr);
+
+ /* Set return value */
ret_value -= f->shared->base_addr;
+done:
FUNC_LEAVE(ret_value);
}