mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-02-17 16:10:24 +08:00
[svn-r1506] Bug fixes to get VL datatype fields in compound datatypes working. Also, some
memory leaks plugged in other routines.
This commit is contained in:
parent
e6fc1366cb
commit
9b50a916c5
@ -2844,6 +2844,10 @@ H5S_hyper_select_deserialize (H5S_t *space, const uint8_t *buf)
|
||||
} /* end if */
|
||||
} /* end for */
|
||||
|
||||
/* Free temporary buffers */
|
||||
H5MM_xfree(start);
|
||||
H5MM_xfree(count);
|
||||
|
||||
done:
|
||||
FUNC_LEAVE (ret_value);
|
||||
} /* H5S_hyper_select_deserialize() */
|
||||
@ -3160,9 +3164,11 @@ H5S_hyper_select_iterate(void *buf, hid_t type_id, H5S_t *space, H5D_operator_t
|
||||
iter_info.src=buf;
|
||||
iter_info.lo_bounds=lo_bounds;
|
||||
iter_info.hi_bounds=hi_bounds;
|
||||
|
||||
/* Set up the size of the memory space */
|
||||
HDmemcpy(iter_info.mem_size, space->extent.u.simple.size, space->extent.u.simple.rank*sizeof(hsize_t));
|
||||
iter_info.mem_size[space->extent.u.simple.rank]=iter_info.elem_size;
|
||||
|
||||
/* Copy the location of the region in the file */
|
||||
iter_info.op=operator;
|
||||
iter_info.op_data=operator_data;
|
||||
@ -3175,6 +3181,9 @@ H5S_hyper_select_iterate(void *buf, hid_t type_id, H5S_t *space, H5D_operator_t
|
||||
H5MM_xfree(lo_bounds);
|
||||
H5MM_xfree(hi_bounds);
|
||||
|
||||
/* Release selection iterator */
|
||||
H5S_sel_iter_release(space,&iter);
|
||||
|
||||
done:
|
||||
FUNC_LEAVE (ret_value);
|
||||
} /* H5S_hyper_select_iterate() */
|
||||
|
43
src/H5T.c
43
src/H5T.c
@ -4696,36 +4696,6 @@ H5T_open_oid (H5G_entry_t *ent)
|
||||
FUNC_LEAVE (dt);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5T_cmp_field_off
|
||||
*
|
||||
* Purpose: Compares field offsets for qsort
|
||||
*
|
||||
* Return: <0, 0, or >0 if field1's offset is less than, equal to, or greater
|
||||
* than field2's offset
|
||||
*
|
||||
* Programmer: Quincey Koziol
|
||||
* Thursday, July 15th, 1999
|
||||
*
|
||||
* Modifications:
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
int
|
||||
H5T_cmp_field_off(const void *_field1, const void *_field2)
|
||||
{
|
||||
const H5T_cmemb_t *field1=(const H5T_cmemb_t *)_field1,
|
||||
*field2=(const H5T_cmemb_t *)_field2;
|
||||
|
||||
if(field1->offset < field2->offset)
|
||||
return(-1);
|
||||
else if(field1->offset > field2->offset)
|
||||
return(1);
|
||||
else
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5T_copy
|
||||
@ -4836,12 +4806,13 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method)
|
||||
HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL,
|
||||
"memory allocation failed");
|
||||
}
|
||||
|
||||
/* Sort the fields based on offsets */
|
||||
H5T_sort_value(old_dt,NULL);
|
||||
|
||||
HDmemcpy(new_dt->u.compnd.memb, old_dt->u.compnd.memb,
|
||||
new_dt->u.compnd.nmembs * sizeof(H5T_cmemb_t));
|
||||
|
||||
/* Sort the fields based on offsets */
|
||||
qsort(new_dt->u.compnd.memb, new_dt->u.compnd.nmembs, sizeof(H5T_cmemb_t), H5T_cmp_field_off);
|
||||
|
||||
for (i=0; i<new_dt->u.compnd.nmembs; i++) {
|
||||
s = new_dt->u.compnd.memb[i].name;
|
||||
new_dt->u.compnd.memb[i].name = H5MM_xstrdup(s);
|
||||
@ -4852,8 +4823,12 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method)
|
||||
new_dt->u.compnd.memb[i].offset += accum_change;
|
||||
|
||||
/* If the field changed size, add that change to the accumulated size change */
|
||||
if(new_dt->u.compnd.memb[i].type->size != old_dt->u.compnd.memb[i].type->size)
|
||||
if(new_dt->u.compnd.memb[i].type->size != old_dt->u.compnd.memb[i].type->size) {
|
||||
/* Adjust the size of the member */
|
||||
new_dt->u.compnd.memb[i].size = (old_dt->u.compnd.memb[i].size*tmp->size)/old_dt->u.compnd.memb[i].type->size;
|
||||
|
||||
accum_change += (new_dt->u.compnd.memb[i].type->size - old_dt->u.compnd.memb[i].type->size);
|
||||
} /* end if */
|
||||
}
|
||||
|
||||
/* Apply the accumulated size change to the size of the compound struct */
|
||||
|
@ -206,9 +206,6 @@ __DLLVAR__ size_t H5T_NATIVE_UINT_LEAST64_ALIGN_g;
|
||||
__DLLVAR__ size_t H5T_NATIVE_INT_FAST64_ALIGN_g;
|
||||
__DLLVAR__ size_t H5T_NATIVE_UINT_FAST64_ALIGN_g;
|
||||
|
||||
/* H5Tcopy support functions */
|
||||
__DLL__ int H5T_cmp_field_off(const void *_field1, const void *_field2);
|
||||
|
||||
/* Conversion functions */
|
||||
__DLL__ herr_t H5T_conv_noop(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata,
|
||||
size_t nelmts, size_t stride, void *buf,
|
||||
|
@ -506,7 +506,7 @@ H5T_vlen_mark(H5T_t *dt, H5F_t *f, H5T_vlen_type_t loc)
|
||||
size_t old_size; /* Preview size of a field */
|
||||
|
||||
/* Sort the fields based on offsets */
|
||||
qsort(dt->u.compnd.memb, dt->u.compnd.nmembs, sizeof(H5T_cmemb_t), H5T_cmp_field_off);
|
||||
H5T_sort_value(dt,NULL);
|
||||
|
||||
for (i=0; i<dt->u.compnd.nmembs; i++) {
|
||||
/* Apply the accumulated size change to the offset of the field */
|
||||
@ -521,9 +521,14 @@ H5T_vlen_mark(H5T_t *dt, H5F_t *f, H5T_vlen_type_t loc)
|
||||
if(H5T_vlen_mark(dt->u.compnd.memb[i].type,f,loc)<0)
|
||||
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location");
|
||||
|
||||
/* If the field changed size, add that change to the accumulated size change */
|
||||
if(old_size != dt->u.compnd.memb[i].type->size)
|
||||
/* Check if the field changed size */
|
||||
if(old_size != dt->u.compnd.memb[i].type->size) {
|
||||
/* Adjust the size of the member */
|
||||
dt->u.compnd.memb[i].size = (dt->u.compnd.memb[i].size*dt->u.compnd.memb[i].type->size)/old_size;
|
||||
|
||||
/* Add that change to the accumulated size change */
|
||||
accum_change += (dt->u.compnd.memb[i].type->size - (int)old_size);
|
||||
} /* end if */
|
||||
} /* end if */
|
||||
} /* end for */
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user