2003-02-12 21:44:31 +08:00
|
|
|
|
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
|
2007-02-07 22:56:24 +08:00
|
|
|
|
* Copyright by The HDF Group. *
|
2003-02-12 21:44:31 +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-02-12 21:44:31 +08:00
|
|
|
|
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Module Info: This module contains the functionality for enumerated datatypes
|
|
|
|
|
* in the H5T interface.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#define H5T_PACKAGE /*suppress error about including H5Tpkg */
|
|
|
|
|
|
2004-06-23 23:36:35 +08:00
|
|
|
|
/* Interface initialization */
|
|
|
|
|
#define H5_INTERFACE_INIT_FUNC H5T_init_enum_interface
|
|
|
|
|
|
|
|
|
|
|
2012-09-11 01:00:05 +08:00
|
|
|
|
#include "H5private.h" /*generic functions */
|
|
|
|
|
#include "H5Eprivate.h" /*error handling */
|
|
|
|
|
#include "H5Iprivate.h" /*ID functions */
|
|
|
|
|
#include "H5MMprivate.h" /*memory management */
|
|
|
|
|
#include "H5Tpkg.h" /*data-type functions */
|
2003-02-12 21:44:31 +08:00
|
|
|
|
|
|
|
|
|
/* Static local functions */
|
2012-09-11 01:00:05 +08:00
|
|
|
|
static char *H5T_enum_nameof(const H5T_t *dt, const void *value, char *name/*out*/,
|
|
|
|
|
size_t size);
|
2004-12-29 22:26:20 +08:00
|
|
|
|
static herr_t H5T_enum_valueof(const H5T_t *dt, const char *name,
|
2012-09-11 01:00:05 +08:00
|
|
|
|
void *value/*out*/);
|
2003-02-12 21:44:31 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*--------------------------------------------------------------------------
|
|
|
|
|
NAME
|
|
|
|
|
H5T_init_enum_interface -- Initialize interface-specific information
|
|
|
|
|
USAGE
|
|
|
|
|
herr_t H5T_init_enum_interface()
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
2003-02-12 21:44:31 +08:00
|
|
|
|
RETURNS
|
|
|
|
|
Non-negative on success/Negative on failure
|
|
|
|
|
DESCRIPTION
|
|
|
|
|
Initializes any interface-specific data or routines. (Just calls
|
|
|
|
|
H5T_init_iterface currently).
|
|
|
|
|
|
|
|
|
|
--------------------------------------------------------------------------*/
|
|
|
|
|
static herr_t
|
|
|
|
|
H5T_init_enum_interface(void)
|
|
|
|
|
{
|
2012-02-09 11:13:27 +08:00
|
|
|
|
FUNC_ENTER_NOAPI_NOINIT_NOERR
|
2003-02-12 21:44:31 +08:00
|
|
|
|
|
2004-04-23 13:06:20 +08:00
|
|
|
|
FUNC_LEAVE_NOAPI(H5T_init())
|
2003-02-12 21:44:31 +08:00
|
|
|
|
} /* H5T_init_enum_interface() */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Function: H5Tenum_create
|
2003-02-12 21:44:31 +08:00
|
|
|
|
*
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Purpose: Create a new enumeration data type based on the specified
|
|
|
|
|
* TYPE, which must be an integer type.
|
2003-02-12 21:44:31 +08:00
|
|
|
|
*
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Return: Success: ID of new enumeration data type
|
2003-02-12 21:44:31 +08:00
|
|
|
|
*
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Failure: Negative
|
2003-02-12 21:44:31 +08:00
|
|
|
|
*
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Programmer: Robb Matzke
|
2003-02-12 21:44:31 +08:00
|
|
|
|
* Tuesday, December 22, 1998
|
|
|
|
|
*
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Modifications:
|
|
|
|
|
*
|
2003-02-12 21:44:31 +08:00
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
hid_t
|
|
|
|
|
H5Tenum_create(hid_t parent_id)
|
|
|
|
|
{
|
2012-09-11 01:00:05 +08:00
|
|
|
|
H5T_t *parent = NULL; /*base integer data type */
|
|
|
|
|
H5T_t *dt = NULL; /*new enumeration data type */
|
|
|
|
|
hid_t ret_value; /*return value */
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
2012-02-09 11:13:27 +08:00
|
|
|
|
FUNC_ENTER_API(FAIL)
|
2006-12-19 03:16:17 +08:00
|
|
|
|
H5TRACE1("i", "i", parent_id);
|
2003-02-12 21:44:31 +08:00
|
|
|
|
|
|
|
|
|
/* Check args */
|
[svn-r18702] Description:
Bring r18672 from metadata journaling "merging" branch to trunk:
Mostly changes to move to only using one 'user data' parameter for
calls to H5AC_protect(), along with some minor reformatting code cleanups.
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 (amani) 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-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
Mac OS X/32 10.6.3 (amazon) in debug mode
Mac OS X/32 10.6.3 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
2010-05-05 21:39:56 +08:00
|
|
|
|
if(NULL == (parent = (H5T_t *)H5I_object_verify(parent_id, H5I_DATATYPE)) || H5T_INTEGER != parent->shared->type)
|
2012-09-11 01:00:05 +08:00
|
|
|
|
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an integer data type")
|
2003-02-12 21:44:31 +08:00
|
|
|
|
|
|
|
|
|
/* Build new type */
|
2012-04-17 05:20:26 +08:00
|
|
|
|
if(NULL == (dt = H5T__enum_create(parent)))
|
2012-09-11 01:00:05 +08:00
|
|
|
|
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "cannot create enum type")
|
2003-02-12 21:44:31 +08:00
|
|
|
|
/* Atomize the type */
|
2012-09-11 01:00:05 +08:00
|
|
|
|
if ((ret_value=H5I_register(H5I_DATATYPE, dt, TRUE))<0)
|
|
|
|
|
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register data type atom")
|
2003-02-12 21:44:31 +08:00
|
|
|
|
|
|
|
|
|
done:
|
2004-04-23 13:06:20 +08:00
|
|
|
|
FUNC_LEAVE_API(ret_value)
|
2003-02-12 21:44:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Function: H5T__enum_create
|
2003-02-12 21:44:31 +08:00
|
|
|
|
*
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Purpose: Private function for H5Tenum_create. Create a new
|
2003-02-12 21:44:31 +08:00
|
|
|
|
* enumeration data type based on the specified
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* TYPE, which must be an integer type.
|
2003-02-12 21:44:31 +08:00
|
|
|
|
*
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Return: Success: new enumeration data type
|
2003-02-12 21:44:31 +08:00
|
|
|
|
*
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Failure: NULL
|
2003-02-12 21:44:31 +08:00
|
|
|
|
*
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Programmer: Raymond Lu
|
2005-08-14 04:53:35 +08:00
|
|
|
|
* October 9, 2002
|
2003-02-12 21:44:31 +08:00
|
|
|
|
*
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Modifications:
|
|
|
|
|
*
|
2003-02-12 21:44:31 +08:00
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
H5T_t *
|
2012-04-17 05:20:26 +08:00
|
|
|
|
H5T__enum_create(const H5T_t *parent)
|
2003-02-12 21:44:31 +08:00
|
|
|
|
{
|
2012-09-11 01:00:05 +08:00
|
|
|
|
H5T_t *ret_value; /*new enumeration data type */
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
2012-04-17 05:20:26 +08:00
|
|
|
|
FUNC_ENTER_PACKAGE
|
2003-02-12 21:44:31 +08:00
|
|
|
|
|
2013-05-22 01:30:54 +08:00
|
|
|
|
HDassert(parent);
|
2003-02-12 21:44:31 +08:00
|
|
|
|
|
|
|
|
|
/* Build new type */
|
2012-04-17 05:20:26 +08:00
|
|
|
|
if(NULL == (ret_value = H5T__alloc()))
|
[svn-r9329]
Purpose:
Feature
Description:
Datatypes and groups now use H5FO "file object" code that was previously
only used by datasets. These objects will hold a file open if the file
is closed but they have not yet been closed. If these objects are unlinked
then relinked, they will not be destroyed. If they are opened twice (even
by two different names), both IDs will "see" changes made to the object
using the other ID.
When an object is opened using two different names (e.g., if a dataset was
opened under one name, then mounted and opened under its new name), calling
H5Iget_name() on a given hid_t will return the name used to open that hid_t,
not the current name of the object (this is a feature, and a change from the
previous behavior of datasets).
Solution:
Used H5FO code that was already in place for datasets. Broke H5D_t's, H5T_t's,
and H5G_t's into a "shared" struct and a private struct. The shared structs
(H5D_shared_t, etc.) hold the object's information and are used by all IDs
that point to a given object in the file. The private structs are pointed
to by the hid_t and contain the object's group entry information (including its
name) and a pointer to the shared struct for that object.
This changed the naming of structs throughout the library (e.g., datatype->size
is now datatype->shared->size). I added an updated H5Tinit.c to windows.zip.
Platforms tested:
Visual Studio 7, sleipnir, arabica, verbena
Misc. update:
2004-09-29 03:04:19 +08:00
|
|
|
|
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
|
|
|
|
|
ret_value->shared->type = H5T_ENUM;
|
|
|
|
|
ret_value->shared->parent = H5T_copy(parent, H5T_COPY_ALL);
|
2013-05-22 01:30:54 +08:00
|
|
|
|
HDassert(ret_value->shared->parent);
|
[svn-r9329]
Purpose:
Feature
Description:
Datatypes and groups now use H5FO "file object" code that was previously
only used by datasets. These objects will hold a file open if the file
is closed but they have not yet been closed. If these objects are unlinked
then relinked, they will not be destroyed. If they are opened twice (even
by two different names), both IDs will "see" changes made to the object
using the other ID.
When an object is opened using two different names (e.g., if a dataset was
opened under one name, then mounted and opened under its new name), calling
H5Iget_name() on a given hid_t will return the name used to open that hid_t,
not the current name of the object (this is a feature, and a change from the
previous behavior of datasets).
Solution:
Used H5FO code that was already in place for datasets. Broke H5D_t's, H5T_t's,
and H5G_t's into a "shared" struct and a private struct. The shared structs
(H5D_shared_t, etc.) hold the object's information and are used by all IDs
that point to a given object in the file. The private structs are pointed
to by the hid_t and contain the object's group entry information (including its
name) and a pointer to the shared struct for that object.
This changed the naming of structs throughout the library (e.g., datatype->size
is now datatype->shared->size). I added an updated H5Tinit.c to windows.zip.
Platforms tested:
Visual Studio 7, sleipnir, arabica, verbena
Misc. update:
2004-09-29 03:04:19 +08:00
|
|
|
|
ret_value->shared->size = ret_value->shared->parent->shared->size;
|
2003-02-12 21:44:31 +08:00
|
|
|
|
|
|
|
|
|
done:
|
2004-04-23 13:06:20 +08:00
|
|
|
|
FUNC_LEAVE_NOAPI(ret_value)
|
2003-02-12 21:44:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Function: H5Tenum_insert
|
|
|
|
|
*
|
|
|
|
|
* Purpose: Insert a new enumeration data type member into an enumeration
|
|
|
|
|
* type. TYPE is the enumeration type, NAME is the name of the
|
|
|
|
|
* new member, and VALUE points to the value of the new member.
|
|
|
|
|
* The NAME and VALUE must both be unique within the TYPE. VALUE
|
|
|
|
|
* points to data which is of the data type defined when the
|
|
|
|
|
* enumeration type was created.
|
2003-02-12 21:44:31 +08:00
|
|
|
|
*
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Return: Success: non-negative
|
2003-02-12 21:44:31 +08:00
|
|
|
|
*
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Failure: negative
|
2003-02-12 21:44:31 +08:00
|
|
|
|
*
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Programmer: Robb Matzke
|
2003-02-12 21:44:31 +08:00
|
|
|
|
* Wednesday, December 23, 1998
|
|
|
|
|
*
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Modifications:
|
|
|
|
|
*
|
2003-02-12 21:44:31 +08:00
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
herr_t
|
2004-04-23 13:06:20 +08:00
|
|
|
|
H5Tenum_insert(hid_t type, const char *name, const void *value)
|
2003-02-12 21:44:31 +08:00
|
|
|
|
{
|
2012-09-11 01:00:05 +08:00
|
|
|
|
H5T_t *dt=NULL;
|
|
|
|
|
herr_t ret_value=SUCCEED; /* Return value */
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
2012-02-09 11:13:27 +08:00
|
|
|
|
FUNC_ENTER_API(FAIL)
|
2007-03-09 00:57:36 +08:00
|
|
|
|
H5TRACE3("e", "i*s*x", type, name, value);
|
2003-02-12 21:44:31 +08:00
|
|
|
|
|
|
|
|
|
/* Check args */
|
[svn-r18702] Description:
Bring r18672 from metadata journaling "merging" branch to trunk:
Mostly changes to move to only using one 'user data' parameter for
calls to H5AC_protect(), along with some minor reformatting code cleanups.
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 (amani) 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-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
Mac OS X/32 10.6.3 (amazon) in debug mode
Mac OS X/32 10.6.3 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
2010-05-05 21:39:56 +08:00
|
|
|
|
if(NULL == (dt = (H5T_t *)H5I_object_verify(type, H5I_DATATYPE)))
|
2012-09-11 01:00:05 +08:00
|
|
|
|
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type")
|
[svn-r18702] Description:
Bring r18672 from metadata journaling "merging" branch to trunk:
Mostly changes to move to only using one 'user data' parameter for
calls to H5AC_protect(), along with some minor reformatting code cleanups.
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 (amani) 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-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
Mac OS X/32 10.6.3 (amazon) in debug mode
Mac OS X/32 10.6.3 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
2010-05-05 21:39:56 +08:00
|
|
|
|
if(H5T_ENUM != dt->shared->type)
|
2012-09-11 01:00:05 +08:00
|
|
|
|
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an enumeration data type")
|
2003-02-12 21:44:31 +08:00
|
|
|
|
if (!name || !*name)
|
2012-09-11 01:00:05 +08:00
|
|
|
|
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified")
|
2003-02-12 21:44:31 +08:00
|
|
|
|
if (!value)
|
2012-09-11 01:00:05 +08:00
|
|
|
|
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no value specified")
|
2003-02-12 21:44:31 +08:00
|
|
|
|
|
|
|
|
|
/* Do work */
|
2012-04-17 05:20:26 +08:00
|
|
|
|
if(H5T__enum_insert(dt, name, value) < 0)
|
2012-09-11 01:00:05 +08:00
|
|
|
|
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to insert new enumeration member")
|
2003-02-12 21:44:31 +08:00
|
|
|
|
|
|
|
|
|
done:
|
2004-04-23 13:06:20 +08:00
|
|
|
|
FUNC_LEAVE_API(ret_value)
|
2003-02-12 21:44:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Function: H5T__enum_insert
|
|
|
|
|
*
|
|
|
|
|
* Purpose: Insert a new member having a NAME and VALUE into an
|
|
|
|
|
* enumeration data TYPE. The NAME and VALUE must both be
|
|
|
|
|
* unique. The VALUE points to data of the data type defined for
|
|
|
|
|
* the enumeration base type.
|
2003-02-12 21:44:31 +08:00
|
|
|
|
*
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Return: Success: non-negative
|
2003-02-12 21:44:31 +08:00
|
|
|
|
*
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Failure: negative
|
2003-02-12 21:44:31 +08:00
|
|
|
|
*
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Programmer: Robb Matzke
|
2003-02-12 21:44:31 +08:00
|
|
|
|
* Wednesday, December 23, 1998
|
|
|
|
|
*
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Modifications:
|
|
|
|
|
*
|
2003-02-12 21:44:31 +08:00
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
herr_t
|
2012-04-17 05:20:26 +08:00
|
|
|
|
H5T__enum_insert(const H5T_t *dt, const char *name, const void *value)
|
2003-02-12 21:44:31 +08:00
|
|
|
|
{
|
2012-09-11 01:00:05 +08:00
|
|
|
|
unsigned i;
|
|
|
|
|
char **names=NULL;
|
|
|
|
|
uint8_t *values=NULL;
|
|
|
|
|
herr_t ret_value=SUCCEED; /* Return value */
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
2012-04-17 05:20:26 +08:00
|
|
|
|
FUNC_ENTER_PACKAGE
|
2003-02-12 21:44:31 +08:00
|
|
|
|
|
2013-05-22 01:30:54 +08:00
|
|
|
|
HDassert(dt);
|
|
|
|
|
HDassert(name && *name);
|
|
|
|
|
HDassert(value);
|
2003-02-12 21:44:31 +08:00
|
|
|
|
|
|
|
|
|
/* The name and value had better not already exist */
|
2012-09-11 01:00:05 +08:00
|
|
|
|
for (i=0; i<dt->shared->u.enumer.nmembs; i++) {
|
|
|
|
|
if (!HDstrcmp(dt->shared->u.enumer.name[i], name))
|
|
|
|
|
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "name redefinition")
|
|
|
|
|
if (!HDmemcmp(dt->shared->u.enumer.value+i*dt->shared->size, value, dt->shared->size))
|
|
|
|
|
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "value redefinition")
|
2003-02-12 21:44:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
2012-09-11 01:00:05 +08:00
|
|
|
|
/* Increase table sizes */
|
[svn-r18702] Description:
Bring r18672 from metadata journaling "merging" branch to trunk:
Mostly changes to move to only using one 'user data' parameter for
calls to H5AC_protect(), along with some minor reformatting code cleanups.
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 (amani) 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-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
Mac OS X/32 10.6.3 (amazon) in debug mode
Mac OS X/32 10.6.3 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
2010-05-05 21:39:56 +08:00
|
|
|
|
if(dt->shared->u.enumer.nmembs >= dt->shared->u.enumer.nalloc) {
|
2012-09-11 01:00:05 +08:00
|
|
|
|
unsigned n = MAX(32, 2*dt->shared->u.enumer.nalloc);
|
[svn-r18702] Description:
Bring r18672 from metadata journaling "merging" branch to trunk:
Mostly changes to move to only using one 'user data' parameter for
calls to H5AC_protect(), along with some minor reformatting code cleanups.
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 (amani) 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-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
Mac OS X/32 10.6.3 (amazon) in debug mode
Mac OS X/32 10.6.3 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
2010-05-05 21:39:56 +08:00
|
|
|
|
|
2012-09-11 01:00:05 +08:00
|
|
|
|
if(NULL == (names = (char **)H5MM_realloc(dt->shared->u.enumer.name, n * sizeof(char *))))
|
|
|
|
|
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
|
|
|
|
|
dt->shared->u.enumer.name = names;
|
2003-02-12 21:44:31 +08:00
|
|
|
|
|
2012-09-11 01:00:05 +08:00
|
|
|
|
if(NULL == (values = (uint8_t *)H5MM_realloc(dt->shared->u.enumer.value, n * dt->shared->size)))
|
|
|
|
|
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
|
|
|
|
|
dt->shared->u.enumer.value = values;
|
|
|
|
|
dt->shared->u.enumer.nalloc = n;
|
2003-02-12 21:44:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* Insert new member at end of member arrays */
|
[svn-r9329]
Purpose:
Feature
Description:
Datatypes and groups now use H5FO "file object" code that was previously
only used by datasets. These objects will hold a file open if the file
is closed but they have not yet been closed. If these objects are unlinked
then relinked, they will not be destroyed. If they are opened twice (even
by two different names), both IDs will "see" changes made to the object
using the other ID.
When an object is opened using two different names (e.g., if a dataset was
opened under one name, then mounted and opened under its new name), calling
H5Iget_name() on a given hid_t will return the name used to open that hid_t,
not the current name of the object (this is a feature, and a change from the
previous behavior of datasets).
Solution:
Used H5FO code that was already in place for datasets. Broke H5D_t's, H5T_t's,
and H5G_t's into a "shared" struct and a private struct. The shared structs
(H5D_shared_t, etc.) hold the object's information and are used by all IDs
that point to a given object in the file. The private structs are pointed
to by the hid_t and contain the object's group entry information (including its
name) and a pointer to the shared struct for that object.
This changed the naming of structs throughout the library (e.g., datatype->size
is now datatype->shared->size). I added an updated H5Tinit.c to windows.zip.
Platforms tested:
Visual Studio 7, sleipnir, arabica, verbena
Misc. update:
2004-09-29 03:04:19 +08:00
|
|
|
|
dt->shared->u.enumer.sorted = H5T_SORT_NONE;
|
|
|
|
|
i = dt->shared->u.enumer.nmembs++;
|
|
|
|
|
dt->shared->u.enumer.name[i] = H5MM_xstrdup(name);
|
2012-09-11 01:00:05 +08:00
|
|
|
|
HDmemcpy(dt->shared->u.enumer.value+i*dt->shared->size, value, dt->shared->size);
|
2003-02-12 21:44:31 +08:00
|
|
|
|
|
|
|
|
|
done:
|
2004-04-23 13:06:20 +08:00
|
|
|
|
FUNC_LEAVE_NOAPI(ret_value)
|
2003-02-12 21:44:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Function: H5Tget_member_value
|
2003-02-12 21:44:31 +08:00
|
|
|
|
*
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Purpose: Return the value for an enumeration data type member.
|
2003-02-12 21:44:31 +08:00
|
|
|
|
*
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Return: Success: non-negative with the member value copied
|
|
|
|
|
* into the memory pointed to by VALUE.
|
2003-02-12 21:44:31 +08:00
|
|
|
|
*
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Failure: negative, VALUE memory is undefined.
|
2003-02-12 21:44:31 +08:00
|
|
|
|
*
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Programmer: Robb Matzke
|
2003-02-12 21:44:31 +08:00
|
|
|
|
* Wednesday, December 23, 1998
|
|
|
|
|
*
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Modifications:
|
|
|
|
|
*
|
2003-02-12 21:44:31 +08:00
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
2003-10-14 03:31:33 +08:00
|
|
|
|
herr_t
|
|
|
|
|
H5Tget_member_value(hid_t type, unsigned membno, void *value/*out*/)
|
2003-02-12 21:44:31 +08:00
|
|
|
|
{
|
2012-09-11 01:00:05 +08:00
|
|
|
|
H5T_t *dt=NULL;
|
|
|
|
|
herr_t ret_value=SUCCEED; /* Return value */
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
2012-02-09 11:13:27 +08:00
|
|
|
|
FUNC_ENTER_API(FAIL)
|
2006-12-19 03:16:17 +08:00
|
|
|
|
H5TRACE3("e", "iIux", type, membno, value);
|
2003-02-12 21:44:31 +08:00
|
|
|
|
|
[svn-r18702] Description:
Bring r18672 from metadata journaling "merging" branch to trunk:
Mostly changes to move to only using one 'user data' parameter for
calls to H5AC_protect(), along with some minor reformatting code cleanups.
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 (amani) 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-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
Mac OS X/32 10.6.3 (amazon) in debug mode
Mac OS X/32 10.6.3 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
2010-05-05 21:39:56 +08:00
|
|
|
|
if(NULL == (dt = (H5T_t *)H5I_object_verify(type, H5I_DATATYPE)))
|
2012-09-11 01:00:05 +08:00
|
|
|
|
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type")
|
[svn-r18702] Description:
Bring r18672 from metadata journaling "merging" branch to trunk:
Mostly changes to move to only using one 'user data' parameter for
calls to H5AC_protect(), along with some minor reformatting code cleanups.
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 (amani) 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-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
Mac OS X/32 10.6.3 (amazon) in debug mode
Mac OS X/32 10.6.3 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
2010-05-05 21:39:56 +08:00
|
|
|
|
if(H5T_ENUM != dt->shared->type)
|
2012-09-11 01:00:05 +08:00
|
|
|
|
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "operation not defined for data type class")
|
|
|
|
|
if (membno>=dt->shared->u.enumer.nmembs)
|
|
|
|
|
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid member number")
|
2003-02-12 21:44:31 +08:00
|
|
|
|
if (!value)
|
2012-09-11 01:00:05 +08:00
|
|
|
|
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "null value buffer")
|
2003-02-12 21:44:31 +08:00
|
|
|
|
|
2012-04-17 05:20:26 +08:00
|
|
|
|
if(H5T__get_member_value(dt, membno, value) < 0)
|
2012-09-11 01:00:05 +08:00
|
|
|
|
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get member value")
|
2003-02-12 21:44:31 +08:00
|
|
|
|
done:
|
2004-04-23 13:06:20 +08:00
|
|
|
|
FUNC_LEAVE_API(ret_value)
|
2003-02-12 21:44:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Function: H5T__get_member_value
|
2003-02-12 21:44:31 +08:00
|
|
|
|
*
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Purpose: Private function for H5T__get_member_value. Return the
|
2003-02-12 21:44:31 +08:00
|
|
|
|
* value for an enumeration data type member.
|
|
|
|
|
*
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Return: Success: non-negative with the member value copied
|
|
|
|
|
* into the memory pointed to by VALUE.
|
2003-02-12 21:44:31 +08:00
|
|
|
|
*
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Failure: negative, VALUE memory is undefined.
|
2003-02-12 21:44:31 +08:00
|
|
|
|
*
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Programmer: Raymond Lu
|
2005-08-14 04:53:35 +08:00
|
|
|
|
* October 9, 2002
|
2003-02-12 21:44:31 +08:00
|
|
|
|
*
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Modifications:
|
|
|
|
|
*
|
2003-02-12 21:44:31 +08:00
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
herr_t
|
2012-04-17 05:20:26 +08:00
|
|
|
|
H5T__get_member_value(const H5T_t *dt, unsigned membno, void *value/*out*/)
|
2003-02-12 21:44:31 +08:00
|
|
|
|
{
|
2012-04-17 05:20:26 +08:00
|
|
|
|
FUNC_ENTER_PACKAGE_NOERR
|
2003-02-12 21:44:31 +08:00
|
|
|
|
|
2013-05-22 01:30:54 +08:00
|
|
|
|
HDassert(dt);
|
|
|
|
|
HDassert(value);
|
2003-02-12 21:44:31 +08:00
|
|
|
|
|
[svn-r9329]
Purpose:
Feature
Description:
Datatypes and groups now use H5FO "file object" code that was previously
only used by datasets. These objects will hold a file open if the file
is closed but they have not yet been closed. If these objects are unlinked
then relinked, they will not be destroyed. If they are opened twice (even
by two different names), both IDs will "see" changes made to the object
using the other ID.
When an object is opened using two different names (e.g., if a dataset was
opened under one name, then mounted and opened under its new name), calling
H5Iget_name() on a given hid_t will return the name used to open that hid_t,
not the current name of the object (this is a feature, and a change from the
previous behavior of datasets).
Solution:
Used H5FO code that was already in place for datasets. Broke H5D_t's, H5T_t's,
and H5G_t's into a "shared" struct and a private struct. The shared structs
(H5D_shared_t, etc.) hold the object's information and are used by all IDs
that point to a given object in the file. The private structs are pointed
to by the hid_t and contain the object's group entry information (including its
name) and a pointer to the shared struct for that object.
This changed the naming of structs throughout the library (e.g., datatype->size
is now datatype->shared->size). I added an updated H5Tinit.c to windows.zip.
Platforms tested:
Visual Studio 7, sleipnir, arabica, verbena
Misc. update:
2004-09-29 03:04:19 +08:00
|
|
|
|
HDmemcpy(value, dt->shared->u.enumer.value + membno*dt->shared->size, dt->shared->size);
|
2003-02-12 21:44:31 +08:00
|
|
|
|
|
2012-04-17 05:20:26 +08:00
|
|
|
|
FUNC_LEAVE_NOAPI(SUCCEED)
|
2003-02-12 21:44:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Function: H5Tenum_nameof
|
2003-02-12 21:44:31 +08:00
|
|
|
|
*
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Purpose: Finds the symbol name that corresponds to the specified VALUE
|
|
|
|
|
* of an enumeration data type TYPE. At most SIZE characters of
|
|
|
|
|
* the symbol name are copied into the NAME buffer. If the
|
|
|
|
|
* entire symbol anem and null terminator do not fit in the NAME
|
|
|
|
|
* buffer then as many characters as possible are copied (not
|
|
|
|
|
* null terminated) and the function fails.
|
2003-02-12 21:44:31 +08:00
|
|
|
|
*
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Return: Success: Non-negative.
|
2003-02-12 21:44:31 +08:00
|
|
|
|
*
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Failure: Negative, first character of NAME is set to
|
|
|
|
|
* null if SIZE allows it.
|
2003-02-12 21:44:31 +08:00
|
|
|
|
*
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Programmer: Robb Matzke
|
2003-02-12 21:44:31 +08:00
|
|
|
|
* Monday, January 4, 1999
|
|
|
|
|
*
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Modifications:
|
|
|
|
|
*
|
2003-02-12 21:44:31 +08:00
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
herr_t
|
2004-04-23 13:06:20 +08:00
|
|
|
|
H5Tenum_nameof(hid_t type, const void *value, char *name/*out*/, size_t size)
|
2003-02-12 21:44:31 +08:00
|
|
|
|
{
|
2012-09-11 01:00:05 +08:00
|
|
|
|
H5T_t *dt = NULL;
|
|
|
|
|
herr_t ret_value=SUCCEED; /* Return value */
|
2003-02-12 21:44:31 +08:00
|
|
|
|
|
2012-02-09 11:13:27 +08:00
|
|
|
|
FUNC_ENTER_API(FAIL)
|
2007-03-09 00:57:36 +08:00
|
|
|
|
H5TRACE4("e", "i*xxz", type, value, name, size);
|
2003-02-12 21:44:31 +08:00
|
|
|
|
|
|
|
|
|
/* Check args */
|
[svn-r18702] Description:
Bring r18672 from metadata journaling "merging" branch to trunk:
Mostly changes to move to only using one 'user data' parameter for
calls to H5AC_protect(), along with some minor reformatting code cleanups.
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 (amani) 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-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
Mac OS X/32 10.6.3 (amazon) in debug mode
Mac OS X/32 10.6.3 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
2010-05-05 21:39:56 +08:00
|
|
|
|
if(NULL == (dt = (H5T_t *)H5I_object_verify(type, H5I_DATATYPE)))
|
2012-09-11 01:00:05 +08:00
|
|
|
|
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type")
|
[svn-r18702] Description:
Bring r18672 from metadata journaling "merging" branch to trunk:
Mostly changes to move to only using one 'user data' parameter for
calls to H5AC_protect(), along with some minor reformatting code cleanups.
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 (amani) 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-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
Mac OS X/32 10.6.3 (amazon) in debug mode
Mac OS X/32 10.6.3 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
2010-05-05 21:39:56 +08:00
|
|
|
|
if(H5T_ENUM != dt->shared->type)
|
2012-09-11 01:00:05 +08:00
|
|
|
|
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an enumeration data type")
|
2003-02-12 21:44:31 +08:00
|
|
|
|
if (!value)
|
2012-09-11 01:00:05 +08:00
|
|
|
|
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no value supplied")
|
2003-02-12 21:44:31 +08:00
|
|
|
|
if (!name)
|
2012-09-11 01:00:05 +08:00
|
|
|
|
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name buffer supplied")
|
2003-02-12 21:44:31 +08:00
|
|
|
|
|
2012-09-11 01:00:05 +08:00
|
|
|
|
if (NULL==H5T_enum_nameof(dt, value, name, size))
|
|
|
|
|
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "nameof query failed")
|
2003-02-12 21:44:31 +08:00
|
|
|
|
|
|
|
|
|
done:
|
2004-04-23 13:06:20 +08:00
|
|
|
|
FUNC_LEAVE_API(ret_value)
|
2003-02-12 21:44:31 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Function: H5T_enum_nameof
|
2003-02-12 21:44:31 +08:00
|
|
|
|
*
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Purpose: Finds the symbol name that corresponds the the specified
|
|
|
|
|
* VALUE of an enumeration data type DT. At most SIZE characters
|
|
|
|
|
* of the symbol name are copied into the NAME buffer. If the
|
|
|
|
|
* entire symbol name and null terminator do not fit in the NAME
|
|
|
|
|
* buffer then as many characters as possible are copied and the
|
|
|
|
|
* function returns failure.
|
2003-02-12 21:44:31 +08:00
|
|
|
|
*
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* If NAME is the null pointer and SIZE is zero then enough
|
|
|
|
|
* space is allocated to hold the result and a pointer to that
|
|
|
|
|
* memory is returned.
|
2003-02-12 21:44:31 +08:00
|
|
|
|
*
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Return: Success: Pointer to NAME
|
2003-02-12 21:44:31 +08:00
|
|
|
|
*
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Failure: NULL, name[0] is set to null.
|
2003-02-12 21:44:31 +08:00
|
|
|
|
*
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Programmer: Robb Matzke
|
2003-02-12 21:44:31 +08:00
|
|
|
|
* Monday, January 4, 1999
|
|
|
|
|
*
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Modifications:
|
|
|
|
|
* Raymond Lu
|
|
|
|
|
* Wednesday, Febuary 9, 2005
|
|
|
|
|
* Made a copy of original datatype and do sorting and search
|
|
|
|
|
* on that copy, to protect the original order of members.
|
2003-02-12 21:44:31 +08:00
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
static char *
|
2004-12-29 22:26:20 +08:00
|
|
|
|
H5T_enum_nameof(const H5T_t *dt, const void *value, char *name/*out*/, size_t size)
|
2003-02-12 21:44:31 +08:00
|
|
|
|
{
|
2012-09-11 01:00:05 +08:00
|
|
|
|
H5T_t *copied_dt = NULL; /* Do sorting in copied datatype */
|
|
|
|
|
unsigned lt, md = 0, rt; /* Indices for binary search */
|
|
|
|
|
int cmp = (-1); /* Comparison result */
|
|
|
|
|
hbool_t alloc_name = FALSE; /* Whether name has been allocated */
|
|
|
|
|
char *ret_value; /* Return value */
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
2012-02-09 11:13:27 +08:00
|
|
|
|
FUNC_ENTER_NOAPI_NOINIT
|
2003-02-12 21:44:31 +08:00
|
|
|
|
|
|
|
|
|
/* Check args */
|
[svn-r20536] Description:
Clean up various warnings & code formatting issues.
Bring changes from Coverity branch to trunk:
r20085:
Purpose: Fix coverity issue 793
Description: Modified H5S_hyper_project_simple_higher() to free the entire span
list in new_space on failure.
r20091:
This is a fix for coverity bug #1683.
Changed the two printfs to use %lu (unsigned long) for printing "dset_size".
r20162:
Purpose: Fix coverity issue 785
Description: Modified H5T_enum_nameof() to free "name" on failure if it was
allocated. Also clarified some code in H5S_hyper_rebuild_helper().
r20189:
Addressed coverity defect 783.
H5SL_new_node() in H5SL.c was failing to free space allocated in its
first alloc if the second alloc failed. Added a call to H5FL_FREE
to address this issue.
This is purely to keep coverity happy -- if this code is ever triggered,
we have much larger problems.
Note that this fix will trigger an unused return value complaint
from coverity next week.
r20190:
Fixed Coverity issues 1561 1565 and 1678 (UNUSED_VALUES) by moving checks of return values to after the function call.
r20191:
Fixed coverity issues 643 644 and 1678 (CHECKED_RETURN).
r20232:
Addressed coverity issues 923-925. Replaced calls to sprintf with calls
to HDsnprintf.
r20233:
Fix coverity issue 662. Don't try to sort 0 attributes in H5Aint.c.
r20234:
Fix coverity issue 664. Check for NULL before dereferencing in H5Gdeprec.c.
r20271:
Purpose: Fix coverity issue 784
Description: Modified H5_debug_mask() to keep a list of files opened for use as
a debugging output stream, and modified H5_term_library to close these files on
exit.
r20272:
addressed coverity issues 838 & 955. Issue was use of strcpy() -- existing
code was safe, but modified to use strncpy() to keep coverity happy.
r20273:
Addresed coverity issues 1388 and 1389.
Initialized sel_iter->type to NULL in H5S_select_iter_init.
r20275:
Purpose: Fix valgrind issue in mf.c
Description: Fixed bug (incomplete if statement) in test_mf_fs_alloc_free() so
the retrieved node gets freed.
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 (amani) 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, w/threadsafe, in production mode
Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode
2011-04-18 02:57:07 +08:00
|
|
|
|
HDassert(dt && H5T_ENUM == dt->shared->type);
|
|
|
|
|
HDassert(value);
|
|
|
|
|
HDassert(name || 0 == size);
|
|
|
|
|
|
|
|
|
|
if(name && size > 0)
|
|
|
|
|
*name = '\0';
|
2003-02-12 21:44:31 +08:00
|
|
|
|
|
|
|
|
|
/* Sanity check */
|
[svn-r20536] Description:
Clean up various warnings & code formatting issues.
Bring changes from Coverity branch to trunk:
r20085:
Purpose: Fix coverity issue 793
Description: Modified H5S_hyper_project_simple_higher() to free the entire span
list in new_space on failure.
r20091:
This is a fix for coverity bug #1683.
Changed the two printfs to use %lu (unsigned long) for printing "dset_size".
r20162:
Purpose: Fix coverity issue 785
Description: Modified H5T_enum_nameof() to free "name" on failure if it was
allocated. Also clarified some code in H5S_hyper_rebuild_helper().
r20189:
Addressed coverity defect 783.
H5SL_new_node() in H5SL.c was failing to free space allocated in its
first alloc if the second alloc failed. Added a call to H5FL_FREE
to address this issue.
This is purely to keep coverity happy -- if this code is ever triggered,
we have much larger problems.
Note that this fix will trigger an unused return value complaint
from coverity next week.
r20190:
Fixed Coverity issues 1561 1565 and 1678 (UNUSED_VALUES) by moving checks of return values to after the function call.
r20191:
Fixed coverity issues 643 644 and 1678 (CHECKED_RETURN).
r20232:
Addressed coverity issues 923-925. Replaced calls to sprintf with calls
to HDsnprintf.
r20233:
Fix coverity issue 662. Don't try to sort 0 attributes in H5Aint.c.
r20234:
Fix coverity issue 664. Check for NULL before dereferencing in H5Gdeprec.c.
r20271:
Purpose: Fix coverity issue 784
Description: Modified H5_debug_mask() to keep a list of files opened for use as
a debugging output stream, and modified H5_term_library to close these files on
exit.
r20272:
addressed coverity issues 838 & 955. Issue was use of strcpy() -- existing
code was safe, but modified to use strncpy() to keep coverity happy.
r20273:
Addresed coverity issues 1388 and 1389.
Initialized sel_iter->type to NULL in H5S_select_iter_init.
r20275:
Purpose: Fix valgrind issue in mf.c
Description: Fixed bug (incomplete if statement) in test_mf_fs_alloc_free() so
the retrieved node gets freed.
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 (amani) 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, w/threadsafe, in production mode
Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode
2011-04-18 02:57:07 +08:00
|
|
|
|
if(dt->shared->u.enumer.nmembs == 0)
|
2004-04-23 13:06:20 +08:00
|
|
|
|
HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, NULL, "datatype has no members")
|
2003-02-12 21:44:31 +08:00
|
|
|
|
|
2005-02-09 23:54:44 +08:00
|
|
|
|
/* Do a binary search over the values to find the correct one. Do sorting
|
|
|
|
|
* and search on the copied datatype to protect the original order. */
|
[svn-r20536] Description:
Clean up various warnings & code formatting issues.
Bring changes from Coverity branch to trunk:
r20085:
Purpose: Fix coverity issue 793
Description: Modified H5S_hyper_project_simple_higher() to free the entire span
list in new_space on failure.
r20091:
This is a fix for coverity bug #1683.
Changed the two printfs to use %lu (unsigned long) for printing "dset_size".
r20162:
Purpose: Fix coverity issue 785
Description: Modified H5T_enum_nameof() to free "name" on failure if it was
allocated. Also clarified some code in H5S_hyper_rebuild_helper().
r20189:
Addressed coverity defect 783.
H5SL_new_node() in H5SL.c was failing to free space allocated in its
first alloc if the second alloc failed. Added a call to H5FL_FREE
to address this issue.
This is purely to keep coverity happy -- if this code is ever triggered,
we have much larger problems.
Note that this fix will trigger an unused return value complaint
from coverity next week.
r20190:
Fixed Coverity issues 1561 1565 and 1678 (UNUSED_VALUES) by moving checks of return values to after the function call.
r20191:
Fixed coverity issues 643 644 and 1678 (CHECKED_RETURN).
r20232:
Addressed coverity issues 923-925. Replaced calls to sprintf with calls
to HDsnprintf.
r20233:
Fix coverity issue 662. Don't try to sort 0 attributes in H5Aint.c.
r20234:
Fix coverity issue 664. Check for NULL before dereferencing in H5Gdeprec.c.
r20271:
Purpose: Fix coverity issue 784
Description: Modified H5_debug_mask() to keep a list of files opened for use as
a debugging output stream, and modified H5_term_library to close these files on
exit.
r20272:
addressed coverity issues 838 & 955. Issue was use of strcpy() -- existing
code was safe, but modified to use strncpy() to keep coverity happy.
r20273:
Addresed coverity issues 1388 and 1389.
Initialized sel_iter->type to NULL in H5S_select_iter_init.
r20275:
Purpose: Fix valgrind issue in mf.c
Description: Fixed bug (incomplete if statement) in test_mf_fs_alloc_free() so
the retrieved node gets freed.
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 (amani) 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, w/threadsafe, in production mode
Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode
2011-04-18 02:57:07 +08:00
|
|
|
|
if(NULL == (copied_dt = H5T_copy(dt, H5T_COPY_ALL)))
|
2012-09-11 01:00:05 +08:00
|
|
|
|
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy data type")
|
2012-04-17 05:20:26 +08:00
|
|
|
|
if(H5T__sort_value(copied_dt, NULL) < 0)
|
[svn-r20536] Description:
Clean up various warnings & code formatting issues.
Bring changes from Coverity branch to trunk:
r20085:
Purpose: Fix coverity issue 793
Description: Modified H5S_hyper_project_simple_higher() to free the entire span
list in new_space on failure.
r20091:
This is a fix for coverity bug #1683.
Changed the two printfs to use %lu (unsigned long) for printing "dset_size".
r20162:
Purpose: Fix coverity issue 785
Description: Modified H5T_enum_nameof() to free "name" on failure if it was
allocated. Also clarified some code in H5S_hyper_rebuild_helper().
r20189:
Addressed coverity defect 783.
H5SL_new_node() in H5SL.c was failing to free space allocated in its
first alloc if the second alloc failed. Added a call to H5FL_FREE
to address this issue.
This is purely to keep coverity happy -- if this code is ever triggered,
we have much larger problems.
Note that this fix will trigger an unused return value complaint
from coverity next week.
r20190:
Fixed Coverity issues 1561 1565 and 1678 (UNUSED_VALUES) by moving checks of return values to after the function call.
r20191:
Fixed coverity issues 643 644 and 1678 (CHECKED_RETURN).
r20232:
Addressed coverity issues 923-925. Replaced calls to sprintf with calls
to HDsnprintf.
r20233:
Fix coverity issue 662. Don't try to sort 0 attributes in H5Aint.c.
r20234:
Fix coverity issue 664. Check for NULL before dereferencing in H5Gdeprec.c.
r20271:
Purpose: Fix coverity issue 784
Description: Modified H5_debug_mask() to keep a list of files opened for use as
a debugging output stream, and modified H5_term_library to close these files on
exit.
r20272:
addressed coverity issues 838 & 955. Issue was use of strcpy() -- existing
code was safe, but modified to use strncpy() to keep coverity happy.
r20273:
Addresed coverity issues 1388 and 1389.
Initialized sel_iter->type to NULL in H5S_select_iter_init.
r20275:
Purpose: Fix valgrind issue in mf.c
Description: Fixed bug (incomplete if statement) in test_mf_fs_alloc_free() so
the retrieved node gets freed.
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 (amani) 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, w/threadsafe, in production mode
Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode
2011-04-18 02:57:07 +08:00
|
|
|
|
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOMPARE, NULL, "value sort failed")
|
2005-02-09 23:54:44 +08:00
|
|
|
|
|
2003-02-12 21:44:31 +08:00
|
|
|
|
lt = 0;
|
2005-02-09 23:54:44 +08:00
|
|
|
|
rt = copied_dt->shared->u.enumer.nmembs;
|
[svn-r20536] Description:
Clean up various warnings & code formatting issues.
Bring changes from Coverity branch to trunk:
r20085:
Purpose: Fix coverity issue 793
Description: Modified H5S_hyper_project_simple_higher() to free the entire span
list in new_space on failure.
r20091:
This is a fix for coverity bug #1683.
Changed the two printfs to use %lu (unsigned long) for printing "dset_size".
r20162:
Purpose: Fix coverity issue 785
Description: Modified H5T_enum_nameof() to free "name" on failure if it was
allocated. Also clarified some code in H5S_hyper_rebuild_helper().
r20189:
Addressed coverity defect 783.
H5SL_new_node() in H5SL.c was failing to free space allocated in its
first alloc if the second alloc failed. Added a call to H5FL_FREE
to address this issue.
This is purely to keep coverity happy -- if this code is ever triggered,
we have much larger problems.
Note that this fix will trigger an unused return value complaint
from coverity next week.
r20190:
Fixed Coverity issues 1561 1565 and 1678 (UNUSED_VALUES) by moving checks of return values to after the function call.
r20191:
Fixed coverity issues 643 644 and 1678 (CHECKED_RETURN).
r20232:
Addressed coverity issues 923-925. Replaced calls to sprintf with calls
to HDsnprintf.
r20233:
Fix coverity issue 662. Don't try to sort 0 attributes in H5Aint.c.
r20234:
Fix coverity issue 664. Check for NULL before dereferencing in H5Gdeprec.c.
r20271:
Purpose: Fix coverity issue 784
Description: Modified H5_debug_mask() to keep a list of files opened for use as
a debugging output stream, and modified H5_term_library to close these files on
exit.
r20272:
addressed coverity issues 838 & 955. Issue was use of strcpy() -- existing
code was safe, but modified to use strncpy() to keep coverity happy.
r20273:
Addresed coverity issues 1388 and 1389.
Initialized sel_iter->type to NULL in H5S_select_iter_init.
r20275:
Purpose: Fix valgrind issue in mf.c
Description: Fixed bug (incomplete if statement) in test_mf_fs_alloc_free() so
the retrieved node gets freed.
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 (amani) 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, w/threadsafe, in production mode
Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode
2011-04-18 02:57:07 +08:00
|
|
|
|
while(lt < rt) {
|
2012-09-11 01:00:05 +08:00
|
|
|
|
md = (lt + rt) / 2;
|
|
|
|
|
cmp = HDmemcmp(value, copied_dt->shared->u.enumer.value + md * copied_dt->shared->size, copied_dt->shared->size);
|
|
|
|
|
if(cmp < 0)
|
|
|
|
|
rt = md;
|
|
|
|
|
else if(cmp > 0)
|
|
|
|
|
lt = md + 1;
|
|
|
|
|
else
|
|
|
|
|
break;
|
[svn-r20536] Description:
Clean up various warnings & code formatting issues.
Bring changes from Coverity branch to trunk:
r20085:
Purpose: Fix coverity issue 793
Description: Modified H5S_hyper_project_simple_higher() to free the entire span
list in new_space on failure.
r20091:
This is a fix for coverity bug #1683.
Changed the two printfs to use %lu (unsigned long) for printing "dset_size".
r20162:
Purpose: Fix coverity issue 785
Description: Modified H5T_enum_nameof() to free "name" on failure if it was
allocated. Also clarified some code in H5S_hyper_rebuild_helper().
r20189:
Addressed coverity defect 783.
H5SL_new_node() in H5SL.c was failing to free space allocated in its
first alloc if the second alloc failed. Added a call to H5FL_FREE
to address this issue.
This is purely to keep coverity happy -- if this code is ever triggered,
we have much larger problems.
Note that this fix will trigger an unused return value complaint
from coverity next week.
r20190:
Fixed Coverity issues 1561 1565 and 1678 (UNUSED_VALUES) by moving checks of return values to after the function call.
r20191:
Fixed coverity issues 643 644 and 1678 (CHECKED_RETURN).
r20232:
Addressed coverity issues 923-925. Replaced calls to sprintf with calls
to HDsnprintf.
r20233:
Fix coverity issue 662. Don't try to sort 0 attributes in H5Aint.c.
r20234:
Fix coverity issue 664. Check for NULL before dereferencing in H5Gdeprec.c.
r20271:
Purpose: Fix coverity issue 784
Description: Modified H5_debug_mask() to keep a list of files opened for use as
a debugging output stream, and modified H5_term_library to close these files on
exit.
r20272:
addressed coverity issues 838 & 955. Issue was use of strcpy() -- existing
code was safe, but modified to use strncpy() to keep coverity happy.
r20273:
Addresed coverity issues 1388 and 1389.
Initialized sel_iter->type to NULL in H5S_select_iter_init.
r20275:
Purpose: Fix valgrind issue in mf.c
Description: Fixed bug (incomplete if statement) in test_mf_fs_alloc_free() so
the retrieved node gets freed.
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 (amani) 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, w/threadsafe, in production mode
Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode
2011-04-18 02:57:07 +08:00
|
|
|
|
} /* end while */
|
|
|
|
|
|
2012-09-11 01:00:05 +08:00
|
|
|
|
/* Value was not yet defined. This fixes bug # 774, 2002/06/05 EIP */
|
[svn-r20536] Description:
Clean up various warnings & code formatting issues.
Bring changes from Coverity branch to trunk:
r20085:
Purpose: Fix coverity issue 793
Description: Modified H5S_hyper_project_simple_higher() to free the entire span
list in new_space on failure.
r20091:
This is a fix for coverity bug #1683.
Changed the two printfs to use %lu (unsigned long) for printing "dset_size".
r20162:
Purpose: Fix coverity issue 785
Description: Modified H5T_enum_nameof() to free "name" on failure if it was
allocated. Also clarified some code in H5S_hyper_rebuild_helper().
r20189:
Addressed coverity defect 783.
H5SL_new_node() in H5SL.c was failing to free space allocated in its
first alloc if the second alloc failed. Added a call to H5FL_FREE
to address this issue.
This is purely to keep coverity happy -- if this code is ever triggered,
we have much larger problems.
Note that this fix will trigger an unused return value complaint
from coverity next week.
r20190:
Fixed Coverity issues 1561 1565 and 1678 (UNUSED_VALUES) by moving checks of return values to after the function call.
r20191:
Fixed coverity issues 643 644 and 1678 (CHECKED_RETURN).
r20232:
Addressed coverity issues 923-925. Replaced calls to sprintf with calls
to HDsnprintf.
r20233:
Fix coverity issue 662. Don't try to sort 0 attributes in H5Aint.c.
r20234:
Fix coverity issue 664. Check for NULL before dereferencing in H5Gdeprec.c.
r20271:
Purpose: Fix coverity issue 784
Description: Modified H5_debug_mask() to keep a list of files opened for use as
a debugging output stream, and modified H5_term_library to close these files on
exit.
r20272:
addressed coverity issues 838 & 955. Issue was use of strcpy() -- existing
code was safe, but modified to use strncpy() to keep coverity happy.
r20273:
Addresed coverity issues 1388 and 1389.
Initialized sel_iter->type to NULL in H5S_select_iter_init.
r20275:
Purpose: Fix valgrind issue in mf.c
Description: Fixed bug (incomplete if statement) in test_mf_fs_alloc_free() so
the retrieved node gets freed.
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 (amani) 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, w/threadsafe, in production mode
Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode
2011-04-18 02:57:07 +08:00
|
|
|
|
if(cmp != 0)
|
2004-04-23 13:06:20 +08:00
|
|
|
|
HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, NULL, "value is currently not defined")
|
2003-02-12 21:44:31 +08:00
|
|
|
|
|
|
|
|
|
/* Save result name */
|
[svn-r20536] Description:
Clean up various warnings & code formatting issues.
Bring changes from Coverity branch to trunk:
r20085:
Purpose: Fix coverity issue 793
Description: Modified H5S_hyper_project_simple_higher() to free the entire span
list in new_space on failure.
r20091:
This is a fix for coverity bug #1683.
Changed the two printfs to use %lu (unsigned long) for printing "dset_size".
r20162:
Purpose: Fix coverity issue 785
Description: Modified H5T_enum_nameof() to free "name" on failure if it was
allocated. Also clarified some code in H5S_hyper_rebuild_helper().
r20189:
Addressed coverity defect 783.
H5SL_new_node() in H5SL.c was failing to free space allocated in its
first alloc if the second alloc failed. Added a call to H5FL_FREE
to address this issue.
This is purely to keep coverity happy -- if this code is ever triggered,
we have much larger problems.
Note that this fix will trigger an unused return value complaint
from coverity next week.
r20190:
Fixed Coverity issues 1561 1565 and 1678 (UNUSED_VALUES) by moving checks of return values to after the function call.
r20191:
Fixed coverity issues 643 644 and 1678 (CHECKED_RETURN).
r20232:
Addressed coverity issues 923-925. Replaced calls to sprintf with calls
to HDsnprintf.
r20233:
Fix coverity issue 662. Don't try to sort 0 attributes in H5Aint.c.
r20234:
Fix coverity issue 664. Check for NULL before dereferencing in H5Gdeprec.c.
r20271:
Purpose: Fix coverity issue 784
Description: Modified H5_debug_mask() to keep a list of files opened for use as
a debugging output stream, and modified H5_term_library to close these files on
exit.
r20272:
addressed coverity issues 838 & 955. Issue was use of strcpy() -- existing
code was safe, but modified to use strncpy() to keep coverity happy.
r20273:
Addresed coverity issues 1388 and 1389.
Initialized sel_iter->type to NULL in H5S_select_iter_init.
r20275:
Purpose: Fix valgrind issue in mf.c
Description: Fixed bug (incomplete if statement) in test_mf_fs_alloc_free() so
the retrieved node gets freed.
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 (amani) 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, w/threadsafe, in production mode
Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode
2011-04-18 02:57:07 +08:00
|
|
|
|
if(!name) {
|
2012-09-11 01:00:05 +08:00
|
|
|
|
if(NULL == (name = (char *)H5MM_malloc(
|
|
|
|
|
HDstrlen(copied_dt->shared->u.enumer.name[md]) + 1)))
|
[svn-r20536] Description:
Clean up various warnings & code formatting issues.
Bring changes from Coverity branch to trunk:
r20085:
Purpose: Fix coverity issue 793
Description: Modified H5S_hyper_project_simple_higher() to free the entire span
list in new_space on failure.
r20091:
This is a fix for coverity bug #1683.
Changed the two printfs to use %lu (unsigned long) for printing "dset_size".
r20162:
Purpose: Fix coverity issue 785
Description: Modified H5T_enum_nameof() to free "name" on failure if it was
allocated. Also clarified some code in H5S_hyper_rebuild_helper().
r20189:
Addressed coverity defect 783.
H5SL_new_node() in H5SL.c was failing to free space allocated in its
first alloc if the second alloc failed. Added a call to H5FL_FREE
to address this issue.
This is purely to keep coverity happy -- if this code is ever triggered,
we have much larger problems.
Note that this fix will trigger an unused return value complaint
from coverity next week.
r20190:
Fixed Coverity issues 1561 1565 and 1678 (UNUSED_VALUES) by moving checks of return values to after the function call.
r20191:
Fixed coverity issues 643 644 and 1678 (CHECKED_RETURN).
r20232:
Addressed coverity issues 923-925. Replaced calls to sprintf with calls
to HDsnprintf.
r20233:
Fix coverity issue 662. Don't try to sort 0 attributes in H5Aint.c.
r20234:
Fix coverity issue 664. Check for NULL before dereferencing in H5Gdeprec.c.
r20271:
Purpose: Fix coverity issue 784
Description: Modified H5_debug_mask() to keep a list of files opened for use as
a debugging output stream, and modified H5_term_library to close these files on
exit.
r20272:
addressed coverity issues 838 & 955. Issue was use of strcpy() -- existing
code was safe, but modified to use strncpy() to keep coverity happy.
r20273:
Addresed coverity issues 1388 and 1389.
Initialized sel_iter->type to NULL in H5S_select_iter_init.
r20275:
Purpose: Fix valgrind issue in mf.c
Description: Fixed bug (incomplete if statement) in test_mf_fs_alloc_free() so
the retrieved node gets freed.
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 (amani) 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, w/threadsafe, in production mode
Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode
2011-04-18 02:57:07 +08:00
|
|
|
|
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed");
|
|
|
|
|
alloc_name = TRUE;
|
|
|
|
|
} /* end if */
|
2005-02-09 23:54:44 +08:00
|
|
|
|
HDstrncpy(name, copied_dt->shared->u.enumer.name[md], size);
|
[svn-r20536] Description:
Clean up various warnings & code formatting issues.
Bring changes from Coverity branch to trunk:
r20085:
Purpose: Fix coverity issue 793
Description: Modified H5S_hyper_project_simple_higher() to free the entire span
list in new_space on failure.
r20091:
This is a fix for coverity bug #1683.
Changed the two printfs to use %lu (unsigned long) for printing "dset_size".
r20162:
Purpose: Fix coverity issue 785
Description: Modified H5T_enum_nameof() to free "name" on failure if it was
allocated. Also clarified some code in H5S_hyper_rebuild_helper().
r20189:
Addressed coverity defect 783.
H5SL_new_node() in H5SL.c was failing to free space allocated in its
first alloc if the second alloc failed. Added a call to H5FL_FREE
to address this issue.
This is purely to keep coverity happy -- if this code is ever triggered,
we have much larger problems.
Note that this fix will trigger an unused return value complaint
from coverity next week.
r20190:
Fixed Coverity issues 1561 1565 and 1678 (UNUSED_VALUES) by moving checks of return values to after the function call.
r20191:
Fixed coverity issues 643 644 and 1678 (CHECKED_RETURN).
r20232:
Addressed coverity issues 923-925. Replaced calls to sprintf with calls
to HDsnprintf.
r20233:
Fix coverity issue 662. Don't try to sort 0 attributes in H5Aint.c.
r20234:
Fix coverity issue 664. Check for NULL before dereferencing in H5Gdeprec.c.
r20271:
Purpose: Fix coverity issue 784
Description: Modified H5_debug_mask() to keep a list of files opened for use as
a debugging output stream, and modified H5_term_library to close these files on
exit.
r20272:
addressed coverity issues 838 & 955. Issue was use of strcpy() -- existing
code was safe, but modified to use strncpy() to keep coverity happy.
r20273:
Addresed coverity issues 1388 and 1389.
Initialized sel_iter->type to NULL in H5S_select_iter_init.
r20275:
Purpose: Fix valgrind issue in mf.c
Description: Fixed bug (incomplete if statement) in test_mf_fs_alloc_free() so
the retrieved node gets freed.
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 (amani) 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, w/threadsafe, in production mode
Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode
2011-04-18 02:57:07 +08:00
|
|
|
|
if(HDstrlen(copied_dt->shared->u.enumer.name[md]) >= size)
|
2012-09-11 01:00:05 +08:00
|
|
|
|
HGOTO_ERROR(H5E_DATATYPE, H5E_NOSPACE, NULL, "name has been truncated")
|
2003-02-12 21:44:31 +08:00
|
|
|
|
|
|
|
|
|
/* Set return value */
|
[svn-r20536] Description:
Clean up various warnings & code formatting issues.
Bring changes from Coverity branch to trunk:
r20085:
Purpose: Fix coverity issue 793
Description: Modified H5S_hyper_project_simple_higher() to free the entire span
list in new_space on failure.
r20091:
This is a fix for coverity bug #1683.
Changed the two printfs to use %lu (unsigned long) for printing "dset_size".
r20162:
Purpose: Fix coverity issue 785
Description: Modified H5T_enum_nameof() to free "name" on failure if it was
allocated. Also clarified some code in H5S_hyper_rebuild_helper().
r20189:
Addressed coverity defect 783.
H5SL_new_node() in H5SL.c was failing to free space allocated in its
first alloc if the second alloc failed. Added a call to H5FL_FREE
to address this issue.
This is purely to keep coverity happy -- if this code is ever triggered,
we have much larger problems.
Note that this fix will trigger an unused return value complaint
from coverity next week.
r20190:
Fixed Coverity issues 1561 1565 and 1678 (UNUSED_VALUES) by moving checks of return values to after the function call.
r20191:
Fixed coverity issues 643 644 and 1678 (CHECKED_RETURN).
r20232:
Addressed coverity issues 923-925. Replaced calls to sprintf with calls
to HDsnprintf.
r20233:
Fix coverity issue 662. Don't try to sort 0 attributes in H5Aint.c.
r20234:
Fix coverity issue 664. Check for NULL before dereferencing in H5Gdeprec.c.
r20271:
Purpose: Fix coverity issue 784
Description: Modified H5_debug_mask() to keep a list of files opened for use as
a debugging output stream, and modified H5_term_library to close these files on
exit.
r20272:
addressed coverity issues 838 & 955. Issue was use of strcpy() -- existing
code was safe, but modified to use strncpy() to keep coverity happy.
r20273:
Addresed coverity issues 1388 and 1389.
Initialized sel_iter->type to NULL in H5S_select_iter_init.
r20275:
Purpose: Fix valgrind issue in mf.c
Description: Fixed bug (incomplete if statement) in test_mf_fs_alloc_free() so
the retrieved node gets freed.
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 (amani) 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, w/threadsafe, in production mode
Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode
2011-04-18 02:57:07 +08:00
|
|
|
|
ret_value = name;
|
2003-02-12 21:44:31 +08:00
|
|
|
|
|
|
|
|
|
done:
|
2010-02-05 10:56:25 +08:00
|
|
|
|
if(copied_dt)
|
|
|
|
|
if(H5T_close(copied_dt) < 0)
|
|
|
|
|
HDONE_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, NULL, "unable to close data type");
|
[svn-r20536] Description:
Clean up various warnings & code formatting issues.
Bring changes from Coverity branch to trunk:
r20085:
Purpose: Fix coverity issue 793
Description: Modified H5S_hyper_project_simple_higher() to free the entire span
list in new_space on failure.
r20091:
This is a fix for coverity bug #1683.
Changed the two printfs to use %lu (unsigned long) for printing "dset_size".
r20162:
Purpose: Fix coverity issue 785
Description: Modified H5T_enum_nameof() to free "name" on failure if it was
allocated. Also clarified some code in H5S_hyper_rebuild_helper().
r20189:
Addressed coverity defect 783.
H5SL_new_node() in H5SL.c was failing to free space allocated in its
first alloc if the second alloc failed. Added a call to H5FL_FREE
to address this issue.
This is purely to keep coverity happy -- if this code is ever triggered,
we have much larger problems.
Note that this fix will trigger an unused return value complaint
from coverity next week.
r20190:
Fixed Coverity issues 1561 1565 and 1678 (UNUSED_VALUES) by moving checks of return values to after the function call.
r20191:
Fixed coverity issues 643 644 and 1678 (CHECKED_RETURN).
r20232:
Addressed coverity issues 923-925. Replaced calls to sprintf with calls
to HDsnprintf.
r20233:
Fix coverity issue 662. Don't try to sort 0 attributes in H5Aint.c.
r20234:
Fix coverity issue 664. Check for NULL before dereferencing in H5Gdeprec.c.
r20271:
Purpose: Fix coverity issue 784
Description: Modified H5_debug_mask() to keep a list of files opened for use as
a debugging output stream, and modified H5_term_library to close these files on
exit.
r20272:
addressed coverity issues 838 & 955. Issue was use of strcpy() -- existing
code was safe, but modified to use strncpy() to keep coverity happy.
r20273:
Addresed coverity issues 1388 and 1389.
Initialized sel_iter->type to NULL in H5S_select_iter_init.
r20275:
Purpose: Fix valgrind issue in mf.c
Description: Fixed bug (incomplete if statement) in test_mf_fs_alloc_free() so
the retrieved node gets freed.
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 (amani) 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, w/threadsafe, in production mode
Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode
2011-04-18 02:57:07 +08:00
|
|
|
|
if(!ret_value && alloc_name)
|
|
|
|
|
H5MM_free(name);
|
2010-02-05 10:56:25 +08:00
|
|
|
|
|
2004-04-23 13:06:20 +08:00
|
|
|
|
FUNC_LEAVE_NOAPI(ret_value)
|
[svn-r20536] Description:
Clean up various warnings & code formatting issues.
Bring changes from Coverity branch to trunk:
r20085:
Purpose: Fix coverity issue 793
Description: Modified H5S_hyper_project_simple_higher() to free the entire span
list in new_space on failure.
r20091:
This is a fix for coverity bug #1683.
Changed the two printfs to use %lu (unsigned long) for printing "dset_size".
r20162:
Purpose: Fix coverity issue 785
Description: Modified H5T_enum_nameof() to free "name" on failure if it was
allocated. Also clarified some code in H5S_hyper_rebuild_helper().
r20189:
Addressed coverity defect 783.
H5SL_new_node() in H5SL.c was failing to free space allocated in its
first alloc if the second alloc failed. Added a call to H5FL_FREE
to address this issue.
This is purely to keep coverity happy -- if this code is ever triggered,
we have much larger problems.
Note that this fix will trigger an unused return value complaint
from coverity next week.
r20190:
Fixed Coverity issues 1561 1565 and 1678 (UNUSED_VALUES) by moving checks of return values to after the function call.
r20191:
Fixed coverity issues 643 644 and 1678 (CHECKED_RETURN).
r20232:
Addressed coverity issues 923-925. Replaced calls to sprintf with calls
to HDsnprintf.
r20233:
Fix coverity issue 662. Don't try to sort 0 attributes in H5Aint.c.
r20234:
Fix coverity issue 664. Check for NULL before dereferencing in H5Gdeprec.c.
r20271:
Purpose: Fix coverity issue 784
Description: Modified H5_debug_mask() to keep a list of files opened for use as
a debugging output stream, and modified H5_term_library to close these files on
exit.
r20272:
addressed coverity issues 838 & 955. Issue was use of strcpy() -- existing
code was safe, but modified to use strncpy() to keep coverity happy.
r20273:
Addresed coverity issues 1388 and 1389.
Initialized sel_iter->type to NULL in H5S_select_iter_init.
r20275:
Purpose: Fix valgrind issue in mf.c
Description: Fixed bug (incomplete if statement) in test_mf_fs_alloc_free() so
the retrieved node gets freed.
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 (amani) 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, w/threadsafe, in production mode
Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode
2011-04-18 02:57:07 +08:00
|
|
|
|
} /* end H5T_enum_nameof() */
|
2003-02-12 21:44:31 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Function: H5Tenum_valueof
|
2003-02-12 21:44:31 +08:00
|
|
|
|
*
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Purpose: Finds the value that corresponds to the specified NAME f an
|
|
|
|
|
* enumeration TYPE. The VALUE argument should be at least as
|
|
|
|
|
* large as the value of H5Tget_size(type) in order to hold the
|
|
|
|
|
* result.
|
2003-02-12 21:44:31 +08:00
|
|
|
|
*
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Return: Success: Non-negative
|
2003-02-12 21:44:31 +08:00
|
|
|
|
*
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Failure: Negative
|
|
|
|
|
*
|
|
|
|
|
* Programmer: Robb Matzke
|
2003-02-12 21:44:31 +08:00
|
|
|
|
* Monday, January 4, 1999
|
|
|
|
|
*
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Modifications:
|
|
|
|
|
* Raymond Lu
|
|
|
|
|
* Wednesday, Febuary 9, 2005
|
|
|
|
|
* Made a copy of original datatype and do sorting and search
|
|
|
|
|
* on that copy, to protect the original order of members.
|
2003-02-12 21:44:31 +08:00
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
herr_t
|
|
|
|
|
H5Tenum_valueof(hid_t type, const char *name, void *value/*out*/)
|
|
|
|
|
{
|
2012-09-11 01:00:05 +08:00
|
|
|
|
H5T_t *dt;
|
|
|
|
|
herr_t ret_value = SUCCEED; /* Return value */
|
2003-02-12 21:44:31 +08:00
|
|
|
|
|
2012-02-09 11:13:27 +08:00
|
|
|
|
FUNC_ENTER_API(FAIL)
|
2007-03-09 00:57:36 +08:00
|
|
|
|
H5TRACE3("e", "i*sx", type, name, value);
|
2003-02-12 21:44:31 +08:00
|
|
|
|
|
|
|
|
|
/* Check args */
|
[svn-r18702] Description:
Bring r18672 from metadata journaling "merging" branch to trunk:
Mostly changes to move to only using one 'user data' parameter for
calls to H5AC_protect(), along with some minor reformatting code cleanups.
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 (amani) 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-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
Mac OS X/32 10.6.3 (amazon) in debug mode
Mac OS X/32 10.6.3 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
2010-05-05 21:39:56 +08:00
|
|
|
|
if(NULL == (dt = (H5T_t *)H5I_object_verify(type, H5I_DATATYPE)))
|
2012-09-11 01:00:05 +08:00
|
|
|
|
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type")
|
[svn-r18702] Description:
Bring r18672 from metadata journaling "merging" branch to trunk:
Mostly changes to move to only using one 'user data' parameter for
calls to H5AC_protect(), along with some minor reformatting code cleanups.
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 (amani) 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-amd64 2.6 (abe) w/parallel, w/FORTRAN, in production mode
Mac OS X/32 10.6.3 (amazon) in debug mode
Mac OS X/32 10.6.3 (amazon) w/C++ & FORTRAN, w/threadsafe,
in production mode
2010-05-05 21:39:56 +08:00
|
|
|
|
if(H5T_ENUM != dt->shared->type)
|
2012-09-11 01:00:05 +08:00
|
|
|
|
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an enumeration data type")
|
[svn-r20536] Description:
Clean up various warnings & code formatting issues.
Bring changes from Coverity branch to trunk:
r20085:
Purpose: Fix coverity issue 793
Description: Modified H5S_hyper_project_simple_higher() to free the entire span
list in new_space on failure.
r20091:
This is a fix for coverity bug #1683.
Changed the two printfs to use %lu (unsigned long) for printing "dset_size".
r20162:
Purpose: Fix coverity issue 785
Description: Modified H5T_enum_nameof() to free "name" on failure if it was
allocated. Also clarified some code in H5S_hyper_rebuild_helper().
r20189:
Addressed coverity defect 783.
H5SL_new_node() in H5SL.c was failing to free space allocated in its
first alloc if the second alloc failed. Added a call to H5FL_FREE
to address this issue.
This is purely to keep coverity happy -- if this code is ever triggered,
we have much larger problems.
Note that this fix will trigger an unused return value complaint
from coverity next week.
r20190:
Fixed Coverity issues 1561 1565 and 1678 (UNUSED_VALUES) by moving checks of return values to after the function call.
r20191:
Fixed coverity issues 643 644 and 1678 (CHECKED_RETURN).
r20232:
Addressed coverity issues 923-925. Replaced calls to sprintf with calls
to HDsnprintf.
r20233:
Fix coverity issue 662. Don't try to sort 0 attributes in H5Aint.c.
r20234:
Fix coverity issue 664. Check for NULL before dereferencing in H5Gdeprec.c.
r20271:
Purpose: Fix coverity issue 784
Description: Modified H5_debug_mask() to keep a list of files opened for use as
a debugging output stream, and modified H5_term_library to close these files on
exit.
r20272:
addressed coverity issues 838 & 955. Issue was use of strcpy() -- existing
code was safe, but modified to use strncpy() to keep coverity happy.
r20273:
Addresed coverity issues 1388 and 1389.
Initialized sel_iter->type to NULL in H5S_select_iter_init.
r20275:
Purpose: Fix valgrind issue in mf.c
Description: Fixed bug (incomplete if statement) in test_mf_fs_alloc_free() so
the retrieved node gets freed.
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 (amani) 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, w/threadsafe, in production mode
Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode
2011-04-18 02:57:07 +08:00
|
|
|
|
if(!name || !*name)
|
2012-09-11 01:00:05 +08:00
|
|
|
|
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name")
|
[svn-r20536] Description:
Clean up various warnings & code formatting issues.
Bring changes from Coverity branch to trunk:
r20085:
Purpose: Fix coverity issue 793
Description: Modified H5S_hyper_project_simple_higher() to free the entire span
list in new_space on failure.
r20091:
This is a fix for coverity bug #1683.
Changed the two printfs to use %lu (unsigned long) for printing "dset_size".
r20162:
Purpose: Fix coverity issue 785
Description: Modified H5T_enum_nameof() to free "name" on failure if it was
allocated. Also clarified some code in H5S_hyper_rebuild_helper().
r20189:
Addressed coverity defect 783.
H5SL_new_node() in H5SL.c was failing to free space allocated in its
first alloc if the second alloc failed. Added a call to H5FL_FREE
to address this issue.
This is purely to keep coverity happy -- if this code is ever triggered,
we have much larger problems.
Note that this fix will trigger an unused return value complaint
from coverity next week.
r20190:
Fixed Coverity issues 1561 1565 and 1678 (UNUSED_VALUES) by moving checks of return values to after the function call.
r20191:
Fixed coverity issues 643 644 and 1678 (CHECKED_RETURN).
r20232:
Addressed coverity issues 923-925. Replaced calls to sprintf with calls
to HDsnprintf.
r20233:
Fix coverity issue 662. Don't try to sort 0 attributes in H5Aint.c.
r20234:
Fix coverity issue 664. Check for NULL before dereferencing in H5Gdeprec.c.
r20271:
Purpose: Fix coverity issue 784
Description: Modified H5_debug_mask() to keep a list of files opened for use as
a debugging output stream, and modified H5_term_library to close these files on
exit.
r20272:
addressed coverity issues 838 & 955. Issue was use of strcpy() -- existing
code was safe, but modified to use strncpy() to keep coverity happy.
r20273:
Addresed coverity issues 1388 and 1389.
Initialized sel_iter->type to NULL in H5S_select_iter_init.
r20275:
Purpose: Fix valgrind issue in mf.c
Description: Fixed bug (incomplete if statement) in test_mf_fs_alloc_free() so
the retrieved node gets freed.
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 (amani) 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, w/threadsafe, in production mode
Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode
2011-04-18 02:57:07 +08:00
|
|
|
|
if(!value)
|
2012-09-11 01:00:05 +08:00
|
|
|
|
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no value buffer")
|
2003-02-12 21:44:31 +08:00
|
|
|
|
|
[svn-r20536] Description:
Clean up various warnings & code formatting issues.
Bring changes from Coverity branch to trunk:
r20085:
Purpose: Fix coverity issue 793
Description: Modified H5S_hyper_project_simple_higher() to free the entire span
list in new_space on failure.
r20091:
This is a fix for coverity bug #1683.
Changed the two printfs to use %lu (unsigned long) for printing "dset_size".
r20162:
Purpose: Fix coverity issue 785
Description: Modified H5T_enum_nameof() to free "name" on failure if it was
allocated. Also clarified some code in H5S_hyper_rebuild_helper().
r20189:
Addressed coverity defect 783.
H5SL_new_node() in H5SL.c was failing to free space allocated in its
first alloc if the second alloc failed. Added a call to H5FL_FREE
to address this issue.
This is purely to keep coverity happy -- if this code is ever triggered,
we have much larger problems.
Note that this fix will trigger an unused return value complaint
from coverity next week.
r20190:
Fixed Coverity issues 1561 1565 and 1678 (UNUSED_VALUES) by moving checks of return values to after the function call.
r20191:
Fixed coverity issues 643 644 and 1678 (CHECKED_RETURN).
r20232:
Addressed coverity issues 923-925. Replaced calls to sprintf with calls
to HDsnprintf.
r20233:
Fix coverity issue 662. Don't try to sort 0 attributes in H5Aint.c.
r20234:
Fix coverity issue 664. Check for NULL before dereferencing in H5Gdeprec.c.
r20271:
Purpose: Fix coverity issue 784
Description: Modified H5_debug_mask() to keep a list of files opened for use as
a debugging output stream, and modified H5_term_library to close these files on
exit.
r20272:
addressed coverity issues 838 & 955. Issue was use of strcpy() -- existing
code was safe, but modified to use strncpy() to keep coverity happy.
r20273:
Addresed coverity issues 1388 and 1389.
Initialized sel_iter->type to NULL in H5S_select_iter_init.
r20275:
Purpose: Fix valgrind issue in mf.c
Description: Fixed bug (incomplete if statement) in test_mf_fs_alloc_free() so
the retrieved node gets freed.
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 (amani) 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, w/threadsafe, in production mode
Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode
2011-04-18 02:57:07 +08:00
|
|
|
|
if(H5T_enum_valueof(dt, name, value) < 0)
|
2012-09-11 01:00:05 +08:00
|
|
|
|
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "valueof query failed")
|
2003-02-12 21:44:31 +08:00
|
|
|
|
|
|
|
|
|
done:
|
2004-04-23 13:06:20 +08:00
|
|
|
|
FUNC_LEAVE_API(ret_value)
|
[svn-r20536] Description:
Clean up various warnings & code formatting issues.
Bring changes from Coverity branch to trunk:
r20085:
Purpose: Fix coverity issue 793
Description: Modified H5S_hyper_project_simple_higher() to free the entire span
list in new_space on failure.
r20091:
This is a fix for coverity bug #1683.
Changed the two printfs to use %lu (unsigned long) for printing "dset_size".
r20162:
Purpose: Fix coverity issue 785
Description: Modified H5T_enum_nameof() to free "name" on failure if it was
allocated. Also clarified some code in H5S_hyper_rebuild_helper().
r20189:
Addressed coverity defect 783.
H5SL_new_node() in H5SL.c was failing to free space allocated in its
first alloc if the second alloc failed. Added a call to H5FL_FREE
to address this issue.
This is purely to keep coverity happy -- if this code is ever triggered,
we have much larger problems.
Note that this fix will trigger an unused return value complaint
from coverity next week.
r20190:
Fixed Coverity issues 1561 1565 and 1678 (UNUSED_VALUES) by moving checks of return values to after the function call.
r20191:
Fixed coverity issues 643 644 and 1678 (CHECKED_RETURN).
r20232:
Addressed coverity issues 923-925. Replaced calls to sprintf with calls
to HDsnprintf.
r20233:
Fix coverity issue 662. Don't try to sort 0 attributes in H5Aint.c.
r20234:
Fix coverity issue 664. Check for NULL before dereferencing in H5Gdeprec.c.
r20271:
Purpose: Fix coverity issue 784
Description: Modified H5_debug_mask() to keep a list of files opened for use as
a debugging output stream, and modified H5_term_library to close these files on
exit.
r20272:
addressed coverity issues 838 & 955. Issue was use of strcpy() -- existing
code was safe, but modified to use strncpy() to keep coverity happy.
r20273:
Addresed coverity issues 1388 and 1389.
Initialized sel_iter->type to NULL in H5S_select_iter_init.
r20275:
Purpose: Fix valgrind issue in mf.c
Description: Fixed bug (incomplete if statement) in test_mf_fs_alloc_free() so
the retrieved node gets freed.
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 (amani) 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, w/threadsafe, in production mode
Linux/PPC 2.6 (heiwa) w/C++ & FORTRAN, w/threadsafe, in debug mode
2011-04-18 02:57:07 +08:00
|
|
|
|
} /* H5Tenum_valueof() */
|
2003-02-12 21:44:31 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*-------------------------------------------------------------------------
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Function: H5T_enum_valueof
|
2003-02-12 21:44:31 +08:00
|
|
|
|
*
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Purpose: Finds the value that corresponds the the specified symbol
|
|
|
|
|
* NAME of an enumeration data type DT and copy it to the VALUE
|
|
|
|
|
* result buffer. The VALUE should be allocated by the caller to
|
|
|
|
|
* be large enough for the result.
|
2003-02-12 21:44:31 +08:00
|
|
|
|
*
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Return: Success: Non-negative, value stored in VALUE.
|
2003-02-12 21:44:31 +08:00
|
|
|
|
*
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Failure: Negative, VALUE is undefined.
|
2003-02-12 21:44:31 +08:00
|
|
|
|
*
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Programmer: Robb Matzke
|
2003-02-12 21:44:31 +08:00
|
|
|
|
* Monday, January 4, 1999
|
|
|
|
|
*
|
2012-09-11 01:00:05 +08:00
|
|
|
|
* Modifications:
|
|
|
|
|
* Raymond Lu
|
|
|
|
|
* Wednesday, Febuary 9, 2005
|
|
|
|
|
* Made a copy of original datatype and do sorting and search
|
|
|
|
|
* on that copy, to protect the original order of members.
|
2003-02-12 21:44:31 +08:00
|
|
|
|
*-------------------------------------------------------------------------
|
|
|
|
|
*/
|
|
|
|
|
static herr_t
|
2004-12-29 22:26:20 +08:00
|
|
|
|
H5T_enum_valueof(const H5T_t *dt, const char *name, void *value/*out*/)
|
2003-02-12 21:44:31 +08:00
|
|
|
|
{
|
2012-09-11 01:00:05 +08:00
|
|
|
|
unsigned lt, md=0, rt; /*indices for binary search */
|
|
|
|
|
int cmp=(-1); /*comparison result */
|
|
|
|
|
H5T_t *copied_dt = NULL; /*do sorting in copied datatype */
|
|
|
|
|
herr_t ret_value=SUCCEED; /* Return value */
|
2005-08-14 04:53:35 +08:00
|
|
|
|
|
2012-02-09 11:13:27 +08:00
|
|
|
|
FUNC_ENTER_NOAPI_NOINIT
|
2003-02-12 21:44:31 +08:00
|
|
|
|
|
|
|
|
|
/* Check args */
|
2013-05-22 01:30:54 +08:00
|
|
|
|
HDassert(dt && H5T_ENUM==dt->shared->type);
|
|
|
|
|
HDassert(name && *name);
|
|
|
|
|
HDassert(value);
|
2003-02-12 21:44:31 +08:00
|
|
|
|
|
|
|
|
|
/* Sanity check */
|
[svn-r9329]
Purpose:
Feature
Description:
Datatypes and groups now use H5FO "file object" code that was previously
only used by datasets. These objects will hold a file open if the file
is closed but they have not yet been closed. If these objects are unlinked
then relinked, they will not be destroyed. If they are opened twice (even
by two different names), both IDs will "see" changes made to the object
using the other ID.
When an object is opened using two different names (e.g., if a dataset was
opened under one name, then mounted and opened under its new name), calling
H5Iget_name() on a given hid_t will return the name used to open that hid_t,
not the current name of the object (this is a feature, and a change from the
previous behavior of datasets).
Solution:
Used H5FO code that was already in place for datasets. Broke H5D_t's, H5T_t's,
and H5G_t's into a "shared" struct and a private struct. The shared structs
(H5D_shared_t, etc.) hold the object's information and are used by all IDs
that point to a given object in the file. The private structs are pointed
to by the hid_t and contain the object's group entry information (including its
name) and a pointer to the shared struct for that object.
This changed the naming of structs throughout the library (e.g., datatype->size
is now datatype->shared->size). I added an updated H5Tinit.c to windows.zip.
Platforms tested:
Visual Studio 7, sleipnir, arabica, verbena
Misc. update:
2004-09-29 03:04:19 +08:00
|
|
|
|
if (dt->shared->u.enumer.nmembs == 0)
|
2004-04-23 13:06:20 +08:00
|
|
|
|
HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, FAIL, "datatype has no members")
|
2003-02-12 21:44:31 +08:00
|
|
|
|
|
2005-02-09 23:54:44 +08:00
|
|
|
|
/* Do a binary search over the names to find the correct one. Do sorting
|
|
|
|
|
* and search on the copied datatype to protect the original order. */
|
2012-09-11 01:00:05 +08:00
|
|
|
|
if (NULL==(copied_dt=H5T_copy(dt, H5T_COPY_ALL)))
|
|
|
|
|
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to copy data type");
|
2012-04-17 05:20:26 +08:00
|
|
|
|
if(H5T__sort_name(copied_dt, NULL) < 0)
|
2004-04-23 13:06:20 +08:00
|
|
|
|
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTCOMPARE, FAIL, "value sort failed")
|
2005-02-09 23:54:44 +08:00
|
|
|
|
|
2003-02-12 21:44:31 +08:00
|
|
|
|
lt = 0;
|
2005-02-09 23:54:44 +08:00
|
|
|
|
rt = copied_dt->shared->u.enumer.nmembs;
|
2003-02-12 21:44:31 +08:00
|
|
|
|
|
2012-09-11 01:00:05 +08:00
|
|
|
|
while (lt<rt) {
|
|
|
|
|
md = (lt+rt)/2;
|
|
|
|
|
cmp = HDstrcmp(name, copied_dt->shared->u.enumer.name[md]);
|
|
|
|
|
if (cmp<0) {
|
|
|
|
|
rt = md;
|
|
|
|
|
} else if (cmp>0) {
|
|
|
|
|
lt = md+1;
|
|
|
|
|
} else {
|
|
|
|
|
break;
|
|
|
|
|
}
|
2003-02-12 21:44:31 +08:00
|
|
|
|
}
|
2012-09-11 01:00:05 +08:00
|
|
|
|
/* Value was not yet defined. This fixes bug # 774, 2002/06/05 EIP */
|
|
|
|
|
if (cmp!=0)
|
2004-04-23 13:06:20 +08:00
|
|
|
|
HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, FAIL, "string doesn't exist in the enumeration type")
|
2003-02-12 21:44:31 +08:00
|
|
|
|
|
2005-02-09 23:54:44 +08:00
|
|
|
|
HDmemcpy(value, copied_dt->shared->u.enumer.value+md*copied_dt->shared->size, copied_dt->shared->size);
|
|
|
|
|
|
2003-02-12 21:44:31 +08:00
|
|
|
|
done:
|
2010-02-05 10:56:25 +08:00
|
|
|
|
if(copied_dt)
|
|
|
|
|
if(H5T_close(copied_dt) < 0)
|
|
|
|
|
HDONE_ERROR(H5E_DATATYPE, H5E_CANTCLOSEOBJ, FAIL, "unable to close data type")
|
|
|
|
|
|
2004-04-23 13:06:20 +08:00
|
|
|
|
FUNC_LEAVE_NOAPI(ret_value)
|
2003-02-12 21:44:31 +08:00
|
|
|
|
}
|
2012-09-11 01:00:05 +08:00
|
|
|
|
|