32 unsigned char* mem_ptr = (
unsigned char*)input_ptr;
34 size_t new_size, occupied_size = input_ptr->
offset - mem_ptr;
36 size_t append_bytes_padded = append_bytes + alignment - 1;
38 if( mem_ptr + input_ptr->
total_size < input_ptr->
offset + append_bytes_padded )
40 if( append_bytes_padded < input_ptr->
total_size )
43 new_size = input_ptr->
total_size + append_bytes_padded;
50 if( *data != input_ptr )
53 mem_ptr = (
unsigned char*)( *data );
54 ( *data )->offset = mem_ptr + occupied_size;
56 ( *data )->total_size = new_size;
59 result_ptr = ( *data )->offset;
61 uintptr_t addr = (uintptr_t)( ( *data )->offset );
62 int pad = addr % alignment;
65 ( *data )->offset += ( alignment - pad );
66 result_ptr = ( *data )->offset;
69 ( *data )->offset += append_bytes;
73 #define FIX_OFFSET( TYPE, FIELD ) \
74 if( copy_ptr->FIELD != NULL ) \
75 copy_ptr->FIELD = (TYPE)( ( (char*)( copy_ptr->FIELD ) - (char*)orig_addr ) + (char*)copy_ptr )
91 for( i = 0; i < 5; i++ )
97 if( copy_ptr->
elems != NULL )
107 if( copy_ptr->
tags != NULL )
122 const char* elem_handle,
131 ptr =
realloc_data( &result, strlen( elem_handle ) + 1, status,
sizeof(
char ) );
132 if( !ptr )
return NULL;
133 strcpy( ptr, elem_handle );
144 if( !ptr )
return NULL;
194 if( H5Tget_class( file_id_type ) != H5T_INTEGER )
196 mhdf_setFail( status,
"Invalid handle or type class for file ID type." );
200 return H5Tget_size( file_id_type );
211 int have_default, have_global;
212 int valsize,
size, close_type = 0;
215 ptr =
realloc_data( &result, strlen( name ) + 1, status,
sizeof(
char ) );
216 if( NULL == ptr )
return NULL;
235 if( have_default ) have_default = valsize;
236 if( have_global ) have_global = valsize;
250 type = H5T_NATIVE_UCHAR;
253 type = H5T_NATIVE_INT;
254 have_default *=
sizeof( int );
255 have_global *=
sizeof( int );
256 valsize *=
sizeof( int );
259 type = H5T_NATIVE_DOUBLE;
260 have_default *=
sizeof( double );
261 have_global *=
sizeof( double );
262 valsize *=
sizeof( double );
265 have_default = ( have_default + 7 ) / 8;
266 have_global = ( have_global + 7 ) / 8;
267 valsize = ( valsize + 7 ) / 8;
271 type = H5Tcopy( H5T_NATIVE_B8 );
274 type = H5Tcopy( H5T_NATIVE_B16 );
278 valsize += 4 - valsize;
279 type = H5Tcopy( H5T_NATIVE_B32 );
285 valsize += 8 - valsize;
286 type = H5Tcopy( H5T_NATIVE_B64 );
290 mhdf_setFail( status,
"Cannot create a bit tag larger than 64-bits. %d bits requested.\n",
297 if( 0 == type ) type = H5T_NATIVE_ULONG;
304 have_default *=
size;
309 mhdf_setFail( status,
"Unknown mhdf_TagDataType value (%d) for tag (\"%s\")", (
int)result->
tags[idx].
type,
320 #if defined( H5Tarray_create_vers ) && H5Tarray_create_vers > 1
321 type = H5Tarray_create2( type, 1, &array_len );
323 type = H5Tarray_create( type, 1, &array_len, 0 );
327 mhdf_setFail( status,
"H5Tarray_create failed for tag (\"%s\")", name );
333 if( have_default || have_global )
337 ptr =
realloc_data( &result, have_default, status,
sizeof(
int ) );
350 ptr =
realloc_data( &result, have_global, status,
sizeof(
int ) );
380 for( i = 0; i < count; ++i )
392 int i, i1, numtags, j, k,
size, *indices, have, num_tag_names = 0;
395 char **elem_handles = 0, **tag_names = 0;
396 unsigned char *array, *matrix;
397 const char* pname[5] = {
"PARALLEL_PARTITION",
"MATERIAL_SET",
"NEUMANN_SET",
"DIRICHLET_SET",
"GEOM_DIMENSION" };
409 if( NULL == result )
return NULL;
463 if( elem_handles == NULL )
475 free( elem_handles );
478 memset( ptr, 0,
size );
484 result =
get_elem_desc( file_handle, result, elem_handles[i], i, status );
487 free( elem_handles );
496 free( elem_handles );
506 free( elem_handles );
510 memset( ptr, 0,
size );
518 result =
get_tag_desc( file_handle, result, tag_names[i], i, file_id_type, status );
521 free( elem_handles );
533 free( elem_handles );
538 memset( array, 0,
size );
547 for( i = 0; i < result->num_elem_desc; ++i )
551 free( elem_handles );
566 indices =
realloc_data( &result,
size *
sizeof(
int ), status,
sizeof(
int ) );
567 if( NULL == indices )
575 if( matrix[i * result->
num_tag_desc + j] ) indices[k++] = j;
608 indices =
realloc_data( &result,
size *
sizeof(
int ), status,
sizeof(
int ) );
617 if( matrix[i * result->
num_tag_desc + j] ) indices[k++] = i;
631 const int NPRIMARY_SETS = 5;
632 ptr =
realloc_data( &result, NPRIMARY_SETS *
sizeof(
int ), status,
sizeof(
int ) );
639 for( i = 0; i < NPRIMARY_SETS; ++i )
642 ptr =
realloc_data( &result, NPRIMARY_SETS *
sizeof(
int* ), status,
sizeof(
int* ) );
650 ptr =
realloc_data( &result, NPRIMARY_SETS *
sizeof(
int* ), status,
sizeof(
int* ) );
659 for( i = 0; i < numtags; i++ )
661 tag_desc = &( result->
tags[i] );
662 for( k = 0; k < NPRIMARY_SETS; k++ )
664 if( strcmp( pname[k], tag_desc->
name ) == 0 )
676 if( nval <= 0 )
continue;
678 ptr =
realloc_data( &result, nval *
sizeof(
int ), status,
sizeof(
int ) );
684 memset( ptr, 0, nval *
sizeof(
int ) );
686 tag_desc = &( result->
tags[i] );
688 ptr =
realloc_data( &result, nval *
sizeof(
int ), status,
sizeof(
int ) );
694 memset( ptr, 0, nval *
sizeof(
int ) );
696 tag_desc = &( result->
tags[i] );
701 id_list =
mhdf_malloc( nval *
sizeof(
long ), status );
707 data_type = H5Dget_type( table[0] );
709 mhdf_read_data( table[0], 0, nval, data_type, id_list, H5P_DEFAULT, status );
715 H5Tclose( data_type );
717 for( i1 = 0; i1 < nval; i1++ )
720 data_type = H5Dget_type( table[1] );
727 H5Tclose( data_type );
742 else if( 0 == k || 1 == k )
753 if( nval <= 0 )
continue;
759 if( nval <= 0 )
continue;
761 ptr =
realloc_data( &result, nval *
sizeof(
int ), status,
sizeof(
int ) );
767 memset( ptr, 0, nval *
sizeof(
int ) );
769 tag_desc = &( result->
tags[i] );
771 ptr =
realloc_data( &result, nval *
sizeof(
int ), status,
sizeof(
int ) );
777 memset( ptr, 0, nval *
sizeof(
int ) );
779 tag_desc = &( result->
tags[i] );
782 for( i1 = 0; i1 < nval; i1++ )