hdf5/src/H5Ostab.c
Robb Matzke b4c5e3e009 [svn-r407] ./src/H5A.c
./src/H5D.c
./src/H5Tconv.c
./src/H5detect.c
	Updated to work with new internal H5T functions.  Fixed some
	data type memory leaks during error recovery.

./src/H5Dprivate.h
	Added H5D_typeof() similar to H5D_entof() that returns a
	pointer directly to the dataset's type.  This is used by
	H5Tcopy() when invoked on a dataset (see below).

./src/H5Epublic.h
	Fixed typos in H5E_BEGIN_TRY and H5E_END_TRY macros.

./src/H5F.c
	Closing a file with objects still open reports the file name
	in the warning message.  Removed unnecessary invalidation of
	shared data types.

./src/H5Gent.c
./src/H5Gpkg.h
./src/H5Gprivate.h
	Added `const' to some arguments.

./src/H5O.c
./src/H5Oprivate.h
./src/H5Oshared.c
	An object header message can now be a pointer to a message in
	some other object header.  The pointer is to the first message
	of the appropriate type in the other object header and hard
	link counts are maintained automatically to prevent dangling
	pointers.  The old global heap method of message sharing is
	also supported although nothing actually uses it.

./src/H5Oattr.c
./src/H5Ocomp.c
./src/H5Ocont.c
./src/H5Odtype.c
./src/H5Oefl.c
./src/H5Olayout.c
./src/H5Oname.c
./src/H5Osdspace.c
./src/H5Oshare.c
./src/H5Ostab.c
	Changed the data type for the shared message info struct to
	H5O_shared_t and added an extra initializer to the class
	methods struct for the set_share method.

./src/H5Odtype.c
	Added the ability to share data type messages by pointing to
	other object headers.

./src/H5T.c
./src/H5Tpkg.h
./src/H5Tprivate.h
./src/H5Tpublic.h
	Added named data types and changed the functionality of some
	API functions as follows:

	* The term `read-only' means that a type handle cannot be
	  modified with functions like H5Tset_*() or H5Tinsert().

	* The term `immutable' means the same as `read-only' with the
	  added restriction that H5Tclose() cannot be called for the
	  type. A transient type is made immutable by calling
	  H5Tlock().

	* Handles to named types are always read-only.

	* Handles to predefined types are immutable.

	* A transient type can be converted to a named type by calling
	  H5Tcommit().  This function will fail if the type is already
	  named or is immutable.

	* The API function H5Tcommitted() returns an indication of
	  whether a data type has been commited (or is named).  If
	  H5Tcommitted() returns TRUE for a data type obtained by
	  calling H5Dget_type() on a dataset, then the dataset is
	  using a shared data type.

	* H5Topen() returns a handle to a named type.

	* H5Tcopy() always returns a handle to a modifiable transient
	  type even when invoked on a named type.  Also, when invoked
	  on a dataset it returns a modifiable transient type which is
	  a copy of the dataset's data type.

	* Using a named data type in the call to H5Dcreate() causes
	  the dataset object header to point to the named data type,
	  but using a transient type causes the type to be copied into
	  the dataset's object header.

	* The data type returned from H5Dget_type() is a named data
	  type or a read-only transient data type depending on whether
	  the dataset points to a named data type.   The old behavior,
	  to return a modifiable transient type, is accomplished by
	  overloading H5Tcopy() to operate on datasets (see above).

	* H5Tshare(), H5Tunshare(), and H5Tis_shared() have been
	  removed from the API.

	The following features were *not* implemented because they
	need more discussion:

	* A named data type can be opened by applying H5Topen() to a
	  dataset in which case the data type is the data type of the
	  dataset (or the data type to which the dataset points if the
	  dataset has a shared data type).

	* A named data type can have attributes like groups or
	  datasets.

	* The members of a compound data type can point to named data
	  types.

./src/h5ls.c
	Reports `Data type' for named data type objects in the file.
1998-06-04 17:27:11 -05:00

272 lines
7.5 KiB
C
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*-------------------------------------------------------------------------
* Copyright (C) 1997 National Center for Supercomputing Applications.
* All rights reserved.
*
*-------------------------------------------------------------------------
*
* Created: H5Ostab.c
* Aug 6 1997
* Robb Matzke <matzke@llnl.gov>
*
* Purpose: Symbol table messages.
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
#include <H5private.h>
#include <H5Eprivate.h>
#include <H5Gprivate.h>
#include <H5MMprivate.h>
#include <H5Oprivate.h>
#define PABLO_MASK H5O_stab_mask
/* PRIVATE PROTOTYPES */
static void *H5O_stab_decode(H5F_t *f, const uint8 *p, H5O_shared_t *sh);
static herr_t H5O_stab_encode(H5F_t *f, uint8 *p, const void *_mesg);
static void *H5O_stab_copy(const void *_mesg, void *_dest);
static size_t H5O_stab_size(H5F_t *f, const void *_mesg);
static herr_t H5O_stab_debug(H5F_t *f, const void *_mesg,
FILE * stream, intn indent, intn fwidth);
/* This message derives from H5O */
const H5O_class_t H5O_STAB[1] = {{
H5O_STAB_ID, /*message id number */
"stab", /*message name for debugging */
sizeof(H5O_stab_t), /*native message size */
H5O_stab_decode, /*decode message */
H5O_stab_encode, /*encode message */
H5O_stab_copy, /*copy the native value */
H5O_stab_size, /*size of symbol table entry */
NULL, /*default reset method */
NULL, /*get share method */
NULL, /*set share method */
H5O_stab_debug, /*debug the message */
}};
/* Interface initialization */
static hbool_t interface_initialize_g = FALSE;
#define INTERFACE_INIT NULL
/*-------------------------------------------------------------------------
* Function: H5O_stab_decode
*
* Purpose: Decode a symbol table message and return a pointer to
* a new one created with malloc().
*
* Return: Success: Ptr to new message in native order.
*
* Failure: NULL
*
* Programmer: Robb Matzke
* matzke@llnl.gov
* Aug 6 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static void *
H5O_stab_decode(H5F_t *f, const uint8 *p, H5O_shared_t __unused__ *sh)
{
H5O_stab_t *stab;
FUNC_ENTER(H5O_stab_decode, NULL);
/* check args */
assert(f);
assert(p);
assert (!sh);
/* decode */
stab = H5MM_xcalloc(1, sizeof(H5O_stab_t));
H5F_addr_decode(f, &p, &(stab->btree_addr));
H5F_addr_decode(f, &p, &(stab->heap_addr));
FUNC_LEAVE(stab);
}
/*-------------------------------------------------------------------------
* Function: H5O_stab_encode
*
* Purpose: Encodes a symbol table message.
*
* Return: Success: SUCCEED
*
* Failure: FAIL
*
* Programmer: Robb Matzke
* matzke@llnl.gov
* Aug 6 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static herr_t
H5O_stab_encode(H5F_t *f, uint8 *p, const void *_mesg)
{
const H5O_stab_t *stab = (const H5O_stab_t *) _mesg;
FUNC_ENTER(H5O_stab_encode, FAIL);
/* check args */
assert(f);
assert(p);
assert(stab);
/* encode */
H5F_addr_encode(f, &p, &(stab->btree_addr));
H5F_addr_encode(f, &p, &(stab->heap_addr));
FUNC_LEAVE(SUCCEED);
}
/*-------------------------------------------------------------------------
* Function: H5O_stab_fast
*
* Purpose: Initializes a new message struct with info from the cache of
* a symbol table entry.
*
* Return: Success: Ptr to message struct, allocated if none
* supplied.
*
* Failure: NULL
*
* Programmer: Robb Matzke
* matzke@llnl.gov
* Aug 6 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
void *
H5O_stab_fast(const H5G_cache_t *cache, const H5O_class_t *type, void *_mesg)
{
H5O_stab_t *stab = NULL;
FUNC_ENTER(H5O_stab_fast, NULL);
/* check args */
assert(cache);
assert(type);
if (H5O_STAB == type) {
if (_mesg) stab = (H5O_stab_t *) _mesg;
else stab = H5MM_xcalloc(1, sizeof(H5O_stab_t));
stab->btree_addr = cache->stab.btree_addr;
stab->heap_addr = cache->stab.heap_addr;
}
FUNC_LEAVE(stab);
}
/*-------------------------------------------------------------------------
* Function: H5O_stab_copy
*
* Purpose: Copies a message from _MESG to _DEST, allocating _DEST if
* necessary.
*
* Return: Success: Ptr to _DEST
*
* Failure: NULL
*
* Programmer: Robb Matzke
* matzke@llnl.gov
* Aug 6 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static void *
H5O_stab_copy(const void *_mesg, void *_dest)
{
const H5O_stab_t *stab = (const H5O_stab_t *) _mesg;
H5O_stab_t *dest = (H5O_stab_t *) _dest;
FUNC_ENTER(H5O_stab_copy, NULL);
/* check args */
assert(stab);
if (!dest)
dest = H5MM_xcalloc(1, sizeof(H5O_stab_t));
/* copy */
*dest = *stab;
FUNC_LEAVE((void *) dest);
}
/*-------------------------------------------------------------------------
* Function: H5O_stab_size
*
* Purpose: Returns the size of the raw message in bytes not counting
* the message type or size fields, but only the data fields.
* This function doesn't take into account alignment.
*
* Return: Success: Message data size in bytes without alignment.
*
* Failure: zero
*
* Programmer: Robb Matzke
* matzke@llnl.gov
* Aug 6 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static size_t
H5O_stab_size(H5F_t *f, const void __unused__ *_mesg)
{
FUNC_ENTER(H5O_stab_size, 0);
FUNC_LEAVE(2 * H5F_SIZEOF_ADDR(f));
}
/*-------------------------------------------------------------------------
* Function: H5O_stab_debug
*
* Purpose: Prints debugging info for a symbol table message.
*
* Return: Success: SUCCEED
*
* Failure: FAIL
*
* Programmer: Robb Matzke
* matzke@llnl.gov
* Aug 6 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static herr_t
H5O_stab_debug(H5F_t __unused__ *f, const void *_mesg, FILE * stream,
intn indent, intn fwidth)
{
const H5O_stab_t *stab = (const H5O_stab_t *) _mesg;
FUNC_ENTER(H5O_stab_debug, FAIL);
/* check args */
assert(f);
assert(stab);
assert(stream);
assert(indent >= 0);
assert(fwidth >= 0);
fprintf(stream, "%*s%-*s ", indent, "", fwidth,
"B-tree address:");
H5F_addr_print(stream, &(stab->btree_addr));
fprintf(stream, "\n");
fprintf(stream, "%*s%-*s ", indent, "", fwidth,
"Name heap address:");
H5F_addr_print(stream, &(stab->heap_addr));
fprintf(stream, "\n");
FUNC_LEAVE(SUCCEED);
}