diff options
author | Allen Byrne <byrn@hdfgroup.org> | 2020-10-01 16:47:45 (GMT) |
---|---|---|
committer | Allen Byrne <byrn@hdfgroup.org> | 2020-10-01 16:47:45 (GMT) |
commit | 1ba1f2f3222cbe8df0bf601929a4bffd478d7e02 (patch) | |
tree | ae51dfc33cf40432dad25a5088767115a98f195e /src/H5Tvlen.c | |
parent | 8eef7d295cc3dd134aef0a826f1de4287629996d (diff) | |
download | hdf5-1ba1f2f3222cbe8df0bf601929a4bffd478d7e02.zip hdf5-1ba1f2f3222cbe8df0bf601929a4bffd478d7e02.tar.gz hdf5-1ba1f2f3222cbe8df0bf601929a4bffd478d7e02.tar.bz2 |
Source formatted
Diffstat (limited to 'src/H5Tvlen.c')
-rw-r--r-- | src/H5Tvlen.c | 509 |
1 files changed, 247 insertions, 262 deletions
diff --git a/src/H5Tvlen.c b/src/H5Tvlen.c index abb719f..5c08130 100644 --- a/src/H5Tvlen.c +++ b/src/H5Tvlen.c @@ -16,53 +16,50 @@ * datatypes in the H5T interface. */ -#define H5T_PACKAGE /*suppress error about including H5Tpkg */ +#define H5T_PACKAGE /*suppress error about including H5Tpkg */ /* Interface initialization */ -#define H5_INTERFACE_INIT_FUNC H5T_init_vlen_interface +#define H5_INTERFACE_INIT_FUNC H5T_init_vlen_interface - -#include "H5private.h" /* Generic Functions */ -#include "H5Dprivate.h" /* Dataset functions */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5HGprivate.h" /* Global Heaps */ -#include "H5Iprivate.h" /* IDs */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5Tpkg.h" /* Datatypes */ +#include "H5private.h" /* Generic Functions */ +#include "H5Dprivate.h" /* Dataset functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5HGprivate.h" /* Global Heaps */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5Tpkg.h" /* Datatypes */ /* Local functions */ -static herr_t H5T_vlen_reclaim_recurse(void *elem, const H5T_t *dt, H5MM_free_t free_func, void *free_info); +static herr_t H5T_vlen_reclaim_recurse(void *elem, const H5T_t *dt, H5MM_free_t free_func, void *free_info); static ssize_t H5T_vlen_seq_mem_getlen(const void *_vl); -static void * H5T_vlen_seq_mem_getptr(void *_vl); -static htri_t H5T_vlen_seq_mem_isnull(const H5F_t *f, void *_vl); -static herr_t H5T_vlen_seq_mem_read(H5F_t *f, hid_t dxpl_id, void *_vl, void *_buf, size_t len); -static herr_t H5T_vlen_seq_mem_write(H5F_t *f, hid_t dxpl_id, const H5T_vlen_alloc_info_t *vl_alloc_info, void *_vl, void *_buf, void *_bg, size_t seq_len, size_t base_size); -static herr_t H5T_vlen_seq_mem_setnull(H5F_t *f, hid_t dxpl_id, void *_vl, void *_bg); +static void * H5T_vlen_seq_mem_getptr(void *_vl); +static htri_t H5T_vlen_seq_mem_isnull(const H5F_t *f, void *_vl); +static herr_t H5T_vlen_seq_mem_read(H5F_t *f, hid_t dxpl_id, void *_vl, void *_buf, size_t len); +static herr_t H5T_vlen_seq_mem_write(H5F_t *f, hid_t dxpl_id, const H5T_vlen_alloc_info_t *vl_alloc_info, + void *_vl, void *_buf, void *_bg, size_t seq_len, size_t base_size); +static herr_t H5T_vlen_seq_mem_setnull(H5F_t *f, hid_t dxpl_id, void *_vl, void *_bg); static ssize_t H5T_vlen_str_mem_getlen(const void *_vl); -static void * H5T_vlen_str_mem_getptr(void *_vl); -static htri_t H5T_vlen_str_mem_isnull(const H5F_t *f, void *_vl); -static herr_t H5T_vlen_str_mem_read(H5F_t *f, hid_t dxpl_id, void *_vl, void *_buf, size_t len); -static herr_t H5T_vlen_str_mem_write(H5F_t *f, hid_t dxpl_id, const H5T_vlen_alloc_info_t *vl_alloc_info, void *_vl, void *_buf, void *_bg, size_t seq_len, size_t base_size); -static herr_t H5T_vlen_str_mem_setnull(H5F_t *f, hid_t dxpl_id, void *_vl, void *_bg); +static void * H5T_vlen_str_mem_getptr(void *_vl); +static htri_t H5T_vlen_str_mem_isnull(const H5F_t *f, void *_vl); +static herr_t H5T_vlen_str_mem_read(H5F_t *f, hid_t dxpl_id, void *_vl, void *_buf, size_t len); +static herr_t H5T_vlen_str_mem_write(H5F_t *f, hid_t dxpl_id, const H5T_vlen_alloc_info_t *vl_alloc_info, + void *_vl, void *_buf, void *_bg, size_t seq_len, size_t base_size); +static herr_t H5T_vlen_str_mem_setnull(H5F_t *f, hid_t dxpl_id, void *_vl, void *_bg); static ssize_t H5T_vlen_disk_getlen(const void *_vl); -static void * H5T_vlen_disk_getptr(void *_vl); -static htri_t H5T_vlen_disk_isnull(const H5F_t *f, void *_vl); -static herr_t H5T_vlen_disk_read(H5F_t *f, hid_t dxpl_id, void *_vl, void *_buf, size_t len); -static herr_t H5T_vlen_disk_write(H5F_t *f, hid_t dxpl_id, const H5T_vlen_alloc_info_t *vl_alloc_info, void *_vl, void *_buf, void *_bg, size_t seq_len, size_t base_size); -static herr_t H5T_vlen_disk_setnull(H5F_t *f, hid_t dxpl_id, void *_vl, void *_bg); +static void * H5T_vlen_disk_getptr(void *_vl); +static htri_t H5T_vlen_disk_isnull(const H5F_t *f, void *_vl); +static herr_t H5T_vlen_disk_read(H5F_t *f, hid_t dxpl_id, void *_vl, void *_buf, size_t len); +static herr_t H5T_vlen_disk_write(H5F_t *f, hid_t dxpl_id, const H5T_vlen_alloc_info_t *vl_alloc_info, + void *_vl, void *_buf, void *_bg, size_t seq_len, size_t base_size); +static herr_t H5T_vlen_disk_setnull(H5F_t *f, hid_t dxpl_id, void *_vl, void *_bg); /* Local variables */ /* Default settings for variable-length allocation routines */ -static H5T_vlen_alloc_info_t H5T_vlen_def_vl_alloc_info ={ - H5D_VLEN_ALLOC, - H5D_VLEN_ALLOC_INFO, - H5D_VLEN_FREE, - H5D_VLEN_FREE_INFO -}; - - +static H5T_vlen_alloc_info_t H5T_vlen_def_vl_alloc_info = {H5D_VLEN_ALLOC, H5D_VLEN_ALLOC_INFO, H5D_VLEN_FREE, + H5D_VLEN_FREE_INFO}; + /*-------------------------------------------------------------------------- NAME H5T_init_vlen_interface -- Initialize interface-specific information @@ -84,7 +81,6 @@ H5T_init_vlen_interface(void) FUNC_LEAVE_NOAPI(H5T_init()) } /* H5T_init_vlen_interface() */ - /*------------------------------------------------------------------------- * Function: H5Tvlen_create * @@ -103,30 +99,29 @@ H5T_init_vlen_interface(void) hid_t H5Tvlen_create(hid_t base_id) { - H5T_t *base = NULL; /*base datatype */ - H5T_t *dt = NULL; /*new datatype */ - hid_t ret_value; /*return value */ + H5T_t *base = NULL; /*base datatype */ + H5T_t *dt = NULL; /*new datatype */ + hid_t ret_value; /*return value */ FUNC_ENTER_API(FAIL) H5TRACE1("i", "i", base_id); /* Check args */ - if(NULL == (base = H5I_object_verify(base_id, H5I_DATATYPE))) + if (NULL == (base = H5I_object_verify(base_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an valid base datatype") /* Create up VL datatype */ - if((dt = H5T__vlen_create(base)) == NULL) + if ((dt = H5T__vlen_create(base)) == NULL) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid VL location") /* Atomize the type */ - if((ret_value = H5I_register(H5I_DATATYPE, dt, TRUE)) < 0) + if ((ret_value = H5I_register(H5I_DATATYPE, dt, TRUE)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype") done: FUNC_LEAVE_API(ret_value) } /* end H5Tvlen_create() */ - /*------------------------------------------------------------------------- * Function: H5T__vlen_create * @@ -145,8 +140,8 @@ done: H5T_t * H5T__vlen_create(const H5T_t *base) { - H5T_t *dt = NULL; /*new VL datatype */ - H5T_t *ret_value; /*return value */ + H5T_t *dt = NULL; /*new VL datatype */ + H5T_t *ret_value; /*return value */ FUNC_ENTER_PACKAGE @@ -154,7 +149,7 @@ H5T__vlen_create(const H5T_t *base) HDassert(base); /* Build new type */ - if(NULL == (dt = H5T__alloc())) + if (NULL == (dt = H5T__alloc())) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, NULL, "memory allocation failed") dt->shared->type = H5T_VLEN; @@ -163,7 +158,7 @@ H5T__vlen_create(const H5T_t *base) * data, not point to the same VL sequences) */ dt->shared->force_conv = TRUE; - if(NULL == (dt->shared->parent = H5T_copy(base, H5T_COPY_ALL))) + if (NULL == (dt->shared->parent = H5T_copy(base, H5T_COPY_ALL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "can't copy base datatype") /* Inherit encoding version from base type */ @@ -173,21 +168,20 @@ H5T__vlen_create(const H5T_t *base) dt->shared->u.vlen.type = H5T_VLEN_SEQUENCE; /* Set up VL information */ - if(H5T_set_loc(dt, NULL, H5T_LOC_MEMORY) < 0) + if (H5T_set_loc(dt, NULL, H5T_LOC_MEMORY) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "invalid datatype location") /* Set return value */ ret_value = dt; done: - if(!ret_value) - if(dt && H5T_close(dt) < 0) + if (!ret_value) + if (dt && H5T_close(dt) < 0) HDONE_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, NULL, "unable to release datatype info") FUNC_LEAVE_NOAPI(ret_value) } /* end H5T__vlen_create() */ - /*------------------------------------------------------------------------- * Function: H5T__vlen_set_loc * @@ -207,7 +201,7 @@ done: htri_t H5T__vlen_set_loc(const H5T_t *dt, H5F_t *f, H5T_loc_t loc) { - htri_t ret_value = FALSE; /* Indicate success, but no location change */ + htri_t ret_value = FALSE; /* Indicate success, but no location change */ FUNC_ENTER_PACKAGE @@ -216,37 +210,39 @@ H5T__vlen_set_loc(const H5T_t *dt, H5F_t *f, H5T_loc_t loc) HDassert(loc >= H5T_LOC_BADLOC && loc < H5T_LOC_MAXLOC); /* Only change the location if it's different */ - if(loc != dt->shared->u.vlen.loc || f != dt->shared->u.vlen.f) { - switch(loc) { - case H5T_LOC_MEMORY: /* Memory based VL datatype */ + if (loc != dt->shared->u.vlen.loc || f != dt->shared->u.vlen.f) { + switch (loc) { + case H5T_LOC_MEMORY: /* Memory based VL datatype */ HDassert(NULL == f); /* Mark this type as being stored in memory */ dt->shared->u.vlen.loc = H5T_LOC_MEMORY; - if(dt->shared->u.vlen.type == H5T_VLEN_SEQUENCE) { + if (dt->shared->u.vlen.type == H5T_VLEN_SEQUENCE) { /* size in memory, disk size is different */ dt->shared->size = sizeof(hvl_t); /* Set up the function pointers to access the VL sequence in memory */ - dt->shared->u.vlen.getlen = H5T_vlen_seq_mem_getlen; - dt->shared->u.vlen.getptr = H5T_vlen_seq_mem_getptr; - dt->shared->u.vlen.isnull = H5T_vlen_seq_mem_isnull; - dt->shared->u.vlen.read = H5T_vlen_seq_mem_read; - dt->shared->u.vlen.write = H5T_vlen_seq_mem_write; + dt->shared->u.vlen.getlen = H5T_vlen_seq_mem_getlen; + dt->shared->u.vlen.getptr = H5T_vlen_seq_mem_getptr; + dt->shared->u.vlen.isnull = H5T_vlen_seq_mem_isnull; + dt->shared->u.vlen.read = H5T_vlen_seq_mem_read; + dt->shared->u.vlen.write = H5T_vlen_seq_mem_write; dt->shared->u.vlen.setnull = H5T_vlen_seq_mem_setnull; - } else if(dt->shared->u.vlen.type == H5T_VLEN_STRING) { + } + else if (dt->shared->u.vlen.type == H5T_VLEN_STRING) { /* size in memory, disk size is different */ dt->shared->size = sizeof(char *); /* Set up the function pointers to access the VL string in memory */ - dt->shared->u.vlen.getlen = H5T_vlen_str_mem_getlen; - dt->shared->u.vlen.getptr = H5T_vlen_str_mem_getptr; - dt->shared->u.vlen.isnull = H5T_vlen_str_mem_isnull; - dt->shared->u.vlen.read = H5T_vlen_str_mem_read; - dt->shared->u.vlen.write = H5T_vlen_str_mem_write; + dt->shared->u.vlen.getlen = H5T_vlen_str_mem_getlen; + dt->shared->u.vlen.getptr = H5T_vlen_str_mem_getptr; + dt->shared->u.vlen.isnull = H5T_vlen_str_mem_isnull; + dt->shared->u.vlen.read = H5T_vlen_str_mem_read; + dt->shared->u.vlen.write = H5T_vlen_str_mem_write; dt->shared->u.vlen.setnull = H5T_vlen_str_mem_setnull; - } else { + } + else { HDassert(0 && "Invalid VL type"); } @@ -254,7 +250,7 @@ H5T__vlen_set_loc(const H5T_t *dt, H5F_t *f, H5T_loc_t loc) dt->shared->u.vlen.f = NULL; break; - case H5T_LOC_DISK: /* Disk based VL datatype */ + case H5T_LOC_DISK: /* Disk based VL datatype */ HDassert(f); /* Mark this type as being stored on disk */ @@ -269,11 +265,11 @@ H5T__vlen_set_loc(const H5T_t *dt, H5F_t *f, H5T_loc_t loc) /* Set up the function pointers to access the VL information on disk */ /* VL sequences and VL strings are stored identically on disk, so use the same functions */ - dt->shared->u.vlen.getlen = H5T_vlen_disk_getlen; - dt->shared->u.vlen.getptr = H5T_vlen_disk_getptr; - dt->shared->u.vlen.isnull = H5T_vlen_disk_isnull; - dt->shared->u.vlen.read = H5T_vlen_disk_read; - dt->shared->u.vlen.write = H5T_vlen_disk_write; + dt->shared->u.vlen.getlen = H5T_vlen_disk_getlen; + dt->shared->u.vlen.getptr = H5T_vlen_disk_getptr; + dt->shared->u.vlen.isnull = H5T_vlen_disk_isnull; + dt->shared->u.vlen.read = H5T_vlen_disk_read; + dt->shared->u.vlen.write = H5T_vlen_disk_write; dt->shared->u.vlen.setnull = H5T_vlen_disk_setnull; /* Set file ID (since this VL is on disk) */ @@ -296,9 +292,8 @@ H5T__vlen_set_loc(const H5T_t *dt, H5F_t *f, H5T_loc_t loc) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5T__vlen_set_loc() */ +} /* end H5T__vlen_set_loc() */ - /*------------------------------------------------------------------------- * Function: H5T_vlen_seq_mem_getlen * @@ -315,9 +310,9 @@ static ssize_t H5T_vlen_seq_mem_getlen(const void *_vl) { #ifdef H5_NO_ALIGNMENT_RESTRICTIONS - const hvl_t *vl=(const hvl_t *)_vl; /* Pointer to the user's hvl_t information */ + const hvl_t *vl = (const hvl_t *)_vl; /* Pointer to the user's hvl_t information */ #else - hvl_t vl; /* User's hvl_t information */ + hvl_t vl; /* User's hvl_t information */ #endif FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -333,9 +328,8 @@ H5T_vlen_seq_mem_getlen(const void *_vl) FUNC_LEAVE_NOAPI((ssize_t)vl.len) #endif -} /* end H5T_vlen_seq_mem_getlen() */ +} /* end H5T_vlen_seq_mem_getlen() */ - /*------------------------------------------------------------------------- * Function: H5T_vlen_seq_mem_getptr * @@ -352,9 +346,9 @@ static void * H5T_vlen_seq_mem_getptr(void *_vl) { #ifdef H5_NO_ALIGNMENT_RESTRICTIONS - const hvl_t *vl=(const hvl_t *)_vl; /* Pointer to the user's hvl_t information */ + const hvl_t *vl = (const hvl_t *)_vl; /* Pointer to the user's hvl_t information */ #else - hvl_t vl; /* User's hvl_t information */ + hvl_t vl; /* User's hvl_t information */ #endif FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -370,9 +364,8 @@ H5T_vlen_seq_mem_getptr(void *_vl) FUNC_LEAVE_NOAPI(vl.p) #endif -} /* end H5T_vlen_seq_mem_getptr() */ +} /* end H5T_vlen_seq_mem_getptr() */ - /*------------------------------------------------------------------------- * Function: H5T_vlen_seq_mem_isnull * @@ -390,9 +383,9 @@ static htri_t H5T_vlen_seq_mem_isnull(const H5F_t H5_ATTR_UNUSED *f, void *_vl) { #ifdef H5_NO_ALIGNMENT_RESTRICTIONS - const hvl_t *vl=(const hvl_t *)_vl; /* Pointer to the user's hvl_t information */ + const hvl_t *vl = (const hvl_t *)_vl; /* Pointer to the user's hvl_t information */ #else - hvl_t vl; /* User's hvl_t information */ + hvl_t vl; /* User's hvl_t information */ #endif FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -401,16 +394,15 @@ H5T_vlen_seq_mem_isnull(const H5F_t H5_ATTR_UNUSED *f, void *_vl) #ifdef H5_NO_ALIGNMENT_RESTRICTIONS HDassert(vl); - FUNC_LEAVE_NOAPI((vl->len==0 || vl->p==NULL) ? TRUE : FALSE) + FUNC_LEAVE_NOAPI((vl->len == 0 || vl->p == NULL) ? TRUE : FALSE) #else HDassert(_vl); HDmemcpy(&vl, _vl, sizeof(hvl_t)); - FUNC_LEAVE_NOAPI((vl.len==0 || vl.p==NULL) ? TRUE : FALSE) + FUNC_LEAVE_NOAPI((vl.len == 0 || vl.p == NULL) ? TRUE : FALSE) #endif -} /* end H5T_vlen_seq_mem_isnull() */ +} /* end H5T_vlen_seq_mem_isnull() */ - /*------------------------------------------------------------------------- * Function: H5T_vlen_seq_mem_read * @@ -428,9 +420,9 @@ static herr_t H5T_vlen_seq_mem_read(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, void *_vl, void *buf, size_t len) { #ifdef H5_NO_ALIGNMENT_RESTRICTIONS - const hvl_t *vl=(const hvl_t *)_vl; /* Pointer to the user's hvl_t information */ + const hvl_t *vl = (const hvl_t *)_vl; /* Pointer to the user's hvl_t information */ #else - hvl_t vl; /* User's hvl_t information */ + hvl_t vl; /* User's hvl_t information */ #endif FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -440,19 +432,18 @@ H5T_vlen_seq_mem_read(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, voi #ifdef H5_NO_ALIGNMENT_RESTRICTIONS HDassert(vl && vl->p); - HDmemcpy(buf,vl->p,len); + HDmemcpy(buf, vl->p, len); #else HDassert(_vl); HDmemcpy(&vl, _vl, sizeof(hvl_t)); HDassert(vl.p); - HDmemcpy(buf,vl.p,len); + HDmemcpy(buf, vl.p, len); #endif FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5T_vlen_seq_mem_read() */ +} /* end H5T_vlen_seq_mem_read() */ - /*------------------------------------------------------------------------- * Function: H5T_vlen_seq_mem_write * @@ -467,11 +458,13 @@ H5T_vlen_seq_mem_read(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, voi */ /* ARGSUSED */ static herr_t -H5T_vlen_seq_mem_write(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, const H5T_vlen_alloc_info_t *vl_alloc_info, void *_vl, void *buf, void H5_ATTR_UNUSED *_bg, size_t seq_len, size_t base_size) +H5T_vlen_seq_mem_write(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, + const H5T_vlen_alloc_info_t *vl_alloc_info, void *_vl, void *buf, + void H5_ATTR_UNUSED *_bg, size_t seq_len, size_t base_size) { - hvl_t vl; /* Temporary hvl_t to use during operation */ + hvl_t vl; /* Temporary hvl_t to use during operation */ size_t len; - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -479,37 +472,36 @@ H5T_vlen_seq_mem_write(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, co HDassert(_vl); HDassert(buf); - if(seq_len!=0) { - len=seq_len*base_size; + if (seq_len != 0) { + len = seq_len * base_size; /* Use the user's memory allocation routine is one is defined */ - if(vl_alloc_info->alloc_func!=NULL) { - if(NULL==(vl.p=(vl_alloc_info->alloc_func)(len,vl_alloc_info->alloc_info))) + if (vl_alloc_info->alloc_func != NULL) { + if (NULL == (vl.p = (vl_alloc_info->alloc_func)(len, vl_alloc_info->alloc_info))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for VL data") - } /* end if */ - else { /* Default to system malloc */ - if(NULL==(vl.p=H5MM_malloc(len))) + } /* end if */ + else { /* Default to system malloc */ + if (NULL == (vl.p = H5MM_malloc(len))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for VL data") - } /* end else */ + } /* end else */ /* Copy the data into the newly allocated buffer */ - HDmemcpy(vl.p,buf,len); + HDmemcpy(vl.p, buf, len); } /* end if */ else - vl.p=NULL; + vl.p = NULL; /* Set the sequence length */ - vl.len=seq_len; + vl.len = seq_len; /* Set pointer in user's buffer with memcpy, to avoid alignment issues */ - HDmemcpy(_vl,&vl,sizeof(hvl_t)); + HDmemcpy(_vl, &vl, sizeof(hvl_t)); done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5T_vlen_seq_mem_write() */ +} /* end H5T_vlen_seq_mem_write() */ - /*------------------------------------------------------------------------- * Function: H5T_vlen_seq_mem_setnull * @@ -524,9 +516,10 @@ done: */ /* ARGSUSED */ static herr_t -H5T_vlen_seq_mem_setnull(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, void *_vl, void H5_ATTR_UNUSED *_bg) +H5T_vlen_seq_mem_setnull(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, void *_vl, + void H5_ATTR_UNUSED *_bg) { - hvl_t vl; /* Temporary hvl_t to use during operation */ + hvl_t vl; /* Temporary hvl_t to use during operation */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -534,16 +527,15 @@ H5T_vlen_seq_mem_setnull(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, HDassert(_vl); /* Set the "nil" hvl_t */ - vl.len=0; - vl.p=NULL; + vl.len = 0; + vl.p = NULL; /* Set pointer in user's buffer with memcpy, to avoid alignment issues */ - HDmemcpy(_vl,&vl,sizeof(hvl_t)); + HDmemcpy(_vl, &vl, sizeof(hvl_t)); FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5T_vlen_seq_mem_setnull() */ +} /* end H5T_vlen_seq_mem_setnull() */ - /*------------------------------------------------------------------------- * Function: H5T_vlen_str_mem_getlen * @@ -560,9 +552,9 @@ static ssize_t H5T_vlen_str_mem_getlen(const void *_vl) { #ifdef H5_NO_ALIGNMENT_RESTRICTIONS - const char *s=*(const char * const *)_vl; /* Pointer to the user's string information */ + const char *s = *(const char *const *)_vl; /* Pointer to the user's string information */ #else - const char *s; /* Pointer to the user's string information */ + const char *s; /* Pointer to the user's string information */ #endif FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -576,9 +568,8 @@ H5T_vlen_str_mem_getlen(const void *_vl) #endif FUNC_LEAVE_NOAPI((ssize_t)HDstrlen(s)) -} /* end H5T_vlen_str_mem_getlen() */ +} /* end H5T_vlen_str_mem_getlen() */ - /*------------------------------------------------------------------------- * Function: H5T_vlen_str_mem_getptr * @@ -595,9 +586,9 @@ static void * H5T_vlen_str_mem_getptr(void *_vl) { #ifdef H5_NO_ALIGNMENT_RESTRICTIONS - char *s=*(char **)_vl; /* Pointer to the user's string information */ + char *s = *(char **)_vl; /* Pointer to the user's string information */ #else - char *s; /* Pointer to the user's string information */ + char *s; /* Pointer to the user's string information */ #endif FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -611,9 +602,8 @@ H5T_vlen_str_mem_getptr(void *_vl) #endif FUNC_LEAVE_NOAPI(s) -} /* end H5T_vlen_str_mem_getptr() */ +} /* end H5T_vlen_str_mem_getptr() */ - /*------------------------------------------------------------------------- * Function: H5T_vlen_str_mem_isnull * @@ -631,9 +621,9 @@ static htri_t H5T_vlen_str_mem_isnull(const H5F_t H5_ATTR_UNUSED *f, void *_vl) { #ifdef H5_NO_ALIGNMENT_RESTRICTIONS - char *s=*(char **)_vl; /* Pointer to the user's string information */ + char *s = *(char **)_vl; /* Pointer to the user's string information */ #else - char *s; /* Pointer to the user's string information */ + char *s; /* Pointer to the user's string information */ #endif FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -642,10 +632,9 @@ H5T_vlen_str_mem_isnull(const H5F_t H5_ATTR_UNUSED *f, void *_vl) HDmemcpy(&s, _vl, sizeof(char *)); #endif - FUNC_LEAVE_NOAPI(s==NULL ? TRUE : FALSE) -} /* end H5T_vlen_str_mem_isnull() */ + FUNC_LEAVE_NOAPI(s == NULL ? TRUE : FALSE) +} /* end H5T_vlen_str_mem_isnull() */ - /*------------------------------------------------------------------------- * Function: H5T_vlen_str_mem_read * @@ -663,14 +652,14 @@ static herr_t H5T_vlen_str_mem_read(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, void *_vl, void *buf, size_t len) { #ifdef H5_NO_ALIGNMENT_RESTRICTIONS - char *s=*(char **)_vl; /* Pointer to the user's string information */ + char *s = *(char **)_vl; /* Pointer to the user's string information */ #else - char *s; /* Pointer to the user's string information */ + char *s; /* Pointer to the user's string information */ #endif FUNC_ENTER_NOAPI_NOINIT_NOERR - if(len>0) { + if (len > 0) { /* check parameters */ HDassert(buf); #ifdef H5_NO_ALIGNMENT_RESTRICTIONS @@ -680,13 +669,12 @@ H5T_vlen_str_mem_read(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, voi HDmemcpy(&s, _vl, sizeof(char *)); #endif - HDmemcpy(buf,s,len); + HDmemcpy(buf, s, len); } /* end if */ FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5T_vlen_str_mem_read() */ +} /* end H5T_vlen_str_mem_read() */ - /*------------------------------------------------------------------------- * Function: H5T_vlen_str_mem_write * @@ -701,11 +689,13 @@ H5T_vlen_str_mem_read(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, voi */ /* ARGSUSED */ static herr_t -H5T_vlen_str_mem_write(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, const H5T_vlen_alloc_info_t *vl_alloc_info, void *_vl, void *buf, void H5_ATTR_UNUSED *_bg, size_t seq_len, size_t base_size) +H5T_vlen_str_mem_write(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, + const H5T_vlen_alloc_info_t *vl_alloc_info, void *_vl, void *buf, + void H5_ATTR_UNUSED *_bg, size_t seq_len, size_t base_size) { - char *t; /* Pointer to temporary buffer allocated */ - size_t len; /* Maximum length of the string to copy */ - herr_t ret_value=SUCCEED; /* Return value */ + char * t; /* Pointer to temporary buffer allocated */ + size_t len; /* Maximum length of the string to copy */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -713,27 +703,26 @@ H5T_vlen_str_mem_write(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, co HDassert(buf); /* Use the user's memory allocation routine if one is defined */ - if(vl_alloc_info->alloc_func!=NULL) { - if(NULL==(t=(vl_alloc_info->alloc_func)((seq_len+1)*base_size,vl_alloc_info->alloc_info))) + if (vl_alloc_info->alloc_func != NULL) { + if (NULL == (t = (vl_alloc_info->alloc_func)((seq_len + 1) * base_size, vl_alloc_info->alloc_info))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for VL data") - } /* end if */ - else { /* Default to system malloc */ - if(NULL==(t=H5MM_malloc((seq_len+1)*base_size))) + } /* end if */ + else { /* Default to system malloc */ + if (NULL == (t = H5MM_malloc((seq_len + 1) * base_size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for VL data") - } /* end else */ + } /* end else */ - len=(seq_len*base_size); - HDmemcpy(t,buf,len); - t[len]='\0'; + len = (seq_len * base_size); + HDmemcpy(t, buf, len); + t[len] = '\0'; /* Set pointer in user's buffer with memcpy, to avoid alignment issues */ - HDmemcpy(_vl,&t,sizeof(char *)); + HDmemcpy(_vl, &t, sizeof(char *)); done: FUNC_LEAVE_NOAPI(ret_value) /*lint !e429 The pointer in 't' has been copied */ -} /* end H5T_vlen_str_mem_write() */ +} /* end H5T_vlen_str_mem_write() */ - /*------------------------------------------------------------------------- * Function: H5T_vlen_str_mem_setnull * @@ -748,19 +737,19 @@ done: */ /* ARGSUSED */ static herr_t -H5T_vlen_str_mem_setnull(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, void *_vl, void H5_ATTR_UNUSED *_bg) +H5T_vlen_str_mem_setnull(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, void *_vl, + void H5_ATTR_UNUSED *_bg) { - char *t=NULL; /* Pointer to temporary buffer allocated */ + char *t = NULL; /* Pointer to temporary buffer allocated */ FUNC_ENTER_NOAPI_NOINIT_NOERR /* Set pointer in user's buffer with memcpy, to avoid alignment issues */ - HDmemcpy(_vl,&t,sizeof(char *)); + HDmemcpy(_vl, &t, sizeof(char *)); FUNC_LEAVE_NOAPI(SUCCEED) /*lint !e429 The pointer in 't' has been copied */ -} /* end H5T_vlen_str_mem_setnull() */ +} /* end H5T_vlen_str_mem_setnull() */ - /*------------------------------------------------------------------------- * Function: H5T_vlen_disk_getlen * @@ -776,8 +765,8 @@ H5T_vlen_str_mem_setnull(H5F_t H5_ATTR_UNUSED *f, hid_t H5_ATTR_UNUSED dxpl_id, static ssize_t H5T_vlen_disk_getlen(const void *_vl) { - const uint8_t *vl=(const uint8_t *)_vl; /* Pointer to the disk VL information */ - size_t seq_len; /* Sequence length */ + const uint8_t *vl = (const uint8_t *)_vl; /* Pointer to the disk VL information */ + size_t seq_len; /* Sequence length */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -787,9 +776,8 @@ H5T_vlen_disk_getlen(const void *_vl) UINT32DECODE(vl, seq_len); FUNC_LEAVE_NOAPI((ssize_t)seq_len) -} /* end H5T_vlen_disk_getlen() */ +} /* end H5T_vlen_disk_getlen() */ - /*------------------------------------------------------------------------- * Function: H5T_vlen_disk_getptr * @@ -812,9 +800,8 @@ H5T_vlen_disk_getptr(void H5_ATTR_UNUSED *vl) HDassert(vl); FUNC_LEAVE_NOAPI(NULL) -} /* end H5T_vlen_disk_getptr() */ +} /* end H5T_vlen_disk_getptr() */ - /*------------------------------------------------------------------------- * Function: H5T_vlen_disk_isnull * @@ -830,8 +817,8 @@ H5T_vlen_disk_getptr(void H5_ATTR_UNUSED *vl) static htri_t H5T_vlen_disk_isnull(const H5F_t *f, void *_vl) { - uint8_t *vl=(uint8_t *)_vl; /* Pointer to the disk VL information */ - haddr_t addr; /* Sequence's heap address */ + uint8_t *vl = (uint8_t *)_vl; /* Pointer to the disk VL information */ + haddr_t addr; /* Sequence's heap address */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -839,15 +826,14 @@ H5T_vlen_disk_isnull(const H5F_t *f, void *_vl) HDassert(vl); /* Skip the sequence's length */ - vl+=4; + vl += 4; /* Get the heap address */ - H5F_addr_decode(f,(const uint8_t **)&vl,&addr); + H5F_addr_decode(f, (const uint8_t **)&vl, &addr); - FUNC_LEAVE_NOAPI(addr==0 ? TRUE : FALSE) -} /* end H5T_vlen_disk_isnull() */ + FUNC_LEAVE_NOAPI(addr == 0 ? TRUE : FALSE) +} /* end H5T_vlen_disk_isnull() */ - /*------------------------------------------------------------------------- * Function: H5T_vlen_disk_read * @@ -864,9 +850,9 @@ H5T_vlen_disk_isnull(const H5F_t *f, void *_vl) static herr_t H5T_vlen_disk_read(H5F_t *f, hid_t dxpl_id, void *_vl, void *buf, size_t H5_ATTR_UNUSED len) { - uint8_t *vl=(uint8_t *)_vl; /* Pointer to the user's hvl_t information */ - H5HG_t hobjid; - herr_t ret_value=SUCCEED; /* Return value */ + uint8_t *vl = (uint8_t *)_vl; /* Pointer to the user's hvl_t information */ + H5HG_t hobjid; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -879,21 +865,20 @@ H5T_vlen_disk_read(H5F_t *f, hid_t dxpl_id, void *_vl, void *buf, size_t H5_ATTR vl += 4; /* Get the heap information */ - H5F_addr_decode(f,(const uint8_t **)&vl,&(hobjid.addr)); - UINT32DECODE(vl,hobjid.idx); + H5F_addr_decode(f, (const uint8_t **)&vl, &(hobjid.addr)); + UINT32DECODE(vl, hobjid.idx); /* Check if this sequence actually has any data */ - if(hobjid.addr>0) { + if (hobjid.addr > 0) { /* Read the VL information from disk */ - if(H5HG_read(f,dxpl_id,&hobjid,buf, NULL)==NULL) + if (H5HG_read(f, dxpl_id, &hobjid, buf, NULL) == NULL) HGOTO_ERROR(H5E_DATATYPE, H5E_READERROR, FAIL, "Unable to read VL information") } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5T_vlen_disk_read() */ +} /* end H5T_vlen_disk_read() */ - /*------------------------------------------------------------------------- * Function: H5T_vlen_disk_write * @@ -909,13 +894,13 @@ done: /* ARGSUSED */ static herr_t H5T_vlen_disk_write(H5F_t *f, hid_t dxpl_id, const H5T_vlen_alloc_info_t H5_ATTR_UNUSED *vl_alloc_info, - void *_vl, void *buf, void *_bg, size_t seq_len, size_t base_size) + void *_vl, void *buf, void *_bg, size_t seq_len, size_t base_size) { uint8_t *vl = (uint8_t *)_vl; /*Pointer to the user's hvl_t information*/ uint8_t *bg = (uint8_t *)_bg; /*Pointer to the old data hvl_t */ - H5HG_t hobjid; /* New VL sequence's heap ID */ - size_t len; /* Size of new sequence on disk (in bytes) */ - herr_t ret_value = SUCCEED; /* Return value */ + H5HG_t hobjid; /* New VL sequence's heap ID */ + size_t len; /* Size of new sequence on disk (in bytes) */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -925,8 +910,8 @@ H5T_vlen_disk_write(H5F_t *f, hid_t dxpl_id, const H5T_vlen_alloc_info_t H5_ATTR HDassert(f); /* Free heap object for old data. */ - if(bg!=NULL) { - H5HG_t bg_hobjid; /* "Background" VL info sequence's ID info */ + if (bg != NULL) { + H5HG_t bg_hobjid; /* "Background" VL info sequence's ID info */ /* Skip the length of the sequence and heap object ID from background data. */ bg += 4; @@ -936,19 +921,19 @@ H5T_vlen_disk_write(H5F_t *f, hid_t dxpl_id, const H5T_vlen_alloc_info_t H5_ATTR UINT32DECODE(bg, bg_hobjid.idx); /* Free heap object for old data */ - if(bg_hobjid.addr > 0) { + if (bg_hobjid.addr > 0) { /* Free heap object */ - if(H5HG_remove(f, dxpl_id, &bg_hobjid) < 0) + if (H5HG_remove(f, dxpl_id, &bg_hobjid) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "Unable to remove heap object") } /* end if */ - } /* end if */ + } /* end if */ /* Set the length of the sequence */ UINT32ENCODE(vl, seq_len); /* Write the VL information to disk (allocates space also) */ - len = (seq_len*base_size); - if(H5HG_insert(f, dxpl_id, len, buf, &hobjid) < 0) + len = (seq_len * base_size); + if (H5HG_insert(f, dxpl_id, len, buf, &hobjid) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "Unable to write VL information") /* Encode the heap information */ @@ -957,9 +942,8 @@ H5T_vlen_disk_write(H5F_t *f, hid_t dxpl_id, const H5T_vlen_alloc_info_t H5_ATTR done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5T_vlen_disk_write() */ +} /* end H5T_vlen_disk_write() */ - /*------------------------------------------------------------------------- * Function: H5T_vlen_disk_setnull * @@ -975,10 +959,10 @@ done: static herr_t H5T_vlen_disk_setnull(H5F_t *f, hid_t dxpl_id, void *_vl, void *_bg) { - uint8_t *vl = (uint8_t *)_vl; /*Pointer to the user's hvl_t information*/ - uint8_t *bg = (uint8_t *)_bg; /*Pointer to the old data hvl_t */ - uint32_t seq_len = 0; /* Sequence length */ - herr_t ret_value = SUCCEED; /* Return value */ + uint8_t *vl = (uint8_t *)_vl; /*Pointer to the user's hvl_t information*/ + uint8_t *bg = (uint8_t *)_bg; /*Pointer to the old data hvl_t */ + uint32_t seq_len = 0; /* Sequence length */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -987,8 +971,8 @@ H5T_vlen_disk_setnull(H5F_t *f, hid_t dxpl_id, void *_vl, void *_bg) HDassert(vl); /* Free heap object for old data. */ - if(bg != NULL) { - H5HG_t bg_hobjid; /* "Background" VL info sequence's ID info */ + if (bg != NULL) { + H5HG_t bg_hobjid; /* "Background" VL info sequence's ID info */ /* Skip the length of the sequence and heap object ID from background data. */ bg += 4; @@ -998,12 +982,12 @@ H5T_vlen_disk_setnull(H5F_t *f, hid_t dxpl_id, void *_vl, void *_bg) UINT32DECODE(bg, bg_hobjid.idx); /* Free heap object for old data */ - if(bg_hobjid.addr > 0) { + if (bg_hobjid.addr > 0) { /* Free heap object */ - if(H5HG_remove(f, dxpl_id, &bg_hobjid) < 0) + if (H5HG_remove(f, dxpl_id, &bg_hobjid) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_WRITEERROR, FAIL, "Unable to remove heap object") - } /* end if */ - } /* end if */ + } /* end if */ + } /* end if */ /* Set the length of the sequence */ UINT32ENCODE(vl, seq_len); @@ -1014,9 +998,8 @@ H5T_vlen_disk_setnull(H5F_t *f, hid_t dxpl_id, void *_vl, void *_bg) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5T_vlen_disk_setnull() */ +} /* end H5T_vlen_disk_setnull() */ - /*-------------------------------------------------------------------------- NAME H5T_vlen_reclaim_recurse @@ -1041,8 +1024,8 @@ done: static herr_t H5T_vlen_reclaim_recurse(void *elem, const H5T_t *dt, H5MM_free_t free_func, void *free_info) { - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + unsigned u; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -1050,69 +1033,72 @@ H5T_vlen_reclaim_recurse(void *elem, const H5T_t *dt, H5MM_free_t free_func, voi HDassert(dt); /* Check the datatype of this element */ - switch(dt->shared->type) { + switch (dt->shared->type) { case H5T_ARRAY: /* Recurse on each element, if the array's base type is array, VL, enum or compound */ - if(H5T_IS_COMPLEX(dt->shared->parent->shared->type)) { - void *off; /* offset of field */ + if (H5T_IS_COMPLEX(dt->shared->parent->shared->type)) { + void *off; /* offset of field */ /* Calculate the offset member and recurse on it */ - for(u = 0; u < dt->shared->u.array.nelem; u++) { + for (u = 0; u < dt->shared->u.array.nelem; u++) { off = ((uint8_t *)elem) + u * (dt->shared->parent->shared->size); - if(H5T_vlen_reclaim_recurse(off, dt->shared->parent, free_func, free_info) < 0) + if (H5T_vlen_reclaim_recurse(off, dt->shared->parent, free_func, free_info) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "Unable to free array element") } /* end for */ - } /* end if */ + } /* end if */ break; case H5T_COMPOUND: /* Check each field and recurse on VL, compound, enum or array ones */ - for(u = 0; u < dt->shared->u.compnd.nmembs; u++) { + for (u = 0; u < dt->shared->u.compnd.nmembs; u++) { /* Recurse if it's VL, compound, enum or array */ - if(H5T_IS_COMPLEX(dt->shared->u.compnd.memb[u].type->shared->type)) { - void *off; /* offset of field */ + if (H5T_IS_COMPLEX(dt->shared->u.compnd.memb[u].type->shared->type)) { + void *off; /* offset of field */ /* Calculate the offset member and recurse on it */ off = ((uint8_t *)elem) + dt->shared->u.compnd.memb[u].offset; - if(H5T_vlen_reclaim_recurse(off, dt->shared->u.compnd.memb[u].type, free_func, free_info) < 0) + if (H5T_vlen_reclaim_recurse(off, dt->shared->u.compnd.memb[u].type, free_func, + free_info) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "Unable to free compound field") } /* end if */ - } /* end for */ + } /* end for */ break; case H5T_VLEN: /* Recurse on the VL information if it's VL, compound, enum or array, then free VL sequence */ - if(dt->shared->u.vlen.type == H5T_VLEN_SEQUENCE) { - hvl_t *vl = (hvl_t *)elem; /* Temp. ptr to the vl info */ + if (dt->shared->u.vlen.type == H5T_VLEN_SEQUENCE) { + hvl_t *vl = (hvl_t *)elem; /* Temp. ptr to the vl info */ /* Check if there is anything actually in this sequence */ - if(vl->len!=0) { + if (vl->len != 0) { /* Recurse if it's VL, array, enum or compound */ - if(H5T_IS_COMPLEX(dt->shared->parent->shared->type)) { - void *off; /* offset of field */ + if (H5T_IS_COMPLEX(dt->shared->parent->shared->type)) { + void *off; /* offset of field */ /* Calculate the offset of each array element and recurse on it */ - while(vl->len > 0) { + while (vl->len > 0) { off = ((uint8_t *)vl->p) + (vl->len - 1) * dt->shared->parent->shared->size; - if(H5T_vlen_reclaim_recurse(off, dt->shared->parent, free_func, free_info) < 0) + if (H5T_vlen_reclaim_recurse(off, dt->shared->parent, free_func, free_info) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "Unable to free VL element") vl->len--; } /* end while */ - } /* end if */ + } /* end if */ /* Free the VL sequence */ - if(free_func != NULL) + if (free_func != NULL) (*free_func)(vl->p, free_info); else H5MM_xfree(vl->p); } /* end if */ - } else if(dt->shared->u.vlen.type == H5T_VLEN_STRING) { + } + else if (dt->shared->u.vlen.type == H5T_VLEN_STRING) { /* Free the VL string */ - if(free_func != NULL) + if (free_func != NULL) (*free_func)(*(char **)elem, free_info); else H5MM_xfree(*(char **)elem); - } else { + } + else { HDassert(0 && "Invalid VL type"); } /* end else */ break; @@ -1123,9 +1109,8 @@ H5T_vlen_reclaim_recurse(void *elem, const H5T_t *dt, H5MM_free_t free_func, voi done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5T_vlen_reclaim_recurse() */ +} /* end H5T_vlen_reclaim_recurse() */ - /*-------------------------------------------------------------------------- NAME H5T_vlen_reclaim @@ -1152,11 +1137,13 @@ done: --------------------------------------------------------------------------*/ /* ARGSUSED */ herr_t -H5T_vlen_reclaim(void *elem, hid_t type_id, unsigned H5_ATTR_UNUSED ndim, const hsize_t H5_ATTR_UNUSED *point, void *op_data) +H5T_vlen_reclaim(void *elem, hid_t type_id, unsigned H5_ATTR_UNUSED ndim, const hsize_t H5_ATTR_UNUSED *point, + void *op_data) { - H5T_vlen_alloc_info_t *vl_alloc_info = (H5T_vlen_alloc_info_t *)op_data; /* VL allocation info from iterator */ - H5T_t *dt; - herr_t ret_value = SUCCEED; /* Return value */ + H5T_vlen_alloc_info_t *vl_alloc_info = + (H5T_vlen_alloc_info_t *)op_data; /* VL allocation info from iterator */ + H5T_t *dt; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -1165,18 +1152,18 @@ H5T_vlen_reclaim(void *elem, hid_t type_id, unsigned H5_ATTR_UNUSED ndim, const HDassert(H5I_DATATYPE == H5I_get_type(type_id)); /* Check args */ - if(NULL == (dt = H5I_object_verify(type_id, H5I_DATATYPE))) + if (NULL == (dt = H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - /* Pull the free function and free info pointer out of the op_data and call the recurse datatype free function */ - if(H5T_vlen_reclaim_recurse(elem, dt, vl_alloc_info->free_func, vl_alloc_info->free_info) < 0) + /* Pull the free function and free info pointer out of the op_data and call the recurse datatype free + * function */ + if (H5T_vlen_reclaim_recurse(elem, dt, vl_alloc_info->free_func, vl_alloc_info->free_info) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "can't reclaim vlen elements") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5T_vlen_reclaim() */ +} /* end H5T_vlen_reclaim() */ - /*-------------------------------------------------------------------------- NAME H5T_vlen_get_alloc_info @@ -1203,8 +1190,8 @@ done: herr_t H5T_vlen_get_alloc_info(hid_t dxpl_id, H5T_vlen_alloc_info_t **vl_alloc_info) { - H5P_genplist_t *plist; /* DX property list */ - herr_t ret_value=SUCCEED; + H5P_genplist_t *plist; /* DX property list */ + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -1212,35 +1199,34 @@ H5T_vlen_get_alloc_info(hid_t dxpl_id, H5T_vlen_alloc_info_t **vl_alloc_info) HDassert(vl_alloc_info); /* Check for the default DXPL */ - if(dxpl_id==H5P_DATASET_XFER_DEFAULT) - *vl_alloc_info=&H5T_vlen_def_vl_alloc_info; + if (dxpl_id == H5P_DATASET_XFER_DEFAULT) + *vl_alloc_info = &H5T_vlen_def_vl_alloc_info; else { /* Check args */ - if(NULL == (plist = H5P_object_verify(dxpl_id,H5P_DATASET_XFER))) + if (NULL == (plist = H5P_object_verify(dxpl_id, H5P_DATASET_XFER))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset transfer property list") /* Get the allocation functions & information */ - if (H5P_get(plist,H5D_XFER_VLEN_ALLOC_NAME,&(*vl_alloc_info)->alloc_func) < 0) + if (H5P_get(plist, H5D_XFER_VLEN_ALLOC_NAME, &(*vl_alloc_info)->alloc_func) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value") - if (H5P_get(plist,H5D_XFER_VLEN_ALLOC_INFO_NAME,&(*vl_alloc_info)->alloc_info) < 0) + if (H5P_get(plist, H5D_XFER_VLEN_ALLOC_INFO_NAME, &(*vl_alloc_info)->alloc_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value") - if (H5P_get(plist,H5D_XFER_VLEN_FREE_NAME,&(*vl_alloc_info)->free_func) < 0) + if (H5P_get(plist, H5D_XFER_VLEN_FREE_NAME, &(*vl_alloc_info)->free_func) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value") - if (H5P_get(plist,H5D_XFER_VLEN_FREE_INFO_NAME,&(*vl_alloc_info)->free_info) < 0) + if (H5P_get(plist, H5D_XFER_VLEN_FREE_INFO_NAME, &(*vl_alloc_info)->free_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get value") } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5T_vlen_get_alloc_info() */ +} /* end H5T_vlen_get_alloc_info() */ - /*------------------------------------------------------------------------- * Function: H5T_vlen_reclaim_elmt * * Purpose: Alternative method to reclaim any VL data for a buffer element. - * - * Use this function when the datatype is already available, but + * + * Use this function when the datatype is already available, but * the allocation info is needed from the dxpl_id before jumping * into recursion. * @@ -1254,9 +1240,9 @@ done: herr_t H5T_vlen_reclaim_elmt(void *elem, H5T_t *dt, hid_t dxpl_id) { - H5T_vlen_alloc_info_t _vl_alloc_info; /* VL allocation info buffer */ - H5T_vlen_alloc_info_t *vl_alloc_info = &_vl_alloc_info; /* VL allocation info */ - herr_t ret_value = SUCCEED; /* return value */ + H5T_vlen_alloc_info_t _vl_alloc_info; /* VL allocation info buffer */ + H5T_vlen_alloc_info_t *vl_alloc_info = &_vl_alloc_info; /* VL allocation info */ + herr_t ret_value = SUCCEED; /* return value */ HDassert(dt); HDassert(elem); @@ -1264,14 +1250,13 @@ H5T_vlen_reclaim_elmt(void *elem, H5T_t *dt, hid_t dxpl_id) FUNC_ENTER_NOAPI(FAIL) /* Get VL allocation info */ - if(H5T_vlen_get_alloc_info(dxpl_id, &vl_alloc_info) < 0) + if (H5T_vlen_get_alloc_info(dxpl_id, &vl_alloc_info) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to retrieve VL allocation info") /* Recurse on buffer to free dynamic fields */ - if(H5T_vlen_reclaim_recurse(elem, dt, vl_alloc_info->free_func, vl_alloc_info->free_info) < 0) + if (H5T_vlen_reclaim_recurse(elem, dt, vl_alloc_info->free_func, vl_alloc_info->free_info) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "can't reclaim vlen elements") done: FUNC_LEAVE_NOAPI(ret_value) } /* H5T_vlen_reclaim_elmt */ - |