2004-08-18 03:54:42 +08:00
|
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
2007-02-07 22:56:24 +08:00
|
|
|
|
* Copyright by The HDF Group. *
|
2003-10-23 05:43:34 +08:00
|
|
|
|
* Copyright by the Board of Trustees of the University of Illinois. *
|
|
|
|
|
* All rights reserved. *
|
|
|
|
|
* *
|
|
|
|
|
* This file is part of HDF5. The full HDF5 copyright notice, including *
|
|
|
|
|
* terms governing use, modification, and redistribution, is contained in *
|
|
|
|
|
* the files COPYING and Copyright.html. COPYING can be found at the root *
|
|
|
|
|
* of the source code distribution tree; Copyright.html can be found at the *
|
|
|
|
|
* root level of an installed copy of the electronic HDF5 document set and *
|
|
|
|
|
* is linked from the top-level documents page. It can also be found at *
|
2007-02-07 22:56:24 +08:00
|
|
|
|
* http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
|
|
|
|
|
* access to either file, you may request a copy from help@hdfgroup.org. *
|
2003-10-23 05:43:34 +08:00
|
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
|
|
|
|
2003-12-05 03:35:33 +08:00
|
|
|
|
#include "h5repack.h"
|
2007-04-05 04:25:42 +08:00
|
|
|
|
#include "h5tools_utils.h"
|
2003-10-23 05:43:34 +08:00
|
|
|
|
|
2004-01-08 23:53:32 +08:00
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: init_packobject
|
|
|
|
|
*
|
|
|
|
|
* Purpose: initialize a pack_info_t structure
|
|
|
|
|
*
|
|
|
|
|
* Return: void
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
void init_packobject(pack_info_t *obj)
|
|
|
|
|
{
|
2007-11-29 04:30:43 +08:00
|
|
|
|
int j, k;
|
2008-09-16 23:52:51 +08:00
|
|
|
|
|
2011-02-15 06:20:32 +08:00
|
|
|
|
HDstrcpy(obj->path,"\0");
|
2007-11-29 04:30:43 +08:00
|
|
|
|
for ( j=0; j<H5_REPACK_MAX_NFILTERS; j++)
|
|
|
|
|
{
|
|
|
|
|
obj->filter[j].filtn = -1;
|
2007-12-15 05:38:23 +08:00
|
|
|
|
for ( k=0; k<CD_VALUES; k++)
|
2008-09-19 00:06:28 +08:00
|
|
|
|
obj->filter[j].cd_values[k] = 0;
|
2007-11-29 04:30:43 +08:00
|
|
|
|
}
|
|
|
|
|
obj->chunk.rank = -1;
|
|
|
|
|
obj->refobj_id = -1;
|
|
|
|
|
obj->layout = H5D_LAYOUT_ERROR;
|
|
|
|
|
obj->nfilters = 0;
|
2004-01-08 23:53:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
2004-01-07 01:49:00 +08:00
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: aux_tblinsert_filter
|
|
|
|
|
*
|
|
|
|
|
* Purpose: auxiliary function, inserts the filter in object OBJS[ I ]
|
|
|
|
|
*
|
|
|
|
|
* Return: void
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
2005-08-14 04:53:35 +08:00
|
|
|
|
static void aux_tblinsert_filter(pack_opttbl_t *table,
|
2006-12-07 23:48:19 +08:00
|
|
|
|
unsigned int I,
|
2004-01-08 23:53:32 +08:00
|
|
|
|
filter_info_t filt)
|
2004-01-07 01:49:00 +08:00
|
|
|
|
{
|
2007-11-29 04:30:43 +08:00
|
|
|
|
if (table->objs[ I ].nfilters<H5_REPACK_MAX_NFILTERS)
|
|
|
|
|
{
|
|
|
|
|
table->objs[ I ].filter[ table->objs[ I ].nfilters++ ] = filt;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2010-05-12 04:10:25 +08:00
|
|
|
|
error_msg("cannot insert the filter in this object.\
|
2007-11-29 04:30:43 +08:00
|
|
|
|
Maximum capacity exceeded\n");
|
|
|
|
|
}
|
2004-01-07 01:49:00 +08:00
|
|
|
|
}
|
|
|
|
|
|
2004-07-16 03:25:27 +08:00
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: aux_tblinsert_layout
|
|
|
|
|
*
|
|
|
|
|
* Purpose: auxiliary function, inserts the layout in object OBJS[ I ]
|
|
|
|
|
*
|
|
|
|
|
* Return: void
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
2005-08-14 04:53:35 +08:00
|
|
|
|
static void aux_tblinsert_layout(pack_opttbl_t *table,
|
2006-12-07 23:48:19 +08:00
|
|
|
|
unsigned int I,
|
2004-07-16 03:25:27 +08:00
|
|
|
|
pack_info_t *pack)
|
|
|
|
|
{
|
2007-11-29 04:30:43 +08:00
|
|
|
|
int k;
|
2008-09-16 23:52:51 +08:00
|
|
|
|
|
2007-11-29 04:30:43 +08:00
|
|
|
|
table->objs[I].layout = pack->layout;
|
|
|
|
|
if (H5D_CHUNKED==pack->layout)
|
|
|
|
|
{
|
|
|
|
|
/* -2 means the NONE option, remove chunking
|
|
|
|
|
and set the layout to contiguous */
|
|
|
|
|
if (pack->chunk.rank==-2)
|
|
|
|
|
{
|
|
|
|
|
table->objs[I].layout = H5D_CONTIGUOUS;
|
|
|
|
|
table->objs[I].chunk.rank = -2;
|
|
|
|
|
}
|
|
|
|
|
/* otherwise set the chunking type */
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
table->objs[I].chunk.rank = pack->chunk.rank;
|
|
|
|
|
for (k = 0; k < pack->chunk.rank; k++)
|
|
|
|
|
table->objs[I].chunk.chunk_lengths[k] = pack->chunk.chunk_lengths[k];
|
|
|
|
|
}
|
|
|
|
|
}
|
2004-07-16 03:25:27 +08:00
|
|
|
|
}
|
|
|
|
|
|
2004-01-07 01:49:00 +08:00
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: aux_inctable
|
|
|
|
|
*
|
|
|
|
|
* Purpose: auxiliary function, increases the size of the collection by N_OBJS
|
|
|
|
|
*
|
|
|
|
|
* Return: 0, ok, -1, fail
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
static int aux_inctable(pack_opttbl_t *table, int n_objs )
|
|
|
|
|
{
|
2007-11-29 04:30:43 +08:00
|
|
|
|
unsigned int i;
|
2008-09-16 23:52:51 +08:00
|
|
|
|
|
2007-11-29 04:30:43 +08:00
|
|
|
|
table->size += n_objs;
|
|
|
|
|
table->objs = (pack_info_t*)realloc(table->objs, table->size * sizeof(pack_info_t));
|
|
|
|
|
if (table->objs==NULL) {
|
2010-05-12 04:10:25 +08:00
|
|
|
|
error_msg("not enough memory for options table\n");
|
2007-11-29 04:30:43 +08:00
|
|
|
|
return -1;
|
|
|
|
|
}
|
|
|
|
|
for (i = table->nelems; i < table->size; i++)
|
|
|
|
|
{
|
|
|
|
|
init_packobject(&table->objs[i]);
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
2004-01-07 01:49:00 +08:00
|
|
|
|
}
|
2003-10-23 05:43:34 +08:00
|
|
|
|
|
[svn-r17980] Description:
Bring Coverity changes into the trunk: (also other minor cleanups)
r17955:
Fix Coverity item 24. Add missing error condition to
H5AC_ext_config_2_int_config.
r17956:
Fix Coverity item 24. Improve error checking in H5A_compact_build_table_cb.
r17957:
Fix Coverity item 150. Fix warning in H5A_compact_build_table_cb.
r17958:
Fix Coverity item 117. Fix error handling in H5B_shared_new.
r17959:
Fix Coverity item 209. Added an assertion for leaf->shared in
H5B2_cache_leaf_dest.
r17960:
Fix Coverity item 208. Added an assertion for internal->shared in
H5B2_cache_internal_dest.
r17961:
Fix Coverity item 89. Reworked the code to avoid array overrun in
H5C__autoadjust__ageout__insert_new_marker.
r17962:
Fix for coverity Resource_leak 195,203,204,205.
r17963:
Fix Coverity item 44. Prevented potential NULL dereference in H5D_btree_debug.
r17964:
Fix Coverity issues #197, 198 & 199: memory not being released. (Also
clean up other resource leaks in nearby and/or similar code).
r17965:
Fix Coverity issue #151: release resources on error
r17966:
Fix Coverity issue #187: Remove leftover code remnant from prior bugfix
which was causing resource leak of open files.
r17967:
Fixed Coverity issues # 193 & 194. Removed unnecessary memory allocation and
added comparison of length of path parameter to the size of the destination
buffer in h5import.h/h5import.c.
r17968:
Fix Coverity item 144. Fixed memory leak on error in H5D_chunk_copy.
r17969:
Fix for coverity Resource_leak #196.
r17970:
Coverity 167-173:
Initialized pointer of buffers.
In error handling, closed types and free memory.
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
Mac OS X/32 10.6.2 (amazon) in debug mode
Mac OS X/32 10.6.2 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
2009-12-10 20:36:56 +08:00
|
|
|
|
|
2003-10-23 05:43:34 +08:00
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: options_table_init
|
|
|
|
|
*
|
|
|
|
|
* Purpose: init options table
|
|
|
|
|
*
|
|
|
|
|
* Return: 0, ok, -1, fail
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
2003-10-29 01:40:05 +08:00
|
|
|
|
int options_table_init( pack_opttbl_t **tbl )
|
2003-10-23 05:43:34 +08:00
|
|
|
|
{
|
2007-11-29 04:30:43 +08:00
|
|
|
|
unsigned int i;
|
[svn-r17980] Description:
Bring Coverity changes into the trunk: (also other minor cleanups)
r17955:
Fix Coverity item 24. Add missing error condition to
H5AC_ext_config_2_int_config.
r17956:
Fix Coverity item 24. Improve error checking in H5A_compact_build_table_cb.
r17957:
Fix Coverity item 150. Fix warning in H5A_compact_build_table_cb.
r17958:
Fix Coverity item 117. Fix error handling in H5B_shared_new.
r17959:
Fix Coverity item 209. Added an assertion for leaf->shared in
H5B2_cache_leaf_dest.
r17960:
Fix Coverity item 208. Added an assertion for internal->shared in
H5B2_cache_internal_dest.
r17961:
Fix Coverity item 89. Reworked the code to avoid array overrun in
H5C__autoadjust__ageout__insert_new_marker.
r17962:
Fix for coverity Resource_leak 195,203,204,205.
r17963:
Fix Coverity item 44. Prevented potential NULL dereference in H5D_btree_debug.
r17964:
Fix Coverity issues #197, 198 & 199: memory not being released. (Also
clean up other resource leaks in nearby and/or similar code).
r17965:
Fix Coverity issue #151: release resources on error
r17966:
Fix Coverity issue #187: Remove leftover code remnant from prior bugfix
which was causing resource leak of open files.
r17967:
Fixed Coverity issues # 193 & 194. Removed unnecessary memory allocation and
added comparison of length of path parameter to the size of the destination
buffer in h5import.h/h5import.c.
r17968:
Fix Coverity item 144. Fixed memory leak on error in H5D_chunk_copy.
r17969:
Fix for coverity Resource_leak #196.
r17970:
Coverity 167-173:
Initialized pointer of buffers.
In error handling, closed types and free memory.
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
Mac OS X/32 10.6.2 (amazon) in debug mode
Mac OS X/32 10.6.2 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
2009-12-10 20:36:56 +08:00
|
|
|
|
pack_opttbl_t *table;
|
|
|
|
|
|
|
|
|
|
if(NULL == (table = (pack_opttbl_t *)malloc(sizeof(pack_opttbl_t))))
|
|
|
|
|
{
|
2010-05-12 04:10:25 +08:00
|
|
|
|
error_msg("not enough memory for options table\n");
|
2007-11-29 04:30:43 +08:00
|
|
|
|
return -1;
|
|
|
|
|
}
|
2008-09-16 23:52:51 +08:00
|
|
|
|
|
2007-11-29 04:30:43 +08:00
|
|
|
|
table->size = 30;
|
|
|
|
|
table->nelems = 0;
|
[svn-r17980] Description:
Bring Coverity changes into the trunk: (also other minor cleanups)
r17955:
Fix Coverity item 24. Add missing error condition to
H5AC_ext_config_2_int_config.
r17956:
Fix Coverity item 24. Improve error checking in H5A_compact_build_table_cb.
r17957:
Fix Coverity item 150. Fix warning in H5A_compact_build_table_cb.
r17958:
Fix Coverity item 117. Fix error handling in H5B_shared_new.
r17959:
Fix Coverity item 209. Added an assertion for leaf->shared in
H5B2_cache_leaf_dest.
r17960:
Fix Coverity item 208. Added an assertion for internal->shared in
H5B2_cache_internal_dest.
r17961:
Fix Coverity item 89. Reworked the code to avoid array overrun in
H5C__autoadjust__ageout__insert_new_marker.
r17962:
Fix for coverity Resource_leak 195,203,204,205.
r17963:
Fix Coverity item 44. Prevented potential NULL dereference in H5D_btree_debug.
r17964:
Fix Coverity issues #197, 198 & 199: memory not being released. (Also
clean up other resource leaks in nearby and/or similar code).
r17965:
Fix Coverity issue #151: release resources on error
r17966:
Fix Coverity issue #187: Remove leftover code remnant from prior bugfix
which was causing resource leak of open files.
r17967:
Fixed Coverity issues # 193 & 194. Removed unnecessary memory allocation and
added comparison of length of path parameter to the size of the destination
buffer in h5import.h/h5import.c.
r17968:
Fix Coverity item 144. Fixed memory leak on error in H5D_chunk_copy.
r17969:
Fix for coverity Resource_leak #196.
r17970:
Coverity 167-173:
Initialized pointer of buffers.
In error handling, closed types and free memory.
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
Mac OS X/32 10.6.2 (amazon) in debug mode
Mac OS X/32 10.6.2 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
2009-12-10 20:36:56 +08:00
|
|
|
|
if(NULL == (table->objs = (pack_info_t*)malloc(table->size * sizeof(pack_info_t))))
|
|
|
|
|
{
|
2010-05-12 04:10:25 +08:00
|
|
|
|
error_msg("not enough memory for options table\n");
|
[svn-r17980] Description:
Bring Coverity changes into the trunk: (also other minor cleanups)
r17955:
Fix Coverity item 24. Add missing error condition to
H5AC_ext_config_2_int_config.
r17956:
Fix Coverity item 24. Improve error checking in H5A_compact_build_table_cb.
r17957:
Fix Coverity item 150. Fix warning in H5A_compact_build_table_cb.
r17958:
Fix Coverity item 117. Fix error handling in H5B_shared_new.
r17959:
Fix Coverity item 209. Added an assertion for leaf->shared in
H5B2_cache_leaf_dest.
r17960:
Fix Coverity item 208. Added an assertion for internal->shared in
H5B2_cache_internal_dest.
r17961:
Fix Coverity item 89. Reworked the code to avoid array overrun in
H5C__autoadjust__ageout__insert_new_marker.
r17962:
Fix for coverity Resource_leak 195,203,204,205.
r17963:
Fix Coverity item 44. Prevented potential NULL dereference in H5D_btree_debug.
r17964:
Fix Coverity issues #197, 198 & 199: memory not being released. (Also
clean up other resource leaks in nearby and/or similar code).
r17965:
Fix Coverity issue #151: release resources on error
r17966:
Fix Coverity issue #187: Remove leftover code remnant from prior bugfix
which was causing resource leak of open files.
r17967:
Fixed Coverity issues # 193 & 194. Removed unnecessary memory allocation and
added comparison of length of path parameter to the size of the destination
buffer in h5import.h/h5import.c.
r17968:
Fix Coverity item 144. Fixed memory leak on error in H5D_chunk_copy.
r17969:
Fix for coverity Resource_leak #196.
r17970:
Coverity 167-173:
Initialized pointer of buffers.
In error handling, closed types and free memory.
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
Mac OS X/32 10.6.2 (amazon) in debug mode
Mac OS X/32 10.6.2 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
2009-12-10 20:36:56 +08:00
|
|
|
|
free(table);
|
2007-11-29 04:30:43 +08:00
|
|
|
|
return -1;
|
|
|
|
|
}
|
2008-09-16 23:52:51 +08:00
|
|
|
|
|
[svn-r17980] Description:
Bring Coverity changes into the trunk: (also other minor cleanups)
r17955:
Fix Coverity item 24. Add missing error condition to
H5AC_ext_config_2_int_config.
r17956:
Fix Coverity item 24. Improve error checking in H5A_compact_build_table_cb.
r17957:
Fix Coverity item 150. Fix warning in H5A_compact_build_table_cb.
r17958:
Fix Coverity item 117. Fix error handling in H5B_shared_new.
r17959:
Fix Coverity item 209. Added an assertion for leaf->shared in
H5B2_cache_leaf_dest.
r17960:
Fix Coverity item 208. Added an assertion for internal->shared in
H5B2_cache_internal_dest.
r17961:
Fix Coverity item 89. Reworked the code to avoid array overrun in
H5C__autoadjust__ageout__insert_new_marker.
r17962:
Fix for coverity Resource_leak 195,203,204,205.
r17963:
Fix Coverity item 44. Prevented potential NULL dereference in H5D_btree_debug.
r17964:
Fix Coverity issues #197, 198 & 199: memory not being released. (Also
clean up other resource leaks in nearby and/or similar code).
r17965:
Fix Coverity issue #151: release resources on error
r17966:
Fix Coverity issue #187: Remove leftover code remnant from prior bugfix
which was causing resource leak of open files.
r17967:
Fixed Coverity issues # 193 & 194. Removed unnecessary memory allocation and
added comparison of length of path parameter to the size of the destination
buffer in h5import.h/h5import.c.
r17968:
Fix Coverity item 144. Fixed memory leak on error in H5D_chunk_copy.
r17969:
Fix for coverity Resource_leak #196.
r17970:
Coverity 167-173:
Initialized pointer of buffers.
In error handling, closed types and free memory.
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
Mac OS X/32 10.6.2 (amazon) in debug mode
Mac OS X/32 10.6.2 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
2009-12-10 20:36:56 +08:00
|
|
|
|
for(i = 0; i < table->size; i++)
|
2007-11-29 04:30:43 +08:00
|
|
|
|
init_packobject(&table->objs[i]);
|
2008-09-16 23:52:51 +08:00
|
|
|
|
|
2007-11-29 04:30:43 +08:00
|
|
|
|
*tbl = table;
|
|
|
|
|
return 0;
|
2003-10-23 05:43:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
[svn-r17980] Description:
Bring Coverity changes into the trunk: (also other minor cleanups)
r17955:
Fix Coverity item 24. Add missing error condition to
H5AC_ext_config_2_int_config.
r17956:
Fix Coverity item 24. Improve error checking in H5A_compact_build_table_cb.
r17957:
Fix Coverity item 150. Fix warning in H5A_compact_build_table_cb.
r17958:
Fix Coverity item 117. Fix error handling in H5B_shared_new.
r17959:
Fix Coverity item 209. Added an assertion for leaf->shared in
H5B2_cache_leaf_dest.
r17960:
Fix Coverity item 208. Added an assertion for internal->shared in
H5B2_cache_internal_dest.
r17961:
Fix Coverity item 89. Reworked the code to avoid array overrun in
H5C__autoadjust__ageout__insert_new_marker.
r17962:
Fix for coverity Resource_leak 195,203,204,205.
r17963:
Fix Coverity item 44. Prevented potential NULL dereference in H5D_btree_debug.
r17964:
Fix Coverity issues #197, 198 & 199: memory not being released. (Also
clean up other resource leaks in nearby and/or similar code).
r17965:
Fix Coverity issue #151: release resources on error
r17966:
Fix Coverity issue #187: Remove leftover code remnant from prior bugfix
which was causing resource leak of open files.
r17967:
Fixed Coverity issues # 193 & 194. Removed unnecessary memory allocation and
added comparison of length of path parameter to the size of the destination
buffer in h5import.h/h5import.c.
r17968:
Fix Coverity item 144. Fixed memory leak on error in H5D_chunk_copy.
r17969:
Fix for coverity Resource_leak #196.
r17970:
Coverity 167-173:
Initialized pointer of buffers.
In error handling, closed types and free memory.
Tested on:
FreeBSD/32 6.3 (duty) in debug mode
FreeBSD/64 6.3 (liberty) w/C++ & FORTRAN, in debug mode
Linux/32 2.6 (jam) w/PGI compilers, w/default API=1.8.x,
w/C++ & FORTRAN, w/threadsafe, in debug mode
Linux/64-amd64 2.6 (smirom) w/Intel compilers, w/default API=1.6.x,
w/C++ & FORTRAN, in production mode
Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN,
w/szip filter, in production mode
Linux/64-ia64 2.6 (cobalt) w/Intel compilers, w/C++ & FORTRAN,
in production mode
Linux/64-ia64 2.4 (tg-login3) w/parallel, w/FORTRAN, in debug mode
Linux/64-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
Mac OS X/32 10.6.2 (amazon) in debug mode
Mac OS X/32 10.6.2 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
2009-12-10 20:36:56 +08:00
|
|
|
|
|
2003-10-23 05:43:34 +08:00
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: options_table_free
|
|
|
|
|
*
|
|
|
|
|
* Purpose: free table memory
|
|
|
|
|
*
|
|
|
|
|
* Return: 0
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
2003-10-29 01:40:05 +08:00
|
|
|
|
int options_table_free( pack_opttbl_t *table )
|
2003-10-23 05:43:34 +08:00
|
|
|
|
{
|
2007-11-29 04:30:43 +08:00
|
|
|
|
free(table->objs);
|
|
|
|
|
free(table);
|
|
|
|
|
return 0;
|
2003-10-23 05:43:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2003-12-31 06:59:33 +08:00
|
|
|
|
* Function: options_add_layout
|
2003-10-23 05:43:34 +08:00
|
|
|
|
*
|
2003-12-31 06:59:33 +08:00
|
|
|
|
* Purpose: add a layout option to the option list
|
2003-10-23 05:43:34 +08:00
|
|
|
|
*
|
|
|
|
|
* Return: 0, ok, -1, fail
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
2003-12-31 06:59:33 +08:00
|
|
|
|
int options_add_layout( obj_list_t *obj_list,
|
|
|
|
|
int n_objs,
|
|
|
|
|
pack_info_t *pack,
|
|
|
|
|
pack_opttbl_t *table )
|
2003-10-23 05:43:34 +08:00
|
|
|
|
{
|
2007-11-29 04:30:43 +08:00
|
|
|
|
unsigned int i, I;
|
|
|
|
|
int j, added=0, found=0;
|
2008-09-16 23:52:51 +08:00
|
|
|
|
|
2007-11-29 04:30:43 +08:00
|
|
|
|
/* increase the size of the collection by N_OBJS if necessary */
|
|
|
|
|
if (table->nelems+n_objs >= table->size)
|
2003-10-23 05:43:34 +08:00
|
|
|
|
{
|
2007-11-29 04:30:43 +08:00
|
|
|
|
if (aux_inctable(table,n_objs)<0)
|
|
|
|
|
return -1;
|
2003-12-31 06:59:33 +08:00
|
|
|
|
}
|
2008-09-16 23:52:51 +08:00
|
|
|
|
|
2007-11-29 04:30:43 +08:00
|
|
|
|
/* search if this object is already in the table; "path" is the key */
|
|
|
|
|
if (table->nelems>0)
|
|
|
|
|
{
|
|
|
|
|
/* go tru the supplied list of names */
|
|
|
|
|
for (j = 0; j < n_objs; j++)
|
|
|
|
|
{
|
|
|
|
|
/* linear table search */
|
|
|
|
|
for (i = 0; i < table->nelems; i++)
|
|
|
|
|
{
|
|
|
|
|
/*already on the table */
|
2011-02-15 06:20:32 +08:00
|
|
|
|
if (HDstrcmp(obj_list[j].obj,table->objs[i].path)==0)
|
2007-11-29 04:30:43 +08:00
|
|
|
|
{
|
|
|
|
|
/* already chunk info inserted for this one; exit */
|
|
|
|
|
if (table->objs[i].chunk.rank>0)
|
|
|
|
|
{
|
2010-05-12 04:10:25 +08:00
|
|
|
|
error_msg("chunk information already inserted for <%s>\n",obj_list[j].obj);
|
2009-10-21 08:34:06 +08:00
|
|
|
|
exit(EXIT_FAILURE);
|
2007-11-29 04:30:43 +08:00
|
|
|
|
}
|
|
|
|
|
/* insert the layout info */
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
aux_tblinsert_layout(table,i,pack);
|
|
|
|
|
found=1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
} /* if */
|
|
|
|
|
} /* i */
|
2008-09-16 23:52:51 +08:00
|
|
|
|
|
2007-11-29 04:30:43 +08:00
|
|
|
|
if (found==0)
|
|
|
|
|
{
|
|
|
|
|
/* keep the grow in a temp var */
|
|
|
|
|
I = table->nelems + added;
|
|
|
|
|
added++;
|
2011-02-15 06:20:32 +08:00
|
|
|
|
HDstrcpy(table->objs[I].path,obj_list[j].obj);
|
2007-11-29 04:30:43 +08:00
|
|
|
|
aux_tblinsert_layout(table,I,pack);
|
|
|
|
|
}
|
|
|
|
|
/* cases where we have an already inserted name but there is a new name also
|
|
|
|
|
example:
|
|
|
|
|
-f dset1:GZIP=1 -l dset1,dset2:CHUNK=20x20
|
|
|
|
|
dset1 is already inserted, but dset2 must also be
|
|
|
|
|
*/
|
2011-02-15 06:20:32 +08:00
|
|
|
|
else if (found==1 && HDstrcmp(obj_list[j].obj,table->objs[i].path)!=0)
|
2007-11-29 04:30:43 +08:00
|
|
|
|
{
|
|
|
|
|
/* keep the grow in a temp var */
|
|
|
|
|
I = table->nelems + added;
|
|
|
|
|
added++;
|
2011-02-15 06:20:32 +08:00
|
|
|
|
HDstrcpy(table->objs[I].path,obj_list[j].obj);
|
2007-11-29 04:30:43 +08:00
|
|
|
|
aux_tblinsert_layout(table,I,pack);
|
|
|
|
|
}
|
|
|
|
|
} /* j */
|
|
|
|
|
}
|
2008-09-16 23:52:51 +08:00
|
|
|
|
|
2007-11-29 04:30:43 +08:00
|
|
|
|
/* first time insertion */
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* go tru the supplied list of names */
|
|
|
|
|
for (j = 0; j < n_objs; j++)
|
|
|
|
|
{
|
|
|
|
|
I = table->nelems + added;
|
|
|
|
|
added++;
|
2011-02-15 06:20:32 +08:00
|
|
|
|
HDstrcpy(table->objs[I].path,obj_list[j].obj);
|
2007-11-29 04:30:43 +08:00
|
|
|
|
aux_tblinsert_layout(table,I,pack);
|
2008-09-16 23:52:51 +08:00
|
|
|
|
|
2007-11-29 04:30:43 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2008-09-16 23:52:51 +08:00
|
|
|
|
|
2007-11-29 04:30:43 +08:00
|
|
|
|
table->nelems+= added;
|
2008-09-16 23:52:51 +08:00
|
|
|
|
|
2007-11-29 04:30:43 +08:00
|
|
|
|
return 0;
|
2003-10-23 05:43:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2003-12-30 04:26:21 +08:00
|
|
|
|
* Function: options_add_filter
|
2003-10-23 05:43:34 +08:00
|
|
|
|
*
|
2003-12-30 04:26:21 +08:00
|
|
|
|
* Purpose: add a compression -f option to the option list
|
2003-10-23 05:43:34 +08:00
|
|
|
|
*
|
|
|
|
|
* Return: 0, ok, -1, fail
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
2003-12-30 04:26:21 +08:00
|
|
|
|
int options_add_filter(obj_list_t *obj_list,
|
|
|
|
|
int n_objs,
|
|
|
|
|
filter_info_t filt,
|
|
|
|
|
pack_opttbl_t *table )
|
2003-10-23 05:43:34 +08:00
|
|
|
|
{
|
2008-09-16 23:52:51 +08:00
|
|
|
|
|
2007-11-29 04:30:43 +08:00
|
|
|
|
unsigned int i, I;
|
|
|
|
|
int j, added=0, found=0;
|
2008-09-16 23:52:51 +08:00
|
|
|
|
|
2007-11-29 04:30:43 +08:00
|
|
|
|
/* increase the size of the collection by N_OBJS if necessary */
|
|
|
|
|
if (table->nelems+n_objs >= table->size)
|
2003-10-23 05:43:34 +08:00
|
|
|
|
{
|
2007-11-29 04:30:43 +08:00
|
|
|
|
if (aux_inctable(table,n_objs)<0)
|
|
|
|
|
return -1;
|
|
|
|
|
}
|
2008-09-16 23:52:51 +08:00
|
|
|
|
|
2007-11-29 04:30:43 +08:00
|
|
|
|
/* search if this object is already in the table; "path" is the key */
|
|
|
|
|
if (table->nelems>0)
|
|
|
|
|
{
|
|
|
|
|
/* go tru the supplied list of names */
|
|
|
|
|
for (j = 0; j < n_objs; j++)
|
|
|
|
|
{
|
|
|
|
|
/* linear table search */
|
|
|
|
|
for (i = 0; i < table->nelems; i++)
|
|
|
|
|
{
|
|
|
|
|
/*already on the table */
|
2011-02-15 06:20:32 +08:00
|
|
|
|
if (HDstrcmp(obj_list[j].obj,table->objs[i].path)==0)
|
2007-11-29 04:30:43 +08:00
|
|
|
|
{
|
|
|
|
|
/* insert */
|
|
|
|
|
aux_tblinsert_filter(table,i,filt);
|
|
|
|
|
found=1;
|
|
|
|
|
break;
|
|
|
|
|
} /* if */
|
|
|
|
|
} /* i */
|
2008-09-16 23:52:51 +08:00
|
|
|
|
|
2007-11-29 04:30:43 +08:00
|
|
|
|
if (found==0)
|
|
|
|
|
{
|
|
|
|
|
/* keep the grow in a temp var */
|
|
|
|
|
I = table->nelems + added;
|
|
|
|
|
added++;
|
2011-02-15 06:20:32 +08:00
|
|
|
|
HDstrcpy(table->objs[I].path,obj_list[j].obj);
|
2007-11-29 04:30:43 +08:00
|
|
|
|
aux_tblinsert_filter(table,I,filt);
|
|
|
|
|
}
|
|
|
|
|
/* cases where we have an already inserted name but there is a new name also
|
|
|
|
|
example:
|
|
|
|
|
-l dset1:CHUNK=20x20 -f dset1,dset2:GZIP=1
|
|
|
|
|
dset1 is already inserted, but dset2 must also be
|
|
|
|
|
*/
|
2011-02-15 06:20:32 +08:00
|
|
|
|
else if (found==1 && HDstrcmp(obj_list[j].obj,table->objs[i].path)!=0)
|
2007-11-29 04:30:43 +08:00
|
|
|
|
{
|
|
|
|
|
/* keep the grow in a temp var */
|
|
|
|
|
I = table->nelems + added;
|
|
|
|
|
added++;
|
2011-02-15 06:20:32 +08:00
|
|
|
|
HDstrcpy(table->objs[I].path,obj_list[j].obj);
|
2007-11-29 04:30:43 +08:00
|
|
|
|
aux_tblinsert_filter(table,I,filt);
|
|
|
|
|
}
|
|
|
|
|
} /* j */
|
|
|
|
|
}
|
2008-09-16 23:52:51 +08:00
|
|
|
|
|
2007-11-29 04:30:43 +08:00
|
|
|
|
/* first time insertion */
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
/* go tru the supplied list of names */
|
|
|
|
|
for (j = 0; j < n_objs; j++)
|
|
|
|
|
{
|
|
|
|
|
I = table->nelems + added;
|
|
|
|
|
added++;
|
2011-02-15 06:20:32 +08:00
|
|
|
|
HDstrcpy(table->objs[I].path,obj_list[j].obj);
|
2007-11-29 04:30:43 +08:00
|
|
|
|
aux_tblinsert_filter(table,I,filt);
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-09-16 23:52:51 +08:00
|
|
|
|
|
2007-11-29 04:30:43 +08:00
|
|
|
|
table->nelems+= added;
|
2008-09-16 23:52:51 +08:00
|
|
|
|
|
2007-11-29 04:30:43 +08:00
|
|
|
|
return 0;
|
2003-10-23 05:43:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
|
|
|
|
* Function: options_get_object
|
|
|
|
|
*
|
|
|
|
|
* Purpose: get object from table; "path" is the key
|
|
|
|
|
*
|
|
|
|
|
* Return: pack_info_t* OBJECT or NULL if not found; PATH is the key
|
|
|
|
|
*
|
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
|
2003-11-11 04:59:32 +08:00
|
|
|
|
pack_info_t* options_get_object( const char *path,
|
2003-10-29 01:40:05 +08:00
|
|
|
|
pack_opttbl_t *table )
|
2003-10-23 05:43:34 +08:00
|
|
|
|
{
|
2007-11-29 04:30:43 +08:00
|
|
|
|
unsigned int i;
|
2008-09-16 23:52:51 +08:00
|
|
|
|
|
2007-11-29 04:30:43 +08:00
|
|
|
|
for ( i = 0; i < table->nelems; i++)
|
|
|
|
|
{
|
|
|
|
|
/* found it */
|
2011-02-15 06:20:32 +08:00
|
|
|
|
if (HDstrcmp(table->objs[i].path,path)==0)
|
2007-11-29 04:30:43 +08:00
|
|
|
|
{
|
|
|
|
|
return (&table->objs[i]);
|
|
|
|
|
}
|
|
|
|
|
}
|
2008-09-16 23:52:51 +08:00
|
|
|
|
|
2007-11-29 04:30:43 +08:00
|
|
|
|
return NULL;
|
2003-10-23 05:43:34 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|