diff options
author | Quincey Koziol <koziol@hdfgroup.org> | 2007-10-04 22:19:07 (GMT) |
---|---|---|
committer | Quincey Koziol <koziol@hdfgroup.org> | 2007-10-04 22:19:07 (GMT) |
commit | 1de51c7bc148b9cb5104936dfd23096a222d0cb8 (patch) | |
tree | b23ea23404fd02a41f4539ebbc8311a1c43fecbe /hl/src/H5IM.c | |
parent | 041de441c5d7468812be8af1346b30db6ea94e3a (diff) | |
download | hdf5-1de51c7bc148b9cb5104936dfd23096a222d0cb8.zip hdf5-1de51c7bc148b9cb5104936dfd23096a222d0cb8.tar.gz hdf5-1de51c7bc148b9cb5104936dfd23096a222d0cb8.tar.bz2 |
[svn-r14187] Description:
Put H5Acreate() under API versioning, with all internal usage shifted
to H5Acreate2().
Add regression tests for H5Acreate1().
Tested on:
FreeBSD/32 6.2 (duty) in debug mode
FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe,
in debug mode
Linux/64-amd64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Mac OS X/32 10.4.10 (amazon) in debug mode
Diffstat (limited to 'hl/src/H5IM.c')
-rw-r--r-- | hl/src/H5IM.c | 146 |
1 files changed, 73 insertions, 73 deletions
diff --git a/hl/src/H5IM.c b/hl/src/H5IM.c index e6bd506..c7e905d 100644 --- a/hl/src/H5IM.c +++ b/hl/src/H5IM.c @@ -52,19 +52,19 @@ herr_t H5IMmake_image_8bit( hid_t loc_id, dims[2] = 1; /* Make the dataset */ - if ( H5LTmake_dataset( loc_id, dset_name, IMAGE8_RANK, dims, H5T_NATIVE_UCHAR, buffer ) < 0 ) + if ( H5LTmake_dataset( loc_id, dset_name, IMAGE8_RANK, dims, H5T_NATIVE_UCHAR, buffer ) < 0) return -1; /* Attach the CLASS attribute */ - if ( H5LTset_attribute_string( loc_id, dset_name, "CLASS", IMAGE_CLASS ) < 0 ) + if ( H5LTset_attribute_string( loc_id, dset_name, "CLASS", IMAGE_CLASS ) < 0) return -1; /* Attach the VERSION attribute */ - if ( H5LTset_attribute_string( loc_id, dset_name, "IMAGE_VERSION", IMAGE_VERSION ) < 0 ) + if ( H5LTset_attribute_string( loc_id, dset_name, "IMAGE_VERSION", IMAGE_VERSION ) < 0) return -1; /* Attach the IMAGE_SUBCLASS attribute */ - if ( H5LTset_attribute_string( loc_id, dset_name, "IMAGE_SUBCLASS", "IMAGE_INDEXED" ) < 0 ) + if ( H5LTset_attribute_string( loc_id, dset_name, "IMAGE_SUBCLASS", "IMAGE_INDEXED" ) < 0) return -1; return 0; @@ -124,23 +124,23 @@ herr_t H5IMmake_image_24bit( hid_t loc_id, else return -1; /* Make the dataset */ - if ( H5LTmake_dataset( loc_id, dset_name, IMAGE24_RANK, dims, H5T_NATIVE_UCHAR, buffer ) < 0 ) + if ( H5LTmake_dataset( loc_id, dset_name, IMAGE24_RANK, dims, H5T_NATIVE_UCHAR, buffer ) < 0) return -1; /* Attach the CLASS attribute */ - if ( H5LTset_attribute_string( loc_id, dset_name, "CLASS", IMAGE_CLASS ) < 0 ) + if ( H5LTset_attribute_string( loc_id, dset_name, "CLASS", IMAGE_CLASS ) < 0) return -1; /* Attach the VERSION attribute */ - if ( H5LTset_attribute_string( loc_id, dset_name, "IMAGE_VERSION", IMAGE_VERSION ) < 0 ) + if ( H5LTset_attribute_string( loc_id, dset_name, "IMAGE_VERSION", IMAGE_VERSION ) < 0) return -1; /* Attach the IMAGE_SUBCLASS attribute */ - if ( H5LTset_attribute_string( loc_id, dset_name, "IMAGE_SUBCLASS", "IMAGE_TRUECOLOR" ) < 0 ) + if ( H5LTset_attribute_string( loc_id, dset_name, "IMAGE_SUBCLASS", "IMAGE_TRUECOLOR" ) < 0) return -1; /* Attach the INTERLACE_MODE attribute. This attributes is only for true color images */ - if ( H5LTset_attribute_string( loc_id, dset_name, "INTERLACE_MODE", interlace ) < 0 ) + if ( H5LTset_attribute_string( loc_id, dset_name, "INTERLACE_MODE", interlace ) < 0) return -1; return 0; @@ -280,11 +280,11 @@ herr_t H5IMget_image_info( hid_t loc_id, } /* Get the dataspace handle */ - if ( (sid = H5Dget_space( did )) < 0 ) + if ( (sid = H5Dget_space( did )) < 0) goto out; /* Get dimensions */ - if ( H5Sget_simple_extent_dims( sid, dims, NULL) < 0 ) + if ( H5Sget_simple_extent_dims( sid, dims, NULL) < 0) goto out; /* Initialize the image dimensions */ @@ -319,7 +319,7 @@ herr_t H5IMget_image_info( hid_t loc_id, } /* Close */ - if ( H5Sclose( sid ) < 0 ) + if ( H5Sclose( sid ) < 0) goto out; @@ -348,27 +348,27 @@ herr_t H5IMget_image_info( hid_t loc_id, /* Get the reference(s) */ - if ( (attr_space_id = H5Aget_space( attr_id )) < 0 ) + if ( (attr_space_id = H5Aget_space( attr_id )) < 0) goto out; *npals = H5Sget_simple_extent_npoints( attr_space_id ); - if ( H5Sclose( attr_space_id ) < 0 ) + if ( H5Sclose( attr_space_id ) < 0) goto out; } /* H5T_REFERENCE */ - if ( H5Tclose( attr_type ) < 0 ) + if ( H5Tclose( attr_type ) < 0) goto out; /* Close the attribute. */ - if ( H5Aclose( attr_id ) < 0 ) + if ( H5Aclose( attr_id ) < 0) goto out; } /* End access to the dataset and release resources used by it. */ - if ( H5Dclose( did ) < 0 ) + if ( H5Dclose( did ) < 0) goto out; return 0; @@ -407,11 +407,11 @@ herr_t H5IMread_image( hid_t loc_id, hid_t did; /* Open the dataset. */ - if ( (did = H5Dopen( loc_id, dset_name )) < 0 ) + if ( (did = H5Dopen( loc_id, dset_name )) < 0) return -1; /* Read */ - if ( H5Dread( did, H5T_NATIVE_UCHAR, H5S_ALL, H5S_ALL, H5P_DEFAULT, buffer ) < 0 ) + if ( H5Dread( did, H5T_NATIVE_UCHAR, H5S_ALL, H5S_ALL, H5P_DEFAULT, buffer ) < 0) goto out; /* End access to the dataset and release resources used by it. */ @@ -468,11 +468,11 @@ herr_t H5IMmake_palette( hid_t loc_id, return -1; /* Attach the attribute "CLASS" to the >>palette<< dataset*/ - if ( H5LTset_attribute_string( loc_id, pal_name, "CLASS", PALETTE_CLASS ) < 0 ) + if ( H5LTset_attribute_string( loc_id, pal_name, "CLASS", PALETTE_CLASS ) < 0) return -1; /* Attach the attribute "PAL_VERSION" to the >>palette<< dataset*/ - if ( H5LTset_attribute_string( loc_id, pal_name, "PAL_VERSION", "1.2" ) < 0 ) + if ( H5LTset_attribute_string( loc_id, pal_name, "PAL_VERSION", "1.2" ) < 0) return -1; return 0; @@ -527,7 +527,7 @@ herr_t H5IMlink_palette( hid_t loc_id, */ /* First we get the image id */ - if ( (image_id = H5Dopen( loc_id, image_name )) < 0 ) + if ( (image_id = H5Dopen( loc_id, image_name )) < 0) return -1; /* Try to find the attribute "PALETTE" on the >>image<< dataset */ @@ -537,31 +537,31 @@ herr_t H5IMlink_palette( hid_t loc_id, * It does not exist. We create the attribute and one reference *------------------------------------------------------------------------- */ - if ( ok_pal == 0 ) + if(ok_pal == 0 ) { - if ( (attr_space_id = H5Screate( H5S_SCALAR )) < 0 ) + if((attr_space_id = H5Screate(H5S_SCALAR)) < 0) goto out; /* Create the attribute type for the reference */ - if ( (attr_type = H5Tcopy( H5T_STD_REF_OBJ )) < 0 ) + if((attr_type = H5Tcopy(H5T_STD_REF_OBJ)) < 0) goto out; /* Create the attribute "PALETTE" to be attached to the image*/ - if ( (attr_id = H5Acreate( image_id, "PALETTE", attr_type, attr_space_id, H5P_DEFAULT )) < 0 ) + if((attr_id = H5Acreate2(image_id, ".", "PALETTE", attr_type, attr_space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; /* Create a reference. The reference is created on the local id. */ - if ( H5Rcreate( &ref, loc_id, pal_name, H5R_OBJECT, -1 ) < 0 ) + if(H5Rcreate(&ref, loc_id, pal_name, H5R_OBJECT, -1) < 0) goto out; /* Write the attribute with the reference */ - if ( H5Awrite( attr_id, attr_type, &ref ) < 0 ) + if(H5Awrite(attr_id, attr_type, &ref) < 0) goto out; /* close */ - if ( H5Sclose( attr_space_id ) < 0 ) + if(H5Sclose(attr_space_id) < 0) goto out; - if ( H5Tclose( attr_type ) < 0 ) + if ( H5Tclose( attr_type ) < 0) goto out; if(H5Aclose(attr_id) < 0) goto out; @@ -593,7 +593,7 @@ herr_t H5IMlink_palette( hid_t loc_id, refbuf = malloc( sizeof(hobj_ref_t) * (int)dim_ref ); - if ( H5Aread( attr_id, attr_type, refbuf ) < 0 ) + if ( H5Aread( attr_id, attr_type, refbuf ) < 0) goto out; /* The attribute must be deleted, in order to the new one can reflect the changes*/ @@ -601,33 +601,33 @@ herr_t H5IMlink_palette( hid_t loc_id, goto out; /* Create a new reference for this palette. */ - if ( H5Rcreate( &ref, loc_id, pal_name, H5R_OBJECT, -1 ) < 0 ) + if ( H5Rcreate( &ref, loc_id, pal_name, H5R_OBJECT, -1 ) < 0) goto out; refbuf[n_refs] = ref; /* Create the data space for the new references */ - if ( H5Sclose( attr_space_id ) < 0 ) + if(H5Sclose(attr_space_id) < 0) goto out; - if ( (attr_space_id = H5Screate_simple( 1, &dim_ref, NULL )) < 0 ) + if((attr_space_id = H5Screate_simple(1, &dim_ref, NULL)) < 0) goto out; /* Create the attribute again with the changes of space */ - if ( H5Aclose( attr_id ) < 0 ) + if(H5Aclose(attr_id) < 0) goto out; - if ( (attr_id = H5Acreate( image_id, "PALETTE", attr_type, attr_space_id, H5P_DEFAULT )) < 0 ) + if((attr_id = H5Acreate2(image_id, ".", "PALETTE", attr_type, attr_space_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto out; /* Write the attribute with the new references */ - if ( H5Awrite( attr_id, attr_type, refbuf ) < 0 ) + if(H5Awrite(attr_id, attr_type, refbuf) < 0) goto out; /* close */ - if ( H5Sclose( attr_space_id ) < 0 ) + if(H5Sclose(attr_space_id) < 0) goto out; - if ( H5Aclose( attr_id ) < 0 ) + if(H5Aclose(attr_id) < 0) goto out; free( refbuf ); @@ -635,7 +635,7 @@ herr_t H5IMlink_palette( hid_t loc_id, } /* ok_pal == 1 */ /* Close the image dataset. */ - if ( H5Dclose( image_id ) < 0 ) + if ( H5Dclose( image_id ) < 0) return -1; return 0; @@ -694,7 +694,7 @@ herr_t H5IMunlink_palette( hid_t loc_id, */ /* First we get the image id */ - if ( (image_id = H5Dopen( loc_id, image_name )) < 0 ) + if ( (image_id = H5Dopen( loc_id, image_name )) < 0) return -1; /* Try to find the attribute "PALETTE" on the >>image<< dataset */ @@ -726,17 +726,17 @@ herr_t H5IMunlink_palette( hid_t loc_id, } /* H5T_REFERENCE */ - if ( H5Tclose( attr_type ) < 0 ) + if ( H5Tclose( attr_type ) < 0) goto out; /* Close the attribute. */ - if ( H5Aclose( attr_id ) < 0 ) + if ( H5Aclose( attr_id ) < 0) goto out; } /* ok_pal */ /* Close the image dataset. */ - if ( H5Dclose( image_id ) < 0 ) + if ( H5Dclose( image_id ) < 0) return -1; return 0; @@ -807,22 +807,22 @@ herr_t H5IMget_npalettes( hid_t loc_id, *npals = H5Sget_simple_extent_npoints( attr_space_id ); - if ( H5Sclose( attr_space_id ) < 0 ) + if ( H5Sclose( attr_space_id ) < 0) goto out; } /* H5T_REFERENCE */ - if ( H5Tclose( attr_type ) < 0 ) + if ( H5Tclose( attr_type ) < 0) goto out; /* Close the attribute. */ - if ( H5Aclose( attr_id ) < 0 ) + if ( H5Aclose( attr_id ) < 0) goto out; } /* Close the image dataset. */ - if ( H5Dclose( image_id ) < 0 ) + if ( H5Dclose( image_id ) < 0) return -1; return 0; @@ -900,32 +900,32 @@ herr_t H5IMget_palette_info( hid_t loc_id, refbuf = malloc( sizeof(hobj_ref_t) * (int)dim_ref ); - if ( H5Aread( attr_id, attr_type, refbuf ) < 0 ) + if ( H5Aread( attr_id, attr_type, refbuf ) < 0) goto out; /* Get the actual palette */ - if ( (pal_id = H5Rdereference( image_id, H5R_OBJECT, &refbuf[pal_number] )) < 0 ) + if ( (pal_id = H5Rdereference( image_id, H5R_OBJECT, &refbuf[pal_number] )) < 0) goto out; - if ( (pal_space_id = H5Dget_space( pal_id )) < 0 ) + if ( (pal_space_id = H5Dget_space( pal_id )) < 0) goto out; - if ( H5Sget_simple_extent_ndims( pal_space_id ) < 0 ) + if ( H5Sget_simple_extent_ndims( pal_space_id ) < 0) goto out; - if ( H5Sget_simple_extent_dims( pal_space_id, pal_dims, pal_maxdims ) < 0 ) + if ( H5Sget_simple_extent_dims( pal_space_id, pal_dims, pal_maxdims ) < 0) goto out; /* close */ if (H5Dclose(pal_id)<0) goto out; - if ( H5Sclose( pal_space_id ) < 0 ) + if ( H5Sclose( pal_space_id ) < 0) goto out; - if ( H5Sclose( attr_space_id ) < 0 ) + if ( H5Sclose( attr_space_id ) < 0) goto out; - if ( H5Tclose( attr_type ) < 0 ) + if ( H5Tclose( attr_type ) < 0) goto out; - if ( H5Aclose( attr_id ) < 0 ) + if ( H5Aclose( attr_id ) < 0) goto out; free( refbuf ); @@ -933,7 +933,7 @@ herr_t H5IMget_palette_info( hid_t loc_id, } /* Close the image dataset. */ - if ( H5Dclose( image_id ) < 0 ) + if ( H5Dclose( image_id ) < 0) return -1; return 0; @@ -1012,31 +1012,31 @@ herr_t H5IMget_palette( hid_t loc_id, refbuf = malloc( sizeof(hobj_ref_t) * (int)dim_ref ); - if ( H5Aread( attr_id, attr_type, refbuf ) < 0 ) + if ( H5Aread( attr_id, attr_type, refbuf ) < 0) goto out; /* Get the palette id */ - if ( (pal_id = H5Rdereference( image_id, H5R_OBJECT, &refbuf[pal_number] )) < 0 ) + if ( (pal_id = H5Rdereference( image_id, H5R_OBJECT, &refbuf[pal_number] )) < 0) goto out; /* Read the palette dataset */ - if ( H5Dread( pal_id, H5Dget_type(pal_id), H5S_ALL, H5S_ALL, H5P_DEFAULT, pal_data ) < 0 ) + if ( H5Dread( pal_id, H5Dget_type(pal_id), H5S_ALL, H5S_ALL, H5P_DEFAULT, pal_data ) < 0) goto out; /* close */ if (H5Dclose(pal_id)<0) goto out; - if ( H5Sclose( attr_space_id ) < 0 ) + if ( H5Sclose( attr_space_id ) < 0) goto out; - if ( H5Tclose( attr_type ) < 0 ) + if ( H5Tclose( attr_type ) < 0) goto out; - if ( H5Aclose( attr_id ) < 0 ) + if ( H5Aclose( attr_id ) < 0) goto out; free( refbuf ); } /* Close the image dataset. */ - if ( H5Dclose( image_id ) < 0 ) + if ( H5Dclose( image_id ) < 0) return -1; return 0; @@ -1084,7 +1084,7 @@ herr_t H5IMis_image( hid_t loc_id, ret = -1; /* Open the dataset. */ - if ( (did = H5Dopen( loc_id, dset_name )) < 0 ) + if ( (did = H5Dopen( loc_id, dset_name )) < 0) return -1; /* Try to find the attribute "CLASS" on the dataset */ @@ -1115,16 +1115,16 @@ herr_t H5IMis_image( hid_t loc_id, else ret = 0; - if ( H5Tclose( attr_type ) < 0 ) + if ( H5Tclose( attr_type ) < 0) goto out; - if ( H5Aclose( attr_id ) < 0 ) + if ( H5Aclose( attr_id ) < 0) goto out; } /* Close the dataset. */ - if ( H5Dclose( did ) < 0 ) + if ( H5Dclose( did ) < 0) return -1; return ret; @@ -1169,7 +1169,7 @@ herr_t H5IMis_palette( hid_t loc_id, ret = -1; /* Open the dataset. */ - if ( (did = H5Dopen( loc_id, dset_name )) < 0 ) + if ( (did = H5Dopen( loc_id, dset_name )) < 0) return -1; /* Try to find the attribute "CLASS" on the dataset */ @@ -1200,16 +1200,16 @@ herr_t H5IMis_palette( hid_t loc_id, else ret = 0; - if ( H5Tclose( attr_type ) < 0 ) + if ( H5Tclose( attr_type ) < 0) goto out; - if ( H5Aclose( attr_id ) < 0 ) + if ( H5Aclose( attr_id ) < 0) goto out; } /* Close the dataset. */ - if ( H5Dclose( did ) < 0 ) + if ( H5Dclose( did ) < 0) return -1; return ret; |