summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>1998-01-16 22:23:43 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>1998-01-16 22:23:43 (GMT)
commitc2c94c31878dc42926661c9cb7e71be620196fc1 (patch)
treeee9ce2ae309882348dc1eafc1d105b5e6646605e /src
parent903e677366a86ea385d5cfe1241f3f53132941de (diff)
downloadhdf5-c2c94c31878dc42926661c9cb7e71be620196fc1.zip
hdf5-c2c94c31878dc42926661c9cb7e71be620196fc1.tar.gz
hdf5-c2c94c31878dc42926661c9cb7e71be620196fc1.tar.bz2
[svn-r157] Reformatted code with indent...
Diffstat (limited to 'src')
-rw-r--r--src/H5.c233
-rw-r--r--src/H5A.c854
-rw-r--r--src/H5AC.c1325
-rw-r--r--src/H5ACprivate.h135
-rw-r--r--src/H5ACpublic.h16
-rw-r--r--src/H5Aprivate.h53
-rw-r--r--src/H5Apublic.h94
-rw-r--r--src/H5B.c2916
-rw-r--r--src/H5Bprivate.h132
-rw-r--r--src/H5Bpublic.h16
-rw-r--r--src/H5C.c1142
-rw-r--r--src/H5Cprivate.h2
-rw-r--r--src/H5Cpublic.h80
-rw-r--r--src/H5D.c1553
-rw-r--r--src/H5Distore.c1237
-rw-r--r--src/H5Dprivate.h43
-rw-r--r--src/H5Dpublic.h34
-rw-r--r--src/H5E.c778
-rw-r--r--src/H5Eprivate.h87
-rw-r--r--src/H5Epublic.h202
-rw-r--r--src/H5F.c1882
-rw-r--r--src/H5Farray.c320
-rw-r--r--src/H5Fcore.c280
-rw-r--r--src/H5Ffamily.c847
-rw-r--r--src/H5Fistore.c1237
-rw-r--r--src/H5Flow.c944
-rw-r--r--src/H5Fprivate.h533
-rw-r--r--src/H5Fpublic.h20
-rw-r--r--src/H5Fsec2.c362
-rw-r--r--src/H5Fstdio.c440
-rw-r--r--src/H5G.c1850
-rw-r--r--src/H5Gent.c487
-rw-r--r--src/H5Gnode.c1577
-rw-r--r--src/H5Gpkg.h80
-rw-r--r--src/H5Gprivate.h98
-rw-r--r--src/H5Gpublic.h32
-rw-r--r--src/H5Gstab.c358
-rw-r--r--src/H5H.c1587
-rw-r--r--src/H5Hprivate.h59
-rw-r--r--src/H5Hpublic.h16
-rw-r--r--src/H5M.c747
-rw-r--r--src/H5MF.c139
-rw-r--r--src/H5MFprivate.h20
-rw-r--r--src/H5MFpublic.h18
-rw-r--r--src/H5MM.c200
-rw-r--r--src/H5MMprivate.h23
-rw-r--r--src/H5MMpublic.h18
-rw-r--r--src/H5Mprivate.h39
-rw-r--r--src/H5Mpublic.h33
-rw-r--r--src/H5O.c2631
-rw-r--r--src/H5Ocont.c207
-rw-r--r--src/H5Odtype.c1345
-rw-r--r--src/H5Oefl.c364
-rw-r--r--src/H5Olayout.c346
-rw-r--r--src/H5Oname.c311
-rw-r--r--src/H5Onull.c38
-rw-r--r--src/H5Oprivate.h184
-rw-r--r--src/H5Opublic.h18
-rw-r--r--src/H5Osdspace.c377
-rw-r--r--src/H5Ostab.c317
-rw-r--r--src/H5P.c1044
-rw-r--r--src/H5Pprivate.h42
-rw-r--r--src/H5Ppublic.h29
-rw-r--r--src/H5T.c4711
-rw-r--r--src/H5Tconv.c174
-rw-r--r--src/H5Tpkg.h110
-rw-r--r--src/H5Tprivate.h51
-rw-r--r--src/H5Tpublic.h289
-rw-r--r--src/H5V.c807
-rw-r--r--src/H5Vprivate.h174
-rw-r--r--src/H5detect.c1279
-rw-r--r--src/H5private.h658
-rw-r--r--src/H5public.h78
-rw-r--r--src/debug.c239
74 files changed, 20199 insertions, 20802 deletions
diff --git a/src/H5.c b/src/H5.c
index faef9f8..c810f99 100644
--- a/src/H5.c
+++ b/src/H5.c
@@ -11,7 +11,7 @@
****************************************************************************/
#ifdef RCSID
-static char RcsId[] = "@(#)$Revision$";
+static char RcsId[] = "@(#)$Revision$";
#endif
/* $Id$ */
@@ -19,51 +19,49 @@ static char RcsId[] = "@(#)$Revision$";
/*LINTLIBRARY */
/*+
FILE
- hdf5.c
+ hdf5.c
HDF library support routines
EXPORTED ROUTINES
- H5dont_atexit -- Indicate that an 'atexit' routine is _not_ to be installed
- H5version -- Check the version of the library
+ H5dont_atexit -- Indicate that an 'atexit' routine is _not_ to be installed
+ H5version -- Check the version of the library
LIBRARY-SCOPED ROUTINES
- H5_init_library -- initialize the HDF5 library
- H5_term_library -- shut-down the HDF5 library
- H5_init_thread -- initialize thread-specific information
+ H5_init_library -- initialize the HDF5 library
+ H5_term_library -- shut-down the HDF5 library
+ H5_init_thread -- initialize thread-specific information
LOCAL ROUTINES
- H5_init_interface -- initialize the H5 interface
+ H5_init_interface -- initialize the H5 interface
+ */
-
/* private headers */
-#include <H5private.h> /*library */
-#include <H5ACprivate.h> /*cache */
-#include <H5Bprivate.h> /*B-link trees */
-#include <H5Eprivate.h> /*error handling */
-#include <H5MMprivate.h> /*memory management */
-#include <H5Tprivate.h> /*data types */
+#include <H5private.h> /*library */
+#include <H5ACprivate.h> /*cache */
+#include <H5Bprivate.h> /*B-link trees */
+#include <H5Eprivate.h> /*error handling */
+#include <H5MMprivate.h> /*memory management */
+#include <H5Tprivate.h> /*data types */
-#define PABLO_MASK H5_mask
+#define PABLO_MASK H5_mask
/*--------------------- Locally scoped variables -----------------------------*/
-
-hbool_t library_initialize_g = FALSE;
-hbool_t thread_initialize_g = FALSE;
-hbool_t install_atexit_g = TRUE;
+hbool_t library_initialize_g = FALSE;
+hbool_t thread_initialize_g = FALSE;
+hbool_t install_atexit_g = TRUE;
typedef struct H5_exit {
- void (*func)(void); /* Interface function to call during exit */
- struct H5_exit *next; /* Pointer to next node with exit function */
+ void (*func) (void); /* Interface function to call during exit */
+ struct H5_exit *next; /* Pointer to next node with exit function */
} H5_exit_t;
-H5_exit_t *lib_exit_head; /* Pointer to the head of the list of 'atexit' functions */
+H5_exit_t *lib_exit_head; /* Pointer to the head of the list of 'atexit' functions */
/* Interface initialization */
-static hbool_t interface_initialize_g = FALSE;
+static hbool_t interface_initialize_g = FALSE;
#define INTERFACE_INIT H5_init_interface
-static herr_t H5_init_interface (void);
+static herr_t H5_init_interface(void);
/*--------------------------------------------------------------------------
NAME
@@ -77,27 +75,26 @@ DESCRIPTION
Initializes any library-global data or routines.
--------------------------------------------------------------------------*/
-herr_t H5_init_library(void)
+herr_t
+H5_init_library(void)
{
- FUNC_ENTER_INIT (H5_init_library, NULL, FAIL);
-
- /* Install atexit() library cleanup routine */
- if(install_atexit_g==TRUE)
- if (HDatexit(&H5_term_library) != 0)
- HRETURN_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL,
- "unable to register atexit function");
-
- /*
- * Initialize interfaces that might not be able to initialize themselves
- * soon enough.
- */
- if (H5T_init_interface ()<0) {
- HRETURN_ERROR (H5E_FUNC, H5E_CANTINIT, FAIL,
- "unable to initialize type interface");
- }
-
-
- FUNC_LEAVE (SUCCEED);
+ FUNC_ENTER_INIT(H5_init_library, NULL, FAIL);
+
+ /* Install atexit() library cleanup routine */
+ if (install_atexit_g == TRUE)
+ if (HDatexit(&H5_term_library) != 0)
+ HRETURN_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL,
+ "unable to register atexit function");
+
+ /*
+ * Initialize interfaces that might not be able to initialize themselves
+ * soon enough.
+ */
+ if (H5T_init_interface() < 0) {
+ HRETURN_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL,
+ "unable to initialize type interface");
+ }
+ FUNC_LEAVE(SUCCEED);
}
/*--------------------------------------------------------------------------
@@ -121,23 +118,23 @@ herr_t H5_init_library(void)
REVISION LOG
--------------------------------------------------------------------------*/
herr_t
-H5_add_exit (void (*func)(void))
+H5_add_exit(void (*func) (void))
{
- herr_t ret_value = SUCCEED;
- H5_exit_t *new;
+ herr_t ret_value = SUCCEED;
+ H5_exit_t *new;
- FUNC_ENTER_INIT (H5_add_exit, NULL, FAIL);
+ FUNC_ENTER_INIT(H5_add_exit, NULL, FAIL);
assert(func);
- new = H5MM_xcalloc (1, sizeof(H5_exit_t));
+ new = H5MM_xcalloc(1, sizeof(H5_exit_t));
- new->func=func;
- new->next=lib_exit_head;
- lib_exit_head=new;
+ new->func = func;
+ new->next = lib_exit_head;
+ lib_exit_head = new;
FUNC_LEAVE(ret_value);
-} /* end H5_add_exit() */
+} /* end H5_add_exit() */
/*--------------------------------------------------------------------------
NAME
@@ -158,19 +155,18 @@ H5_add_exit (void (*func)(void))
REVISION LOG
--------------------------------------------------------------------------*/
void
-H5_term_library (void)
+H5_term_library(void)
{
- H5_exit_t *temp;
-
- temp=lib_exit_head;
- while(lib_exit_head!=NULL)
- {
- (*lib_exit_head->func)();
- lib_exit_head=lib_exit_head->next;
- HDfree(temp);
- temp=lib_exit_head;
- } /* end while */
-} /* end H5_term_library() */
+ H5_exit_t *temp;
+
+ temp = lib_exit_head;
+ while (lib_exit_head != NULL) {
+ (*lib_exit_head->func) ();
+ lib_exit_head = lib_exit_head->next;
+ HDfree(temp);
+ temp = lib_exit_head;
+ } /* end while */
+} /* end H5_term_library() */
/*--------------------------------------------------------------------------
NAME
@@ -184,22 +180,23 @@ DESCRIPTION
Initializes any thread-specific data or routines.
--------------------------------------------------------------------------*/
-herr_t H5_init_thread(void)
+herr_t
+H5_init_thread(void)
{
- FUNC_ENTER_INIT (H5_init_thread, NULL, FAIL);
+ FUNC_ENTER_INIT(H5_init_thread, NULL, FAIL);
/* Create/initialize this thread's error stack */
- if((H5E_thrdid_g=H5Ecreate(16))==FAIL)
- HRETURN_ERROR (H5E_FUNC, H5E_CANTINIT, FAIL,
- "unable to create thread error stack");
+ if ((H5E_thrdid_g = H5Ecreate(16)) == FAIL)
+ HRETURN_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL,
+ "unable to create thread error stack");
/* Add the "thread termination" routine to the exit chain */
- if(H5_add_exit(&H5_term_thread)==FAIL)
- HRETURN_ERROR (H5E_FUNC, H5E_CANTINIT, FAIL,
- "unable to set thread atexit function");
+ if (H5_add_exit(&H5_term_thread) == FAIL)
+ HRETURN_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL,
+ "unable to set thread atexit function");
- FUNC_LEAVE (SUCCEED);
-} /* H5_init_thread */
+ FUNC_LEAVE(SUCCEED);
+} /* H5_init_thread */
/*--------------------------------------------------------------------------
NAME
@@ -220,10 +217,10 @@ herr_t H5_init_thread(void)
REVISION LOG
--------------------------------------------------------------------------*/
void
-H5_term_thread (void)
+H5_term_thread(void)
{
- H5Eclose (H5E_thrdid_g);
-} /* end H5_term_thread() */
+ H5Eclose(H5E_thrdid_g);
+} /* end H5_term_thread() */
/*--------------------------------------------------------------------------
NAME
@@ -237,12 +234,13 @@ DESCRIPTION
Initializes any interface-specific data or routines.
--------------------------------------------------------------------------*/
-static herr_t H5_init_interface(void)
+static herr_t
+H5_init_interface(void)
{
- FUNC_ENTER (H5_init_interface, FAIL);
+ FUNC_ENTER(H5_init_interface, FAIL);
- FUNC_LEAVE (SUCCEED);
-} /* H5_init_interface */
+ FUNC_LEAVE(SUCCEED);
+} /* H5_init_interface */
/*--------------------------------------------------------------------------
NAME
@@ -270,15 +268,16 @@ static herr_t H5_init_interface(void)
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
-herr_t H5dont_atexit(void)
+herr_t
+H5dont_atexit(void)
{
- FUNC_ENTER_INIT (H5dont_atexit, NULL, FAIL);
+ FUNC_ENTER_INIT(H5dont_atexit, NULL, FAIL);
- if(install_atexit_g == TRUE)
- install_atexit_g=FALSE;
+ if (install_atexit_g == TRUE)
+ install_atexit_g = FALSE;
- FUNC_LEAVE (SUCCEED);
-} /* end H5dont_atexit() */
+ FUNC_LEAVE(SUCCEED);
+} /* end H5dont_atexit() */
/*--------------------------------------------------------------------------
NAME
@@ -296,50 +295,46 @@ DESCRIPTION
Checks the version numbers of the library.
--------------------------------------------------------------------------*/
-herr_t H5version(uintn *majnum, uintn *minnum, uintn *relnum, uintn *patnum)
+herr_t
+H5version(uintn *majnum, uintn *minnum, uintn *relnum, uintn *patnum)
{
- herr_t ret_value = SUCCEED;
+ herr_t ret_value = SUCCEED;
- FUNC_ENTER (H5version, FAIL);
+ FUNC_ENTER(H5version, FAIL);
/* Clear errors and check args and all the boring stuff. */
H5ECLEAR;
- if (majnum==NULL || minnum==NULL || relnum==NULL || patnum==NULL)
+ if (majnum == NULL || minnum == NULL || relnum == NULL || patnum == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL,
- "null pointer argument");
+ "null pointer argument");
/* Set the version information */
- *majnum=HDF5_MAJOR_VERSION;
- *minnum=HDF5_MINOR_VERSION;
- *relnum=HDF5_RELEASE_VERSION;
- *patnum=HDF5_PATCH_VERSION;
-
-done:
- if(ret_value == FAIL)
- { /* Error condition cleanup */
+ *majnum = HDF5_MAJOR_VERSION;
+ *minnum = HDF5_MINOR_VERSION;
+ *relnum = HDF5_RELEASE_VERSION;
+ *patnum = HDF5_PATCH_VERSION;
- } /* end if */
+ done:
+ if (ret_value == FAIL) { /* Error condition cleanup */
+ } /* end if */
/* Normal function cleanup */
-
FUNC_LEAVE(ret_value);
}
-
-
/*-------------------------------------------------------------------------
- * Function: H5init
+ * Function: H5init
*
- * Purpose: Initialize the library. This is normally called
- * automatically, but if you find that an HDF5 library function
- * is failing inexplicably, then try calling this function
- * first.
+ * Purpose: Initialize the library. This is normally called
+ * automatically, but if you find that an HDF5 library function
+ * is failing inexplicably, then try calling this function
+ * first.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Tuesday, December 9, 1997
*
* Modifications:
@@ -347,11 +342,9 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5init (void)
+H5init(void)
{
- FUNC_ENTER (H5init, FAIL);
- /* all work is done by FUNC_ENTER() */
- FUNC_LEAVE (SUCCEED);
+ FUNC_ENTER(H5init, FAIL);
+ /* all work is done by FUNC_ENTER() */
+ FUNC_LEAVE(SUCCEED);
}
-
-
diff --git a/src/H5A.c b/src/H5A.c
index b0d9965..8e20c02 100644
--- a/src/H5A.c
+++ b/src/H5A.c
@@ -11,85 +11,87 @@
****************************************************************************/
#ifdef RCSID
-static char RcsId[] = "@(#)$Revision$";
+static char RcsId[] = "@(#)$Revision$";
#endif
/* $Id$ */
/*
-FILE
- atom.c - Internal storage routines for handling "atoms"
-
-REMARKS
- Atoms are just ID's which allow objects (void *'s currently) to be
- bundled into "groups" for more general storage.
-
-DESIGN
- The groups are stored in an array of pointers to store each group in an
- element. Each "atomic group" node contains a link to a hash table to
- manage the atoms in each group. The allowed "atomic groups" are stored
- in an enum (called group_t) in atom.h.
-
-BUGS/LIMITATIONS
- Can't interate over the atoms in a group.
-
-LOCAL ROUTINES
- H5A_find_atom - Returns a pointer to an atom_info_t from a atom ID
- H5A_get_atom_node - Gets an atom node (uses the atom free list)
- H5A_release_atom_node - Releases an atom node (uses the atom free list)
-EXPORTED ROUTINES
- Atom Functions:
- H5Aregister_atom - Register an object in a group and get an atom for it
- H5Aatom_object - Get the object for an atom
- H5Aatom_group - Get the group for an atom
- H5Aremove_atom - Remove an atom from a group
- H5Asearch_atom - Search a group for a particular object
- H5Ais_reserved - Check whether an atom is a reserved atom in a group
- Atom Group Functions:
- H5Ainit_group - Initialize a group to store atoms in
- H5Adestroy_group - Destroy an atomic group
- Atom Group Cleanup:
- H5Ashutdown - Terminate various static buffers.
-
-AUTHOR
+ FILE
+ atom.c - Internal storage routines for handling "atoms"
+
+ REMARKS
+ Atoms are just ID's which allow objects (void *'s currently) to be
+ bundled into "groups" for more general storage.
+
+ DESIGN
+ The groups are stored in an array of pointers to store each group in an
+ element. Each "atomic group" node contains a link to a hash table to
+ manage the atoms in each group. The allowed "atomic groups" are stored
+ in an enum (called group_t) in atom.h.
+
+ BUGS/LIMITATIONS
+ Can't interate over the atoms in a group.
+
+ LOCAL ROUTINES
+ H5A_find_atom - Returns a pointer to an atom_info_t from a atom ID
+ H5A_get_atom_node - Gets an atom node (uses the atom free list)
+ H5A_release_atom_node - Releases an atom node (uses the atom free list)
+ EXPORTED ROUTINES
+ Atom Functions:
+ H5Aregister_atom - Register an object in a group and get an atom for it
+ H5Aatom_object - Get the object for an atom
+ H5Aatom_group - Get the group for an atom
+ H5Aremove_atom - Remove an atom from a group
+ H5Asearch_atom - Search a group for a particular object
+ H5Ais_reserved - Check whether an atom is a reserved atom in a group
+ Atom Group Functions:
+ H5Ainit_group - Initialize a group to store atoms in
+ H5Adestroy_group - Destroy an atomic group
+ Atom Group Cleanup:
+ H5Ashutdown - Terminate various static buffers.
+
+ AUTHOR
Quincey Koziol
-MODIFICATION HISTORY
+ MODIFICATION HISTORY
1/3/96 - Starting writing specs & coding prototype
1/7/96 - Finished coding prototype
6/10/97 - Moved into HDF5 library
-*/
+ */
#include <H5private.h>
#include <H5Aprivate.h>
#include <H5Eprivate.h>
-#define PABLO_MASK H5A_mask
-
+#define PABLO_MASK H5A_mask
/*-------------------- Locally scoped variables -----------------------------*/
#ifdef ATOMS_ARE_CACHED
/* Array of pointers to atomic groups */
-static hid_t atom_id_cache[ATOM_CACHE_SIZE]={-1,-1,-1,-1};
-static VOIDP atom_obj_cache[ATOM_CACHE_SIZE]={NULL};
+static hid_t atom_id_cache[ATOM_CACHE_SIZE] =
+{-1, -1, -1, -1};
+static VOIDP atom_obj_cache[ATOM_CACHE_SIZE] =
+{NULL};
#endif
/* Array of pointers to atomic groups */
-static atom_group_t *atom_group_list[MAXGROUP]={NULL};
+static atom_group_t *atom_group_list[MAXGROUP] =
+{NULL};
/* Pointer to the atom node free list */
-static atom_info_t *atom_free_list=NULL;
+static atom_info_t *atom_free_list = NULL;
/* Interface initialialization? */
-static hbool_t interface_initialize_g = FALSE;
+static hbool_t interface_initialize_g = FALSE;
#define INTERFACE_INIT H5A_init_interface
-static herr_t H5A_init_interface(void);
+static herr_t H5A_init_interface(void);
/*--------------------- Local function prototypes ---------------------------*/
-static atom_info_t *H5A_find_atom(hid_t atm);
-static atom_info_t *H5A_get_atom_node(void);
-static herr_t H5A_release_atom_node(atom_info_t *atm);
+static atom_info_t *H5A_find_atom(hid_t atm);
+static atom_info_t *H5A_get_atom_node(void);
+static herr_t H5A_release_atom_node(atom_info_t *atm);
/*--------------------------------------------------------------------------
NAME
@@ -101,16 +103,17 @@ RETURNS
DESCRIPTION
Initializes any interface-specific data or routines.
--------------------------------------------------------------------------*/
-static herr_t H5A_init_interface(void)
+static herr_t
+H5A_init_interface(void)
{
- herr_t ret_value = SUCCEED;
- FUNC_ENTER (H5A_init_interface, FAIL);
+ herr_t ret_value = SUCCEED;
+ FUNC_ENTER(H5A_init_interface, FAIL);
/* Registers the cleanup routine with the exit chain */
- ret_value=H5_add_exit(&H5A_term_interface);
+ ret_value = H5_add_exit(&H5A_term_interface);
FUNC_LEAVE(ret_value);
-} /* H5E_init_interface */
+} /* H5E_init_interface */
/******************************************************************************
NAME
@@ -129,76 +132,72 @@ static herr_t H5A_init_interface(void)
Returns SUCCEED if successful and FAIL otherwise
*******************************************************************************/
-intn H5Ainit_group(group_t grp, /* IN: Group to initialize */
- intn hash_size, /* IN: Minimum hash table size to use for group */
- uintn reserved, /* IN: Number of hash table entries to reserve */
- herr_t (*free_func)(void *) /* IN: Function to call when releasing ref counted objects */
+intn
+H5Ainit_group(group_t grp, /* IN: Group to initialize */
+ intn hash_size, /* IN: Minimum hash table size to use for group */
+ uintn reserved, /* IN: Number of hash table entries to reserve */
+ herr_t (*free_func) (void *) /* IN: Function to call when releasing ref counted objects */
)
{
- atom_group_t *grp_ptr=NULL; /* ptr to the atomic group */
- intn ret_value=SUCCEED;
+ atom_group_t *grp_ptr = NULL; /* ptr to the atomic group */
+ intn ret_value = SUCCEED;
- FUNC_ENTER (H5Ainit_group, FAIL);
+ FUNC_ENTER(H5Ainit_group, FAIL);
- if((grp<=BADGROUP || grp>=MAXGROUP) && hash_size>0)
+ if ((grp <= BADGROUP || grp >= MAXGROUP) && hash_size > 0)
HGOTO_DONE(FAIL);
#ifdef HASH_SIZE_POWER_2
/* If anyone knows a faster test for a power of two, please change this silly code -QAK */
- if(!(hash_size==2 || hash_size==4 || hash_size==8 || hash_size==16
- || hash_size==32 || hash_size==64 || hash_size==128 || hash_size==256
- || hash_size==512 || hash_size==1024 || hash_size==2048
- || hash_size==4096 || hash_size==8192 || hash_size==16374
- || hash_size==32768 || hash_size==65536 || hash_size==131072
- || hash_size==262144 || hash_size==524288 || hash_size==1048576
- || hash_size==2097152 || hash_size==4194304 || hash_size==8388608
- || hash_size==16777216 || hash_size==33554432 || hash_size==67108864
- || hash_size==134217728 || hash_size==268435456))
+ if (!(hash_size == 2 || hash_size == 4 || hash_size == 8 || hash_size == 16
+ || hash_size == 32 || hash_size == 64 || hash_size == 128 || hash_size == 256
+ || hash_size == 512 || hash_size == 1024 || hash_size == 2048
+ || hash_size == 4096 || hash_size == 8192 || hash_size == 16374
+ || hash_size == 32768 || hash_size == 65536 || hash_size == 131072
+ || hash_size == 262144 || hash_size == 524288 || hash_size == 1048576
+ || hash_size == 2097152 || hash_size == 4194304 || hash_size == 8388608
+ || hash_size == 16777216 || hash_size == 33554432 || hash_size == 67108864
+ || hash_size == 134217728 || hash_size == 268435456))
HGOTO_DONE(FAIL);
#endif /* HASH_SIZE_POWER_2 */
- if(atom_group_list[grp]==NULL)
- { /* Allocate the group information */
- grp_ptr=(atom_group_t *)HDcalloc(1,sizeof(atom_group_t));
- if(grp_ptr==NULL)
- HGOTO_DONE(FAIL);
- atom_group_list[grp]=grp_ptr;
- } /* end if */
- else /* Get the pointer to the existing group */
- grp_ptr=atom_group_list[grp];
-
- if(grp_ptr->count==0)
- { /* Initialize the atom group structure */
- grp_ptr->hash_size=hash_size;
- grp_ptr->reserved=reserved;
- grp_ptr->wrapped=0;
- grp_ptr->atoms=0;
- grp_ptr->nextid=reserved;
- grp_ptr->free_func=free_func;
- if((grp_ptr->atom_list=(atom_info_t **)HDcalloc(hash_size,sizeof(atom_info_t *)))==NULL)
+ if (atom_group_list[grp] == NULL) { /* Allocate the group information */
+ grp_ptr = (atom_group_t *) HDcalloc(1, sizeof(atom_group_t));
+ if (grp_ptr == NULL)
HGOTO_DONE(FAIL);
- } /* end if */
-
+ atom_group_list[grp] = grp_ptr;
+ }
+ /* end if */
+ else /* Get the pointer to the existing group */
+ grp_ptr = atom_group_list[grp];
+
+ if (grp_ptr->count == 0) { /* Initialize the atom group structure */
+ grp_ptr->hash_size = hash_size;
+ grp_ptr->reserved = reserved;
+ grp_ptr->wrapped = 0;
+ grp_ptr->atoms = 0;
+ grp_ptr->nextid = reserved;
+ grp_ptr->free_func = free_func;
+ if ((grp_ptr->atom_list = (atom_info_t **) HDcalloc(hash_size, sizeof(atom_info_t *))) == NULL)
+ HGOTO_DONE(FAIL);
+ } /* end if */
/* Increment the count of the times this group has been initialized */
grp_ptr->count++;
#ifdef QAK
-printf("%s: group ID=%d, count=%d, current # of active atoms=%d\n",FUNC,grp,grp_ptr->count,grp_ptr->atoms);
+ printf("%s: group ID=%d, count=%d, current # of active atoms=%d\n", FUNC, grp, grp_ptr->count, grp_ptr->atoms);
#endif /* QAK */
-done:
- if(ret_value == FAIL)
- { /* Error condition cleanup */
- if(grp_ptr!=NULL)
- {
- if(grp_ptr->atom_list!=NULL)
+ done:
+ if (ret_value == FAIL) { /* Error condition cleanup */
+ if (grp_ptr != NULL) {
+ if (grp_ptr->atom_list != NULL)
HDfree(grp_ptr->atom_list);
HDfree(grp_ptr);
- } /* end if */
- } /* end if */
-
+ } /* end if */
+ } /* end if */
/* Normal function cleanup */
FUNC_LEAVE(ret_value);
-} /* end H5Ainit_group() */
+} /* end H5Ainit_group() */
/******************************************************************************
NAME
@@ -214,51 +213,47 @@ done:
Returns SUCCEED if successful and FAIL otherwise
*******************************************************************************/
-intn H5Adestroy_group(group_t grp /* IN: Group to destroy */
+intn
+H5Adestroy_group(group_t grp /* IN: Group to destroy */
)
{
- atom_group_t *grp_ptr=NULL; /* ptr to the atomic group */
- intn ret_value=SUCCEED;
+ atom_group_t *grp_ptr = NULL; /* ptr to the atomic group */
+ intn ret_value = SUCCEED;
- FUNC_ENTER (H5Adestroy_group, FAIL);
+ FUNC_ENTER(H5Adestroy_group, FAIL);
- if(grp<=BADGROUP || grp>=MAXGROUP)
+ if (grp <= BADGROUP || grp >= MAXGROUP)
HGOTO_DONE(FAIL);
- grp_ptr=atom_group_list[grp];
- if(grp_ptr==NULL || grp_ptr->count<=0)
+ grp_ptr = atom_group_list[grp];
+ if (grp_ptr == NULL || grp_ptr->count <= 0)
HGOTO_DONE(FAIL);
#ifdef QAK
-printf("%s: group ID=%d, count=%d, current # of active atoms=%d\n",FUNC,grp,grp_ptr->count,grp_ptr->atoms);
+ printf("%s: group ID=%d, count=%d, current # of active atoms=%d\n", FUNC, grp, grp_ptr->count, grp_ptr->atoms);
#endif /* QAK */
/* Decrement the number of users of the atomic group */
- if((--(grp_ptr->count))==0)
- {
+ if ((--(grp_ptr->count)) == 0) {
#ifdef ATOMS_ARE_CACHED
- {
- uintn i;
-
- for(i=0; i<ATOM_CACHE_SIZE; i++)
- if(ATOM_TO_GROUP(atom_id_cache[i])==grp)
- {
- atom_id_cache[i]=(-1);
- atom_obj_cache[i]=NULL;
- } /* end if */
- } /* end block */
+ {
+ uintn i;
+
+ for (i = 0; i < ATOM_CACHE_SIZE; i++)
+ if (ATOM_TO_GROUP(atom_id_cache[i]) == grp) {
+ atom_id_cache[i] = (-1);
+ atom_obj_cache[i] = NULL;
+ } /* end if */
+ } /* end block */
#endif /* ATOMS_ARE_CACHED */
HDfree(grp_ptr->atom_list);
- } /* end if */
-
-done:
- if(ret_value == FAIL)
- { /* Error condition cleanup */
-
- } /* end if */
+ } /* end if */
+ done:
+ if (ret_value == FAIL) { /* Error condition cleanup */
+ } /* end if */
/* Normal function cleanup */
FUNC_LEAVE(ret_value);
-} /* end H5Adestroy_group() */
+} /* end H5Adestroy_group() */
/******************************************************************************
NAME
@@ -276,42 +271,43 @@ done:
Returns atom if successful and FAIL otherwise
*******************************************************************************/
-hid_t H5Aregister_atom(group_t grp, /* IN: Group to register the object in */
- const void *object /* IN: Object to attach to atom */
+hid_t
+H5Aregister_atom(group_t grp, /* IN: Group to register the object in */
+ const void *object /* IN: Object to attach to atom */
)
{
- atom_group_t *grp_ptr=NULL; /* ptr to the atomic group */
- atom_info_t *atm_ptr=NULL; /* ptr to the new atom */
- hid_t atm_id; /* new atom ID */
- uintn hash_loc; /* new item's hash table location */
- hid_t ret_value=SUCCEED;
+ atom_group_t *grp_ptr = NULL; /* ptr to the atomic group */
+ atom_info_t *atm_ptr = NULL; /* ptr to the new atom */
+ hid_t atm_id; /* new atom ID */
+ uintn hash_loc; /* new item's hash table location */
+ hid_t ret_value = SUCCEED;
- FUNC_ENTER (H5Aregister_atom, FAIL);
+ FUNC_ENTER(H5Aregister_atom, FAIL);
- if(grp<=BADGROUP || grp>=MAXGROUP)
+ if (grp <= BADGROUP || grp >= MAXGROUP)
HGOTO_DONE(FAIL);
- grp_ptr=atom_group_list[grp];
- if(grp_ptr==NULL || grp_ptr->count<=0)
+ grp_ptr = atom_group_list[grp];
+ if (grp_ptr == NULL || grp_ptr->count <= 0)
HGOTO_DONE(FAIL);
- if((atm_ptr=H5A_get_atom_node())==NULL)
+ if ((atm_ptr = H5A_get_atom_node()) == NULL)
HGOTO_DONE(FAIL);
/* Create the atom & it's ID */
- atm_id=MAKE_ATOM(grp,grp_ptr->nextid);
- atm_ptr->id=atm_id;
- atm_ptr->count=1; /* reference count all objects (even if no 'free' function defined */
- atm_ptr->obj_ptr=object;
- atm_ptr->next=NULL;
+ atm_id = MAKE_ATOM(grp, grp_ptr->nextid);
+ atm_ptr->id = atm_id;
+ atm_ptr->count = 1; /* reference count all objects (even if no 'free' function defined */
+ atm_ptr->obj_ptr = object;
+ atm_ptr->next = NULL;
/* hash bucket already full, prepend to front of chain */
- hash_loc=grp_ptr->nextid%(uintn)grp_ptr->hash_size;
- if(grp_ptr->atom_list[hash_loc]!=NULL)
- atm_ptr->next=grp_ptr->atom_list[hash_loc];
+ hash_loc = grp_ptr->nextid % (uintn) grp_ptr->hash_size;
+ if (grp_ptr->atom_list[hash_loc] != NULL)
+ atm_ptr->next = grp_ptr->atom_list[hash_loc];
/* Insert into the group */
- grp_ptr->atom_list[hash_loc]=atm_ptr;
+ grp_ptr->atom_list[hash_loc] = atm_ptr;
grp_ptr->atoms++;
grp_ptr->nextid++;
@@ -320,51 +316,45 @@ hid_t H5Aregister_atom(group_t grp, /* IN: Group to register the object in *
* wrapping around, thus necessitating checking for duplicate atoms being
* handed out.
*/
- if(grp_ptr->nextid>(uintn)ATOM_MASK || grp_ptr->wrapped!=0)
- {
- if(grp_ptr->wrapped==0)
- {
- grp_ptr->wrapped=1; /* set the "wrapped around" flag if it isn't already */
- grp_ptr->nextid=grp_ptr->reserved; /* re-start the ID counter */
- } /* end if */
+ if (grp_ptr->nextid > (uintn) ATOM_MASK || grp_ptr->wrapped != 0) {
+ if (grp_ptr->wrapped == 0) {
+ grp_ptr->wrapped = 1; /* set the "wrapped around" flag if it isn't already */
+ grp_ptr->nextid = grp_ptr->reserved; /* re-start the ID counter */
+ } /* end if */
do {
- hid_t next_atom=MAKE_ATOM(grp,grp_ptr->nextid); /* new atom to check for */
- atom_info_t *curr_atm; /* ptr to the current atom */
+ hid_t next_atom = MAKE_ATOM(grp, grp_ptr->nextid); /* new atom to check for */
+ atom_info_t *curr_atm; /* ptr to the current atom */
- curr_atm=grp_ptr->atom_list[(uintn)ATOM_TO_LOC(grp_ptr->nextid,grp_ptr->hash_size)];
- if(curr_atm==NULL) /* Ha! this is not likely... */
+ curr_atm = grp_ptr->atom_list[(uintn) ATOM_TO_LOC(grp_ptr->nextid, grp_ptr->hash_size)];
+ if (curr_atm == NULL) /* Ha! this is not likely... */
break;
- while(curr_atm!=NULL)
- {
- if(curr_atm->id==next_atom)
- break;
- curr_atm=curr_atm->next;
- } /* end while */
- if(curr_atm==NULL) /* must not have found a match */
+ while (curr_atm != NULL) {
+ if (curr_atm->id == next_atom)
+ break;
+ curr_atm = curr_atm->next;
+ } /* end while */
+ if (curr_atm == NULL) /* must not have found a match */
break;
grp_ptr->nextid++;
- } while(grp_ptr->nextid<=(uintn)ATOM_MASK);
- if(grp_ptr->nextid>(uintn)ATOM_MASK) /* All the atoms are gone! */
+ } while (grp_ptr->nextid <= (uintn) ATOM_MASK);
+ if (grp_ptr->nextid > (uintn) ATOM_MASK) /* All the atoms are gone! */
HGOTO_DONE(FAIL);
- } /* end if */
+ } /* end if */
+ ret_value = atm_id;
- ret_value=atm_id;
-
-done:
- if(ret_value == FAIL)
- { /* Error condition cleanup */
-
- } /* end if */
+ done:
+ if (ret_value == FAIL) { /* Error condition cleanup */
+ } /* end if */
/* Normal function cleanup */
FUNC_LEAVE(ret_value);
-} /* end H5Aregister_atom() */
+} /* end H5Aregister_atom() */
/******************************************************************************
NAME
H5A_inc_ref - Adds a reference to a reference counted atom.
- IN: Atom to increment reference count for
+ IN: Atom to increment reference count for
DESCRIPTION
Increments the number of references outstanding for an atom. This will
fail if the group is not a reference counted group.
@@ -374,27 +364,25 @@ done:
*******************************************************************************/
hid_t
-H5A_inc_ref (hid_t atm)
+H5A_inc_ref(hid_t atm)
{
- group_t grp = ATOM_TO_GROUP (atm); /* Group the object is in */
- atom_group_t *grp_ptr = NULL; /* ptr to the atomic group */
- atom_info_t *atm_ptr = NULL; /* ptr to the new atom */
- hid_t ret_value=FAIL;
-
- FUNC_ENTER (H5A_inc_ref, FAIL);
-
- grp_ptr = atom_group_list[grp];
- if (grp_ptr==NULL || grp_ptr->count<=0 || grp_ptr->free_func==NULL) {
- HRETURN (FAIL);
- }
+ group_t grp = ATOM_TO_GROUP(atm); /* Group the object is in */
+ atom_group_t *grp_ptr = NULL; /* ptr to the atomic group */
+ atom_info_t *atm_ptr = NULL; /* ptr to the new atom */
+ hid_t ret_value = FAIL;
- /* General lookup of the atom */
- if ((atm_ptr=H5A_find_atom(atm))!=NULL) {
- atm_ptr->count++;
- ret_value=atm;
- }
+ FUNC_ENTER(H5A_inc_ref, FAIL);
- FUNC_LEAVE (ret_value);
+ grp_ptr = atom_group_list[grp];
+ if (grp_ptr == NULL || grp_ptr->count <= 0 || grp_ptr->free_func == NULL) {
+ HRETURN(FAIL);
+ }
+ /* General lookup of the atom */
+ if ((atm_ptr = H5A_find_atom(atm)) != NULL) {
+ atm_ptr->count++;
+ ret_value = atm;
+ }
+ FUNC_LEAVE(ret_value);
}
/******************************************************************************
@@ -408,54 +396,51 @@ H5A_inc_ref (hid_t atm)
Returns object ptr if successful and NULL otherwise
*******************************************************************************/
-VOIDP H5Aatom_object(hid_t atm /* IN: Atom to retrieve object for */
+VOIDP
+H5Aatom_object(hid_t atm /* IN: Atom to retrieve object for */
)
{
#ifdef ATOMS_ARE_CACHED
- uintn i; /* local counter */
+ uintn i; /* local counter */
#endif /* ATOMS_ARE_CACHED */
- atom_info_t *atm_ptr=NULL; /* ptr to the new atom */
- VOIDP ret_value=NULL;
+ atom_info_t *atm_ptr = NULL; /* ptr to the new atom */
+ VOIDP ret_value = NULL;
- FUNC_ENTER (H5Aatom_object, NULL);
+ FUNC_ENTER(H5Aatom_object, NULL);
#ifdef ATOMS_ARE_CACHED
/* Look for the atom in the cache first */
- for(i=0; i<ATOM_CACHE_SIZE; i++)
- if(atom_id_cache[i]==atm)
- {
- ret_value=atom_obj_cache[i];
- if(i>0)
- { /* Implement a simple "move forward" caching scheme */
- hid_t t_atom=atom_id_cache[i-1];
- VOIDP t_obj=atom_obj_cache[i-1];
-
- atom_id_cache[i-1]=atom_id_cache[i];
- atom_obj_cache[i-1]=atom_obj_cache[i];
- atom_id_cache[i]=t_atom;
- atom_obj_cache[i]=t_obj;
- } /* end if */
+ for (i = 0; i < ATOM_CACHE_SIZE; i++)
+ if (atom_id_cache[i] == atm) {
+ ret_value = atom_obj_cache[i];
+ if (i > 0) { /* Implement a simple "move forward" caching scheme */
+ hid_t t_atom = atom_id_cache[i - 1];
+ VOIDP t_obj = atom_obj_cache[i - 1];
+
+ atom_id_cache[i - 1] = atom_id_cache[i];
+ atom_obj_cache[i - 1] = atom_obj_cache[i];
+ atom_id_cache[i] = t_atom;
+ atom_obj_cache[i] = t_obj;
+ } /* end if */
HGOTO_DONE(ret_value);
- } /* end if */
-#endif /* ATOMS_ARE_CACHED */
+ } /* end if */
+#endif /* ATOMS_ARE_CACHED */
/* General lookup of the atom */
- if((atm_ptr=H5A_find_atom(atm))==NULL)
+ if ((atm_ptr = H5A_find_atom(atm)) == NULL)
HGOTO_DONE(NULL);
/* Check if we've found the correct atom */
- if(atm_ptr!=NULL)
- ret_value=atm_ptr->obj_ptr;
-
-done:
- if(ret_value == NULL)
- { /* Error condition cleanup */
+ if (atm_ptr != NULL)
+ ret_value = atm_ptr->obj_ptr;
- } /* end if */
+ done:
+ if (ret_value == NULL) { /* Error condition cleanup */
+ } /* end if */
/* Normal function cleanup */
FUNC_LEAVE(ret_value);
-} /* end H5Aatom_object() */
+} /* end H5Aatom_object() */
/******************************************************************************
NAME
@@ -468,26 +453,25 @@ done:
Returns group if successful and BADGROUP otherwise
*******************************************************************************/
-group_t H5Aatom_group(hid_t atm /* IN: Atom to retrieve group for */
+group_t
+H5Aatom_group(hid_t atm /* IN: Atom to retrieve group for */
)
{
- group_t ret_value=BADGROUP;
+ group_t ret_value = BADGROUP;
- FUNC_ENTER (H5Aatom_group, FAIL);
+ FUNC_ENTER(H5Aatom_group, FAIL);
- ret_value=ATOM_TO_GROUP(atm);
- if(ret_value<=BADGROUP || ret_value>=MAXGROUP)
+ ret_value = ATOM_TO_GROUP(atm);
+ if (ret_value <= BADGROUP || ret_value >= MAXGROUP)
HGOTO_DONE(BADGROUP);
-done:
- if(ret_value == BADGROUP)
- { /* Error condition cleanup */
-
- } /* end if */
+ done:
+ if (ret_value == BADGROUP) { /* Error condition cleanup */
+ } /* end if */
/* Normal function cleanup */
FUNC_LEAVE(ret_value);
-} /* end H5Aatom_group() */
+} /* end H5Aatom_group() */
/******************************************************************************
NAME
@@ -500,79 +484,76 @@ done:
Returns atom's object if successful and NULL otherwise
*******************************************************************************/
-VOIDP H5Aremove_atom(hid_t atm /* IN: Atom to remove */
+VOIDP
+H5Aremove_atom(hid_t atm /* IN: Atom to remove */
)
{
- atom_group_t *grp_ptr=NULL; /* ptr to the atomic group */
- atom_info_t *curr_atm, /* ptr to the current atom */
- *last_atm; /* ptr to the last atom */
- group_t grp; /* atom's atomic group */
- uintn hash_loc; /* atom's hash table location */
+ atom_group_t *grp_ptr = NULL; /* ptr to the atomic group */
+ atom_info_t *curr_atm, /* ptr to the current atom */
+ *last_atm; /* ptr to the last atom */
+ group_t grp; /* atom's atomic group */
+ uintn hash_loc; /* atom's hash table location */
#ifdef ATOMS_ARE_CACHED
- uintn i; /* local counting variable */
+ uintn i; /* local counting variable */
#endif /* ATOMS_ARE_CACHED */
- VOIDP ret_value=NULL;
+ VOIDP ret_value = NULL;
- FUNC_ENTER (H5Aremove_atom, NULL);
+ FUNC_ENTER(H5Aremove_atom, NULL);
- grp=ATOM_TO_GROUP(atm);
- if(grp<=BADGROUP || grp>=MAXGROUP)
+ grp = ATOM_TO_GROUP(atm);
+ if (grp <= BADGROUP || grp >= MAXGROUP)
HGOTO_DONE(NULL);
- grp_ptr=atom_group_list[grp];
- if(grp_ptr==NULL || grp_ptr->count<=0)
+ grp_ptr = atom_group_list[grp];
+ if (grp_ptr == NULL || grp_ptr->count <= 0)
HGOTO_DONE(NULL);
/* Get the location in which the atom is located */
- hash_loc=(uintn)ATOM_TO_LOC(atm,grp_ptr->hash_size);
- curr_atm=grp_ptr->atom_list[hash_loc];
- if(curr_atm==NULL)
+ hash_loc = (uintn) ATOM_TO_LOC(atm, grp_ptr->hash_size);
+ curr_atm = grp_ptr->atom_list[hash_loc];
+ if (curr_atm == NULL)
HGOTO_DONE(NULL);
- last_atm=NULL;
- while(curr_atm!=NULL)
- {
- if(curr_atm->id==atm)
- break;
- last_atm=curr_atm;
- curr_atm=curr_atm->next;
- } /* end while */
-
- if(curr_atm!=NULL)
- {
- if(last_atm==NULL) /* atom is the first the chain */
- grp_ptr->atom_list[hash_loc]=curr_atm->next;
- else
- last_atm->next=curr_atm->next;
- ret_value=curr_atm->obj_ptr;
- H5A_release_atom_node(curr_atm);
- } /* end if */
- else /* couldn't find the atom in the proper place */
+ last_atm = NULL;
+ while (curr_atm != NULL) {
+ if (curr_atm->id == atm)
+ break;
+ last_atm = curr_atm;
+ curr_atm = curr_atm->next;
+ } /* end while */
+
+ if (curr_atm != NULL) {
+ if (last_atm == NULL) /* atom is the first the chain */
+ grp_ptr->atom_list[hash_loc] = curr_atm->next;
+ else
+ last_atm->next = curr_atm->next;
+ ret_value = curr_atm->obj_ptr;
+ H5A_release_atom_node(curr_atm);
+ }
+ /* end if */
+ else /* couldn't find the atom in the proper place */
HGOTO_DONE(NULL);
-
+
#ifdef ATOMS_ARE_CACHED
/* Delete object from cache */
- for(i=0; i<ATOM_CACHE_SIZE; i++)
- if(atom_id_cache[i]==atm)
- {
- atom_id_cache[i]=(-1);
- atom_obj_cache[i]=NULL;
- break; /* we assume there is only one instance in the cache */
- } /* end if */
-#endif /* ATOMS_ARE_CACHED */
+ for (i = 0; i < ATOM_CACHE_SIZE; i++)
+ if (atom_id_cache[i] == atm) {
+ atom_id_cache[i] = (-1);
+ atom_obj_cache[i] = NULL;
+ break; /* we assume there is only one instance in the cache */
+ } /* end if */
+#endif /* ATOMS_ARE_CACHED */
/* Decrement the number of atoms in the group */
(grp_ptr->atoms)--;
-done:
- if(ret_value == NULL)
- { /* Error condition cleanup */
-
- } /* end if */
+ done:
+ if (ret_value == NULL) { /* Error condition cleanup */
+ } /* end if */
/* Normal function cleanup */
FUNC_LEAVE(ret_value);
-} /* end H5Aremove_atom() */
+} /* end H5Aremove_atom() */
/******************************************************************************
NAME
@@ -589,35 +570,33 @@ done:
*******************************************************************************/
intn
-H5A_dec_ref (hid_t atm)
+H5A_dec_ref(hid_t atm)
{
- group_t grp = ATOM_TO_GROUP(atm); /* Group the object is in */
- atom_group_t *grp_ptr=NULL; /* ptr to the atomic group */
- atom_info_t *atm_ptr=NULL; /* ptr to the new atom */
- VOIDP obj; /* object to call 'free' function with */
- intn ret_value=FAIL;
-
- FUNC_ENTER (H5A_dec_ref, FAIL);
-
- grp_ptr = atom_group_list[grp];
- if (grp_ptr==NULL || grp_ptr->count<=0 || grp_ptr->free_func==NULL) {
- HRETURN (FAIL);
- }
-
- /* General lookup of the atom */
- if ((atm_ptr=H5A_find_atom(atm))!=NULL) {
- /* Decrement the reference count */
- atm_ptr->count--;
-
- /* If the reference count is zero, remove the object from the group */
- if (0==atm_ptr->count && (obj=H5Aremove_atom(atm))!=NULL) {
- /* call the user's 'free' function for the atom's information */
- (*grp_ptr->free_func)(obj);
- }
- ret_value=SUCCEED;
- }
-
- FUNC_LEAVE (ret_value);
+ group_t grp = ATOM_TO_GROUP(atm); /* Group the object is in */
+ atom_group_t *grp_ptr = NULL; /* ptr to the atomic group */
+ atom_info_t *atm_ptr = NULL; /* ptr to the new atom */
+ VOIDP obj; /* object to call 'free' function with */
+ intn ret_value = FAIL;
+
+ FUNC_ENTER(H5A_dec_ref, FAIL);
+
+ grp_ptr = atom_group_list[grp];
+ if (grp_ptr == NULL || grp_ptr->count <= 0 || grp_ptr->free_func == NULL) {
+ HRETURN(FAIL);
+ }
+ /* General lookup of the atom */
+ if ((atm_ptr = H5A_find_atom(atm)) != NULL) {
+ /* Decrement the reference count */
+ atm_ptr->count--;
+
+ /* If the reference count is zero, remove the object from the group */
+ if (0 == atm_ptr->count && (obj = H5Aremove_atom(atm)) != NULL) {
+ /* call the user's 'free' function for the atom's information */
+ (*grp_ptr->free_func) (obj);
+ }
+ ret_value = SUCCEED;
+ }
+ FUNC_LEAVE(ret_value);
}
/******************************************************************************
@@ -634,46 +613,43 @@ H5A_dec_ref (hid_t atm)
Returns pointer an atom's object if successful and NULL otherwise
*******************************************************************************/
-VOIDP H5Asearch_atom(group_t grp, /* IN: Group to search for the object in */
- H5Asearch_func_t func, /* IN: Ptr to the comparison function */
- const VOIDP key /* IN: pointer to key to compare against */
+VOIDP
+H5Asearch_atom(group_t grp, /* IN: Group to search for the object in */
+ H5Asearch_func_t func, /* IN: Ptr to the comparison function */
+ const VOIDP key /* IN: pointer to key to compare against */
)
{
- atom_group_t *grp_ptr=NULL; /* ptr to the atomic group */
- atom_info_t *atm_ptr=NULL; /* ptr to the new atom */
- intn i; /* local counting variable */
- VOIDP ret_value=NULL;
+ atom_group_t *grp_ptr = NULL; /* ptr to the atomic group */
+ atom_info_t *atm_ptr = NULL; /* ptr to the new atom */
+ intn i; /* local counting variable */
+ VOIDP ret_value = NULL;
- FUNC_ENTER (H5Asearch_atom, NULL);
+ FUNC_ENTER(H5Asearch_atom, NULL);
- if(grp<=BADGROUP || grp>=MAXGROUP)
+ if (grp <= BADGROUP || grp >= MAXGROUP)
HGOTO_DONE(NULL);
- grp_ptr=atom_group_list[grp];
- if(grp_ptr==NULL || grp_ptr->count<=0)
+ grp_ptr = atom_group_list[grp];
+ if (grp_ptr == NULL || grp_ptr->count <= 0)
HGOTO_DONE(NULL);
/* Start at the beginning of the array */
- for(i=0; i<grp_ptr->hash_size; i++)
- {
- atm_ptr=grp_ptr->atom_list[i];
- while(atm_ptr!=NULL)
- {
- if((*func)(atm_ptr->obj_ptr,key))
- HGOTO_DONE(atm_ptr->obj_ptr); /* found the item we are looking for */
- atm_ptr=atm_ptr->next;
- } /* end while */
- } /* end for */
-
-done:
- if(ret_value == NULL)
- { /* Error condition cleanup */
-
- } /* end if */
-
+ for (i = 0; i < grp_ptr->hash_size; i++) {
+ atm_ptr = grp_ptr->atom_list[i];
+ while (atm_ptr != NULL) {
+ if ((*func) (atm_ptr->obj_ptr, key))
+ HGOTO_DONE(atm_ptr->obj_ptr); /* found the item we are looking for */
+ atm_ptr = atm_ptr->next;
+ } /* end while */
+ } /* end for */
+
+ done:
+ if (ret_value == NULL) { /* Error condition cleanup */
+
+ } /* end if */
/* Normal function cleanup */
FUNC_LEAVE(ret_value);
-} /* end H5Asearch_atom() */
+} /* end H5Asearch_atom() */
/******************************************************************************
NAME
@@ -687,38 +663,37 @@ done:
Returns BTRUE/BFALSE/BFAIL
*******************************************************************************/
-intn H5Ais_reserved(hid_t atm /* IN: Group to search for the object in */
+intn
+H5Ais_reserved(hid_t atm /* IN: Group to search for the object in */
)
{
- atom_group_t *grp_ptr=NULL; /* ptr to the atomic group */
- group_t grp; /* atom's atomic group */
- hbool_t ret_value=BFAIL;
+ atom_group_t *grp_ptr = NULL; /* ptr to the atomic group */
+ group_t grp; /* atom's atomic group */
+ hbool_t ret_value = BFAIL;
- FUNC_ENTER (H5Ais_reserved, FAIL);
+ FUNC_ENTER(H5Ais_reserved, FAIL);
- grp=ATOM_TO_GROUP(atm);
- if(grp<=BADGROUP || grp>=MAXGROUP)
+ grp = ATOM_TO_GROUP(atm);
+ if (grp <= BADGROUP || grp >= MAXGROUP)
HGOTO_DONE(BFAIL);
- grp_ptr=atom_group_list[grp];
- if(grp_ptr==NULL)
+ grp_ptr = atom_group_list[grp];
+ if (grp_ptr == NULL)
HGOTO_DONE(BFAIL);
/* Get the location in which the atom is located */
- if((atm&ATOM_MASK)<grp_ptr->reserved)
- ret_value=BTRUE;
+ if ((atm & ATOM_MASK) < grp_ptr->reserved)
+ ret_value = BTRUE;
else
- ret_value=BFALSE;
-
-done:
- if(ret_value == BFAIL)
- { /* Error condition cleanup */
+ ret_value = BFALSE;
- } /* end if */
+ done:
+ if (ret_value == BFAIL) { /* Error condition cleanup */
+ } /* end if */
/* Normal function cleanup */
FUNC_LEAVE(ret_value);
-} /* end H5Ais_reserved() */
+} /* end H5Ais_reserved() */
/******************************************************************************
NAME
@@ -731,54 +706,51 @@ done:
Returns atom ptr if successful and NULL otherwise
*******************************************************************************/
-static atom_info_t *H5A_find_atom(hid_t atm /* IN: Atom to retrieve atom for */
+static atom_info_t *
+H5A_find_atom(hid_t atm /* IN: Atom to retrieve atom for */
)
{
- atom_group_t *grp_ptr=NULL; /* ptr to the atomic group */
- atom_info_t *atm_ptr=NULL; /* ptr to the new atom */
- group_t grp; /* atom's atomic group */
- uintn hash_loc; /* atom's hash table location */
- atom_info_t *ret_value=NULL;
+ atom_group_t *grp_ptr = NULL; /* ptr to the atomic group */
+ atom_info_t *atm_ptr = NULL; /* ptr to the new atom */
+ group_t grp; /* atom's atomic group */
+ uintn hash_loc; /* atom's hash table location */
+ atom_info_t *ret_value = NULL;
- FUNC_ENTER (H5A_find_atom, NULL);
+ FUNC_ENTER(H5A_find_atom, NULL);
- grp=ATOM_TO_GROUP(atm);
- if(grp<=BADGROUP || grp>=MAXGROUP)
+ grp = ATOM_TO_GROUP(atm);
+ if (grp <= BADGROUP || grp >= MAXGROUP)
HGOTO_DONE(NULL);
- grp_ptr=atom_group_list[grp];
- if(grp_ptr==NULL || grp_ptr->count<=0)
+ grp_ptr = atom_group_list[grp];
+ if (grp_ptr == NULL || grp_ptr->count <= 0)
HGOTO_DONE(NULL);
/* Get the location in which the atom is located */
- hash_loc=(uintn)ATOM_TO_LOC(atm,grp_ptr->hash_size);
- atm_ptr=grp_ptr->atom_list[hash_loc];
- if(atm_ptr==NULL)
+ hash_loc = (uintn) ATOM_TO_LOC(atm, grp_ptr->hash_size);
+ atm_ptr = grp_ptr->atom_list[hash_loc];
+ if (atm_ptr == NULL)
HGOTO_DONE(NULL);
- while(atm_ptr!=NULL)
- {
- if(atm_ptr->id==atm)
- break;
- atm_ptr=atm_ptr->next;
- } /* end while */
- ret_value=atm_ptr;
+ while (atm_ptr != NULL) {
+ if (atm_ptr->id == atm)
+ break;
+ atm_ptr = atm_ptr->next;
+ } /* end while */
+ ret_value = atm_ptr;
#ifdef ATOMS_ARE_CACHED
- atom_id_cache[ATOM_CACHE_SIZE-1]=atm;
- atom_obj_cache[ATOM_CACHE_SIZE-1]=atm_ptr->obj_ptr;
+ atom_id_cache[ATOM_CACHE_SIZE - 1] = atm;
+ atom_obj_cache[ATOM_CACHE_SIZE - 1] = atm_ptr->obj_ptr;
#endif /* ATOMS_ARE_CACHED */
-done:
- if(ret_value == NULL)
- { /* Error condition cleanup */
+ done:
+ if (ret_value == NULL) { /* Error condition cleanup */
- } /* end if */
-
- /* Normal function cleanup */
-
- FUNC_LEAVE (ret_value);
-} /* end H5A_find_atom() */
+ } /* end if */
+ /* Normal function cleanup */
+ FUNC_LEAVE(ret_value);
+} /* end H5A_find_atom() */
/******************************************************************************
NAME
@@ -792,33 +764,30 @@ done:
Returns atom ptr if successful and NULL otherwise
*******************************************************************************/
-static atom_info_t *H5A_get_atom_node(void)
+static atom_info_t *
+H5A_get_atom_node(void)
{
- atom_info_t *ret_value=NULL;
+ atom_info_t *ret_value = NULL;
- FUNC_ENTER (H5A_get_atom_node, NULL);
+ FUNC_ENTER(H5A_get_atom_node, NULL);
- if(atom_free_list!=NULL)
- {
- ret_value=atom_free_list;
- atom_free_list=atom_free_list->next;
- } /* end if */
- else
- {
- if((ret_value=(atom_info_t *)HDmalloc(sizeof(atom_info_t)))==NULL)
- HGOTO_DONE(NULL);
- } /* end else */
-
-done:
- if(ret_value == NULL)
- { /* Error condition cleanup */
+ if (atom_free_list != NULL) {
+ ret_value = atom_free_list;
+ atom_free_list = atom_free_list->next;
+ }
+ /* end if */
+ else {
+ if ((ret_value = (atom_info_t *) HDmalloc(sizeof(atom_info_t))) == NULL)
+ HGOTO_DONE(NULL);
+ } /* end else */
- } /* end if */
+ done:
+ if (ret_value == NULL) { /* Error condition cleanup */
- /* Normal function cleanup */
-
- FUNC_LEAVE (ret_value);
-} /* end H5A_get_atom_node() */
+ } /* end if */
+ /* Normal function cleanup */
+ FUNC_LEAVE(ret_value);
+} /* end H5A_get_atom_node() */
/******************************************************************************
NAME
@@ -834,14 +803,14 @@ done:
static herr_t
H5A_release_atom_node(atom_info_t *atm)
{
- FUNC_ENTER (H5A_release_atom_node, FAIL);
+ FUNC_ENTER(H5A_release_atom_node, FAIL);
/* Insert the atom at the beginning of the free list */
- atm->next=atom_free_list;
- atom_free_list=atm;
+ atm->next = atom_free_list;
+ atom_free_list = atm;
- FUNC_LEAVE (SUCCEED);
-} /* end H5A_release_atom_node() */
+ FUNC_LEAVE(SUCCEED);
+} /* end H5A_release_atom_node() */
/*--------------------------------------------------------------------------
NAME
@@ -860,28 +829,23 @@ H5A_release_atom_node(atom_info_t *atm)
EXAMPLES
REVISION LOG
--------------------------------------------------------------------------*/
-void H5A_term_interface(void)
+void
+H5A_term_interface(void)
{
- atom_info_t *curr;
- intn i;
+ atom_info_t *curr;
+ intn i;
/* Release the free-list if it exists */
- if(atom_free_list!=NULL)
- {
- while(atom_free_list!=NULL)
- {
- curr=atom_free_list;
- atom_free_list=atom_free_list->next;
+ if (atom_free_list != NULL) {
+ while (atom_free_list != NULL) {
+ curr = atom_free_list;
+ atom_free_list = atom_free_list->next;
HDfree(curr);
- } /* end while */
- } /* end if */
-
- for(i=0; i<(intn)MAXGROUP; i++)
- if(atom_group_list[i]!=NULL)
- {
+ } /* end while */
+ } /* end if */
+ for (i = 0; i < (intn) MAXGROUP; i++)
+ if (atom_group_list[i] != NULL) {
HDfree(atom_group_list[i]);
- atom_group_list[i]=NULL;
- } /* end if */
-
-} /* end H5A_term_interface() */
-
+ atom_group_list[i] = NULL;
+ } /* end if */
+} /* end H5A_term_interface() */
diff --git a/src/H5AC.c b/src/H5AC.c
index 8a5f4ed..42a7b9f 100644
--- a/src/H5AC.c
+++ b/src/H5AC.c
@@ -1,22 +1,22 @@
/*-------------------------------------------------------------------------
- * Copyright (C) 1997 National Center for Supercomputing Applications.
+ * Copyright (C) 1997 National Center for Supercomputing Applications.
* All rights reserved.
*
*-------------------------------------------------------------------------
*
- * Created: hdf5cache.c
- * Jul 9 1997
- * Robb Matzke <matzke@llnl.gov>
+ * Created: hdf5cache.c
+ * Jul 9 1997
+ * Robb Matzke <matzke@llnl.gov>
*
- * Purpose: Functions in this file implement a cache for
- * things which exist on disk. All "things" associated
- * with a particular HDF file share the same cache; each
- * HDF file has it's own cache.
+ * Purpose: Functions in this file implement a cache for
+ * things which exist on disk. All "things" associated
+ * with a particular HDF file share the same cache; each
+ * HDF file has it's own cache.
*
* Modifications:
*
- * Robb Matzke, 4 Aug 1997
- * Added calls to H5E.
+ * Robb Matzke, 4 Aug 1997
+ * Added calls to H5E.
*
*-------------------------------------------------------------------------
*/
@@ -34,256 +34,248 @@
/*
* Private file-scope variables.
*/
-#define PABLO_MASK H5AC_mask
-#define INTERFACE_INIT NULL
-static int interface_initialize_g = FALSE; /*initialized?*/
-
+#define PABLO_MASK H5AC_mask
+#define INTERFACE_INIT NULL
+static int interface_initialize_g = FALSE; /*initialized? */
#ifdef H5AC_SORT_BY_ADDR
-static H5AC_t *current_cache_g = NULL; /*for sorting */
+static H5AC_t *current_cache_g = NULL; /*for sorting */
#endif
-
/*-------------------------------------------------------------------------
- * Function: H5AC_create
+ * Function: H5AC_create
*
- * Purpose: Initialize the cache just after a file is opened. The
- * SIZE_HINT is the number of cache slots desired. If you
- * pass an invalid value then H5AC_NSLOTS is used. You can
- * turn off caching by using 1 for the SIZE_HINT value.
+ * Purpose: Initialize the cache just after a file is opened. The
+ * SIZE_HINT is the number of cache slots desired. If you
+ * pass an invalid value then H5AC_NSLOTS is used. You can
+ * turn off caching by using 1 for the SIZE_HINT value.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jul 9 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jul 9 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
-H5AC_create (H5F_t *f, intn size_hint)
+H5AC_create(H5F_t *f, intn size_hint)
{
- H5AC_t *cache = NULL;
- FUNC_ENTER (H5AC_create, FAIL);
+ H5AC_t *cache = NULL;
+ FUNC_ENTER(H5AC_create, FAIL);
- assert (f);
- assert (NULL==f->shared->cache);
- if (size_hint<1) size_hint = H5AC_NSLOTS;
+ assert(f);
+ assert(NULL == f->shared->cache);
+ if (size_hint < 1)
+ size_hint = H5AC_NSLOTS;
- f->shared->cache = cache = H5MM_xcalloc (1, sizeof (H5AC_t));
- cache->nslots = size_hint;
- cache->slot = H5MM_xcalloc (cache->nslots, sizeof (H5AC_slot_t));
+ f->shared->cache = cache = H5MM_xcalloc(1, sizeof(H5AC_t));
+ cache->nslots = size_hint;
+ cache->slot = H5MM_xcalloc(cache->nslots, sizeof(H5AC_slot_t));
- FUNC_LEAVE (SUCCEED);
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5AC_dest
+ * Function: H5AC_dest
*
- * Purpose: Flushes all data to disk and destroys the cache.
- * This function fails if any object are protected since the
- * resulting file might not be consistent.
+ * Purpose: Flushes all data to disk and destroys the cache.
+ * This function fails if any object are protected since the
+ * resulting file might not be consistent.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jul 9 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jul 9 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
-H5AC_dest (H5F_t *f)
+H5AC_dest(H5F_t *f)
{
- H5AC_t *cache = NULL;
- FUNC_ENTER (H5AC_dest, FAIL);
-
- assert (f);
- assert (f->shared->cache);
- cache = f->shared->cache;
-
- if (H5AC_flush (f, NULL, NO_ADDR, TRUE)<0) {
- HRETURN_ERROR (H5E_CACHE, H5E_CANTFLUSH, FAIL,
- "unable to flush cache");
- }
+ H5AC_t *cache = NULL;
+ FUNC_ENTER(H5AC_dest, FAIL);
+ assert(f);
+ assert(f->shared->cache);
+ cache = f->shared->cache;
+
+ if (H5AC_flush(f, NULL, NO_ADDR, TRUE) < 0) {
+ HRETURN_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL,
+ "unable to flush cache");
+ }
#ifdef H5AC_DEBUG
- {
- intn i;
- for (i=0; i<cache->nslots; i++) {
- cache->slot[i].prot = H5MM_xfree (cache->slot[i].prot);
- cache->slot[i].aprots = 0;
- cache->slot[i].nprots = 0;
- }
- }
+ {
+ intn i;
+ for (i = 0; i < cache->nslots; i++) {
+ cache->slot[i].prot = H5MM_xfree(cache->slot[i].prot);
+ cache->slot[i].aprots = 0;
+ cache->slot[i].nprots = 0;
+ }
+ }
#endif
- cache->slot = H5MM_xfree (cache->slot);
- cache->nslots = 0;
- f->shared->cache = cache = H5MM_xfree (cache);
- FUNC_LEAVE (SUCCEED);
+ cache->slot = H5MM_xfree(cache->slot);
+ cache->nslots = 0;
+ f->shared->cache = cache = H5MM_xfree(cache);
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5AC_find_f
+ * Function: H5AC_find_f
*
- * Purpose: Given an object type and the address at which that object
- * is located in the file, return a pointer to the object.
- * The optional UDATA1 and UDATA2 structures are passed down to
- * the function that is responsible for loading the object into
- * memory.
+ * Purpose: Given an object type and the address at which that object
+ * is located in the file, return a pointer to the object.
+ * The optional UDATA1 and UDATA2 structures are passed down to
+ * the function that is responsible for loading the object into
+ * memory.
*
- * The returned pointer is guaranteed to be valid until the next
- * call to an H5AC function (if you want a pointer which is valid
- * indefinately then see H5AC_protect()).
+ * The returned pointer is guaranteed to be valid until the next
+ * call to an H5AC function (if you want a pointer which is valid
+ * indefinately then see H5AC_protect()).
*
- * If H5AC_DEBUG is defined then this function also
- * checks that the requested object is not currently
- * protected since it is illegal to modify a protected object
- * except through the pointer returned by H5AC_protect().
+ * If H5AC_DEBUG is defined then this function also
+ * checks that the requested object is not currently
+ * protected since it is illegal to modify a protected object
+ * except through the pointer returned by H5AC_protect().
*
- * Return: Success: Pointer to the object. The pointer is
- * valid until some other cache function
- * is called.
+ * Return: Success: Pointer to the object. The pointer is
+ * valid until some other cache function
+ * is called.
*
- * Failure: NULL
+ * Failure: NULL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jul 9 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jul 9 1997
*
* Modifications:
*
- * Robb Matzke, 4 Aug 1997
- * Fails immediately if the cached object is at the correct address
- * but is of the wrong type. This happens if the caller doesn't know
- * what type of object is at the address and calls this function with
- * various type identifiers until one succeeds (cf., the debugger).
+ * Robb Matzke, 4 Aug 1997
+ * Fails immediately if the cached object is at the correct address
+ * but is of the wrong type. This happens if the caller doesn't know
+ * what type of object is at the address and calls this function with
+ * various type identifiers until one succeeds (cf., the debugger).
*
- * Robb Matzke, 30 Oct 1997
- * Keeps track of hits, misses, and flushes per object type so we have
- * some cache performance diagnostics.
+ * Robb Matzke, 30 Oct 1997
+ * Keeps track of hits, misses, and flushes per object type so we have
+ * some cache performance diagnostics.
*
*-------------------------------------------------------------------------
*/
-void *
-H5AC_find_f (H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
- const void *udata1, void *udata2)
+void *
+H5AC_find_f(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
+ const void *udata1, void *udata2)
{
- unsigned idx;
- herr_t status;
- void *thing = NULL;
- herr_t (*flush)(H5F_t*,hbool_t,const haddr_t*,void*)=NULL;
- H5AC_slot_t *slot = NULL;
- H5AC_t *cache = NULL;
-
- FUNC_ENTER (H5AC_find, NULL);
-
- assert (f);
- assert (f->shared->cache);
- assert (type);
- assert (type->load);
- assert (type->flush);
- assert (addr && H5F_addr_defined (addr));
- idx = H5AC_HASH (f, addr);
- cache = f->shared->cache;
- slot = cache->slot + idx;
-
- /*
- * Return right away if the item is in the cache.
- */
- if (slot->type==type && H5F_addr_eq (&(slot->addr), addr)) {
- cache->diagnostics[type->id].nhits++;
- HRETURN (slot->thing);
- }
- cache->diagnostics[type->id].nmisses++;
-
- /*
- * Fail if the item in the cache is at the correct address but is
- * of the wrong type.
- */
- if (slot->type && slot->type!=type && H5F_addr_eq (&(slot->addr), addr)) {
- HRETURN_ERROR (H5E_CACHE, H5E_BADTYPE, NULL,
- "internal error (correct address, wrong type)");
- }
-
+ unsigned idx;
+ herr_t status;
+ void *thing = NULL;
+ herr_t (*flush) (H5F_t *, hbool_t, const haddr_t *, void *) = NULL;
+ H5AC_slot_t *slot = NULL;
+ H5AC_t *cache = NULL;
+
+ FUNC_ENTER(H5AC_find, NULL);
+
+ assert(f);
+ assert(f->shared->cache);
+ assert(type);
+ assert(type->load);
+ assert(type->flush);
+ assert(addr && H5F_addr_defined(addr));
+ idx = H5AC_HASH(f, addr);
+ cache = f->shared->cache;
+ slot = cache->slot + idx;
+
+ /*
+ * Return right away if the item is in the cache.
+ */
+ if (slot->type == type && H5F_addr_eq(&(slot->addr), addr)) {
+ cache->diagnostics[type->id].nhits++;
+ HRETURN(slot->thing);
+ }
+ cache->diagnostics[type->id].nmisses++;
+
+ /*
+ * Fail if the item in the cache is at the correct address but is
+ * of the wrong type.
+ */
+ if (slot->type && slot->type != type && H5F_addr_eq(&(slot->addr), addr)) {
+ HRETURN_ERROR(H5E_CACHE, H5E_BADTYPE, NULL,
+ "internal error (correct address, wrong type)");
+ }
#ifdef H5AC_DEBUG
- /*
- * Check that the requested thing isn't protected, for protected things
- * can only be modified through the pointer already handed out by the
- * H5AC_protect() function.
- */
- {
- intn i;
- for (i=0; i<slot->nprots; i++) {
- assert (H5F_addr_ne (addr, &(slot->prot[i].addr)));
- }
- }
+ /*
+ * Check that the requested thing isn't protected, for protected things
+ * can only be modified through the pointer already handed out by the
+ * H5AC_protect() function.
+ */
+ {
+ intn i;
+ for (i = 0; i < slot->nprots; i++) {
+ assert(H5F_addr_ne(addr, &(slot->prot[i].addr)));
+ }
+ }
#endif
- /*
- * Load a new thing. If it can't be loaded, then return an error
- * without preempting anything.
- */
- if (NULL==(thing=(type->load)(f, addr, udata1, udata2))) {
- HRETURN_ERROR (H5E_CACHE, H5E_CANTLOAD, NULL, "unable to load object");
- }
-
- /*
- * Free the previous cache entry if there is one.
- */
- if (slot->type) {
- flush = slot->type->flush;
- status = (flush)(f, TRUE, &(slot->addr), slot->thing);
- if (status<0) {
- /*
- * The old thing could not be removed from the stack.
- * Release the new thing and fail.
- */
- if ((type->flush)(f, TRUE, addr, thing)<0) {
- HRETURN_ERROR (H5E_CACHE, H5E_CANTFLUSH, NULL,
- "unable to flush just-loaded object");
- }
- HRETURN_ERROR (H5E_CACHE, H5E_CANTFLUSH, NULL,
- "unable to flush existing cached object");
- }
- cache->diagnostics[slot->type->id].nflushes++;
- }
-
- /*
- * Make the cache point to the new thing.
- */
- slot->type = type;
- slot->addr = *addr;
- slot->thing = thing;
-
- FUNC_LEAVE (thing);
+ /*
+ * Load a new thing. If it can't be loaded, then return an error
+ * without preempting anything.
+ */
+ if (NULL == (thing = (type->load) (f, addr, udata1, udata2))) {
+ HRETURN_ERROR(H5E_CACHE, H5E_CANTLOAD, NULL, "unable to load object");
+ }
+ /*
+ * Free the previous cache entry if there is one.
+ */
+ if (slot->type) {
+ flush = slot->type->flush;
+ status = (flush) (f, TRUE, &(slot->addr), slot->thing);
+ if (status < 0) {
+ /*
+ * The old thing could not be removed from the stack.
+ * Release the new thing and fail.
+ */
+ if ((type->flush) (f, TRUE, addr, thing) < 0) {
+ HRETURN_ERROR(H5E_CACHE, H5E_CANTFLUSH, NULL,
+ "unable to flush just-loaded object");
+ }
+ HRETURN_ERROR(H5E_CACHE, H5E_CANTFLUSH, NULL,
+ "unable to flush existing cached object");
+ }
+ cache->diagnostics[slot->type->id].nflushes++;
+ }
+ /*
+ * Make the cache point to the new thing.
+ */
+ slot->type = type;
+ slot->addr = *addr;
+ slot->thing = thing;
+
+ FUNC_LEAVE(thing);
}
-
/*-------------------------------------------------------------------------
- * Function: H5AC_compare
+ * Function: H5AC_compare
*
- * Purpose: Compare two hash entries by address. Unused entries are
- * all equal to one another and greater than all used entries.
+ * Purpose: Compare two hash entries by address. Unused entries are
+ * all equal to one another and greater than all used entries.
*
- * Return: Success: -1, 0, 1
+ * Return: Success: -1, 0, 1
*
- * Failure: never fails
+ * Failure: never fails
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Aug 12 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Aug 12 1997
*
* Modifications:
*
@@ -291,545 +283,538 @@ H5AC_find_f (H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
*/
#ifdef H5AC_SORT_BY_ADDR
static int
-H5AC_compare (const void *_a, const void *_b)
+H5AC_compare(const void *_a, const void *_b)
{
- intn a = *((const intn *)_a);
- intn b = *((const intn *)_b);
-
- assert (current_cache_g);
-
- if (NULL==current_cache_g->slot[a].type) {
- if (NULL==current_cache_g->slot[b].type) {
- return 0;
- } else {
- return -1;
- }
- } else if (NULL==current_cache_g->slot[b].type) {
- return 1;
- } else if (current_cache_g->slot[a].addr < current_cache_g->slot[b].addr) {
- return -1;
- } else if (current_cache_g->slot[a].addr > current_cache_g->slot[b].addr) {
- return 1;
- }
- return 0;
+ intn a = *((const intn *) _a);
+ intn b = *((const intn *) _b);
+
+ assert(current_cache_g);
+
+ if (NULL == current_cache_g->slot[a].type) {
+ if (NULL == current_cache_g->slot[b].type) {
+ return 0;
+ } else {
+ return -1;
+ }
+ } else if (NULL == current_cache_g->slot[b].type) {
+ return 1;
+ } else if (current_cache_g->slot[a].addr < current_cache_g->slot[b].addr) {
+ return -1;
+ } else if (current_cache_g->slot[a].addr > current_cache_g->slot[b].addr) {
+ return 1;
+ }
+ return 0;
}
#endif
-
/*-------------------------------------------------------------------------
- * Function: H5AC_flush
+ * Function: H5AC_flush
*
- * Purpose: Flushes (and destroys if DESTROY is non-zero) the specified
- * entry from the cache. If the entry TYPE is CACHE_FREE and
- * ADDR is the null pointer then all types of entries are
- * flushed. If TYPE is CACHE_FREE and ADDR is non-null, then
- * whatever is cached at ADDR is flushed. Otherwise the thing
- * at ADDR is flushed if it is the correct type.
+ * Purpose: Flushes (and destroys if DESTROY is non-zero) the specified
+ * entry from the cache. If the entry TYPE is CACHE_FREE and
+ * ADDR is the null pointer then all types of entries are
+ * flushed. If TYPE is CACHE_FREE and ADDR is non-null, then
+ * whatever is cached at ADDR is flushed. Otherwise the thing
+ * at ADDR is flushed if it is the correct type.
*
- * If there are protected objects they will not be flushed.
- * However, an attempt will be made to flush all non-protected
- * items before this function returns failure.
+ * If there are protected objects they will not be flushed.
+ * However, an attempt will be made to flush all non-protected
+ * items before this function returns failure.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL if there was a request to flush all
- * items and something was protected.
+ * Failure: FAIL if there was a request to flush all
+ * items and something was protected.
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jul 9 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jul 9 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
-H5AC_flush (H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
- hbool_t destroy)
+H5AC_flush(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
+ hbool_t destroy)
{
- uintn i;
- herr_t status;
- herr_t (*flush)(H5F_t*,hbool_t,const haddr_t*,void*)=NULL;
- H5AC_slot_t *slot;
- intn *map=NULL;
- intn nslots;
- H5AC_t *cache=NULL;
+ uintn i;
+ herr_t status;
+ herr_t (*flush) (H5F_t *, hbool_t, const haddr_t *, void *) = NULL;
+ H5AC_slot_t *slot;
+ intn *map = NULL;
+ intn nslots;
+ H5AC_t *cache = NULL;
- FUNC_ENTER (H5AC_flush, FAIL);
+ FUNC_ENTER(H5AC_flush, FAIL);
- assert (f);
- assert (f->shared->cache);
- cache = f->shared->cache;
+ assert(f);
+ assert(f->shared->cache);
+ cache = f->shared->cache;
- if (!addr) {
+ if (!addr) {
#ifdef H5AC_SORT_BY_ADDR
- /*
- * Sort the cache entries by address since flushing them in
- * ascending order by address may be much more efficient.
- */
- map = H5MM_xmalloc (cache->nslots * sizeof(intn));
- for (i=nslots=0; i<cache->nslots; i++) {
- if (cache->slot[i].type) map[nslots++] = i;
- }
- assert (NULL==current_cache_g);
- current_cache_g = cache;
- HDqsort (map, nslots, sizeof(intn), H5AC_compare);
- current_cache_g = NULL;
+ /*
+ * Sort the cache entries by address since flushing them in
+ * ascending order by address may be much more efficient.
+ */
+ map = H5MM_xmalloc(cache->nslots * sizeof(intn));
+ for (i = nslots = 0; i < cache->nslots; i++) {
+ if (cache->slot[i].type)
+ map[nslots++] = i;
+ }
+ assert(NULL == current_cache_g);
+ current_cache_g = cache;
+ HDqsort(map, nslots, sizeof(intn), H5AC_compare);
+ current_cache_g = NULL;
#ifdef NDEBUG
- for (i=1; i<nslots; i++) {
- assert (H5F_addr_lt (&(cache->slot[i-1].addr),
- &(cache->slot[i].addr)));
- }
+ for (i = 1; i < nslots; i++) {
+ assert(H5F_addr_lt(&(cache->slot[i - 1].addr),
+ &(cache->slot[i].addr)));
+ }
#endif
#else
- nslots = cache->nslots;
+ nslots = cache->nslots;
#endif
- /*
- * Look at all cache entries.
- */
- for (i=0; i<nslots; i++) {
+ /*
+ * Look at all cache entries.
+ */
+ for (i = 0; i < nslots; i++) {
#ifdef H5AC_SORT_BY_ADDR
- slot = cache->slot + map[i];
- if (NULL==slot->type) break; /*the rest are empty*/
+ slot = cache->slot + map[i];
+ if (NULL == slot->type)
+ break; /*the rest are empty */
#else
- slot = cache->slot + i;
- if (NULL==slot->type) continue;
+ slot = cache->slot + i;
+ if (NULL == slot->type)
+ continue;
#endif
- if (!type || type==slot->type) {
- flush = slot->type->flush;
- status = (flush)(f, destroy, &(slot->addr), slot->thing);
- if (status<0) {
- map = H5MM_xfree (map);
- HRETURN_ERROR (H5E_CACHE, H5E_CANTFLUSH, FAIL,
- "can't flush cache");
- }
- cache->diagnostics[slot->type->id].nflushes++;
- if (destroy) slot->type = NULL;
- }
- }
- map = H5MM_xfree (map);
-
- /*
- * If there are protected object then fail. However, everything
- * else should have been flushed.
- */
- if (cache->nprots>0) {
- HRETURN_ERROR (H5E_CACHE, H5E_PROTECT, FAIL,
- "cache has protected items");
- }
-
- } else {
- i = H5AC_HASH (f, addr);
- if ((!type || cache->slot[i].type==type) &&
- H5F_addr_eq (&(cache->slot[i].addr), addr)) {
- /*
- * Flush just this entry.
- */
- flush = cache->slot[i].type->flush;
- status = (flush) (f, destroy, &(cache->slot[i].addr),
- cache->slot[i].thing);
- if (status<0) {
- HRETURN_ERROR (H5E_CACHE, H5E_CANTFLUSH, FAIL,
- "can't flush object");
- }
- cache->diagnostics[cache->slot[i].type->id].nflushes++;
- if (destroy) cache->slot[i].type = NULL;
- }
- }
-
- FUNC_LEAVE (SUCCEED);
+ if (!type || type == slot->type) {
+ flush = slot->type->flush;
+ status = (flush) (f, destroy, &(slot->addr), slot->thing);
+ if (status < 0) {
+ map = H5MM_xfree(map);
+ HRETURN_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL,
+ "can't flush cache");
+ }
+ cache->diagnostics[slot->type->id].nflushes++;
+ if (destroy)
+ slot->type = NULL;
+ }
+ }
+ map = H5MM_xfree(map);
+
+ /*
+ * If there are protected object then fail. However, everything
+ * else should have been flushed.
+ */
+ if (cache->nprots > 0) {
+ HRETURN_ERROR(H5E_CACHE, H5E_PROTECT, FAIL,
+ "cache has protected items");
+ }
+ } else {
+ i = H5AC_HASH(f, addr);
+ if ((!type || cache->slot[i].type == type) &&
+ H5F_addr_eq(&(cache->slot[i].addr), addr)) {
+ /*
+ * Flush just this entry.
+ */
+ flush = cache->slot[i].type->flush;
+ status = (flush) (f, destroy, &(cache->slot[i].addr),
+ cache->slot[i].thing);
+ if (status < 0) {
+ HRETURN_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL,
+ "can't flush object");
+ }
+ cache->diagnostics[cache->slot[i].type->id].nflushes++;
+ if (destroy)
+ cache->slot[i].type = NULL;
+ }
+ }
+
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5AC_set
+ * Function: H5AC_set
*
- * Purpose: Adds the specified thing to the cache. The thing need not
- * exist on disk yet, but it must have an address and disk
- * space reserved.
+ * Purpose: Adds the specified thing to the cache. The thing need not
+ * exist on disk yet, but it must have an address and disk
+ * space reserved.
*
- * If H5AC_DEBUG is defined then this function checks
- * that the object being inserted isn't a protected object.
+ * If H5AC_DEBUG is defined then this function checks
+ * that the object being inserted isn't a protected object.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jul 9 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jul 9 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
-H5AC_set (H5F_t *f, const H5AC_class_t *type, const haddr_t *addr, void *thing)
+H5AC_set(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr, void *thing)
{
- herr_t status;
- uintn idx;
- herr_t (*flush)(H5F_t*,hbool_t,const haddr_t*,void*)=NULL;
- H5AC_slot_t *slot = NULL;
- H5AC_t *cache=NULL;
-
- FUNC_ENTER (H5AC_set, FAIL);
-
- assert (f);
- assert (f->shared->cache);
- assert (type);
- assert (type->flush);
- assert (addr && H5F_addr_defined (addr));
- assert (thing);
- idx = H5AC_HASH (f, addr);
- cache = f->shared->cache;
- slot = cache->slot + idx;
+ herr_t status;
+ uintn idx;
+ herr_t (*flush) (H5F_t *, hbool_t, const haddr_t *, void *) = NULL;
+ H5AC_slot_t *slot = NULL;
+ H5AC_t *cache = NULL;
+
+ FUNC_ENTER(H5AC_set, FAIL);
+
+ assert(f);
+ assert(f->shared->cache);
+ assert(type);
+ assert(type->flush);
+ assert(addr && H5F_addr_defined(addr));
+ assert(thing);
+ idx = H5AC_HASH(f, addr);
+ cache = f->shared->cache;
+ slot = cache->slot + idx;
#ifdef H5AC_DEBUG
- {
- intn i;
- for (i=0; i<slot->nprots; i++) {
- assert (H5F_addr_ne (addr, &(slot->prot[i].addr)));
- }
- }
+ {
+ intn i;
+ for (i = 0; i < slot->nprots; i++) {
+ assert(H5F_addr_ne(addr, &(slot->prot[i].addr)));
+ }
+ }
#endif
-
- if (slot->type) {
- flush = slot->type->flush;
- status = (flush)(f, TRUE, &(slot->addr), slot->thing);
- if (status<0) {
- HRETURN_ERROR (H5E_CACHE, H5E_CANTFLUSH, FAIL,
- "can't flush object");
- }
- cache->diagnostics[slot->type->id].nflushes++;
- }
-
- slot->type = type;
- slot->addr = *addr;
- slot->thing = thing;
- cache->diagnostics[type->id].ninits++;
-
- FUNC_LEAVE (SUCCEED);
-}
+ if (slot->type) {
+ flush = slot->type->flush;
+ status = (flush) (f, TRUE, &(slot->addr), slot->thing);
+ if (status < 0) {
+ HRETURN_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL,
+ "can't flush object");
+ }
+ cache->diagnostics[slot->type->id].nflushes++;
+ }
+ slot->type = type;
+ slot->addr = *addr;
+ slot->thing = thing;
+ cache->diagnostics[type->id].ninits++;
+
+ FUNC_LEAVE(SUCCEED);
+}
/*-------------------------------------------------------------------------
- * Function: H5AC_rename
+ * Function: H5AC_rename
*
- * Purpose: Use this function to notify the cache that an object's
- * file address changed.
+ * Purpose: Use this function to notify the cache that an object's
+ * file address changed.
*
- * If H5AC_DEBUG is defined then this function checks
- * that the old and new addresses don't correspond to the
- * address of a protected object.
+ * If H5AC_DEBUG is defined then this function checks
+ * that the old and new addresses don't correspond to the
+ * address of a protected object.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jul 9 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jul 9 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
-H5AC_rename (H5F_t *f, const H5AC_class_t *type,
- const haddr_t *old_addr, const haddr_t *new_addr)
+H5AC_rename(H5F_t *f, const H5AC_class_t *type,
+ const haddr_t *old_addr, const haddr_t *new_addr)
{
- uintn old_idx, new_idx;
- herr_t (*flush)(H5F_t*, hbool_t, const haddr_t*, void*);
- herr_t status;
- H5AC_t *cache=NULL;
-
- FUNC_ENTER (H5AC_rename, FAIL);
-
- assert (f);
- assert (f->shared->cache);
- assert (type);
- assert (old_addr);
- assert (new_addr);
- old_idx = H5AC_HASH (f, old_addr);
- new_idx = H5AC_HASH (f, new_addr);
- cache = f->shared->cache;
+ uintn old_idx, new_idx;
+ herr_t (*flush) (H5F_t *, hbool_t, const haddr_t *, void *);
+ herr_t status;
+ H5AC_t *cache = NULL;
+
+ FUNC_ENTER(H5AC_rename, FAIL);
+
+ assert(f);
+ assert(f->shared->cache);
+ assert(type);
+ assert(old_addr);
+ assert(new_addr);
+ old_idx = H5AC_HASH(f, old_addr);
+ new_idx = H5AC_HASH(f, new_addr);
+ cache = f->shared->cache;
#ifdef H5AC_DEBUG
- {
- int i;
-
- for (i=0; i<cache->slot[old_idx].nprots; i++) {
- assert (H5F_addr_ne (old_addr, &(cache->slot[old_idx].prot[i].addr)));
- }
- for (i=0; i<cache->slot[new_idx].nprots; i++) {
- assert (H5F_addr_ne (new_addr, &(cache->slot[new_idx].prot[i].addr)));
- }
- }
+ {
+ int i;
+
+ for (i = 0; i < cache->slot[old_idx].nprots; i++) {
+ assert(H5F_addr_ne(old_addr, &(cache->slot[old_idx].prot[i].addr)));
+ }
+ for (i = 0; i < cache->slot[new_idx].nprots; i++) {
+ assert(H5F_addr_ne(new_addr, &(cache->slot[new_idx].prot[i].addr)));
+ }
+ }
#endif
-
- /*
- * We don't need to do anything if the object isn't cached or if the
- * new hash value is the same as the old one.
- */
- if (cache->slot[old_idx].type!=type ||
- H5F_addr_ne (&(cache->slot[old_idx].addr), old_addr)) {
- HRETURN (SUCCEED);
- }
- if (old_idx==new_idx) {
- cache->slot[old_idx].addr = *new_addr;
- HRETURN (SUCCEED);
- }
-
- /*
- * Free the item from the destination cache line.
- */
- if (cache->slot[new_idx].type) {
- flush = cache->slot[new_idx].type->flush;
- status = (flush)(f, TRUE, &(cache->slot[new_idx].addr),
- cache->slot[new_idx].thing);
- if (status<0) {
- HRETURN_ERROR (H5E_CACHE, H5E_CANTFLUSH, FAIL,
- "can't flush object");
- }
- cache->diagnostics[cache->slot[new_idx].type->id].nflushes++;
- }
-
- /*
- * Move the source to the destination (it might not be cached)
- */
- cache->slot[new_idx].type = cache->slot[old_idx].type;
- cache->slot[new_idx].addr = *new_addr;
- cache->slot[new_idx].thing = cache->slot[old_idx].thing;
- cache->slot[old_idx].type = NULL;
-
- FUNC_LEAVE (SUCCEED);
-}
+ /*
+ * We don't need to do anything if the object isn't cached or if the
+ * new hash value is the same as the old one.
+ */
+ if (cache->slot[old_idx].type != type ||
+ H5F_addr_ne(&(cache->slot[old_idx].addr), old_addr)) {
+ HRETURN(SUCCEED);
+ }
+ if (old_idx == new_idx) {
+ cache->slot[old_idx].addr = *new_addr;
+ HRETURN(SUCCEED);
+ }
+ /*
+ * Free the item from the destination cache line.
+ */
+ if (cache->slot[new_idx].type) {
+ flush = cache->slot[new_idx].type->flush;
+ status = (flush) (f, TRUE, &(cache->slot[new_idx].addr),
+ cache->slot[new_idx].thing);
+ if (status < 0) {
+ HRETURN_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL,
+ "can't flush object");
+ }
+ cache->diagnostics[cache->slot[new_idx].type->id].nflushes++;
+ }
+ /*
+ * Move the source to the destination (it might not be cached)
+ */
+ cache->slot[new_idx].type = cache->slot[old_idx].type;
+ cache->slot[new_idx].addr = *new_addr;
+ cache->slot[new_idx].thing = cache->slot[old_idx].thing;
+ cache->slot[old_idx].type = NULL;
+
+ FUNC_LEAVE(SUCCEED);
+}
/*-------------------------------------------------------------------------
- * Function: H5AC_protect
+ * Function: H5AC_protect
*
- * Purpose: Similar to H5AC_find() except the object is removed from
- * the cache and given to the caller, preventing other parts
- * of the program from modifying the protected object or
- * preempting it from the cache.
+ * Purpose: Similar to H5AC_find() except the object is removed from
+ * the cache and given to the caller, preventing other parts
+ * of the program from modifying the protected object or
+ * preempting it from the cache.
*
- * The caller must call H5AC_unprotect() when finished with
- * the pointer.
+ * The caller must call H5AC_unprotect() when finished with
+ * the pointer.
*
- * If H5AC_DEBUG is defined then we check that the
- * requested object isn't already protected.
+ * If H5AC_DEBUG is defined then we check that the
+ * requested object isn't already protected.
*
- * Return: Success: Ptr to the object.
+ * Return: Success: Ptr to the object.
*
- * Failure: NULL
+ * Failure: NULL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Sep 2 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Sep 2 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-void *
-H5AC_protect (H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
- const void *udata1, void *udata2)
+void *
+H5AC_protect(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
+ const void *udata1, void *udata2)
{
- int idx;
- void *thing = NULL;
- H5AC_t *cache = NULL;
- H5AC_slot_t *slot = NULL;
+ int idx;
+ void *thing = NULL;
+ H5AC_t *cache = NULL;
+ H5AC_slot_t *slot = NULL;
#ifdef H5AC_DEBUG
- static ncalls = 0;
- if (0==ncalls++) {
- fprintf (stderr, "HDF5-DIAG: debugging cache (expensive)\n");
- }
+ static ncalls = 0;
+ if (0 == ncalls++) {
+ fprintf(stderr, "HDF5-DIAG: debugging cache (expensive)\n");
+ }
#endif
-
- FUNC_ENTER (H5AC_protect, NULL);
-
- /* check args */
- assert (f);
- assert (f->shared->cache);
- assert (type);
- assert (type->load);
- assert (type->flush);
- assert (addr && H5F_addr_defined (addr));
- idx = H5AC_HASH (f, addr);
- cache = f->shared->cache;
- slot = cache->slot+idx;
-
- if (slot->type==type && H5F_addr_eq (&(slot->addr), addr)) {
- /*
- * The object is already cached; simply remove it from the cache.
- */
- cache->diagnostics[slot->type->id].nhits++;
- thing = slot->thing;
- slot->type = NULL;
- H5F_addr_undef (&(slot->addr));
- slot->thing = NULL;
-
- } else if (slot->type && H5F_addr_eq (&(slot->addr), addr)) {
- /*
- * Right address but wrong object type.
- */
- HRETURN_ERROR (H5E_CACHE, H5E_BADTYPE, NULL,
- "internal error");
-
- } else {
+
+ FUNC_ENTER(H5AC_protect, NULL);
+
+ /* check args */
+ assert(f);
+ assert(f->shared->cache);
+ assert(type);
+ assert(type->load);
+ assert(type->flush);
+ assert(addr && H5F_addr_defined(addr));
+ idx = H5AC_HASH(f, addr);
+ cache = f->shared->cache;
+ slot = cache->slot + idx;
+
+ if (slot->type == type && H5F_addr_eq(&(slot->addr), addr)) {
+ /*
+ * The object is already cached; simply remove it from the cache.
+ */
+ cache->diagnostics[slot->type->id].nhits++;
+ thing = slot->thing;
+ slot->type = NULL;
+ H5F_addr_undef(&(slot->addr));
+ slot->thing = NULL;
+
+ } else if (slot->type && H5F_addr_eq(&(slot->addr), addr)) {
+ /*
+ * Right address but wrong object type.
+ */
+ HRETURN_ERROR(H5E_CACHE, H5E_BADTYPE, NULL,
+ "internal error");
+
+ } else {
#ifdef H5AC_DEBUG
- /*
- * Check that the requested thing isn't protected, for protected things
- * can only be modified through the pointer already handed out by the
- * H5AC_protect() function.
- */
- intn i;
- for (i=0; i<slot->nprots; i++) {
- assert (H5F_addr_ne (addr, &(slot->prot[i].addr)));
- }
+ /*
+ * Check that the requested thing isn't protected, for protected things
+ * can only be modified through the pointer already handed out by the
+ * H5AC_protect() function.
+ */
+ intn i;
+ for (i = 0; i < slot->nprots; i++) {
+ assert(H5F_addr_ne(addr, &(slot->prot[i].addr)));
+ }
#endif
- /*
- * Load a new thing. If it can't be loaded, then return an error
- * without preempting anything.
- */
- cache->diagnostics[type->id].nmisses++;
- if (NULL==(thing=(type->load)(f, addr, udata1, udata2))) {
- HRETURN_ERROR (H5E_CACHE, H5E_CANTLOAD, NULL,
- "can't load object");
- }
- }
+ /*
+ * Load a new thing. If it can't be loaded, then return an error
+ * without preempting anything.
+ */
+ cache->diagnostics[type->id].nmisses++;
+ if (NULL == (thing = (type->load) (f, addr, udata1, udata2))) {
+ HRETURN_ERROR(H5E_CACHE, H5E_CANTLOAD, NULL,
+ "can't load object");
+ }
+ }
#ifdef H5AC_DEBUG
- /*
- * Add the protected object to the protect debugging fields of the
- * cache.
- */
- if (slot->nprots>=slot->aprots) {
- slot->aprots += 10;
- slot->prot = H5MM_xrealloc (slot->prot,
- slot->aprots * sizeof(H5AC_prot_t));
- }
- slot->prot[slot->nprots].type = type;
- slot->prot[slot->nprots].addr = *addr;
- slot->prot[slot->nprots].thing = thing;
- slot->nprots += 1;
+ /*
+ * Add the protected object to the protect debugging fields of the
+ * cache.
+ */
+ if (slot->nprots >= slot->aprots) {
+ slot->aprots += 10;
+ slot->prot = H5MM_xrealloc(slot->prot,
+ slot->aprots * sizeof(H5AC_prot_t));
+ }
+ slot->prot[slot->nprots].type = type;
+ slot->prot[slot->nprots].addr = *addr;
+ slot->prot[slot->nprots].thing = thing;
+ slot->nprots += 1;
#endif
- cache->nprots += 1;
- FUNC_LEAVE (thing);
+ cache->nprots += 1;
+ FUNC_LEAVE(thing);
}
-
/*-------------------------------------------------------------------------
- * Function: H5AC_unprotect
+ * Function: H5AC_unprotect
*
- * Purpose: This function should be called to undo the effect of
- * H5AC_protect(). The TYPE and ADDR arguments should be the
- * same as the corresponding call to H5AC_protect() and the
- * THING argument should be the value returned by H5AC_protect().
+ * Purpose: This function should be called to undo the effect of
+ * H5AC_protect(). The TYPE and ADDR arguments should be the
+ * same as the corresponding call to H5AC_protect() and the
+ * THING argument should be the value returned by H5AC_protect().
*
- * If H5AC_DEBUG is defined then this function fails
- * if the TYPE and ADDR arguments are not what was used when the
- * object was protected or if the object was never protected.
+ * If H5AC_DEBUG is defined then this function fails
+ * if the TYPE and ADDR arguments are not what was used when the
+ * object was protected or if the object was never protected.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Sep 2 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Sep 2 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
-H5AC_unprotect (H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
- void *thing)
+H5AC_unprotect(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
+ void *thing)
{
- herr_t status;
- uintn idx;
- herr_t (*flush)(H5F_t*,hbool_t,const haddr_t*,void*)=NULL;
- H5AC_t *cache = NULL;
- H5AC_slot_t *slot = NULL;
-
- FUNC_ENTER (H5AC_unprotect, FAIL);
-
- /* check args */
- assert (f);
- assert (f->shared->cache);
- assert (type);
- assert (type->flush);
- assert (addr && H5F_addr_defined (addr));
- assert (thing);
- idx = H5AC_HASH (f, addr);
- cache = f->shared->cache;
- slot = cache->slot + idx;
-
- /*
- * Flush any object already in the cache at that location. It had
- * better not be another copy of the protected object.
- */
- if (slot->type) {
- assert (H5F_addr_ne (&(slot->addr), addr));
- flush = slot->type->flush;
- status = (flush)(f, TRUE, &(slot->addr), slot->thing);
- if (status<0) {
- HRETURN_ERROR (H5E_CACHE, H5E_CANTFLUSH, FAIL,
- "can't flush object");
- }
- cache->diagnostics[slot->type->id].nflushes++;
- }
-
+ herr_t status;
+ uintn idx;
+ herr_t (*flush) (H5F_t *, hbool_t, const haddr_t *, void *) = NULL;
+ H5AC_t *cache = NULL;
+ H5AC_slot_t *slot = NULL;
+
+ FUNC_ENTER(H5AC_unprotect, FAIL);
+
+ /* check args */
+ assert(f);
+ assert(f->shared->cache);
+ assert(type);
+ assert(type->flush);
+ assert(addr && H5F_addr_defined(addr));
+ assert(thing);
+ idx = H5AC_HASH(f, addr);
+ cache = f->shared->cache;
+ slot = cache->slot + idx;
+
+ /*
+ * Flush any object already in the cache at that location. It had
+ * better not be another copy of the protected object.
+ */
+ if (slot->type) {
+ assert(H5F_addr_ne(&(slot->addr), addr));
+ flush = slot->type->flush;
+ status = (flush) (f, TRUE, &(slot->addr), slot->thing);
+ if (status < 0) {
+ HRETURN_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL,
+ "can't flush object");
+ }
+ cache->diagnostics[slot->type->id].nflushes++;
+ }
#ifdef H5AC_DEBUG
- /*
- * Remove the object's protect data to indicate that it is no longer
- * protected.
- */
- {
- int found, i;
- for (i=0,found=FALSE; i<slot->nprots && !found; i++) {
- if (H5F_addr_eq (addr, &(slot->prot[i].addr))) {
- assert (slot->prot[i].type==type);
- HDmemmove (slot->prot+i, slot->prot+i+1,
- ((slot->nprots-i)-1) * sizeof(H5AC_prot_t));
- slot->nprots -= 1;
- found = TRUE;
- }
- }
- assert (found);
- }
+ /*
+ * Remove the object's protect data to indicate that it is no longer
+ * protected.
+ */
+ {
+ int found, i;
+ for (i = 0, found = FALSE; i < slot->nprots && !found; i++) {
+ if (H5F_addr_eq(addr, &(slot->prot[i].addr))) {
+ assert(slot->prot[i].type == type);
+ HDmemmove(slot->prot + i, slot->prot + i + 1,
+ ((slot->nprots - i) - 1) * sizeof(H5AC_prot_t));
+ slot->nprots -= 1;
+ found = TRUE;
+ }
+ }
+ assert(found);
+ }
#endif
- /*
- * Insert the object back into the cache; it is no longer protected.
- */
- slot->type = type;
- slot->addr = *addr;
- slot->thing = thing;
- cache->nprots -= 1;
+ /*
+ * Insert the object back into the cache; it is no longer protected.
+ */
+ slot->type = type;
+ slot->addr = *addr;
+ slot->thing = thing;
+ cache->nprots -= 1;
- FUNC_LEAVE (SUCCEED);
+ FUNC_LEAVE(SUCCEED);
}
-
-
/*-------------------------------------------------------------------------
- * Function: H5AC_debug
+ * Function: H5AC_debug
*
- * Purpose: Prints debugging info about the cache.
+ * Purpose: Prints debugging info about the cache.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Thursday, October 30, 1997
*
* Modifications:
@@ -837,57 +822,57 @@ H5AC_unprotect (H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
*-------------------------------------------------------------------------
*/
herr_t
-H5AC_debug (H5F_t *f)
+H5AC_debug(H5F_t *f)
{
- H5AC_subid_t i;
- char s[32], ascii[32];
- H5AC_t *cache = f->shared->cache;
- double miss_rate;
-
- FUNC_ENTER (H5AC_debug, FAIL);
-
- fprintf (stderr, "HDF5-DIAG: cache diagnostics for %s\n", f->name);
- fprintf (stderr, " %18s %8s %8s %8s %8s+%-8s\n",
- "", "Hits", "Misses", "MissRate", "Inits", "Flushes");
-
- for (i=0; i<H5AC_NTYPES; i++) {
-
- switch (i) {
- case H5AC_BT_ID:
- strcpy (s, "B-tree nodes");
- break;
- case H5AC_SNODE_ID:
- strcpy (s, "symbol table nodes");
- break;
- case H5AC_HEAP_ID:
- strcpy (s, "heaps");
- break;
- case H5AC_OHDR_ID:
- strcpy (s, "object headers");
- break;
- default:
- sprintf (s, "unknown id %d", i);
- }
-
- if (cache->diagnostics[i].nhits) {
- miss_rate = 100.0 * cache->diagnostics[i].nmisses /
- cache->diagnostics[i].nhits;
- } else {
- miss_rate = 0.0;
- }
-
- if (miss_rate>100) {
- sprintf (ascii, "%7d%%", (int)(miss_rate+0.5));
- } else {
- sprintf (ascii, "%7.2f%%", miss_rate);
- }
- fprintf (stderr, " %18s: %8d %8d %7s %8d%+-9d\n", s,
- cache->diagnostics[i].nhits,
- cache->diagnostics[i].nmisses,
- ascii,
- cache->diagnostics[i].ninits,
- cache->diagnostics[i].nflushes-cache->diagnostics[i].ninits);
- }
-
- FUNC_LEAVE (SUCCEED);
+ H5AC_subid_t i;
+ char s[32], ascii[32];
+ H5AC_t *cache = f->shared->cache;
+ double miss_rate;
+
+ FUNC_ENTER(H5AC_debug, FAIL);
+
+ fprintf(stderr, "HDF5-DIAG: cache diagnostics for %s\n", f->name);
+ fprintf(stderr, " %18s %8s %8s %8s %8s+%-8s\n",
+ "", "Hits", "Misses", "MissRate", "Inits", "Flushes");
+
+ for (i = 0; i < H5AC_NTYPES; i++) {
+
+ switch (i) {
+ case H5AC_BT_ID:
+ strcpy(s, "B-tree nodes");
+ break;
+ case H5AC_SNODE_ID:
+ strcpy(s, "symbol table nodes");
+ break;
+ case H5AC_HEAP_ID:
+ strcpy(s, "heaps");
+ break;
+ case H5AC_OHDR_ID:
+ strcpy(s, "object headers");
+ break;
+ default:
+ sprintf(s, "unknown id %d", i);
+ }
+
+ if (cache->diagnostics[i].nhits) {
+ miss_rate = 100.0 * cache->diagnostics[i].nmisses /
+ cache->diagnostics[i].nhits;
+ } else {
+ miss_rate = 0.0;
+ }
+
+ if (miss_rate > 100) {
+ sprintf(ascii, "%7d%%", (int) (miss_rate + 0.5));
+ } else {
+ sprintf(ascii, "%7.2f%%", miss_rate);
+ }
+ fprintf(stderr, " %18s: %8d %8d %7s %8d%+-9d\n", s,
+ cache->diagnostics[i].nhits,
+ cache->diagnostics[i].nmisses,
+ ascii,
+ cache->diagnostics[i].ninits,
+ cache->diagnostics[i].nflushes - cache->diagnostics[i].ninits);
+ }
+
+ FUNC_LEAVE(SUCCEED);
}
diff --git a/src/H5ACprivate.h b/src/H5ACprivate.h
index 075966f..50df708 100644
--- a/src/H5ACprivate.h
+++ b/src/H5ACprivate.h
@@ -1,23 +1,23 @@
/*-------------------------------------------------------------------------
- * Copyright (C) 1997 National Center for Supercomputing Applications.
+ * Copyright (C) 1997 National Center for Supercomputing Applications.
* All rights reserved.
*
*-------------------------------------------------------------------------
*
- * Created: H5ACprivate.h
- * Jul 9 1997
- * Robb Matzke <matzke@llnl.gov>
+ * Created: H5ACprivate.h
+ * Jul 9 1997
+ * Robb Matzke <matzke@llnl.gov>
*
- * Purpose: Constants and typedefs available to the rest of the
- * library.
+ * Purpose: Constants and typedefs available to the rest of the
+ * library.
*
- * Modifications:
+ * Modifications:
*
*-------------------------------------------------------------------------
*/
#ifndef _H5ACprivate_H
#define _H5ACprivate_H
-#include <H5ACpublic.h> /*public prototypes */
+#include <H5ACpublic.h> /*public prototypes */
/* Pivate headers needed by this header */
#include <H5private.h>
@@ -25,9 +25,9 @@
/*
* Feature: Define H5AC_DEBUG on the compiler command line if you want to
- * debug H5AC_protect() and H5AC_unprotect() by insuring that
- * nothing accesses protected objects. NDEBUG must not be defined
- * in order for this to have any effect.
+ * debug H5AC_protect() and H5AC_unprotect() by insuring that
+ * nothing accesses protected objects. NDEBUG must not be defined
+ * in order for this to have any effect.
*/
#ifdef NDEBUG
# undef H5AC_DEBUG
@@ -39,29 +39,29 @@
* to cache the object. That variable will be of type H5AC_class_t and
* have the following required fields...
*
- * LOAD: Loads an object from disk to memory. The function
- * should allocate some data structure and return it.
+ * LOAD: Loads an object from disk to memory. The function
+ * should allocate some data structure and return it.
*
- * FLUSH: Writes some data structure back to disk. It would be
- * wise for the data structure to include dirty flags to
- * indicate whether it really needs to be written. This
- * function is also responsible for freeing memory allocated
- * by the LOAD method if the DEST argument is non-zero.
+ * FLUSH: Writes some data structure back to disk. It would be
+ * wise for the data structure to include dirty flags to
+ * indicate whether it really needs to be written. This
+ * function is also responsible for freeing memory allocated
+ * by the LOAD method if the DEST argument is non-zero.
*/
typedef enum H5AC_subid_t {
- H5AC_BT_ID =0, /*B-tree nodes */
- H5AC_SNODE_ID =1, /*symbol table nodes */
- H5AC_HEAP_ID =2, /*object or name heap */
- H5AC_OHDR_ID =3, /*object header */
- H5AC_NTYPES =4 /*THIS MUST BE LAST!*/
+ H5AC_BT_ID = 0, /*B-tree nodes */
+ H5AC_SNODE_ID = 1, /*symbol table nodes */
+ H5AC_HEAP_ID = 2, /*object or name heap */
+ H5AC_OHDR_ID = 3, /*object header */
+ H5AC_NTYPES = 4 /*THIS MUST BE LAST! */
} H5AC_subid_t;
typedef struct H5AC_class_t {
- H5AC_subid_t id;
- void *(*load)(H5F_t*, const haddr_t *addr, const void *udata1,
- void *udata2);
- herr_t (*flush)(H5F_t*, hbool_t dest, const haddr_t *addr,
- void *thing);
+ H5AC_subid_t id;
+ void *(*load) (H5F_t *, const haddr_t *addr, const void *udata1,
+ void *udata2);
+ herr_t (*flush) (H5F_t *, hbool_t dest, const haddr_t *addr,
+ void *thing);
} H5AC_class_t;
/*
@@ -69,64 +69,63 @@ typedef struct H5AC_class_t {
* cache entry by hashing the object's file address. Each file has its
* own cache, an array of slots.
*/
-#define H5AC_NSLOTS 10330 /*prime number tend to work best */
+#define H5AC_NSLOTS 10330 /*prime number tend to work best */
#define H5AC_HASH(F,ADDR_P) H5F_addr_hash(ADDR_P,(F)->shared->cache->nslots)
typedef struct H5AC_prot_t {
- const H5AC_class_t *type; /*type of protected thing */
- haddr_t addr; /*address of protected thing */
- void *thing; /*(possible) protected thing */
+ const H5AC_class_t *type; /*type of protected thing */
+ haddr_t addr; /*address of protected thing */
+ void *thing; /*(possible) protected thing */
} H5AC_prot_t;
typedef struct H5AC_slot_t {
- const H5AC_class_t *type; /*type of object stored here */
- haddr_t addr; /*file address for object */
- void *thing; /*the thing which is cached */
+ const H5AC_class_t *type; /*type of object stored here */
+ haddr_t addr; /*file address for object */
+ void *thing; /*the thing which is cached */
#ifdef H5AC_DEBUG
- intn nprots; /*number of things protected */
- intn aprots; /*nelmts of `prot' array */
- H5AC_prot_t *prot; /*array of protected things */
+ intn nprots; /*number of things protected */
+ intn aprots; /*nelmts of `prot' array */
+ H5AC_prot_t *prot; /*array of protected things */
#endif
} H5AC_slot_t;
typedef struct H5AC_t {
- intn nslots; /*number of cache slots */
- H5AC_slot_t *slot; /*the cache slots */
- intn nprots; /*number of protected objects */
- struct {
- uintn nhits; /*number of cache hits */
- uintn nmisses; /*number of cache misses */
- uintn ninits; /*number of cache initializations */
- uintn nflushes; /*number of flushes to disk */
- } diagnostics[H5AC_NTYPES]; /*diagnostics for each type of object */
+ intn nslots; /*number of cache slots */
+ H5AC_slot_t *slot; /*the cache slots */
+ intn nprots; /*number of protected objects */
+ struct {
+ uintn nhits; /*number of cache hits */
+ uintn nmisses; /*number of cache misses */
+ uintn ninits; /*number of cache initializations */
+ uintn nflushes; /*number of flushes to disk */
+ } diagnostics[H5AC_NTYPES]; /*diagnostics for each type of object */
} H5AC_t;
/*
* Library prototypes.
*/
-herr_t H5AC_dest (H5F_t *f);
-void *H5AC_find_f (H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
- const void *udata1, void *udata2);
-void * H5AC_protect (H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
- const void *udata1, void *udata2);
-herr_t H5AC_unprotect (H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
- void *thing);
-herr_t H5AC_flush (H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
- hbool_t destroy);
-herr_t H5AC_create (H5F_t *f, intn size_hint);
-herr_t H5AC_rename (H5F_t *f, const H5AC_class_t *type,
- const haddr_t *old_addr, const haddr_t *new_addr);
-herr_t H5AC_set (H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
- void *thing);
-herr_t H5AC_debug (H5F_t *f);
+herr_t H5AC_dest(H5F_t *f);
+void *H5AC_find_f(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
+ const void *udata1, void *udata2);
+void *H5AC_protect(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
+ const void *udata1, void *udata2);
+herr_t H5AC_unprotect(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
+ void *thing);
+herr_t H5AC_flush(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
+ hbool_t destroy);
+herr_t H5AC_create(H5F_t *f, intn size_hint);
+herr_t H5AC_rename(H5F_t *f, const H5AC_class_t *type,
+ const haddr_t *old_addr, const haddr_t *new_addr);
+herr_t H5AC_set(H5F_t *f, const H5AC_class_t *type, const haddr_t *addr,
+ void *thing);
+herr_t H5AC_debug(H5F_t *f);
-#define H5AC_find(F,TYPE,ADDR_P,UDATA1,UDATA2) \
- (((F)->shared->cache->slot[H5AC_HASH(F,ADDR_P)].type==(TYPE) && \
+#define H5AC_find(F,TYPE,ADDR_P,UDATA1,UDATA2) \
+ (((F)->shared->cache->slot[H5AC_HASH(F,ADDR_P)].type==(TYPE) && \
H5F_addr_eq (&((F)->shared->cache->slot[H5AC_HASH(F,ADDR_P)].addr), \
- ADDR_P)) ? \
- ((F)->shared->cache->diagnostics[(TYPE)->id].nhits++, \
- (F)->shared->cache->slot[H5AC_HASH(F,ADDR_P)].thing) : \
+ ADDR_P)) ? \
+ ((F)->shared->cache->diagnostics[(TYPE)->id].nhits++, \
+ (F)->shared->cache->slot[H5AC_HASH(F,ADDR_P)].thing) : \
H5AC_find_f (F, TYPE, ADDR_P, UDATA1, UDATA2))
-
#endif /* !_H5ACprivate_H */
diff --git a/src/H5ACpublic.h b/src/H5ACpublic.h
index fb20c6d..b827139 100644
--- a/src/H5ACpublic.h
+++ b/src/H5ACpublic.h
@@ -1,16 +1,16 @@
/*-------------------------------------------------------------------------
- * Copyright (C) 1997 National Center for Supercomputing Applications.
+ * Copyright (C) 1997 National Center for Supercomputing Applications.
* All rights reserved.
*
*-------------------------------------------------------------------------
*
- * Created: H5ACproto.h
- * Jul 10 1997
- * Robb Matzke <matzke@llnl.gov>
+ * Created: H5ACproto.h
+ * Jul 10 1997
+ * Robb Matzke <matzke@llnl.gov>
*
- * Purpose: Public include file for cache functions.
+ * Purpose: Public include file for cache functions.
*
- * Modifications:
+ * Modifications:
*
*-------------------------------------------------------------------------
*/
@@ -21,11 +21,11 @@
#include <H5public.h>
#ifdef __cplusplus
-extern "C" {
+extern "C" {
#endif
#ifdef __cplusplus
}
-#endif
#endif
+#endif
diff --git a/src/H5Aprivate.h b/src/H5Aprivate.h
index 916ed89..5788944 100644
--- a/src/H5Aprivate.h
+++ b/src/H5Aprivate.h
@@ -20,7 +20,7 @@
/* avoid re-inclusion */
#ifndef _H5Aprivate_H
#define _H5Aprivate_H
-#include <H5Apublic.h> /* Include Public Definitions */
+#include <H5Apublic.h> /* Include Public Definitions */
/* Private headers needed by this file */
#include <H5private.h>
@@ -37,7 +37,7 @@
#define ATOMS_ARE_CACHED
#ifdef ATOMS_ARE_CACHED
-# define ATOM_CACHE_SIZE 4 /* # of previous atoms cached */
+# define ATOM_CACHE_SIZE 4 /* # of previous atoms cached */
#endif
/* Map an atom to a Group number */
@@ -57,37 +57,36 @@
#endif
/* Default sizes of the hash-tables for various atom groups */
-#define H5A_ERRSTACK_HASHSIZE 64
-#define H5A_FILEID_HASHSIZE 64
-#define H5A_TEMPID_HASHSIZE 64
-#define H5A_DATATYPEID_HASHSIZE 64
+#define H5A_ERRSTACK_HASHSIZE 64
+#define H5A_FILEID_HASHSIZE 64
+#define H5A_TEMPID_HASHSIZE 64
+#define H5A_DATATYPEID_HASHSIZE 64
#define H5A_DATASPACEID_HASHSIZE 64
-#define H5A_DATASETID_HASHSIZE 64
-#define H5A_OID_HASHSIZE 64
-#define H5A_GROUPID_HASHSIZE 64
+#define H5A_DATASETID_HASHSIZE 64
+#define H5A_OID_HASHSIZE 64
+#define H5A_GROUPID_HASHSIZE 64
/* Atom information structure used */
typedef struct atom_info_struct_tag {
- hid_t id; /* atom ID for this info */
- uintn count; /* ref. count for this atom */
- VOIDP *obj_ptr; /* pointer associated with the atom */
- struct atom_info_struct_tag *next; /* link to next atom (in case of hash-clash) */
- }atom_info_t;
+ hid_t id; /* atom ID for this info */
+ uintn count; /* ref. count for this atom */
+ VOIDP *obj_ptr; /* pointer associated with the atom */
+ struct atom_info_struct_tag *next; /* link to next atom (in case of hash-clash) */
+} atom_info_t;
/* Atom group structure used */
typedef struct atom_group_struct_tag {
- uintn count; /* # of times this group has been initialized */
- uintn reserved; /* # of atoms to reserve for constant atoms */
- uintn wrapped; /* whether the id count has wrapped around */
- intn hash_size; /* size of the hash table to store the atoms in */
- uintn atoms; /* current number of atoms held */
- uintn nextid; /* atom ID to use for the next atom */
- herr_t (*free_func)(void *); /* Pointer to function to call when releasing ref counted object */
- atom_info_t **atom_list;/* pointer to an array of ptrs to atoms */
- }atom_group_t;
-
-intn H5A_dec_ref (hid_t atm);
-hid_t H5A_inc_ref (hid_t atm);
+ uintn count; /* # of times this group has been initialized */
+ uintn reserved; /* # of atoms to reserve for constant atoms */
+ uintn wrapped; /* whether the id count has wrapped around */
+ intn hash_size; /* size of the hash table to store the atoms in */
+ uintn atoms; /* current number of atoms held */
+ uintn nextid; /* atom ID to use for the next atom */
+ herr_t (*free_func) (void *); /* Pointer to function to call when releasing ref counted object */
+ atom_info_t **atom_list; /* pointer to an array of ptrs to atoms */
+} atom_group_t;
+
+intn H5A_dec_ref(hid_t atm);
+hid_t H5A_inc_ref(hid_t atm);
#endif
-
diff --git a/src/H5Apublic.h b/src/H5Apublic.h
index 60c4d40..971bfc3 100644
--- a/src/H5Apublic.h
+++ b/src/H5Apublic.h
@@ -24,33 +24,33 @@
/* Group values allowed */
typedef enum {
- BADGROUP=(-1), /* Invalid Group */
- H5_ERR=0, /* Group ID for Error stack objects */
- H5_FILE, /* Group ID for File objects */
- H5_TEMPLATE_0, /* Group ID for Template objects */
- H5_TEMPLATE_1, /* Group ID for Template objects */
- H5_TEMPLATE_2, /* Group ID for Template objects */
- H5_TEMPLATE_3, /* Group ID for Template objects */
- H5_TEMPLATE_4, /* Group ID for Template objects */
- H5_TEMPLATE_5, /* Group ID for Template objects */
- H5_TEMPLATE_6, /* Group ID for Template objects */
- H5_TEMPLATE_7, /* Group ID for Template objects */
+ BADGROUP = (-1), /* Invalid Group */
+ H5_ERR = 0, /* Group ID for Error stack objects */
+ H5_FILE, /* Group ID for File objects */
+ H5_TEMPLATE_0, /* Group ID for Template objects */
+ H5_TEMPLATE_1, /* Group ID for Template objects */
+ H5_TEMPLATE_2, /* Group ID for Template objects */
+ H5_TEMPLATE_3, /* Group ID for Template objects */
+ H5_TEMPLATE_4, /* Group ID for Template objects */
+ H5_TEMPLATE_5, /* Group ID for Template objects */
+ H5_TEMPLATE_6, /* Group ID for Template objects */
+ H5_TEMPLATE_7, /* Group ID for Template objects */
#ifndef NDEBUG
- H5_TEMPLATE_MAX, /* Not really a group ID */
+ H5_TEMPLATE_MAX, /* Not really a group ID */
#endif
- H5_GROUP, /* Group ID for Group objects */
- H5_DATATYPE, /* Group ID for Datatype objects */
- H5_DATASPACE, /* Group ID for Dataspace objects */
- H5_DATASET, /* Group ID for Dataset objects */
- H5_DIRECTORY, /* Group ID for Directory objects */
- MAXGROUP /* Highest group in group_t (Invalid as true group) */
+ H5_GROUP, /* Group ID for Group objects */
+ H5_DATATYPE, /* Group ID for Datatype objects */
+ H5_DATASPACE, /* Group ID for Dataspace objects */
+ H5_DATASET, /* Group ID for Dataset objects */
+ H5_DIRECTORY, /* Group ID for Directory objects */
+ MAXGROUP /* Highest group in group_t (Invalid as true group) */
} group_t;
/* Type of atoms to return to users */
typedef int32 hid_t;
/* Type of the function to compare objects & keys */
-typedef intn (*H5Asearch_func_t)(const VOIDP obj, const VOIDP key);
+typedef intn (*H5Asearch_func_t) (const VOIDP obj, const VOIDP key);
/* # of bits to use for Group ID in each atom (change if MAXGROUP>16) */
#define GROUP_BITS 8
@@ -61,11 +61,11 @@ typedef intn (*H5Asearch_func_t)(const VOIDP obj, const VOIDP key);
#define ATOM_MASK 0x0FFFFFFF
/* Combine a Group number and an atom index into an atom */
-#define MAKE_ATOM(g,i) ((((hid_t)(g)&GROUP_MASK)<<ATOM_BITS)| \
- ((hid_t)(i)&ATOM_MASK))
+#define MAKE_ATOM(g,i) ((((hid_t)(g)&GROUP_MASK)<<ATOM_BITS)| \
+ ((hid_t)(i)&ATOM_MASK))
#ifdef __cplusplus
-extern "C" {
+extern "C" {
#endif
/* Functions in H5A.c */
@@ -82,11 +82,11 @@ extern "C" {
Returns SUCCEED if successful and FAIL otherwise
*******************************************************************************/
-intn H5Ainit_group(group_t grp, /* IN: Group to initialize */
- intn hash_size, /* IN: Minimum hash table size to use for group */
- uintn reserved, /* IN: Number of hash table entries to reserve */
- herr_t (*free_func)(void *) /* IN: Function to call when releasing ref counted objects */
-);
+ intn H5Ainit_group(group_t grp, /* IN: Group to initialize */
+ intn hash_size, /* IN: Minimum hash table size to use for group */
+ uintn reserved, /* IN: Number of hash table entries to reserve */
+ herr_t (*free_func) (void *) /* IN: Function to call when releasing ref counted objects */
+ );
/******************************************************************************
NAME
@@ -102,8 +102,8 @@ intn H5Ainit_group(group_t grp, /* IN: Group to initialize */
Returns SUCCEED if successful and FAIL otherwise
*******************************************************************************/
-intn H5Adestroy_group(group_t grp /* IN: Group to destroy */
-);
+ intn H5Adestroy_group(group_t grp /* IN: Group to destroy */
+ );
/******************************************************************************
NAME
@@ -121,9 +121,9 @@ intn H5Adestroy_group(group_t grp /* IN: Group to destroy */
Returns atom if successful and FAIL otherwise
*******************************************************************************/
-hid_t H5Aregister_atom(group_t grp, /* IN: Group to register the object in */
- const void *object /* IN: Object to attach to atom */
-);
+ hid_t H5Aregister_atom(group_t grp, /* IN: Group to register the object in */
+ const void *object /* IN: Object to attach to atom */
+ );
/******************************************************************************
NAME
@@ -136,8 +136,8 @@ hid_t H5Aregister_atom(group_t grp, /* IN: Group to register the object in *
Returns object ptr if successful and NULL otherwise
*******************************************************************************/
-VOIDP H5Aatom_object(hid_t atm /* IN: Atom to retrieve object for */
-);
+ VOIDP H5Aatom_object(hid_t atm /* IN: Atom to retrieve object for */
+ );
/******************************************************************************
NAME
@@ -150,8 +150,8 @@ VOIDP H5Aatom_object(hid_t atm /* IN: Atom to retrieve object for */
Returns group if successful and FAIL otherwise
*******************************************************************************/
-group_t H5Aatom_group(hid_t atm /* IN: Atom to retrieve group for */
-);
+ group_t H5Aatom_group(hid_t atm /* IN: Atom to retrieve group for */
+ );
/******************************************************************************
NAME
@@ -164,9 +164,8 @@ group_t H5Aatom_group(hid_t atm /* IN: Atom to retrieve group for */
Returns atom's object if successful and FAIL otherwise
*******************************************************************************/
-VOIDP H5Aremove_atom(hid_t atm /* IN: Atom to remove */
-);
-
+ VOIDP H5Aremove_atom(hid_t atm /* IN: Atom to remove */
+ );
/******************************************************************************
NAME
@@ -182,10 +181,10 @@ VOIDP H5Aremove_atom(hid_t atm /* IN: Atom to remove */
Returns pointer an atom's object if successful and NULL otherwise
*******************************************************************************/
-VOIDP H5Asearch_atom(group_t grp, /* IN: Group to search for the object in */
- H5Asearch_func_t func, /* IN: Ptr to the comparison function */
- const VOIDP key /* IN: pointer to key to compare against */
-);
+ VOIDP H5Asearch_atom(group_t grp, /* IN: Group to search for the object in */
+ H5Asearch_func_t func, /* IN: Ptr to the comparison function */
+ const VOIDP key /* IN: pointer to key to compare against */
+ );
/******************************************************************************
NAME
@@ -199,8 +198,8 @@ VOIDP H5Asearch_atom(group_t grp, /* IN: Group to search for the object i
Returns BTRUE/BFALSE/BFAIL
*******************************************************************************/
-intn H5Ais_reserved(hid_t atm /* IN: Group to search for the object in */
-);
+ intn H5Ais_reserved(hid_t atm /* IN: Group to search for the object in */
+ );
/******************************************************************************
NAME
@@ -213,11 +212,10 @@ intn H5Ais_reserved(hid_t atm /* IN: Group to search for the object in */
Returns SUCCEED/FAIL
*******************************************************************************/
-void H5A_term_interface(void);
+ void H5A_term_interface(void);
#ifdef __cplusplus
}
-#endif
#endif
-
+#endif
diff --git a/src/H5B.c b/src/H5B.c
index 6adf671..e7436c6 100644
--- a/src/H5B.c
+++ b/src/H5B.c
@@ -1,717 +1,705 @@
/*-------------------------------------------------------------------------
- * Copyright (C) 1997 National Center for Supercomputing Applications.
+ * Copyright (C) 1997 National Center for Supercomputing Applications.
* All rights reserved.
*
*-------------------------------------------------------------------------
*
- * Created: hdf5btree.c
- * Jul 10 1997
- * Robb Matzke <matzke@llnl.gov>
+ * Created: hdf5btree.c
+ * Jul 10 1997
+ * Robb Matzke <matzke@llnl.gov>
*
- * Purpose: Implements balanced, sibling-linked, N-ary trees
- * capable of storing any type of data with unique key
- * values.
+ * Purpose: Implements balanced, sibling-linked, N-ary trees
+ * capable of storing any type of data with unique key
+ * values.
*
- * A B-link-tree is a balanced tree where each node has
- * a pointer to its left and right siblings. A
- * B-link-tree is a rooted tree having the following
- * properties:
+ * A B-link-tree is a balanced tree where each node has
+ * a pointer to its left and right siblings. A
+ * B-link-tree is a rooted tree having the following
+ * properties:
*
- * 1. Every node, x, has the following fields:
+ * 1. Every node, x, has the following fields:
*
- * a. level[x], the level in the tree at which node
- * x appears. Leaf nodes are at level zero.
+ * a. level[x], the level in the tree at which node
+ * x appears. Leaf nodes are at level zero.
*
- * b. n[x], the number of children pointed to by the
- * node. Internal nodes point to subtrees while
- * leaf nodes point to arbitrary data.
+ * b. n[x], the number of children pointed to by the
+ * node. Internal nodes point to subtrees while
+ * leaf nodes point to arbitrary data.
*
- * c. The child pointers themselves, child[x,i] such
- * that 0 <= i < n[x].
+ * c. The child pointers themselves, child[x,i] such
+ * that 0 <= i < n[x].
*
- * d. n[x]+1 key values stored in increasing
- * order:
+ * d. n[x]+1 key values stored in increasing
+ * order:
*
- * key[x,0] < key[x,1] < ... < key[x,n[x]].
+ * key[x,0] < key[x,1] < ... < key[x,n[x]].
*
- * e. left[x] is a pointer to the node's left sibling
- * or the null pointer if this is the left-most
- * node at this level in the tree.
- *
- * f. right[x] is a pointer to the node's right
- * sibling or the null pointer if this is the
- * right-most node at this level in the tree.
+ * e. left[x] is a pointer to the node's left sibling
+ * or the null pointer if this is the left-most
+ * node at this level in the tree.
+ *
+ * f. right[x] is a pointer to the node's right
+ * sibling or the null pointer if this is the
+ * right-most node at this level in the tree.
*
- * 3. The keys key[x,i] partition the key spaces of the
- * children of x:
+ * 3. The keys key[x,i] partition the key spaces of the
+ * children of x:
*
- * key[x,i] <= key[child[x,i],j] <= key[x,i+1]
+ * key[x,i] <= key[child[x,i],j] <= key[x,i+1]
*
- * for any valid combination of i and j.
+ * for any valid combination of i and j.
*
- * 4. There are lower and upper bounds on the number of
- * child pointers a node can contain. These bounds
- * can be expressed in terms of a fixed integer k>=2
- * called the `minimum degree' of the B-tree.
+ * 4. There are lower and upper bounds on the number of
+ * child pointers a node can contain. These bounds
+ * can be expressed in terms of a fixed integer k>=2
+ * called the `minimum degree' of the B-tree.
*
- * a. Every node other than the root must have at least
- * k child pointers and k+1 keys. If the tree is
- * nonempty, the root must have at least one child
- * pointer and two keys.
+ * a. Every node other than the root must have at least
+ * k child pointers and k+1 keys. If the tree is
+ * nonempty, the root must have at least one child
+ * pointer and two keys.
*
- * b. Every node can contain at most 2k child pointers
- * and 2k+1 keys. A node is `full' if it contains
- * exactly 2k child pointers and 2k+1 keys.
+ * b. Every node can contain at most 2k child pointers
+ * and 2k+1 keys. A node is `full' if it contains
+ * exactly 2k child pointers and 2k+1 keys.
*
- * 5. When searching for a particular value, V, and
- * key[V] = key[x,i] for some node x and entry i,
- * then:
+ * 5. When searching for a particular value, V, and
+ * key[V] = key[x,i] for some node x and entry i,
+ * then:
*
- * a. If i=0 the child[0] is followed.
+ * a. If i=0 the child[0] is followed.
*
- * b. If i=n[x] the child[n[x]-1] is followed.
+ * b. If i=n[x] the child[n[x]-1] is followed.
*
- * c. Otherwise, the child that is followed
- * (either child[x,i-1] or child[x,i]) is
- * determined by the type of object to which the
- * leaf nodes of the tree point and is controlled
- * by the key comparison function registered for
- * that type of B-tree.
+ * c. Otherwise, the child that is followed
+ * (either child[x,i-1] or child[x,i]) is
+ * determined by the type of object to which the
+ * leaf nodes of the tree point and is controlled
+ * by the key comparison function registered for
+ * that type of B-tree.
*
*
* Modifications:
*
- * Robb Matzke, 4 Aug 1997
- * Added calls to H5E.
+ * Robb Matzke, 4 Aug 1997
+ * Added calls to H5E.
*
*-------------------------------------------------------------------------
*/
/* private headers */
-#include <H5private.h> /*library */
-#include <H5ACprivate.h> /*cache */
-#include <H5Bprivate.h> /*B-link trees */
-#include <H5Eprivate.h> /*error handling */
-#include <H5MFprivate.h> /*File memory management */
-#include <H5MMprivate.h> /*Core memory management */
+#include <H5private.h> /*library */
+#include <H5ACprivate.h> /*cache */
+#include <H5Bprivate.h> /*B-link trees */
+#include <H5Eprivate.h> /*error handling */
+#include <H5MFprivate.h> /*File memory management */
+#include <H5MMprivate.h> /*Core memory management */
-#define PABLO_MASK H5B_mask
+#define PABLO_MASK H5B_mask
#define BOUND(MIN,X,MAX) ((X)<(MIN)?(MIN):((X)>(MAX)?(MAX):(X)))
/* PRIVATE PROTOTYPES */
-static H5B_ins_t H5B_insert_helper (H5F_t *f, const haddr_t *addr,
- const H5B_class_t *type,
- uint8 *lt_key, hbool_t *lt_key_changed,
- uint8 *md_key, void *udata,
- uint8 *rt_key, hbool_t *rt_key_changed,
- haddr_t *retval);
-static herr_t H5B_insert_child (H5F_t *f, const H5B_class_t *type,
- H5B_t *bt, intn idx, const haddr_t *child,
- H5B_ins_t anchor, void *md_key);
-static herr_t H5B_flush (H5F_t *f, hbool_t destroy, const haddr_t *addr,
- H5B_t *b);
-static H5B_t *H5B_load (H5F_t *f, const haddr_t *addr, const void *_type,
- void *udata);
-static herr_t H5B_decode_key (H5F_t *f, H5B_t *bt, intn idx);
-static herr_t H5B_decode_keys (H5F_t *f, H5B_t *bt, intn idx);
-static size_t H5B_nodesize (H5F_t *f, const H5B_class_t *type,
- size_t *total_nkey_size, size_t sizeof_rkey);
-static herr_t H5B_split (H5F_t *f, const H5B_class_t *type, H5B_t *old_bt,
- const haddr_t *old_addr, void *udata,
- haddr_t *new_addr /*out*/);
+static H5B_ins_t H5B_insert_helper(H5F_t *f, const haddr_t *addr,
+ const H5B_class_t *type,
+ uint8 *lt_key, hbool_t *lt_key_changed,
+ uint8 *md_key, void *udata,
+ uint8 *rt_key, hbool_t *rt_key_changed,
+ haddr_t *retval);
+static herr_t H5B_insert_child(H5F_t *f, const H5B_class_t *type,
+ H5B_t *bt, intn idx, const haddr_t *child,
+ H5B_ins_t anchor, void *md_key);
+static herr_t H5B_flush(H5F_t *f, hbool_t destroy, const haddr_t *addr,
+ H5B_t *b);
+static H5B_t *H5B_load(H5F_t *f, const haddr_t *addr, const void *_type,
+ void *udata);
+static herr_t H5B_decode_key(H5F_t *f, H5B_t *bt, intn idx);
+static herr_t H5B_decode_keys(H5F_t *f, H5B_t *bt, intn idx);
+static size_t H5B_nodesize(H5F_t *f, const H5B_class_t *type,
+ size_t *total_nkey_size, size_t sizeof_rkey);
+static herr_t H5B_split(H5F_t *f, const H5B_class_t *type, H5B_t *old_bt,
+ const haddr_t *old_addr, void *udata,
+ haddr_t *new_addr /*out */ );
#ifdef H5B_DEBUG
-static herr_t H5B_assert (H5F_t *f, const haddr_t *addr,
- const H5B_class_t *type, void *udata);
+static herr_t H5B_assert(H5F_t *f, const haddr_t *addr,
+ const H5B_class_t *type, void *udata);
#endif
/* H5B inherits cache-like properties from H5AC */
-static const H5AC_class_t H5AC_BT[1] = {{
- H5AC_BT_ID,
- (void*(*)(H5F_t*,const haddr_t*,const void*,void*))H5B_load,
- (herr_t(*)(H5F_t*,hbool_t,const haddr_t*,void*))H5B_flush,
-}};
+static const H5AC_class_t H5AC_BT[1] =
+{
+ {
+ H5AC_BT_ID,
+ (void *(*)(H5F_t *, const haddr_t *, const void *, void *)) H5B_load,
+ (herr_t (*)(H5F_t *, hbool_t, const haddr_t *, void *)) H5B_flush,
+ }};
/* Interface initialization? */
#define INTERFACE_INIT NULL
-static interface_initialize_g = FALSE;
-
+static interface_initialize_g = FALSE;
/*-------------------------------------------------------------------------
- * Function: H5B_create
+ * Function: H5B_create
*
- * Purpose: Creates a new empty B-tree leaf node. The UDATA pointer is
- * passed as an argument to the sizeof_rkey() method for the
- * B-tree.
+ * Purpose: Creates a new empty B-tree leaf node. The UDATA pointer is
+ * passed as an argument to the sizeof_rkey() method for the
+ * B-tree.
*
- * Return: Success: SUCCEED, address of new node is returned
- * through the RETVAL argument.
+ * Return: Success: SUCCEED, address of new node is returned
+ * through the RETVAL argument.
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jun 23 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jun 23 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
-H5B_create (H5F_t *f, const H5B_class_t *type, void *udata, haddr_t *retval)
+H5B_create(H5F_t *f, const H5B_class_t *type, void *udata, haddr_t *retval)
{
- H5B_t *bt=NULL;
- size_t size, sizeof_rkey;
- size_t total_native_keysize;
- intn offset, i;
-
- FUNC_ENTER (H5B_create, FAIL);
-
- /*
- * Check arguments.
- */
- assert (f);
- assert (type);
- assert (retval);
-
- /*
- * Allocate file and memory data structures.
- */
- sizeof_rkey = (type->get_sizeof_rkey)(f, udata);
- size = H5B_nodesize (f, type, &total_native_keysize, sizeof_rkey);
- if (H5MF_alloc (f, H5MF_META, size, retval)<0) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "can't allocate file space for B-tree root node");
- }
- bt = H5MM_xmalloc (sizeof(H5B_t));
- bt->type = type;
- bt->sizeof_rkey = sizeof_rkey;
- bt->dirty = TRUE;
- bt->ndirty = 0;
- bt->type = type;
- bt->level = 0;
- H5F_addr_undef (&(bt->left));
- H5F_addr_undef (&(bt->right));
- bt->nchildren = 0;
- bt->page = H5MM_xcalloc (1, size); /*use calloc() to keep file clean*/
- bt->native = H5MM_xmalloc (total_native_keysize);
- bt->child = H5MM_xmalloc (2*H5B_K(f,type) * sizeof(haddr_t));
- bt->key = H5MM_xmalloc ((2*H5B_K(f,type)+1) * sizeof(H5B_key_t));
-
- /*
- * Initialize each entry's raw child and key pointers to point into the
- * `page' buffer. Each native key pointer should be null until the key is
- * translated to native format.
- */
- for (i=0,offset=H5B_SIZEOF_HDR(f);
- i<2*H5B_K(f,type);
- i++,offset+=bt->sizeof_rkey+H5F_SIZEOF_ADDR(f)) {
-
- bt->key[i].dirty = FALSE;
- bt->key[i].rkey = bt->page + offset;
- bt->key[i].nkey = NULL;
- H5F_addr_undef (bt->child+i);
- }
-
- /*
- * The last possible key...
- */
- bt->key[2*H5B_K(f,type)].dirty = FALSE;
- bt->key[2*H5B_K(f,type)].rkey = bt->page + offset;
- bt->key[2*H5B_K(f,type)].nkey = NULL;
-
- /*
- * Cache the new B-tree node.
- */
- if (H5AC_set (f, H5AC_BT, retval, bt)<0) {
- HRETURN_ERROR (H5E_BTREE, H5E_CANTINIT, FAIL,
- "can't add B-tree root node to cache");
- }
-
+ H5B_t *bt = NULL;
+ size_t size, sizeof_rkey;
+ size_t total_native_keysize;
+ intn offset, i;
+
+ FUNC_ENTER(H5B_create, FAIL);
+
+ /*
+ * Check arguments.
+ */
+ assert(f);
+ assert(type);
+ assert(retval);
+
+ /*
+ * Allocate file and memory data structures.
+ */
+ sizeof_rkey = (type->get_sizeof_rkey) (f, udata);
+ size = H5B_nodesize(f, type, &total_native_keysize, sizeof_rkey);
+ if (H5MF_alloc(f, H5MF_META, size, retval) < 0) {
+ HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "can't allocate file space for B-tree root node");
+ }
+ bt = H5MM_xmalloc(sizeof(H5B_t));
+ bt->type = type;
+ bt->sizeof_rkey = sizeof_rkey;
+ bt->dirty = TRUE;
+ bt->ndirty = 0;
+ bt->type = type;
+ bt->level = 0;
+ H5F_addr_undef(&(bt->left));
+ H5F_addr_undef(&(bt->right));
+ bt->nchildren = 0;
+ bt->page = H5MM_xcalloc(1, size); /*use calloc() to keep file clean */
+ bt->native = H5MM_xmalloc(total_native_keysize);
+ bt->child = H5MM_xmalloc(2 * H5B_K(f, type) * sizeof(haddr_t));
+ bt->key = H5MM_xmalloc((2 * H5B_K(f, type) + 1) * sizeof(H5B_key_t));
+
+ /*
+ * Initialize each entry's raw child and key pointers to point into the
+ * `page' buffer. Each native key pointer should be null until the key is
+ * translated to native format.
+ */
+ for (i = 0, offset = H5B_SIZEOF_HDR(f);
+ i < 2 * H5B_K(f, type);
+ i++, offset += bt->sizeof_rkey + H5F_SIZEOF_ADDR(f)) {
+
+ bt->key[i].dirty = FALSE;
+ bt->key[i].rkey = bt->page + offset;
+ bt->key[i].nkey = NULL;
+ H5F_addr_undef(bt->child + i);
+ }
+
+ /*
+ * The last possible key...
+ */
+ bt->key[2 * H5B_K(f, type)].dirty = FALSE;
+ bt->key[2 * H5B_K(f, type)].rkey = bt->page + offset;
+ bt->key[2 * H5B_K(f, type)].nkey = NULL;
+
+ /*
+ * Cache the new B-tree node.
+ */
+ if (H5AC_set(f, H5AC_BT, retval, bt) < 0) {
+ HRETURN_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL,
+ "can't add B-tree root node to cache");
+ }
#ifdef H5B_DEBUG
- H5B_assert (f, retval, type, udata);
+ H5B_assert(f, retval, type, udata);
#endif
- FUNC_LEAVE (SUCCEED);
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5B_load
+ * Function: H5B_load
*
- * Purpose: Loads a B-tree node from the disk.
+ * Purpose: Loads a B-tree node from the disk.
*
- * Return: Success: Pointer to a new B-tree node.
+ * Return: Success: Pointer to a new B-tree node.
*
- * Failure: NULL
+ * Failure: NULL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jun 23 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jun 23 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-static H5B_t *
-H5B_load (H5F_t *f, const haddr_t *addr, const void *_type, void *udata)
+static H5B_t *
+H5B_load(H5F_t *f, const haddr_t *addr, const void *_type, void *udata)
{
- const H5B_class_t *type = (const H5B_class_t *)_type;
- size_t size, total_nkey_size;
- H5B_t *bt = NULL;
- intn i;
- uint8 *p;
- H5B_t *ret_value = NULL;
-
- FUNC_ENTER (H5B_load, NULL);
-
- /* Check arguments */
- assert (f);
- assert (addr && H5F_addr_defined (addr));
- assert (type);
- assert (type->get_sizeof_rkey);
-
- bt = H5MM_xmalloc (sizeof(H5B_t));
- bt->sizeof_rkey = (type->get_sizeof_rkey)(f, udata);
- size = H5B_nodesize (f, type, &total_nkey_size, bt->sizeof_rkey);
- bt->type = type;
- bt->dirty = FALSE;
- bt->ndirty = 0;
- bt->page = H5MM_xmalloc (size);
- bt->native = H5MM_xmalloc (total_nkey_size);
- bt->key = H5MM_xmalloc ((2*H5B_K(f,type)+1) * sizeof(H5B_key_t));
- bt->child = H5MM_xmalloc (2 * H5B_K(f,type) * sizeof(haddr_t));
- if (H5F_block_read (f, addr, size, bt->page)<0) {
- HRETURN_ERROR (H5E_BTREE, H5E_READERROR, NULL,
- "can't read B-tree node");
- }
- p = bt->page;
-
- /* magic number */
- if (HDmemcmp (p, H5B_MAGIC, H5B_SIZEOF_MAGIC)) {
- HGOTO_ERROR (H5E_BTREE, H5E_CANTLOAD, NULL,
- "wrong B-tree signature");
- }
- p += 4;
-
- /* node type and level */
- if (*p++ != type->id) {
- HGOTO_ERROR (H5E_BTREE, H5E_CANTLOAD, NULL,
- "incorrect B-tree node level");
- }
- bt->level = *p++;
-
- /* entries used */
- UINT16DECODE (p, bt->nchildren);
-
- /* sibling pointers */
- H5F_addr_decode (f, (const uint8**)&p, &(bt->left));
- H5F_addr_decode (f, (const uint8**)&p, &(bt->right));
-
- /* the child/key pairs */
- for (i=0; i<2*H5B_K(f,type); i++) {
-
- bt->key[i].dirty = FALSE;
- bt->key[i].rkey = p;
- p += bt->sizeof_rkey;
- bt->key[i].nkey = NULL;
-
- if (i<bt->nchildren) {
- H5F_addr_decode (f, (const uint8**)&p, bt->child+i);
- } else {
- H5F_addr_undef (bt->child+i);
- p += H5F_SIZEOF_ADDR(f);
- }
- }
-
- bt->key[2*H5B_K(f,type)].dirty = FALSE;
- bt->key[2*H5B_K(f,type)].rkey = p;
- bt->key[2*H5B_K(f,type)].nkey = NULL;
- ret_value = bt;
-
- done:
- if (!ret_value && bt) {
- H5MM_xfree (bt->child);
- H5MM_xfree (bt->key);
- H5MM_xfree (bt->page);
- H5MM_xfree (bt->native);
- H5MM_xfree (bt);
- }
-
- FUNC_LEAVE (ret_value);
+ const H5B_class_t *type = (const H5B_class_t *) _type;
+ size_t size, total_nkey_size;
+ H5B_t *bt = NULL;
+ intn i;
+ uint8 *p;
+ H5B_t *ret_value = NULL;
+
+ FUNC_ENTER(H5B_load, NULL);
+
+ /* Check arguments */
+ assert(f);
+ assert(addr && H5F_addr_defined(addr));
+ assert(type);
+ assert(type->get_sizeof_rkey);
+
+ bt = H5MM_xmalloc(sizeof(H5B_t));
+ bt->sizeof_rkey = (type->get_sizeof_rkey) (f, udata);
+ size = H5B_nodesize(f, type, &total_nkey_size, bt->sizeof_rkey);
+ bt->type = type;
+ bt->dirty = FALSE;
+ bt->ndirty = 0;
+ bt->page = H5MM_xmalloc(size);
+ bt->native = H5MM_xmalloc(total_nkey_size);
+ bt->key = H5MM_xmalloc((2 * H5B_K(f, type) + 1) * sizeof(H5B_key_t));
+ bt->child = H5MM_xmalloc(2 * H5B_K(f, type) * sizeof(haddr_t));
+ if (H5F_block_read(f, addr, size, bt->page) < 0) {
+ HRETURN_ERROR(H5E_BTREE, H5E_READERROR, NULL,
+ "can't read B-tree node");
+ }
+ p = bt->page;
+
+ /* magic number */
+ if (HDmemcmp(p, H5B_MAGIC, H5B_SIZEOF_MAGIC)) {
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, NULL,
+ "wrong B-tree signature");
+ }
+ p += 4;
+
+ /* node type and level */
+ if (*p++ != type->id) {
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, NULL,
+ "incorrect B-tree node level");
+ }
+ bt->level = *p++;
+
+ /* entries used */
+ UINT16DECODE(p, bt->nchildren);
+
+ /* sibling pointers */
+ H5F_addr_decode(f, (const uint8 **) &p, &(bt->left));
+ H5F_addr_decode(f, (const uint8 **) &p, &(bt->right));
+
+ /* the child/key pairs */
+ for (i = 0; i < 2 * H5B_K(f, type); i++) {
+
+ bt->key[i].dirty = FALSE;
+ bt->key[i].rkey = p;
+ p += bt->sizeof_rkey;
+ bt->key[i].nkey = NULL;
+
+ if (i < bt->nchildren) {
+ H5F_addr_decode(f, (const uint8 **) &p, bt->child + i);
+ } else {
+ H5F_addr_undef(bt->child + i);
+ p += H5F_SIZEOF_ADDR(f);
+ }
+ }
+
+ bt->key[2 * H5B_K(f, type)].dirty = FALSE;
+ bt->key[2 * H5B_K(f, type)].rkey = p;
+ bt->key[2 * H5B_K(f, type)].nkey = NULL;
+ ret_value = bt;
+
+ done:
+ if (!ret_value && bt) {
+ H5MM_xfree(bt->child);
+ H5MM_xfree(bt->key);
+ H5MM_xfree(bt->page);
+ H5MM_xfree(bt->native);
+ H5MM_xfree(bt);
+ }
+ FUNC_LEAVE(ret_value);
}
-
/*-------------------------------------------------------------------------
- * Function: H5B_flush
+ * Function: H5B_flush
*
- * Purpose: Flushes a dirty B-tree node to disk.
+ * Purpose: Flushes a dirty B-tree node to disk.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jun 23 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jun 23 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static herr_t
-H5B_flush (H5F_t *f, hbool_t destroy, const haddr_t *addr, H5B_t *bt)
+H5B_flush(H5F_t *f, hbool_t destroy, const haddr_t *addr, H5B_t *bt)
{
- intn i;
- size_t size = 0;
- uint8 *p = bt->page;
-
- FUNC_ENTER (H5B_flush, FAIL);
-
- /*
- * Check arguments.
- */
- assert (f);
- assert (addr && H5F_addr_defined (addr));
- assert (bt);
- assert (bt->type);
- assert (bt->type->encode);
-
- size = H5B_nodesize (f, bt->type, NULL, bt->sizeof_rkey);
-
- if (bt->dirty) {
-
- /* magic number */
- HDmemcpy (p, H5B_MAGIC, H5B_SIZEOF_MAGIC);
- p += 4;
-
- /* node type and level */
- *p++ = bt->type->id;
- *p++ = bt->level;
-
- /* entries used */
- UINT16ENCODE (p, bt->nchildren);
-
- /* sibling pointers */
- H5F_addr_encode (f, &p, &(bt->left));
- H5F_addr_encode (f, &p, &(bt->right));
-
- /* child keys and pointers */
- for (i=0; i<=bt->nchildren; i++) {
-
- /* encode the key */
- assert (bt->key[i].rkey == p);
- if (bt->key[i].dirty) {
- if (bt->key[i].nkey) {
- if ((bt->type->encode)(f, bt, bt->key[i].rkey,
- bt->key[i].nkey)<0) {
- HRETURN_ERROR (H5E_BTREE, H5E_CANTENCODE, FAIL,
- "unable to encode B-tree key");
- }
- }
- bt->key[i].dirty = FALSE;
- }
- p += bt->sizeof_rkey;
-
- /* encode the child address */
- if (i<bt->ndirty) {
- H5F_addr_encode (f, &p, &(bt->child[i]));
- } else {
- p += H5F_SIZEOF_ADDR(f);
- }
- }
-
- /*
- * Write the disk page. We always write the header, but we don't
- * bother writing data for the child entries that don't exist or
- * for the final unchanged children.
- */
- if (H5F_block_write (f, addr, size, bt->page)<0) {
- HRETURN_ERROR (H5E_BTREE, H5E_CANTFLUSH, FAIL,
- "unable to save B-tree node to disk");
- }
- bt->dirty = FALSE;
- bt->ndirty = 0;
- }
-
- if (destroy) {
- H5MM_xfree (bt->child);
- H5MM_xfree (bt->key);
- H5MM_xfree (bt->page);
- H5MM_xfree (bt->native);
- H5MM_xfree (bt);
- }
-
- FUNC_LEAVE (SUCCEED);
+ intn i;
+ size_t size = 0;
+ uint8 *p = bt->page;
+
+ FUNC_ENTER(H5B_flush, FAIL);
+
+ /*
+ * Check arguments.
+ */
+ assert(f);
+ assert(addr && H5F_addr_defined(addr));
+ assert(bt);
+ assert(bt->type);
+ assert(bt->type->encode);
+
+ size = H5B_nodesize(f, bt->type, NULL, bt->sizeof_rkey);
+
+ if (bt->dirty) {
+
+ /* magic number */
+ HDmemcpy(p, H5B_MAGIC, H5B_SIZEOF_MAGIC);
+ p += 4;
+
+ /* node type and level */
+ *p++ = bt->type->id;
+ *p++ = bt->level;
+
+ /* entries used */
+ UINT16ENCODE(p, bt->nchildren);
+
+ /* sibling pointers */
+ H5F_addr_encode(f, &p, &(bt->left));
+ H5F_addr_encode(f, &p, &(bt->right));
+
+ /* child keys and pointers */
+ for (i = 0; i <= bt->nchildren; i++) {
+
+ /* encode the key */
+ assert(bt->key[i].rkey == p);
+ if (bt->key[i].dirty) {
+ if (bt->key[i].nkey) {
+ if ((bt->type->encode) (f, bt, bt->key[i].rkey,
+ bt->key[i].nkey) < 0) {
+ HRETURN_ERROR(H5E_BTREE, H5E_CANTENCODE, FAIL,
+ "unable to encode B-tree key");
+ }
+ }
+ bt->key[i].dirty = FALSE;
+ }
+ p += bt->sizeof_rkey;
+
+ /* encode the child address */
+ if (i < bt->ndirty) {
+ H5F_addr_encode(f, &p, &(bt->child[i]));
+ } else {
+ p += H5F_SIZEOF_ADDR(f);
+ }
+ }
+
+ /*
+ * Write the disk page. We always write the header, but we don't
+ * bother writing data for the child entries that don't exist or
+ * for the final unchanged children.
+ */
+ if (H5F_block_write(f, addr, size, bt->page) < 0) {
+ HRETURN_ERROR(H5E_BTREE, H5E_CANTFLUSH, FAIL,
+ "unable to save B-tree node to disk");
+ }
+ bt->dirty = FALSE;
+ bt->ndirty = 0;
+ }
+ if (destroy) {
+ H5MM_xfree(bt->child);
+ H5MM_xfree(bt->key);
+ H5MM_xfree(bt->page);
+ H5MM_xfree(bt->native);
+ H5MM_xfree(bt);
+ }
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5B_find
+ * Function: H5B_find
*
- * Purpose: Locate the specified information in a B-tree and return
- * that information by filling in fields of the caller-supplied
- * UDATA pointer depending on the type of leaf node
- * requested. The UDATA can point to additional data passed
- * to the key comparison function.
+ * Purpose: Locate the specified information in a B-tree and return
+ * that information by filling in fields of the caller-supplied
+ * UDATA pointer depending on the type of leaf node
+ * requested. The UDATA can point to additional data passed
+ * to the key comparison function.
*
- * Note: This function does not follow the left/right sibling
- * pointers since it assumes that all nodes can be reached
- * from the parent node.
+ * Note: This function does not follow the left/right sibling
+ * pointers since it assumes that all nodes can be reached
+ * from the parent node.
*
- * Return: Success: SUCCEED if found, values returned through the
- * UDATA argument.
+ * Return: Success: SUCCEED if found, values returned through the
+ * UDATA argument.
*
- * Failure: FAIL if not found, UDATA is undefined.
+ * Failure: FAIL if not found, UDATA is undefined.
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jun 23 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jun 23 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
-H5B_find (H5F_t *f, const H5B_class_t *type, const haddr_t *addr, void *udata)
+H5B_find(H5F_t *f, const H5B_class_t *type, const haddr_t *addr, void *udata)
{
- H5B_t *bt=NULL;
- intn idx=-1, lt=0, rt, cmp=1;
- int ret_value = FAIL;
-
- FUNC_ENTER (H5B_find, FAIL);
-
- /*
- * Check arguments.
- */
- assert (f);
- assert (type);
- assert (type->decode);
- assert (type->cmp3);
- assert (type->found);
- assert (addr && H5F_addr_defined (addr));
-
- /*
- * Perform a binary search to locate the child which contains
- * the thing for which we're searching.
- */
- if (NULL==(bt=H5AC_protect (f, H5AC_BT, addr, type, udata))) {
- HGOTO_ERROR (H5E_BTREE, H5E_CANTLOAD, FAIL,
- "unable to load B-tree node");
- }
- rt = bt->nchildren;
-
- while (lt<rt && cmp) {
- idx = (lt + rt) / 2;
- if (H5B_decode_keys (f, bt, idx)<0) {
- HGOTO_ERROR (H5E_BTREE, H5E_CANTDECODE, FAIL,
- "unable to decode B-tree key(s)");
- }
-
- /* compare */
- if ((cmp=(type->cmp3)(f, bt->key[idx].nkey, udata,
- bt->key[idx+1].nkey))<0) {
- rt = idx;
- } else {
- lt = idx+1;
- }
- }
- if (cmp) {
- HGOTO_ERROR (H5E_BTREE, H5E_NOTFOUND, FAIL,
- "B-tree key not found");
- }
-
- /*
- * Follow the link to the subtree or to the data node.
- */
- assert (idx>=0 && idx<bt->nchildren);
- if (bt->level > 0) {
- if ((ret_value = H5B_find (f, type, bt->child+idx, udata))<0) {
- HGOTO_ERROR (H5E_BTREE, H5E_NOTFOUND, FAIL,
- "key not found in subtree");
- }
- } else {
- ret_value = (type->found)(f, bt->child+idx, bt->key[idx].nkey,
- udata, bt->key[idx+1].nkey);
- if (ret_value<0) {
- HGOTO_ERROR (H5E_BTREE, H5E_NOTFOUND, FAIL,
- "key not found in leaf node");
- }
- }
-
-done:
- if (bt && H5AC_unprotect (f, H5AC_BT, addr, bt)<0) {
- HRETURN_ERROR (H5E_BTREE, H5E_PROTECT, FAIL,
- "unable to release node");
- }
- FUNC_LEAVE (ret_value);
+ H5B_t *bt = NULL;
+ intn idx = -1, lt = 0, rt, cmp = 1;
+ int ret_value = FAIL;
+
+ FUNC_ENTER(H5B_find, FAIL);
+
+ /*
+ * Check arguments.
+ */
+ assert(f);
+ assert(type);
+ assert(type->decode);
+ assert(type->cmp3);
+ assert(type->found);
+ assert(addr && H5F_addr_defined(addr));
+
+ /*
+ * Perform a binary search to locate the child which contains
+ * the thing for which we're searching.
+ */
+ if (NULL == (bt = H5AC_protect(f, H5AC_BT, addr, type, udata))) {
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL,
+ "unable to load B-tree node");
+ }
+ rt = bt->nchildren;
+
+ while (lt < rt && cmp) {
+ idx = (lt + rt) / 2;
+ if (H5B_decode_keys(f, bt, idx) < 0) {
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, FAIL,
+ "unable to decode B-tree key(s)");
+ }
+ /* compare */
+ if ((cmp = (type->cmp3) (f, bt->key[idx].nkey, udata,
+ bt->key[idx + 1].nkey)) < 0) {
+ rt = idx;
+ } else {
+ lt = idx + 1;
+ }
+ }
+ if (cmp) {
+ HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL,
+ "B-tree key not found");
+ }
+ /*
+ * Follow the link to the subtree or to the data node.
+ */
+ assert(idx >= 0 && idx < bt->nchildren);
+ if (bt->level > 0) {
+ if ((ret_value = H5B_find(f, type, bt->child + idx, udata)) < 0) {
+ HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL,
+ "key not found in subtree");
+ }
+ } else {
+ ret_value = (type->found) (f, bt->child + idx, bt->key[idx].nkey,
+ udata, bt->key[idx + 1].nkey);
+ if (ret_value < 0) {
+ HGOTO_ERROR(H5E_BTREE, H5E_NOTFOUND, FAIL,
+ "key not found in leaf node");
+ }
+ }
+
+ done:
+ if (bt && H5AC_unprotect(f, H5AC_BT, addr, bt) < 0) {
+ HRETURN_ERROR(H5E_BTREE, H5E_PROTECT, FAIL,
+ "unable to release node");
+ }
+ FUNC_LEAVE(ret_value);
}
-
/*-------------------------------------------------------------------------
- * Function: H5B_split
+ * Function: H5B_split
*
- * Purpose: Split a single node into two nodes. The old node will
- * contain the left children and the new node will contain the
- * right children.
+ * Purpose: Split a single node into two nodes. The old node will
+ * contain the left children and the new node will contain the
+ * right children.
*
- * The UDATA pointer is passed to the sizeof_rkey() method but is
- * otherwise unused.
+ * The UDATA pointer is passed to the sizeof_rkey() method but is
+ * otherwise unused.
*
- * The OLD_BT argument is a pointer to a protected B-tree
- * node.
+ * The OLD_BT argument is a pointer to a protected B-tree
+ * node.
*
- * Return: Success: SUCCEED. The address of the new node is
- * returned through the NEW_ADDR argument.
+ * Return: Success: SUCCEED. The address of the new node is
+ * returned through the NEW_ADDR argument.
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jul 3 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jul 3 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static herr_t
-H5B_split (H5F_t *f, const H5B_class_t *type, H5B_t *old_bt,
- const haddr_t *old_addr, void *udata, haddr_t *new_addr /*out*/)
+H5B_split(H5F_t *f, const H5B_class_t *type, H5B_t *old_bt,
+ const haddr_t *old_addr, void *udata, haddr_t *new_addr /*out */ )
{
- H5B_t *new_bt=NULL, *tmp_bt=NULL;
- herr_t ret_value=FAIL;
- intn i, k;
- size_t recsize = 0;
-
- FUNC_ENTER (H5B_split, FAIL);
-
- /*
- * Check arguments.
- */
- assert (f);
- assert (type);
- assert (old_addr && H5F_addr_defined (old_addr));
-
- /*
- * Initialize variables.
- */
- assert (old_bt->nchildren == 2*H5B_K(f,type));
- recsize = old_bt->sizeof_rkey + H5F_SIZEOF_ADDR(f);
- k = H5B_K(f,type);
-
- /*
- * Create the new B-tree node.
- */
- if (H5B_create (f, type, udata, new_addr/*out*/)<0) {
- HGOTO_ERROR (H5E_BTREE, H5E_CANTINIT, FAIL,
- "unable to create B-tree");
- }
- if (NULL==(new_bt=H5AC_protect (f, H5AC_BT, new_addr, type, udata))) {
- HGOTO_ERROR (H5E_BTREE, H5E_CANTLOAD, FAIL,
- "unable to protect B-tree");
- }
- new_bt->level = old_bt->level;
-
- /*
- * Copy data from the old node to the new node.
- */
- HDmemcpy (new_bt->page + H5B_SIZEOF_HDR(f),
- old_bt->page + H5B_SIZEOF_HDR(f) + k*recsize,
- k*recsize + new_bt->sizeof_rkey);
- HDmemcpy (new_bt->native,
- old_bt->native + k*type->sizeof_nkey,
- (k+1) * type->sizeof_nkey);
-
- for (i=0; i<=k; i++) {
- /* key */
- new_bt->key[i].dirty = old_bt->key[k+i].dirty;
- if (old_bt->key[k+i].nkey) {
- new_bt->key[i].nkey = new_bt->native + i*type->sizeof_nkey;
- }
- /* child */
- if (i<k) {
- new_bt->child[i] = old_bt->child[k+i];
- }
- }
- new_bt->ndirty = new_bt->nchildren = k;
-
- /*
- * Truncate the old node.
- */
- old_bt->dirty = TRUE;
- old_bt->ndirty = old_bt->nchildren = k;
-
- /*
- * Update sibling pointers.
- */
- new_bt->left = *old_addr;
- new_bt->right = old_bt->right;
-
- if (H5F_addr_defined (&(old_bt->right))) {
- if (NULL==(tmp_bt=H5AC_find (f, H5AC_BT, &(old_bt->right), type,
- udata))) {
- HGOTO_ERROR (H5E_BTREE, H5E_CANTLOAD, FAIL,
- "unable to load right sibling");
- }
- tmp_bt->dirty = TRUE;
- tmp_bt->left = *new_addr;
- }
- old_bt->right = *new_addr;
-
- HGOTO_DONE (SUCCEED);
-
-done:
- {
- if (new_bt && H5AC_unprotect (f, H5AC_BT, new_addr, new_bt)<0) {
- HRETURN_ERROR (H5E_BTREE, H5E_PROTECT, FAIL,
- "unable to release B-tree node");
- }
- }
- FUNC_LEAVE (ret_value);
+ H5B_t *new_bt = NULL, *tmp_bt = NULL;
+ herr_t ret_value = FAIL;
+ intn i, k;
+ size_t recsize = 0;
+
+ FUNC_ENTER(H5B_split, FAIL);
+
+ /*
+ * Check arguments.
+ */
+ assert(f);
+ assert(type);
+ assert(old_addr && H5F_addr_defined(old_addr));
+
+ /*
+ * Initialize variables.
+ */
+ assert(old_bt->nchildren == 2 * H5B_K(f, type));
+ recsize = old_bt->sizeof_rkey + H5F_SIZEOF_ADDR(f);
+ k = H5B_K(f, type);
+
+ /*
+ * Create the new B-tree node.
+ */
+ if (H5B_create(f, type, udata, new_addr /*out */ ) < 0) {
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL,
+ "unable to create B-tree");
+ }
+ if (NULL == (new_bt = H5AC_protect(f, H5AC_BT, new_addr, type, udata))) {
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL,
+ "unable to protect B-tree");
+ }
+ new_bt->level = old_bt->level;
+
+ /*
+ * Copy data from the old node to the new node.
+ */
+ HDmemcpy(new_bt->page + H5B_SIZEOF_HDR(f),
+ old_bt->page + H5B_SIZEOF_HDR(f) + k * recsize,
+ k * recsize + new_bt->sizeof_rkey);
+ HDmemcpy(new_bt->native,
+ old_bt->native + k * type->sizeof_nkey,
+ (k + 1) * type->sizeof_nkey);
+
+ for (i = 0; i <= k; i++) {
+ /* key */
+ new_bt->key[i].dirty = old_bt->key[k + i].dirty;
+ if (old_bt->key[k + i].nkey) {
+ new_bt->key[i].nkey = new_bt->native + i * type->sizeof_nkey;
+ }
+ /* child */
+ if (i < k) {
+ new_bt->child[i] = old_bt->child[k + i];
+ }
+ }
+ new_bt->ndirty = new_bt->nchildren = k;
+
+ /*
+ * Truncate the old node.
+ */
+ old_bt->dirty = TRUE;
+ old_bt->ndirty = old_bt->nchildren = k;
+
+ /*
+ * Update sibling pointers.
+ */
+ new_bt->left = *old_addr;
+ new_bt->right = old_bt->right;
+
+ if (H5F_addr_defined(&(old_bt->right))) {
+ if (NULL == (tmp_bt = H5AC_find(f, H5AC_BT, &(old_bt->right), type,
+ udata))) {
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL,
+ "unable to load right sibling");
+ }
+ tmp_bt->dirty = TRUE;
+ tmp_bt->left = *new_addr;
+ }
+ old_bt->right = *new_addr;
+
+ HGOTO_DONE(SUCCEED);
+
+ done:
+ {
+ if (new_bt && H5AC_unprotect(f, H5AC_BT, new_addr, new_bt) < 0) {
+ HRETURN_ERROR(H5E_BTREE, H5E_PROTECT, FAIL,
+ "unable to release B-tree node");
+ }
+ }
+ FUNC_LEAVE(ret_value);
}
-
/*-------------------------------------------------------------------------
- * Function: H5B_decode_key
+ * Function: H5B_decode_key
*
- * Purpose: Decode the specified key into native format.
+ * Purpose: Decode the specified key into native format.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jul 8 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jul 8 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static herr_t
-H5B_decode_key (H5F_t *f, H5B_t *bt, intn idx)
+H5B_decode_key(H5F_t *f, H5B_t *bt, intn idx)
{
- FUNC_ENTER (H5B_decode_key, FAIL);
-
- bt->key[idx].nkey = bt->native + idx * bt->type->sizeof_nkey;
- if ((bt->type->decode)(f, bt, bt->key[idx].rkey,
- bt->key[idx].nkey)<0) {
- HRETURN_ERROR (H5E_BTREE, H5E_CANTDECODE, FAIL,
- "unable to decode key");
- }
-
- FUNC_LEAVE (SUCCEED);
+ FUNC_ENTER(H5B_decode_key, FAIL);
+
+ bt->key[idx].nkey = bt->native + idx * bt->type->sizeof_nkey;
+ if ((bt->type->decode) (f, bt, bt->key[idx].rkey,
+ bt->key[idx].nkey) < 0) {
+ HRETURN_ERROR(H5E_BTREE, H5E_CANTDECODE, FAIL,
+ "unable to decode key");
+ }
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5B_decode_keys
+ * Function: H5B_decode_keys
*
- * Purpose: Decode keys on either side of the specified branch.
+ * Purpose: Decode keys on either side of the specified branch.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Tuesday, October 14, 1997
*
* Modifications:
@@ -719,912 +707,888 @@ H5B_decode_key (H5F_t *f, H5B_t *bt, intn idx)
*-------------------------------------------------------------------------
*/
static herr_t
-H5B_decode_keys (H5F_t *f, H5B_t *bt, intn idx)
+H5B_decode_keys(H5F_t *f, H5B_t *bt, intn idx)
{
- FUNC_ENTER (H5B_decode_keys, FAIL);
-
- assert (f);
- assert (bt);
- assert (idx>=0 && idx<bt->nchildren);
-
- if (!bt->key[idx].nkey && H5B_decode_key (f, bt, idx)<0) {
- HRETURN_ERROR (H5E_BTREE, H5E_CANTDECODE, FAIL,
- "unable to decode key");
- }
- if (!bt->key[idx+1].nkey && H5B_decode_key (f, bt, idx+1)<0) {
- HRETURN_ERROR (H5E_BTREE, H5E_CANTDECODE, FAIL,
- "unable to decode key");
- }
-
- FUNC_LEAVE (SUCCEED);
+ FUNC_ENTER(H5B_decode_keys, FAIL);
+
+ assert(f);
+ assert(bt);
+ assert(idx >= 0 && idx < bt->nchildren);
+
+ if (!bt->key[idx].nkey && H5B_decode_key(f, bt, idx) < 0) {
+ HRETURN_ERROR(H5E_BTREE, H5E_CANTDECODE, FAIL,
+ "unable to decode key");
+ }
+ if (!bt->key[idx + 1].nkey && H5B_decode_key(f, bt, idx + 1) < 0) {
+ HRETURN_ERROR(H5E_BTREE, H5E_CANTDECODE, FAIL,
+ "unable to decode key");
+ }
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5B_insert
+ * Function: H5B_insert
*
- * Purpose: Adds a new item to the B-tree. If the root node of
- * the B-tree splits then the B-tree gets a new address.
+ * Purpose: Adds a new item to the B-tree. If the root node of
+ * the B-tree splits then the B-tree gets a new address.
*
- * Return: Success: SUCCEED.
+ * Return: Success: SUCCEED.
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jun 23 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jun 23 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
-H5B_insert (H5F_t *f, const H5B_class_t *type, const haddr_t *addr,
- void *udata)
+H5B_insert(H5F_t *f, const H5B_class_t *type, const haddr_t *addr,
+ void *udata)
{
- uint8 lt_key[1024], md_key[1024], rt_key[1024];
- hbool_t lt_key_changed=FALSE, rt_key_changed=FALSE;
- haddr_t child, old_root;
- intn level;
- H5B_t *bt;
- size_t size;
- uint8 *buf;
- H5B_ins_t my_ins = H5B_INS_ERROR;
-
- FUNC_ENTER (H5B_insert, FAIL);
-
- /*
- * Check arguments.
- */
- assert (f);
- assert (type);
- assert (type->sizeof_nkey <= sizeof lt_key);
- assert (addr && H5F_addr_defined (addr));
-
- if ((my_ins=H5B_insert_helper (f, addr, type, lt_key, &lt_key_changed,
- md_key, udata, rt_key, &rt_key_changed,
- &child/*out*/))<0 || my_ins<0) {
- HRETURN_ERROR (H5E_BTREE, H5E_CANTINIT, FAIL,
- "unable to insert key");
- }
- if (H5B_INS_NOOP==my_ins) HRETURN (SUCCEED);
- assert (H5B_INS_RIGHT==my_ins);
-
- /* the current root */
- if (NULL==(bt = H5AC_find (f, H5AC_BT, addr, type, udata))) {
- HRETURN_ERROR (H5E_BTREE, H5E_CANTLOAD, FAIL,
- "unable to locate root of B-tree");
- }
- level = bt->level;
- if (!lt_key_changed) {
- if (!bt->key[0].nkey && H5B_decode_key (f, bt, 0)<0) {
- HRETURN_ERROR (H5E_BTREE, H5E_CANTDECODE, FAIL,
- "unable to decode key");
- }
- HDmemcpy (lt_key, bt->key[0].nkey, type->sizeof_nkey);
- }
-
- /* the new node */
- if (NULL==(bt = H5AC_find (f, H5AC_BT, &child, type, udata))) {
- HRETURN_ERROR (H5E_BTREE, H5E_CANTLOAD, FAIL,
- "unable to load new node");
- }
- if (!rt_key_changed) {
- if (!bt->key[bt->nchildren].nkey &&
- H5B_decode_key (f, bt, bt->nchildren)<0) {
- HRETURN_ERROR (H5E_BTREE, H5E_CANTDECODE, FAIL,
- "unable to decode key");
- }
- HDmemcpy (rt_key, bt->key[bt->nchildren].nkey, type->sizeof_nkey);
- }
-
- /*
- * Copy the old root node to some other file location and make the new
- * root at the old root's previous address. This prevents the B-tree
- * from "moving".
- */
- size = H5B_nodesize (f, type, NULL, bt->sizeof_rkey);
- buf = H5MM_xmalloc (size);
- if (H5MF_alloc (f, H5MF_META, size, &old_root/*out*/)<0) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "unable to allocate file space to move root");
- }
- if (H5AC_flush (f, H5AC_BT, addr, FALSE)<0) {
- HRETURN_ERROR (H5E_BTREE, H5E_CANTFLUSH, FAIL,
- "unable to flush B-tree root node");
- }
- if (H5F_block_read (f, addr, size, buf)<0) {
- HRETURN_ERROR (H5E_BTREE, H5E_READERROR, FAIL,
- "unable to read B-tree root node");
- }
- if (H5F_block_write (f, &old_root, size, buf)<0) {
- HRETURN_ERROR (H5E_BTREE, H5E_WRITEERROR, FAIL,
- "unable to move B-tree root node");
- }
- if (H5AC_rename (f, H5AC_BT, addr, &old_root)<0) {
- HRETURN_ERROR (H5E_BTREE, H5E_CANTSPLIT, FAIL,
- "unable to move B-tree root node");
- }
-
- buf = H5MM_xfree (buf);
-
- /* update the new child's left pointer */
- if (NULL==(bt=H5AC_find (f, H5AC_BT, &child, type, udata))) {
- HRETURN_ERROR (H5E_BTREE, H5E_CANTLOAD, FAIL,
- "unable to load new child");
- }
- bt->dirty = TRUE;
- bt->left = old_root;
-
- /* clear the old root at the old address (we already copied it)*/
- if (NULL==(bt=H5AC_find (f, H5AC_BT, addr, type, udata))) {
- HRETURN_ERROR (H5E_BTREE, H5E_CANTLOAD, FAIL,
- "unable to clear old root location");
- }
- bt->dirty = TRUE;
- bt->ndirty = 0;
- H5F_addr_undef (&(bt->left));
- H5F_addr_undef (&(bt->right));
- bt->nchildren = 0;
-
- /* the new root */
- if (NULL==(bt = H5AC_find (f, H5AC_BT, addr, type, udata))) {
- HRETURN_ERROR (H5E_BTREE, H5E_CANTLOAD, FAIL,
- "unable to load new root");
- }
- bt->dirty = TRUE;
- bt->ndirty = 2;
- bt->level = level+1;
- bt->nchildren = 2;
-
- bt->child[0] = old_root;
- bt->key[0].dirty = TRUE;
- bt->key[0].nkey = bt->native;
- HDmemcpy (bt->key[0].nkey, lt_key, type->sizeof_nkey);
-
- bt->child[1] = child;
- bt->key[1].dirty = TRUE;
- bt->key[1].nkey = bt->native + type->sizeof_nkey;
- HDmemcpy (bt->key[1].nkey, md_key, type->sizeof_nkey);
-
- bt->key[2].dirty = TRUE;
- bt->key[2].nkey = bt->native + 2 * type->sizeof_nkey;
- HDmemcpy (bt->key[2].nkey, rt_key, type->sizeof_nkey);
+ uint8 lt_key[1024], md_key[1024], rt_key[1024];
+ hbool_t lt_key_changed = FALSE, rt_key_changed = FALSE;
+ haddr_t child, old_root;
+ intn level;
+ H5B_t *bt;
+ size_t size;
+ uint8 *buf;
+ H5B_ins_t my_ins = H5B_INS_ERROR;
+
+ FUNC_ENTER(H5B_insert, FAIL);
+
+ /*
+ * Check arguments.
+ */
+ assert(f);
+ assert(type);
+ assert(type->sizeof_nkey <= sizeof lt_key);
+ assert(addr && H5F_addr_defined(addr));
+
+ if ((my_ins = H5B_insert_helper(f, addr, type, lt_key, &lt_key_changed,
+ md_key, udata, rt_key, &rt_key_changed,
+ &child /*out */ )) < 0 || my_ins < 0) {
+ HRETURN_ERROR(H5E_BTREE, H5E_CANTINIT, FAIL,
+ "unable to insert key");
+ }
+ if (H5B_INS_NOOP == my_ins)
+ HRETURN(SUCCEED);
+ assert(H5B_INS_RIGHT == my_ins);
+
+ /* the current root */
+ if (NULL == (bt = H5AC_find(f, H5AC_BT, addr, type, udata))) {
+ HRETURN_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL,
+ "unable to locate root of B-tree");
+ }
+ level = bt->level;
+ if (!lt_key_changed) {
+ if (!bt->key[0].nkey && H5B_decode_key(f, bt, 0) < 0) {
+ HRETURN_ERROR(H5E_BTREE, H5E_CANTDECODE, FAIL,
+ "unable to decode key");
+ }
+ HDmemcpy(lt_key, bt->key[0].nkey, type->sizeof_nkey);
+ }
+ /* the new node */
+ if (NULL == (bt = H5AC_find(f, H5AC_BT, &child, type, udata))) {
+ HRETURN_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL,
+ "unable to load new node");
+ }
+ if (!rt_key_changed) {
+ if (!bt->key[bt->nchildren].nkey &&
+ H5B_decode_key(f, bt, bt->nchildren) < 0) {
+ HRETURN_ERROR(H5E_BTREE, H5E_CANTDECODE, FAIL,
+ "unable to decode key");
+ }
+ HDmemcpy(rt_key, bt->key[bt->nchildren].nkey, type->sizeof_nkey);
+ }
+ /*
+ * Copy the old root node to some other file location and make the new
+ * root at the old root's previous address. This prevents the B-tree
+ * from "moving".
+ */
+ size = H5B_nodesize(f, type, NULL, bt->sizeof_rkey);
+ buf = H5MM_xmalloc(size);
+ if (H5MF_alloc(f, H5MF_META, size, &old_root /*out */ ) < 0) {
+ HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "unable to allocate file space to move root");
+ }
+ if (H5AC_flush(f, H5AC_BT, addr, FALSE) < 0) {
+ HRETURN_ERROR(H5E_BTREE, H5E_CANTFLUSH, FAIL,
+ "unable to flush B-tree root node");
+ }
+ if (H5F_block_read(f, addr, size, buf) < 0) {
+ HRETURN_ERROR(H5E_BTREE, H5E_READERROR, FAIL,
+ "unable to read B-tree root node");
+ }
+ if (H5F_block_write(f, &old_root, size, buf) < 0) {
+ HRETURN_ERROR(H5E_BTREE, H5E_WRITEERROR, FAIL,
+ "unable to move B-tree root node");
+ }
+ if (H5AC_rename(f, H5AC_BT, addr, &old_root) < 0) {
+ HRETURN_ERROR(H5E_BTREE, H5E_CANTSPLIT, FAIL,
+ "unable to move B-tree root node");
+ }
+ buf = H5MM_xfree(buf);
+
+ /* update the new child's left pointer */
+ if (NULL == (bt = H5AC_find(f, H5AC_BT, &child, type, udata))) {
+ HRETURN_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL,
+ "unable to load new child");
+ }
+ bt->dirty = TRUE;
+ bt->left = old_root;
+
+ /* clear the old root at the old address (we already copied it) */
+ if (NULL == (bt = H5AC_find(f, H5AC_BT, addr, type, udata))) {
+ HRETURN_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL,
+ "unable to clear old root location");
+ }
+ bt->dirty = TRUE;
+ bt->ndirty = 0;
+ H5F_addr_undef(&(bt->left));
+ H5F_addr_undef(&(bt->right));
+ bt->nchildren = 0;
+
+ /* the new root */
+ if (NULL == (bt = H5AC_find(f, H5AC_BT, addr, type, udata))) {
+ HRETURN_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL,
+ "unable to load new root");
+ }
+ bt->dirty = TRUE;
+ bt->ndirty = 2;
+ bt->level = level + 1;
+ bt->nchildren = 2;
+
+ bt->child[0] = old_root;
+ bt->key[0].dirty = TRUE;
+ bt->key[0].nkey = bt->native;
+ HDmemcpy(bt->key[0].nkey, lt_key, type->sizeof_nkey);
+
+ bt->child[1] = child;
+ bt->key[1].dirty = TRUE;
+ bt->key[1].nkey = bt->native + type->sizeof_nkey;
+ HDmemcpy(bt->key[1].nkey, md_key, type->sizeof_nkey);
+
+ bt->key[2].dirty = TRUE;
+ bt->key[2].nkey = bt->native + 2 * type->sizeof_nkey;
+ HDmemcpy(bt->key[2].nkey, rt_key, type->sizeof_nkey);
#ifdef H5B_DEBUG
- H5B_assert (f, addr, type, udata);
+ H5B_assert(f, addr, type, udata);
#endif
- FUNC_LEAVE (SUCCEED);
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5B_insert_child
+ * Function: H5B_insert_child
*
- * Purpose: Insert a child at the specified address with the
- * specified left or right key. The BT argument is a pointer
- * to a protected B-tree node.
+ * Purpose: Insert a child at the specified address with the
+ * specified left or right key. The BT argument is a pointer
+ * to a protected B-tree node.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jul 8 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jul 8 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static herr_t
-H5B_insert_child (H5F_t *f, const H5B_class_t *type, H5B_t *bt,
- intn idx, const haddr_t *child, H5B_ins_t anchor,
- void *md_key)
+H5B_insert_child(H5F_t *f, const H5B_class_t *type, H5B_t *bt,
+ intn idx, const haddr_t *child, H5B_ins_t anchor,
+ void *md_key)
{
- size_t recsize;
- intn i;
-
- FUNC_ENTER (H5B_insert_child, FAIL);
- assert (bt);
- assert (child);
-
- bt->dirty = TRUE;
- recsize = bt->sizeof_rkey + H5F_SIZEOF_ADDR(f);
-
- if (H5B_INS_RIGHT==anchor) {
- /*
- * The MD_KEY is the left key of the new node.
- */
- HDmemmove (bt->page + H5B_SIZEOF_HDR(f) + (idx+1)*recsize,
- bt->page + H5B_SIZEOF_HDR(f) + idx*recsize,
- (bt->nchildren-idx)*recsize + bt->sizeof_rkey);
-
- HDmemmove (bt->native + (idx+1) * type->sizeof_nkey,
- bt->native + idx * type->sizeof_nkey,
- ((bt->nchildren-idx)+1) * type->sizeof_nkey);
-
- for (i=bt->nchildren; i>=idx; --i) {
- bt->key[i+1].dirty = bt->key[i].dirty;
- if (bt->key[i].nkey) {
- bt->key[i+1].nkey = bt->native + (i+1) * type->sizeof_nkey;
- } else {
- bt->key[i+1].nkey = NULL;
- }
- }
- bt->key[idx].dirty = TRUE;
- bt->key[idx].nkey = bt->native + idx * type->sizeof_nkey;
- HDmemcpy (bt->key[idx].nkey, md_key, type->sizeof_nkey);
-
- } else {
- /*
- * The MD_KEY is the right key of the new node.
- */
- HDmemmove (bt->page + (H5B_SIZEOF_HDR(f) +
- (idx+1)*recsize + bt->sizeof_rkey),
- bt->page + (H5B_SIZEOF_HDR(f) +
- idx*recsize + bt->sizeof_rkey),
- (bt->nchildren-idx) * recsize);
-
- HDmemmove (bt->native + (idx+2)*type->sizeof_nkey,
- bt->native + (idx+1)*type->sizeof_nkey,
- (bt->nchildren-idx) * type->sizeof_nkey);
-
- for (i=bt->nchildren; i>idx; --i) {
- bt->key[i+1].dirty = bt->key[i].dirty;
- if (bt->key[i].nkey) {
- bt->key[i+1].nkey = bt->native + (i+1) * type->sizeof_nkey;
- } else {
- bt->key[i+1].nkey = NULL;
- }
- }
- bt->key[idx+1].dirty = TRUE;
- bt->key[idx+1].nkey = bt->native + (idx+1) * type->sizeof_nkey;
- HDmemcpy (bt->key[idx+1].nkey, md_key, type->sizeof_nkey);
- }
-
- HDmemmove (bt->child + idx + 1,
- bt->child + idx,
- (bt->nchildren - idx) * sizeof(haddr_t));
-
- bt->child[idx] = *child;
- bt->nchildren += 1;
- bt->ndirty = bt->nchildren;
-
- FUNC_LEAVE (SUCCEED);
-}
-
-
+ size_t recsize;
+ intn i;
+
+ FUNC_ENTER(H5B_insert_child, FAIL);
+ assert(bt);
+ assert(child);
+
+ bt->dirty = TRUE;
+ recsize = bt->sizeof_rkey + H5F_SIZEOF_ADDR(f);
+
+ if (H5B_INS_RIGHT == anchor) {
+ /*
+ * The MD_KEY is the left key of the new node.
+ */
+ HDmemmove(bt->page + H5B_SIZEOF_HDR(f) + (idx + 1) * recsize,
+ bt->page + H5B_SIZEOF_HDR(f) + idx * recsize,
+ (bt->nchildren - idx) * recsize + bt->sizeof_rkey);
+
+ HDmemmove(bt->native + (idx + 1) * type->sizeof_nkey,
+ bt->native + idx * type->sizeof_nkey,
+ ((bt->nchildren - idx) + 1) * type->sizeof_nkey);
+
+ for (i = bt->nchildren; i >= idx; --i) {
+ bt->key[i + 1].dirty = bt->key[i].dirty;
+ if (bt->key[i].nkey) {
+ bt->key[i + 1].nkey = bt->native + (i + 1) * type->sizeof_nkey;
+ } else {
+ bt->key[i + 1].nkey = NULL;
+ }
+ }
+ bt->key[idx].dirty = TRUE;
+ bt->key[idx].nkey = bt->native + idx * type->sizeof_nkey;
+ HDmemcpy(bt->key[idx].nkey, md_key, type->sizeof_nkey);
+
+ } else {
+ /*
+ * The MD_KEY is the right key of the new node.
+ */
+ HDmemmove(bt->page + (H5B_SIZEOF_HDR(f) +
+ (idx + 1) * recsize + bt->sizeof_rkey),
+ bt->page + (H5B_SIZEOF_HDR(f) +
+ idx * recsize + bt->sizeof_rkey),
+ (bt->nchildren - idx) * recsize);
+
+ HDmemmove(bt->native + (idx + 2) * type->sizeof_nkey,
+ bt->native + (idx + 1) * type->sizeof_nkey,
+ (bt->nchildren - idx) * type->sizeof_nkey);
+
+ for (i = bt->nchildren; i > idx; --i) {
+ bt->key[i + 1].dirty = bt->key[i].dirty;
+ if (bt->key[i].nkey) {
+ bt->key[i + 1].nkey = bt->native + (i + 1) * type->sizeof_nkey;
+ } else {
+ bt->key[i + 1].nkey = NULL;
+ }
+ }
+ bt->key[idx + 1].dirty = TRUE;
+ bt->key[idx + 1].nkey = bt->native + (idx + 1) * type->sizeof_nkey;
+ HDmemcpy(bt->key[idx + 1].nkey, md_key, type->sizeof_nkey);
+ }
+
+ HDmemmove(bt->child + idx + 1,
+ bt->child + idx,
+ (bt->nchildren - idx) * sizeof(haddr_t));
+
+ bt->child[idx] = *child;
+ bt->nchildren += 1;
+ bt->ndirty = bt->nchildren;
+
+ FUNC_LEAVE(SUCCEED);
+}
/*-------------------------------------------------------------------------
- * Function: H5B_insert_helper
+ * Function: H5B_insert_helper
*
- * Purpose: Inserts the item UDATA into the tree rooted at ADDR and having
- * the specified type.
+ * Purpose: Inserts the item UDATA into the tree rooted at ADDR and having
+ * the specified type.
*
- * On return, if LT_KEY_CHANGED is non-zero, then LT_KEY is
- * the new native left key. Similarily for RT_KEY_CHANGED
- * and RT_KEY.
+ * On return, if LT_KEY_CHANGED is non-zero, then LT_KEY is
+ * the new native left key. Similarily for RT_KEY_CHANGED
+ * and RT_KEY.
*
- * If the node splits, then MD_KEY contains the key that
- * was split between the two nodes (that is, the key that
- * appears as the max key in the left node and the min key
- * in the right node).
+ * If the node splits, then MD_KEY contains the key that
+ * was split between the two nodes (that is, the key that
+ * appears as the max key in the left node and the min key
+ * in the right node).
*
- * Return: Success: A B-tree operation. The address of the new
- * node, if the node splits, is returned through
- * the NEW_NODE argument. The new node is always
- * to the right of the previous node.
+ * Return: Success: A B-tree operation. The address of the new
+ * node, if the node splits, is returned through
+ * the NEW_NODE argument. The new node is always
+ * to the right of the previous node.
*
- * Failure: H5B_INS_ERROR
+ * Failure: H5B_INS_ERROR
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jul 9 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jul 9 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static H5B_ins_t
-H5B_insert_helper (H5F_t *f, const haddr_t *addr, const H5B_class_t *type,
- uint8 *lt_key, hbool_t *lt_key_changed,
- uint8 *md_key, void *udata,
- uint8 *rt_key, hbool_t *rt_key_changed,
- haddr_t *new_node/*out*/)
+H5B_insert_helper(H5F_t *f, const haddr_t *addr, const H5B_class_t *type,
+ uint8 *lt_key, hbool_t *lt_key_changed,
+ uint8 *md_key, void *udata,
+ uint8 *rt_key, hbool_t *rt_key_changed,
+ haddr_t *new_node /*out */ )
{
- H5B_t *bt=NULL, *twin=NULL, *tmp_bt=NULL;
- intn lt=0, idx=-1, rt, cmp=-1;
- haddr_t child_addr;
- H5B_ins_t my_ins = H5B_INS_ERROR;
- H5B_ins_t ret_value = H5B_INS_ERROR;
-
- FUNC_ENTER (H5B_insert_helper, H5B_INS_ERROR);
-
- /*
- * Check arguments
- */
- assert (f);
- assert (addr && H5F_addr_defined (addr));
- assert (type);
- assert (type->decode);
- assert (type->cmp3);
- assert (type->new);
- assert (lt_key);
- assert (lt_key_changed);
- assert (rt_key);
- assert (rt_key_changed);
- assert (new_node);
-
- *lt_key_changed = FALSE;
- *rt_key_changed = FALSE;
-
- /*
- * Use a binary search to find the child that will receive the new
- * data. When the search completes IDX points to the child that
- * should get the new data.
- */
- if (NULL==(bt=H5AC_protect (f, H5AC_BT, addr, type, udata))) {
- HGOTO_ERROR (H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR,
- "unable to load node");
- }
- rt = bt->nchildren;
-
- while (lt<rt && cmp) {
- idx = (lt + rt) / 2;
- if (H5B_decode_keys (f, bt, idx)<0) {
- HRETURN_ERROR (H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR,
- "unable to decode key");
- }
- if ((cmp=(type->cmp3)(f, bt->key[idx].nkey, udata,
- bt->key[idx+1].nkey))<0) {
- rt = idx;
- } else {
- lt = idx+1;
- }
- }
-
- if (0==bt->nchildren) {
- /*
- * The value being inserted will be the only value in this tree. We
- * must necessarily be at level zero.
- */
- assert (0==bt->level);
- bt->key[0].nkey = bt->native;
- bt->key[1].nkey = bt->native + type->sizeof_nkey;
- if ((type->new)(f, H5B_INS_FIRST, bt->key[0].nkey, udata,
- bt->key[1].nkey, bt->child+0/*out*/)<0) {
- bt->key[0].nkey = bt->key[1].nkey = NULL;
- HGOTO_ERROR (H5E_BTREE, H5E_CANTINIT, H5B_INS_ERROR,
- "unable to create leaf node");
- }
- bt->nchildren = 1;
- bt->dirty = TRUE;
- bt->ndirty = 1;
- bt->key[0].dirty = TRUE;
- bt->key[1].dirty = TRUE;
- idx = 0;
-
- if (type->follow_min) {
- if ((my_ins=(type->insert)(f, bt->child+idx,
- bt->key[idx].nkey, lt_key_changed,
- md_key, udata,
- bt->key[idx+1].nkey, rt_key_changed,
- &child_addr/*out*/))<0) {
- HGOTO_ERROR (H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR,
- "can't insert first leaf node");
- }
- } else {
- my_ins = H5B_INS_NOOP;
- }
-
- } else if (cmp<0 && idx<=0 && bt->level>0) {
- /*
- * The value being inserted is less than any value in this tree. Follow
- * the minimum branch out of this node to a subtree.
- */
- idx = 0;
- if (H5B_decode_keys (f, bt, idx)<0) {
- HGOTO_ERROR (H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR,
- "unable to decode key");
- }
- if ((my_ins=H5B_insert_helper (f, bt->child+idx, type,
- bt->key[idx].nkey, lt_key_changed,
- md_key, udata,
- bt->key[idx+1].nkey, rt_key_changed,
- &child_addr/*out*/))<0) {
- HGOTO_ERROR (H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR,
- "can't insert minimum subtree");
- }
-
- } else if (cmp<0 && idx<=0 && type->follow_min) {
- /*
- * The value being inserted is less than any leaf node out of this
- * current node. Follow the minimum branch to a leaf node and let the
- * subclass handle the problem.
- */
- idx = 0;
- if (H5B_decode_keys (f, bt, idx)<0) {
- HGOTO_ERROR (H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR,
- "unable to decode key");
- }
- if ((my_ins=(type->insert)(f, bt->child+idx,
- bt->key[idx].nkey, lt_key_changed,
- md_key, udata,
- bt->key[idx+1].nkey, rt_key_changed,
- &child_addr/*out*/))<0) {
- HGOTO_ERROR (H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR,
- "can't insert minimum leaf node");
- }
-
- } else if (cmp<0 && idx<=0) {
- /*
- * The value being inserted is less than any leaf node out of the
- * current node. Create a new minimum leaf node out of this B-tree
- * node. This node is not empty (handled above).
- */
- idx = 0;
- if (H5B_decode_keys (f, bt, idx)<0) {
- HGOTO_ERROR (H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR,
- "unable to decode key");
- }
- my_ins = H5B_INS_LEFT;
- HDmemcpy (md_key, bt->key[idx].nkey, type->sizeof_nkey);
- if ((type->new)(f, H5B_INS_LEFT, bt->key[idx].nkey, udata, md_key,
- &child_addr/*out*/)<0) {
- HGOTO_ERROR (H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR,
- "can't insert minimum leaf node");
- }
- *lt_key_changed = TRUE;
-
- } else if (cmp>0 && idx+1>=bt->nchildren && bt->level>0) {
- /*
- * The value being inserted is larger than any value in this tree.
- * Follow the maximum branch out of this node to a subtree.
- */
- idx = bt->nchildren - 1;
- if (H5B_decode_keys (f, bt, idx)<0) {
- HGOTO_ERROR (H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR,
- "unable to decode key");
- }
- if ((my_ins=H5B_insert_helper (f, bt->child+idx, type,
- bt->key[idx].nkey, lt_key_changed,
- md_key, udata,
- bt->key[idx+1].nkey, rt_key_changed,
- &child_addr/*out*/))<0) {
- HGOTO_ERROR (H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR,
- "can't insert maximum subtree");
- }
-
- } else if (cmp>0 && idx+1>=bt->nchildren && type->follow_max) {
- /*
- * The value being inserted is larger than any leaf node out of the
- * current node. Follow the maximum branch to a leaf node and let the
- * subclass handle the problem.
- */
- idx = bt->nchildren - 1;
- if (H5B_decode_keys (f, bt, idx)<0) {
- HGOTO_ERROR (H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR,
- "unable to decode key");
- }
- if ((my_ins=(type->insert)(f, bt->child+idx,
- bt->key[idx].nkey, lt_key_changed,
- md_key, udata,
- bt->key[idx+1].nkey, rt_key_changed,
- &child_addr/*out*/))<0) {
- HGOTO_ERROR (H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR,
- "can't insert maximum leaf node");
- }
-
- } else if (cmp>0 && idx+1>=bt->nchildren) {
- /*
- * The value being inserted is larger than any leaf node out of the
- * current node. Create a new maximum leaf node out of this B-tree
- * node.
- */
- idx = bt->nchildren - 1;
- if (H5B_decode_keys (f, bt, idx)<0) {
- HGOTO_ERROR (H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR,
- "unable to decode key");
- }
- my_ins = H5B_INS_RIGHT;
- HDmemcpy (md_key, bt->key[idx+1].nkey, type->sizeof_nkey);
- if ((type->new)(f, H5B_INS_RIGHT, md_key, udata, bt->key[idx+1].nkey,
- &child_addr/*out*/)<0) {
- HGOTO_ERROR (H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR,
- "can't insert maximum leaf node");
- }
- *rt_key_changed = TRUE;
-
- } else if (cmp) {
- /*
- * We couldn't figure out which branch to follow out of this node. THIS
- * IS A MAJOR PROBLEM THAT NEEDS TO BE FIXED --rpm.
- */
- assert ("INTERNAL HDF5 ERROR (see rpm)" && 0);
-
- } else if (bt->level>0) {
- /*
- * Follow a branch out of this node to another subtree.
- */
- assert (idx>=0 && idx<bt->nchildren);
- if ((my_ins=H5B_insert_helper (f, bt->child+idx, type,
- bt->key[idx].nkey, lt_key_changed,
- md_key, udata,
- bt->key[idx+1].nkey, rt_key_changed,
- &child_addr/*out*/))<0) {
- HGOTO_ERROR (H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR,
- "can't insert subtree");
- }
-
- } else {
- /*
- * Follow a branch out of this node to a leaf node of some other type.
- */
- assert (idx>=0 && idx<bt->nchildren);
- if ((my_ins=(type->insert)(f, bt->child+idx,
- bt->key[idx].nkey, lt_key_changed,
- md_key, udata,
- bt->key[idx+1].nkey, rt_key_changed,
- &child_addr/*out*/))<0) {
- HGOTO_ERROR (H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR,
- "can't insert leaf node");
- }
-
- }
- assert (my_ins>=0);
-
- /*
- * Update the left and right keys of the current node.
- */
- if (*lt_key_changed) {
- bt->dirty = TRUE;
- bt->key[idx].dirty = TRUE;
- if (idx>0) {
- *lt_key_changed = FALSE;
- } else {
- HDmemcpy (lt_key, bt->key[idx].nkey, type->sizeof_nkey);
- }
- }
- if (*rt_key_changed) {
- bt->dirty = TRUE;
- bt->key[idx+1].dirty = TRUE;
- if (idx+1<bt->nchildren) {
- *rt_key_changed = FALSE;
- } else {
- HDmemcpy (rt_key, bt->key[idx+1].nkey, type->sizeof_nkey);
- }
- }
-
- if (H5B_INS_CHANGE==my_ins) {
- /*
- * The insertion simply changed the address for the child.
- */
- bt->child[idx] = child_addr;
- bt->dirty = TRUE;
- bt->ndirty = MAX (bt->ndirty, idx+1);
- ret_value = H5B_INS_NOOP;
-
- } else if (H5B_INS_LEFT==my_ins || H5B_INS_RIGHT==my_ins) {
- /* Make sure IDX is the slot number for the new node. */
- if (H5B_INS_RIGHT==my_ins) idx++;
-
- /* If this node is full then split it before inserting the new child. */
- if (bt->nchildren==2*H5B_K (f, type)) {
- if (H5B_split (f, type, bt, addr, udata, new_node/*out*/)<0) {
- HGOTO_ERROR (H5E_BTREE, H5E_CANTSPLIT, H5B_INS_ERROR,
- "can't split node");
- }
- if (NULL==(twin=H5AC_protect (f, H5AC_BT, new_node, type, udata))) {
- HGOTO_ERROR (H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR,
- "can't load B-tree");
- }
- if (idx<=H5B_K (f, type)) {
- tmp_bt = bt;
- } else {
- idx -= H5B_K (f, type);
- tmp_bt = twin;
- }
- } else {
- tmp_bt = bt;
- }
-
- /* Insert the child */
- if (H5B_insert_child (f, type, tmp_bt, idx, &child_addr, my_ins,
- md_key)<0) {
- HGOTO_ERROR (H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR,
- "can't insert child");
- }
- }
-
-
- /*
- * If this node split, return the mid key (the one that is shared
- * by the left and right node).
- */
- if (twin) {
- if (!twin->key[0].nkey && H5B_decode_key (f, twin, 0)<0) {
- HGOTO_ERROR (H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR,
- "unable to decode key");
- }
- HDmemcpy (md_key, twin->key[0].nkey, type->sizeof_nkey);
- ret_value = H5B_INS_RIGHT;
+ H5B_t *bt = NULL, *twin = NULL, *tmp_bt = NULL;
+ intn lt = 0, idx = -1, rt, cmp = -1;
+ haddr_t child_addr;
+ H5B_ins_t my_ins = H5B_INS_ERROR;
+ H5B_ins_t ret_value = H5B_INS_ERROR;
+
+ FUNC_ENTER(H5B_insert_helper, H5B_INS_ERROR);
+
+ /*
+ * Check arguments
+ */
+ assert(f);
+ assert(addr && H5F_addr_defined(addr));
+ assert(type);
+ assert(type->decode);
+ assert(type->cmp3);
+ assert(type->new);
+ assert(lt_key);
+ assert(lt_key_changed);
+ assert(rt_key);
+ assert(rt_key_changed);
+ assert(new_node);
+
+ *lt_key_changed = FALSE;
+ *rt_key_changed = FALSE;
+
+ /*
+ * Use a binary search to find the child that will receive the new
+ * data. When the search completes IDX points to the child that
+ * should get the new data.
+ */
+ if (NULL == (bt = H5AC_protect(f, H5AC_BT, addr, type, udata))) {
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR,
+ "unable to load node");
+ }
+ rt = bt->nchildren;
+
+ while (lt < rt && cmp) {
+ idx = (lt + rt) / 2;
+ if (H5B_decode_keys(f, bt, idx) < 0) {
+ HRETURN_ERROR(H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR,
+ "unable to decode key");
+ }
+ if ((cmp = (type->cmp3) (f, bt->key[idx].nkey, udata,
+ bt->key[idx + 1].nkey)) < 0) {
+ rt = idx;
+ } else {
+ lt = idx + 1;
+ }
+ }
+
+ if (0 == bt->nchildren) {
+ /*
+ * The value being inserted will be the only value in this tree. We
+ * must necessarily be at level zero.
+ */
+ assert(0 == bt->level);
+ bt->key[0].nkey = bt->native;
+ bt->key[1].nkey = bt->native + type->sizeof_nkey;
+ if ((type->new) (f, H5B_INS_FIRST, bt->key[0].nkey, udata,
+ bt->key[1].nkey, bt->child + 0 /*out */ ) < 0) {
+ bt->key[0].nkey = bt->key[1].nkey = NULL;
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTINIT, H5B_INS_ERROR,
+ "unable to create leaf node");
+ }
+ bt->nchildren = 1;
+ bt->dirty = TRUE;
+ bt->ndirty = 1;
+ bt->key[0].dirty = TRUE;
+ bt->key[1].dirty = TRUE;
+ idx = 0;
+
+ if (type->follow_min) {
+ if ((my_ins = (type->insert) (f, bt->child + idx,
+ bt->key[idx].nkey, lt_key_changed,
+ md_key, udata,
+ bt->key[idx + 1].nkey, rt_key_changed,
+ &child_addr /*out */ )) < 0) {
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR,
+ "can't insert first leaf node");
+ }
+ } else {
+ my_ins = H5B_INS_NOOP;
+ }
+
+ } else if (cmp < 0 && idx <= 0 && bt->level > 0) {
+ /*
+ * The value being inserted is less than any value in this tree. Follow
+ * the minimum branch out of this node to a subtree.
+ */
+ idx = 0;
+ if (H5B_decode_keys(f, bt, idx) < 0) {
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR,
+ "unable to decode key");
+ }
+ if ((my_ins = H5B_insert_helper(f, bt->child + idx, type,
+ bt->key[idx].nkey, lt_key_changed,
+ md_key, udata,
+ bt->key[idx + 1].nkey, rt_key_changed,
+ &child_addr /*out */ )) < 0) {
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR,
+ "can't insert minimum subtree");
+ }
+ } else if (cmp < 0 && idx <= 0 && type->follow_min) {
+ /*
+ * The value being inserted is less than any leaf node out of this
+ * current node. Follow the minimum branch to a leaf node and let the
+ * subclass handle the problem.
+ */
+ idx = 0;
+ if (H5B_decode_keys(f, bt, idx) < 0) {
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR,
+ "unable to decode key");
+ }
+ if ((my_ins = (type->insert) (f, bt->child + idx,
+ bt->key[idx].nkey, lt_key_changed,
+ md_key, udata,
+ bt->key[idx + 1].nkey, rt_key_changed,
+ &child_addr /*out */ )) < 0) {
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR,
+ "can't insert minimum leaf node");
+ }
+ } else if (cmp < 0 && idx <= 0) {
+ /*
+ * The value being inserted is less than any leaf node out of the
+ * current node. Create a new minimum leaf node out of this B-tree
+ * node. This node is not empty (handled above).
+ */
+ idx = 0;
+ if (H5B_decode_keys(f, bt, idx) < 0) {
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR,
+ "unable to decode key");
+ }
+ my_ins = H5B_INS_LEFT;
+ HDmemcpy(md_key, bt->key[idx].nkey, type->sizeof_nkey);
+ if ((type->new) (f, H5B_INS_LEFT, bt->key[idx].nkey, udata, md_key,
+ &child_addr /*out */ ) < 0) {
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR,
+ "can't insert minimum leaf node");
+ }
+ *lt_key_changed = TRUE;
+
+ } else if (cmp > 0 && idx + 1 >= bt->nchildren && bt->level > 0) {
+ /*
+ * The value being inserted is larger than any value in this tree.
+ * Follow the maximum branch out of this node to a subtree.
+ */
+ idx = bt->nchildren - 1;
+ if (H5B_decode_keys(f, bt, idx) < 0) {
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR,
+ "unable to decode key");
+ }
+ if ((my_ins = H5B_insert_helper(f, bt->child + idx, type,
+ bt->key[idx].nkey, lt_key_changed,
+ md_key, udata,
+ bt->key[idx + 1].nkey, rt_key_changed,
+ &child_addr /*out */ )) < 0) {
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR,
+ "can't insert maximum subtree");
+ }
+ } else if (cmp > 0 && idx + 1 >= bt->nchildren && type->follow_max) {
+ /*
+ * The value being inserted is larger than any leaf node out of the
+ * current node. Follow the maximum branch to a leaf node and let the
+ * subclass handle the problem.
+ */
+ idx = bt->nchildren - 1;
+ if (H5B_decode_keys(f, bt, idx) < 0) {
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR,
+ "unable to decode key");
+ }
+ if ((my_ins = (type->insert) (f, bt->child + idx,
+ bt->key[idx].nkey, lt_key_changed,
+ md_key, udata,
+ bt->key[idx + 1].nkey, rt_key_changed,
+ &child_addr /*out */ )) < 0) {
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR,
+ "can't insert maximum leaf node");
+ }
+ } else if (cmp > 0 && idx + 1 >= bt->nchildren) {
+ /*
+ * The value being inserted is larger than any leaf node out of the
+ * current node. Create a new maximum leaf node out of this B-tree
+ * node.
+ */
+ idx = bt->nchildren - 1;
+ if (H5B_decode_keys(f, bt, idx) < 0) {
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR,
+ "unable to decode key");
+ }
+ my_ins = H5B_INS_RIGHT;
+ HDmemcpy(md_key, bt->key[idx + 1].nkey, type->sizeof_nkey);
+ if ((type->new) (f, H5B_INS_RIGHT, md_key, udata, bt->key[idx + 1].nkey,
+ &child_addr /*out */ ) < 0) {
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR,
+ "can't insert maximum leaf node");
+ }
+ *rt_key_changed = TRUE;
+
+ } else if (cmp) {
+ /*
+ * We couldn't figure out which branch to follow out of this node. THIS
+ * IS A MAJOR PROBLEM THAT NEEDS TO BE FIXED --rpm.
+ */
+ assert("INTERNAL HDF5 ERROR (see rpm)" && 0);
+
+ } else if (bt->level > 0) {
+ /*
+ * Follow a branch out of this node to another subtree.
+ */
+ assert(idx >= 0 && idx < bt->nchildren);
+ if ((my_ins = H5B_insert_helper(f, bt->child + idx, type,
+ bt->key[idx].nkey, lt_key_changed,
+ md_key, udata,
+ bt->key[idx + 1].nkey, rt_key_changed,
+ &child_addr /*out */ )) < 0) {
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR,
+ "can't insert subtree");
+ }
+ } else {
+ /*
+ * Follow a branch out of this node to a leaf node of some other type.
+ */
+ assert(idx >= 0 && idx < bt->nchildren);
+ if ((my_ins = (type->insert) (f, bt->child + idx,
+ bt->key[idx].nkey, lt_key_changed,
+ md_key, udata,
+ bt->key[idx + 1].nkey, rt_key_changed,
+ &child_addr /*out */ )) < 0) {
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR,
+ "can't insert leaf node");
+ }
+ }
+ assert(my_ins >= 0);
+
+ /*
+ * Update the left and right keys of the current node.
+ */
+ if (*lt_key_changed) {
+ bt->dirty = TRUE;
+ bt->key[idx].dirty = TRUE;
+ if (idx > 0) {
+ *lt_key_changed = FALSE;
+ } else {
+ HDmemcpy(lt_key, bt->key[idx].nkey, type->sizeof_nkey);
+ }
+ }
+ if (*rt_key_changed) {
+ bt->dirty = TRUE;
+ bt->key[idx + 1].dirty = TRUE;
+ if (idx + 1 < bt->nchildren) {
+ *rt_key_changed = FALSE;
+ } else {
+ HDmemcpy(rt_key, bt->key[idx + 1].nkey, type->sizeof_nkey);
+ }
+ }
+ if (H5B_INS_CHANGE == my_ins) {
+ /*
+ * The insertion simply changed the address for the child.
+ */
+ bt->child[idx] = child_addr;
+ bt->dirty = TRUE;
+ bt->ndirty = MAX(bt->ndirty, idx + 1);
+ ret_value = H5B_INS_NOOP;
+
+ } else if (H5B_INS_LEFT == my_ins || H5B_INS_RIGHT == my_ins) {
+ /* Make sure IDX is the slot number for the new node. */
+ if (H5B_INS_RIGHT == my_ins)
+ idx++;
+
+ /* If this node is full then split it before inserting the new child. */
+ if (bt->nchildren == 2 * H5B_K(f, type)) {
+ if (H5B_split(f, type, bt, addr, udata, new_node /*out */ ) < 0) {
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTSPLIT, H5B_INS_ERROR,
+ "can't split node");
+ }
+ if (NULL == (twin = H5AC_protect(f, H5AC_BT, new_node, type, udata))) {
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, H5B_INS_ERROR,
+ "can't load B-tree");
+ }
+ if (idx <= H5B_K(f, type)) {
+ tmp_bt = bt;
+ } else {
+ idx -= H5B_K(f, type);
+ tmp_bt = twin;
+ }
+ } else {
+ tmp_bt = bt;
+ }
+
+ /* Insert the child */
+ if (H5B_insert_child(f, type, tmp_bt, idx, &child_addr, my_ins,
+ md_key) < 0) {
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTINSERT, H5B_INS_ERROR,
+ "can't insert child");
+ }
+ }
+ /*
+ * If this node split, return the mid key (the one that is shared
+ * by the left and right node).
+ */
+ if (twin) {
+ if (!twin->key[0].nkey && H5B_decode_key(f, twin, 0) < 0) {
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTDECODE, H5B_INS_ERROR,
+ "unable to decode key");
+ }
+ HDmemcpy(md_key, twin->key[0].nkey, type->sizeof_nkey);
+ ret_value = H5B_INS_RIGHT;
#ifdef H5B_DEBUG
- /*
- * The max key in the original left node must be equal to the min key
- * in the new node.
- */
- if (!bt->key[bt->nchildren].nkey) {
- herr_t status = H5B_decode_key (f, bt, bt->nchildren);
- assert (status>=0);
- }
- cmp = (type->cmp2)(f, bt->key[bt->nchildren].nkey, udata,
- twin->key[0].nkey);
- assert (0==cmp);
+ /*
+ * The max key in the original left node must be equal to the min key
+ * in the new node.
+ */
+ if (!bt->key[bt->nchildren].nkey) {
+ herr_t status = H5B_decode_key(f, bt, bt->nchildren);
+ assert(status >= 0);
+ }
+ cmp = (type->cmp2) (f, bt->key[bt->nchildren].nkey, udata,
+ twin->key[0].nkey);
+ assert(0 == cmp);
#endif
- } else {
- ret_value = H5B_INS_NOOP;
- }
-
-done:
- {
- herr_t e1 = (bt && H5AC_unprotect (f, H5AC_BT, addr, bt)<0);
- herr_t e2 = (twin && H5AC_unprotect (f, H5AC_BT, new_node, twin)<0);
- if (e1 || e2) { /*use vars to prevent short-circuit of side effects*/
- HRETURN_ERROR (H5E_BTREE, H5E_PROTECT, H5B_INS_ERROR,
- "unable to release node(s)");
- }
- }
-
- FUNC_LEAVE (ret_value);
+ } else {
+ ret_value = H5B_INS_NOOP;
+ }
+
+ done:
+ {
+ herr_t e1 = (bt && H5AC_unprotect(f, H5AC_BT, addr, bt) < 0);
+ herr_t e2 = (twin && H5AC_unprotect(f, H5AC_BT, new_node, twin) < 0);
+ if (e1 || e2) { /*use vars to prevent short-circuit of side effects */
+ HRETURN_ERROR(H5E_BTREE, H5E_PROTECT, H5B_INS_ERROR,
+ "unable to release node(s)");
+ }
+ }
+
+ FUNC_LEAVE(ret_value);
}
-
/*-------------------------------------------------------------------------
- * Function: H5B_list
+ * Function: H5B_list
*
- * Purpose: Calls the list callback for each leaf node of the
- * B-tree, passing it the UDATA structure.
+ * Purpose: Calls the list callback for each leaf node of the
+ * B-tree, passing it the UDATA structure.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jun 23 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jun 23 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
-H5B_list (H5F_t *f, const H5B_class_t *type, const haddr_t *addr, void *udata)
+H5B_list(H5F_t *f, const H5B_class_t *type, const haddr_t *addr, void *udata)
{
- H5B_t *bt=NULL;
- haddr_t next_addr;
- const haddr_t *cur_addr=NULL;
- intn i;
- herr_t ret_value = FAIL;
-
- FUNC_ENTER (H5B_list, FAIL);
-
- /*
- * Check arguments.
- */
- assert (f);
- assert (type);
- assert (type->list);
- assert (addr && H5F_addr_defined (addr));
- assert (udata);
-
- if (NULL==(bt = H5AC_find (f, H5AC_BT, addr, type, udata))) {
- HRETURN_ERROR (H5E_BTREE, H5E_CANTLOAD, FAIL,
- "unable to load B-tree node");
- }
-
- if (bt->level>0) {
- if (H5B_list (f, type, bt->child+0, udata)<0) {
- HRETURN_ERROR (H5E_BTREE, H5E_CANTLIST, FAIL,
- "unable to list B-tree node");
- } else {
- HRETURN (SUCCEED);
- }
- } else {
-
- for (cur_addr=addr; !H5F_addr_defined (cur_addr); cur_addr=&next_addr) {
- if (NULL==(bt=H5AC_protect (f, H5AC_BT, cur_addr, type, udata))) {
- HGOTO_ERROR (H5E_BTREE, H5E_CANTLOAD, FAIL,
- "unable to protect B-tree node");
- }
-
- for (i=0; i<bt->nchildren; i++) {
- if ((type->list)(f, bt->child+i, udata)<0) {
- HGOTO_ERROR (H5E_BTREE, H5E_CANTLOAD, FAIL,
- "unable to list leaf node");
- }
- }
-
- next_addr = bt->right;
- if (H5AC_unprotect (f, H5AC_BT, addr, bt)<0) {
- HRETURN_ERROR (H5E_BTREE, H5E_PROTECT, FAIL,
- "unable to release B-tree node");
- }
- bt = NULL;
- }
- }
- HGOTO_DONE (SUCCEED);
-
-done:
- if (bt && H5AC_unprotect (f, H5AC_BT, cur_addr, bt)<0) {
- HRETURN_ERROR (H5E_BTREE, H5E_PROTECT, FAIL,
- "unable to release B-tree node");
- }
- FUNC_LEAVE (ret_value);
+ H5B_t *bt = NULL;
+ haddr_t next_addr;
+ const haddr_t *cur_addr = NULL;
+ intn i;
+ herr_t ret_value = FAIL;
+
+ FUNC_ENTER(H5B_list, FAIL);
+
+ /*
+ * Check arguments.
+ */
+ assert(f);
+ assert(type);
+ assert(type->list);
+ assert(addr && H5F_addr_defined(addr));
+ assert(udata);
+
+ if (NULL == (bt = H5AC_find(f, H5AC_BT, addr, type, udata))) {
+ HRETURN_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL,
+ "unable to load B-tree node");
+ }
+ if (bt->level > 0) {
+ if (H5B_list(f, type, bt->child + 0, udata) < 0) {
+ HRETURN_ERROR(H5E_BTREE, H5E_CANTLIST, FAIL,
+ "unable to list B-tree node");
+ } else {
+ HRETURN(SUCCEED);
+ }
+ } else {
+
+ for (cur_addr = addr; !H5F_addr_defined(cur_addr); cur_addr = &next_addr) {
+ if (NULL == (bt = H5AC_protect(f, H5AC_BT, cur_addr, type, udata))) {
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL,
+ "unable to protect B-tree node");
+ }
+ for (i = 0; i < bt->nchildren; i++) {
+ if ((type->list) (f, bt->child + i, udata) < 0) {
+ HGOTO_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL,
+ "unable to list leaf node");
+ }
+ }
+
+ next_addr = bt->right;
+ if (H5AC_unprotect(f, H5AC_BT, addr, bt) < 0) {
+ HRETURN_ERROR(H5E_BTREE, H5E_PROTECT, FAIL,
+ "unable to release B-tree node");
+ }
+ bt = NULL;
+ }
+ }
+ HGOTO_DONE(SUCCEED);
+
+ done:
+ if (bt && H5AC_unprotect(f, H5AC_BT, cur_addr, bt) < 0) {
+ HRETURN_ERROR(H5E_BTREE, H5E_PROTECT, FAIL,
+ "unable to release B-tree node");
+ }
+ FUNC_LEAVE(ret_value);
}
-
/*-------------------------------------------------------------------------
- * Function: H5B_nodesize
+ * Function: H5B_nodesize
*
- * Purpose: Returns the number of bytes needed for this type of
- * B-tree node. The size is the size of the header plus
- * enough space for 2t child pointers and 2t+1 keys.
+ * Purpose: Returns the number of bytes needed for this type of
+ * B-tree node. The size is the size of the header plus
+ * enough space for 2t child pointers and 2t+1 keys.
*
- * If TOTAL_NKEY_SIZE is non-null, what it points to will
- * be initialized with the total number of bytes required to
- * hold all the key values in native order.
+ * If TOTAL_NKEY_SIZE is non-null, what it points to will
+ * be initialized with the total number of bytes required to
+ * hold all the key values in native order.
*
- * Return: Success: Size of node in file.
+ * Return: Success: Size of node in file.
*
- * Failure: 0
+ * Failure: 0
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jul 3 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jul 3 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static size_t
-H5B_nodesize (H5F_t *f, const H5B_class_t *type,
- size_t *total_nkey_size, size_t sizeof_rkey)
+H5B_nodesize(H5F_t *f, const H5B_class_t *type,
+ size_t *total_nkey_size, size_t sizeof_rkey)
{
- size_t size;
-
- FUNC_ENTER (H5B_nodesize, (size_t)0);
-
- /*
- * Check arguments.
- */
- assert (f);
- assert (type);
- assert (sizeof_rkey>0);
- assert (H5B_K (f, type)>0);
-
- /*
- * Total native key size.
- */
- if (total_nkey_size) {
- *total_nkey_size = (2 * H5B_K(f,type) + 1) * type->sizeof_nkey;
- }
-
- /*
- * Total node size.
- */
- size = (H5B_SIZEOF_HDR(f) + /*node header */
- 2 * H5B_K(f,type) * H5F_SIZEOF_ADDR(f) + /*child pointers*/
- (2*H5B_K(f,type)+1) * sizeof_rkey); /*keys */
-
- FUNC_LEAVE (size);
+ size_t size;
+
+ FUNC_ENTER(H5B_nodesize, (size_t) 0);
+
+ /*
+ * Check arguments.
+ */
+ assert(f);
+ assert(type);
+ assert(sizeof_rkey > 0);
+ assert(H5B_K(f, type) > 0);
+
+ /*
+ * Total native key size.
+ */
+ if (total_nkey_size) {
+ *total_nkey_size = (2 * H5B_K(f, type) + 1) * type->sizeof_nkey;
+ }
+ /*
+ * Total node size.
+ */
+ size = (H5B_SIZEOF_HDR(f) + /*node header */
+ 2 * H5B_K(f, type) * H5F_SIZEOF_ADDR(f) + /*child pointers */
+ (2 * H5B_K(f, type) + 1) * sizeof_rkey); /*keys */
+
+ FUNC_LEAVE(size);
}
-
/*-------------------------------------------------------------------------
- * Function: H5B_debug
+ * Function: H5B_debug
*
- * Purpose: Prints debugging info about a B-tree.
+ * Purpose: Prints debugging info about a B-tree.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Aug 4 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Aug 4 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
-H5B_debug (H5F_t *f, const haddr_t *addr, FILE *stream, intn indent,
- intn fwidth, const H5B_class_t *type, void *udata)
+H5B_debug(H5F_t *f, const haddr_t *addr, FILE * stream, intn indent,
+ intn fwidth, const H5B_class_t *type, void *udata)
{
- H5B_t *bt = NULL;
- int i;
-
- FUNC_ENTER (H5B_debug, FAIL);
-
- /*
- * Check arguments.
- */
- assert (f);
- assert (addr && H5F_addr_defined (addr));
- assert (stream);
- assert (indent>=0);
- assert (fwidth>=0);
- assert (type);
-
- /*
- * Load the tree node.
- */
- if (NULL==(bt=H5AC_find (f, H5AC_BT, addr, type, udata))) {
- HRETURN_ERROR (H5E_BTREE, H5E_CANTLOAD, FAIL,
- "unable to load B-tree node");
- }
-
- /*
- * Print the values.
- */
- fprintf (stream, "%*s%-*s %d\n", indent, "", fwidth,
- "Tree type ID:",
- (int)(bt->type->id));
- fprintf (stream, "%*s%-*s %lu\n", indent, "", fwidth,
- "Size of raw (disk) key:",
- (unsigned long)(bt->sizeof_rkey));
- fprintf (stream, "%*s%-*s %s\n", indent, "", fwidth,
- "Dirty flag:",
- bt->dirty?"True":"False");
- fprintf (stream, "%*s%-*s %d\n", indent, "", fwidth,
- "Number of initial dirty children:",
- (int)(bt->ndirty));
- fprintf (stream, "%*s%-*s %d\n", indent, "", fwidth,
- "Level:",
- (int)(bt->level));
-
- fprintf (stream, "%*s%-*s ", indent, "", fwidth,
- "Address of left sibling:");
- H5F_addr_print (stream, &(bt->left));
- fprintf (stream, "\n");
-
- fprintf (stream, "%*s%-*s ", indent, "", fwidth,
- "Address of right sibling:");
- H5F_addr_print (stream, &(bt->right));
- fprintf (stream, "\n");
-
- fprintf (stream, "%*s%-*s %d (%d)\n", indent, "", fwidth,
- "Number of children (max):",
- (int)(bt->nchildren),
- (int)(2*H5B_K(f,type)));
-
- /*
- * Print the child addresses
- */
- for (i=0; i<bt->nchildren; i++) {
- fprintf (stream, "%*sChild %d...\n", indent, "", i);
- fprintf (stream, "%*s%-*s ", indent+3, "", MAX(0,fwidth-3),
- "Address:");
- H5F_addr_print (stream, bt->child+i);
- fprintf (stream, "\n");
- }
-
- FUNC_LEAVE (SUCCEED);
+ H5B_t *bt = NULL;
+ int i;
+
+ FUNC_ENTER(H5B_debug, FAIL);
+
+ /*
+ * Check arguments.
+ */
+ assert(f);
+ assert(addr && H5F_addr_defined(addr));
+ assert(stream);
+ assert(indent >= 0);
+ assert(fwidth >= 0);
+ assert(type);
+
+ /*
+ * Load the tree node.
+ */
+ if (NULL == (bt = H5AC_find(f, H5AC_BT, addr, type, udata))) {
+ HRETURN_ERROR(H5E_BTREE, H5E_CANTLOAD, FAIL,
+ "unable to load B-tree node");
+ }
+ /*
+ * Print the values.
+ */
+ fprintf(stream, "%*s%-*s %d\n", indent, "", fwidth,
+ "Tree type ID:",
+ (int) (bt->type->id));
+ fprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth,
+ "Size of raw (disk) key:",
+ (unsigned long) (bt->sizeof_rkey));
+ fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
+ "Dirty flag:",
+ bt->dirty ? "True" : "False");
+ fprintf(stream, "%*s%-*s %d\n", indent, "", fwidth,
+ "Number of initial dirty children:",
+ (int) (bt->ndirty));
+ fprintf(stream, "%*s%-*s %d\n", indent, "", fwidth,
+ "Level:",
+ (int) (bt->level));
+
+ fprintf(stream, "%*s%-*s ", indent, "", fwidth,
+ "Address of left sibling:");
+ H5F_addr_print(stream, &(bt->left));
+ fprintf(stream, "\n");
+
+ fprintf(stream, "%*s%-*s ", indent, "", fwidth,
+ "Address of right sibling:");
+ H5F_addr_print(stream, &(bt->right));
+ fprintf(stream, "\n");
+
+ fprintf(stream, "%*s%-*s %d (%d)\n", indent, "", fwidth,
+ "Number of children (max):",
+ (int) (bt->nchildren),
+ (int) (2 * H5B_K(f, type)));
+
+ /*
+ * Print the child addresses
+ */
+ for (i = 0; i < bt->nchildren; i++) {
+ fprintf(stream, "%*sChild %d...\n", indent, "", i);
+ fprintf(stream, "%*s%-*s ", indent + 3, "", MAX(0, fwidth - 3),
+ "Address:");
+ H5F_addr_print(stream, bt->child + i);
+ fprintf(stream, "\n");
+ }
+
+ FUNC_LEAVE(SUCCEED);
}
-
-
/*-------------------------------------------------------------------------
- * Function: H5B_assert
+ * Function: H5B_assert
*
- * Purpose: Verifies that the tree is structured correctly.
+ * Purpose: Verifies that the tree is structured correctly.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: aborts if something is wrong.
+ * Failure: aborts if something is wrong.
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Tuesday, November 4, 1997
*
* Modifications:
@@ -1633,100 +1597,98 @@ H5B_debug (H5F_t *f, const haddr_t *addr, FILE *stream, intn indent,
*/
#ifdef H5B_DEBUG
static herr_t
-H5B_assert (H5F_t *f, const haddr_t *addr, const H5B_class_t *type,
- void *udata)
+H5B_assert(H5F_t *f, const haddr_t *addr, const H5B_class_t *type,
+ void *udata)
{
- H5B_t *bt = NULL;
- intn i, ncell, cmp;
- static int ncalls=0;
- herr_t status;
-
- /* A queue of child data */
- struct child_t {
- haddr_t addr;
- int level;
- struct child_t *next;
- } *head=NULL, *tail=NULL, *prev=NULL, *cur=NULL, *tmp=NULL;
-
- FUNC_ENTER (H5B_assert, FAIL);
- if (0==ncalls++) {
- fprintf (stderr, "HDF5-DIAG: debugging B-trees (expensive)\n");
- }
-
- /* Initialize the queue */
- bt = H5AC_find (f, H5AC_BT, addr, type, udata);
- assert (bt);
- cur = H5MM_xcalloc (1, sizeof(struct child_t));
- cur->addr = *addr;
- cur->level = bt->level;
- head = tail = cur;
-
- /*
- * Do a breadth-first search of the tree. New nodes are added to the end
- * of the queue as the `cur' pointer is advanced toward the end. We don't
- * remove any nodes from the queue because we need them in the uniqueness
- * test.
- */
- for (ncell=0; cur; ncell++) {
- bt = H5AC_protect (f, H5AC_BT, &(cur->addr), type, udata);
- assert (bt);
-
- /* Check node header */
- assert (bt->ndirty>=0 && bt->ndirty<=bt->nchildren);
- assert (bt->level==cur->level);
- if (cur->next && cur->next->level==bt->level) {
- assert (H5F_addr_eq (&(bt->right), &(cur->next->addr)));
- } else {
- assert (!H5F_addr_defined (&(bt->right)));
- }
- if (prev && prev->level==bt->level) {
- assert (H5F_addr_eq (&(bt->left), &(prev->addr)));
- } else {
- assert (!H5F_addr_defined (&(bt->left)));
- }
-
- if (cur->level>0) {
- for (i=0; i<bt->nchildren; i++) {
-
- /*
- * Check that child nodes haven't already been seen. If they
- * have then the tree has a cycle.
- */
- for (tmp=head; tmp; tmp=tmp->next) {
- assert (H5F_addr_ne (&(tmp->addr), bt->child+i));
- }
-
- /* Add the child node to the end of the queue */
- tmp = H5MM_xcalloc (1, sizeof(struct child_t));
- tmp->addr = bt->child[i];
- tmp->level = bt->level - 1;
- tail->next = tmp;
- tail = tmp;
-
- /* Check that the keys are monotonically increasing */
- status = H5B_decode_keys (f, bt, i);
- assert (status>=0);
- cmp = (type->cmp2)(f, bt->key[i].nkey, udata, bt->key[i+1].nkey);
- assert (cmp<0);
- }
- }
-
- /* Release node */
- status = H5AC_unprotect (f, H5AC_BT, &(cur->addr), bt);
- assert (status>=0);
-
- /* Advance current location in queue */
- prev = cur;
- cur = cur->next;
- }
-
- /* Free all entries from queue */
- while (head) {
- tmp = head->next;
- H5MM_xfree (head);
- head = tmp;
- }
-
- FUNC_LEAVE (SUCCEED);
+ H5B_t *bt = NULL;
+ intn i, ncell, cmp;
+ static int ncalls = 0;
+ herr_t status;
+
+ /* A queue of child data */
+ struct child_t {
+ haddr_t addr;
+ int level;
+ struct child_t *next;
+ } *head = NULL, *tail = NULL, *prev = NULL, *cur = NULL, *tmp = NULL;
+
+ FUNC_ENTER(H5B_assert, FAIL);
+ if (0 == ncalls++) {
+ fprintf(stderr, "HDF5-DIAG: debugging B-trees (expensive)\n");
+ }
+ /* Initialize the queue */
+ bt = H5AC_find(f, H5AC_BT, addr, type, udata);
+ assert(bt);
+ cur = H5MM_xcalloc(1, sizeof(struct child_t));
+ cur->addr = *addr;
+ cur->level = bt->level;
+ head = tail = cur;
+
+ /*
+ * Do a breadth-first search of the tree. New nodes are added to the end
+ * of the queue as the `cur' pointer is advanced toward the end. We don't
+ * remove any nodes from the queue because we need them in the uniqueness
+ * test.
+ */
+ for (ncell = 0; cur; ncell++) {
+ bt = H5AC_protect(f, H5AC_BT, &(cur->addr), type, udata);
+ assert(bt);
+
+ /* Check node header */
+ assert(bt->ndirty >= 0 && bt->ndirty <= bt->nchildren);
+ assert(bt->level == cur->level);
+ if (cur->next && cur->next->level == bt->level) {
+ assert(H5F_addr_eq(&(bt->right), &(cur->next->addr)));
+ } else {
+ assert(!H5F_addr_defined(&(bt->right)));
+ }
+ if (prev && prev->level == bt->level) {
+ assert(H5F_addr_eq(&(bt->left), &(prev->addr)));
+ } else {
+ assert(!H5F_addr_defined(&(bt->left)));
+ }
+
+ if (cur->level > 0) {
+ for (i = 0; i < bt->nchildren; i++) {
+
+ /*
+ * Check that child nodes haven't already been seen. If they
+ * have then the tree has a cycle.
+ */
+ for (tmp = head; tmp; tmp = tmp->next) {
+ assert(H5F_addr_ne(&(tmp->addr), bt->child + i));
+ }
+
+ /* Add the child node to the end of the queue */
+ tmp = H5MM_xcalloc(1, sizeof(struct child_t));
+ tmp->addr = bt->child[i];
+ tmp->level = bt->level - 1;
+ tail->next = tmp;
+ tail = tmp;
+
+ /* Check that the keys are monotonically increasing */
+ status = H5B_decode_keys(f, bt, i);
+ assert(status >= 0);
+ cmp = (type->cmp2) (f, bt->key[i].nkey, udata, bt->key[i + 1].nkey);
+ assert(cmp < 0);
+ }
+ }
+ /* Release node */
+ status = H5AC_unprotect(f, H5AC_BT, &(cur->addr), bt);
+ assert(status >= 0);
+
+ /* Advance current location in queue */
+ prev = cur;
+ cur = cur->next;
+ }
+
+ /* Free all entries from queue */
+ while (head) {
+ tmp = head->next;
+ H5MM_xfree(head);
+ head = tmp;
+ }
+
+ FUNC_LEAVE(SUCCEED);
}
#endif /* H5B_DEBUG */
diff --git a/src/H5Bprivate.h b/src/H5Bprivate.h
index 0719238..dfc29a0 100644
--- a/src/H5Bprivate.h
+++ b/src/H5Bprivate.h
@@ -1,22 +1,22 @@
/*-------------------------------------------------------------------------
- * Copyright (C) 1997 National Center for Supercomputing Applications.
+ * Copyright (C) 1997 National Center for Supercomputing Applications.
* All rights reserved.
*
*-------------------------------------------------------------------------
*
- * Created: H5Bprivate.h
- * Jul 10 1997
- * Robb Matzke <matzke@llnl.gov>
+ * Created: H5Bprivate.h
+ * Jul 10 1997
+ * Robb Matzke <matzke@llnl.gov>
*
- * Purpose: Private non-prototype header.
+ * Purpose: Private non-prototype header.
*
- * Modifications:
+ * Modifications:
*
*-------------------------------------------------------------------------
*/
#ifndef _H5Bprivate_H
#define _H5Bprivate_H
-#include <H5Bpublic.h> /*API prototypes */
+#include <H5Bpublic.h> /*API prototypes */
/* Private headers needed by this file */
#include <H5private.h>
@@ -24,40 +24,38 @@
/*
* Feature: Define this constant if you want to check B-tree consistency
- * after each B-tree operation. Note that this slows down the
- * library considerably! Debugging the B-tree depends on assert()
- * being enabled.
+ * after each B-tree operation. Note that this slows down the
+ * library considerably! Debugging the B-tree depends on assert()
+ * being enabled.
*/
#ifdef NDEBUG
# undef H5B_DEBUG
#endif
+#define H5B_MAGIC "TREE" /*tree node magic number */
+#define H5B_SIZEOF_MAGIC 4 /*size of magic number */
-#define H5B_MAGIC "TREE" /*tree node magic number */
-#define H5B_SIZEOF_MAGIC 4 /*size of magic number */
+#define H5B_SIZEOF_HDR(F) \
+ (H5B_SIZEOF_MAGIC + /*magic number */ \
+ 4 + /*type, level, num entries */ \
+ 2*H5F_SIZEOF_ADDR(F)) /*left and right sibling addresses */
-#define H5B_SIZEOF_HDR(F) \
- (H5B_SIZEOF_MAGIC + /*magic number */ \
- 4 + /*type, level, num entries */ \
- 2*H5F_SIZEOF_ADDR(F)) /*left and right sibling addresses */
-
-#define H5B_K(F,TYPE) /*K value given file and Btree subclass */ \
+#define H5B_K(F,TYPE) /*K value given file and Btree subclass */ \
((F)->shared->create_parms.btree_k[(TYPE)->id])
typedef enum H5B_ins_t {
- H5B_INS_ERROR =-1, /*error return value */
- H5B_INS_NOOP =0, /*insert made no changes */
- H5B_INS_LEFT =1, /*insert new node to left of cur node */
- H5B_INS_RIGHT =2, /*insert new node to right of cur node */
- H5B_INS_CHANGE =3, /*change child address for cur node */
- H5B_INS_FIRST =4 /*insert first node in (sub)tree */
+ H5B_INS_ERROR = -1, /*error return value */
+ H5B_INS_NOOP = 0, /*insert made no changes */
+ H5B_INS_LEFT = 1, /*insert new node to left of cur node */
+ H5B_INS_RIGHT = 2, /*insert new node to right of cur node */
+ H5B_INS_CHANGE = 3, /*change child address for cur node */
+ H5B_INS_FIRST = 4 /*insert first node in (sub)tree */
} H5B_ins_t;
typedef enum H5B_subid_t {
- H5B_SNODE_ID =0, /*B-tree is for symbol table nodes */
- H5B_ISTORE_ID =1 /*B-tree is for indexed object storage */
+ H5B_SNODE_ID = 0, /*B-tree is for symbol table nodes */
+ H5B_ISTORE_ID = 1 /*B-tree is for indexed object storage */
} H5B_subid_t;
-
/*
* Each class of object that can be pointed to by a B-link tree has a
@@ -66,61 +64,59 @@ typedef enum H5B_subid_t {
* has an array of K values indexed by the `id' class field below. The
* array is initialized with the HDF5_BTREE_K_DEFAULT macro.
*/
-struct H5B_t; /*forward decl*/
+struct H5B_t; /*forward decl */
typedef struct H5B_class_t {
- H5B_subid_t id; /*id as found in file */
- size_t sizeof_nkey; /*size of native (memory) key */
- size_t (*get_sizeof_rkey)(H5F_t*,const void*);/*raw key size */
- herr_t (*new)(H5F_t*,H5B_ins_t,void*,void*,void*,haddr_t*);
- intn (*cmp2)(H5F_t*,void*,void*,void*); /*compare 2 keys */
- intn (*cmp3)(H5F_t*,void*,void*,void*); /*compare 3 keys */
- herr_t (*found)(H5F_t*,const haddr_t*,const void*,void*,const void*);
- H5B_ins_t (*insert)(H5F_t*,const haddr_t*,void*,hbool_t*,void*,void*,
- void*,hbool_t*,haddr_t*); /*insert new data */
- hbool_t follow_min; /*min insert uses min leaf, not new() */
- hbool_t follow_max; /*max insert uses max leaf, not new() */
- herr_t (*list)(H5F_t*,const haddr_t*,void*); /*walk leaf nodes */
- herr_t (*decode)(H5F_t*,struct H5B_t*,uint8*,void*);
- herr_t (*encode)(H5F_t*,struct H5B_t*,uint8*,void*);
+ H5B_subid_t id; /*id as found in file */
+ size_t sizeof_nkey; /*size of native (memory) key */
+ size_t (*get_sizeof_rkey) (H5F_t *, const void *); /*raw key size */
+ herr_t (*new) (H5F_t *, H5B_ins_t, void *, void *, void *, haddr_t *);
+ intn (*cmp2) (H5F_t *, void *, void *, void *); /*compare 2 keys */
+ intn (*cmp3) (H5F_t *, void *, void *, void *); /*compare 3 keys */
+ herr_t (*found) (H5F_t *, const haddr_t *, const void *, void *, const void *);
+ H5B_ins_t (*insert) (H5F_t *, const haddr_t *, void *, hbool_t *, void *, void *,
+ void *, hbool_t *, haddr_t *); /*insert new data */
+ hbool_t follow_min; /*min insert uses min leaf, not new() */
+ hbool_t follow_max; /*max insert uses max leaf, not new() */
+ herr_t (*list) (H5F_t *, const haddr_t *, void *); /*walk leaf nodes */
+ herr_t (*decode) (H5F_t *, struct H5B_t *, uint8 *, void *);
+ herr_t (*encode) (H5F_t *, struct H5B_t *, uint8 *, void *);
} H5B_class_t;
/*
* The B-tree node as stored in memory...
*/
typedef struct H5B_key_t {
- hbool_t dirty; /*native key is more recent than raw key*/
- uint8 *rkey; /*ptr into node->page for raw key */
- void *nkey; /*null or ptr into node->native for key */
+ hbool_t dirty; /*native key is more recent than raw key */
+ uint8 *rkey; /*ptr into node->page for raw key */
+ void *nkey; /*null or ptr into node->native for key */
} H5B_key_t;
typedef struct H5B_t {
- const H5B_class_t *type; /*type of tree */
- size_t sizeof_rkey; /*size of raw (disk) key */
- hbool_t dirty; /*something in the tree is dirty */
- intn ndirty; /*num child ptrs to emit */
- intn level; /*node level */
- haddr_t left; /*address of left sibling */
- haddr_t right; /*address of right sibling */
- intn nchildren; /*number of child pointers */
- uint8 *page; /*disk page */
- uint8 *native; /*array of keys in native format */
- H5B_key_t *key; /*2k+1 key entries */
- haddr_t *child; /*2k child pointers */
+ const H5B_class_t *type; /*type of tree */
+ size_t sizeof_rkey; /*size of raw (disk) key */
+ hbool_t dirty; /*something in the tree is dirty */
+ intn ndirty; /*num child ptrs to emit */
+ intn level; /*node level */
+ haddr_t left; /*address of left sibling */
+ haddr_t right; /*address of right sibling */
+ intn nchildren; /*number of child pointers */
+ uint8 *page; /*disk page */
+ uint8 *native; /*array of keys in native format */
+ H5B_key_t *key; /*2k+1 key entries */
+ haddr_t *child; /*2k child pointers */
} H5B_t;
-
/*
* Library prototypes.
*/
-herr_t H5B_debug (H5F_t *f, const haddr_t *addr, FILE *stream, intn indent,
- intn fwidth, const H5B_class_t *type, void *udata);
-herr_t H5B_create (H5F_t *f, const H5B_class_t *type, void *udata, haddr_t*);
-herr_t H5B_find (H5F_t *f, const H5B_class_t *type, const haddr_t *addr,
- void *udata);
-herr_t H5B_insert (H5F_t *f, const H5B_class_t *type, const haddr_t *addr,
- void *udata);
-herr_t H5B_list (H5F_t *f, const H5B_class_t *type, const haddr_t *addr,
- void *udata);
-
+herr_t H5B_debug(H5F_t *f, const haddr_t *addr, FILE * stream, intn indent,
+ intn fwidth, const H5B_class_t *type, void *udata);
+herr_t H5B_create(H5F_t *f, const H5B_class_t *type, void *udata, haddr_t *);
+herr_t H5B_find(H5F_t *f, const H5B_class_t *type, const haddr_t *addr,
+ void *udata);
+herr_t H5B_insert(H5F_t *f, const H5B_class_t *type, const haddr_t *addr,
+ void *udata);
+herr_t H5B_list(H5F_t *f, const H5B_class_t *type, const haddr_t *addr,
+ void *udata);
#endif
diff --git a/src/H5Bpublic.h b/src/H5Bpublic.h
index 593373b..7fbb6c0 100644
--- a/src/H5Bpublic.h
+++ b/src/H5Bpublic.h
@@ -1,16 +1,16 @@
/*-------------------------------------------------------------------------
- * Copyright (C) 1997 National Center for Supercomputing Applications.
+ * Copyright (C) 1997 National Center for Supercomputing Applications.
* All rights reserved.
*
*-------------------------------------------------------------------------
*
- * Created: H5Bproto.h
- * Jul 10 1997
- * Robb Matzke <matzke@llnl.gov>
+ * Created: H5Bproto.h
+ * Jul 10 1997
+ * Robb Matzke <matzke@llnl.gov>
*
- * Purpose: Public declarations for the H5B package.
+ * Purpose: Public declarations for the H5B package.
*
- * Modifications:
+ * Modifications:
*
*-------------------------------------------------------------------------
*/
@@ -21,11 +21,11 @@
#include <H5public.h>
#ifdef __cplusplus
-extern "C" {
+extern "C" {
#endif
#ifdef __cplusplus
}
-#endif
#endif
+#endif
diff --git a/src/H5C.c b/src/H5C.c
index 22349d4..20c3351 100644
--- a/src/H5C.c
+++ b/src/H5C.c
@@ -11,7 +11,7 @@
****************************************************************************/
#ifdef RCSID
-static char RcsId[] = "@(#)$Revision$";
+static char RcsId[] = "@(#)$Revision$";
#endif
/* $Id$ */
@@ -19,23 +19,23 @@ static char RcsId[] = "@(#)$Revision$";
#include <stdarg.h>
/* Private header files */
-#include <H5private.h> /* Generic Functions */
-#include <H5Aprivate.h> /* Atoms */
-#include <H5Bprivate.h> /* B-tree subclass names */
-#include <H5Cprivate.h> /* Template information */
-#include <H5Dprivate.h> /* Datasets */
-#include <H5Eprivate.h> /* Error handling */
-#include <H5MMprivate.h> /* Memory management */
+#include <H5private.h> /* Generic Functions */
+#include <H5Aprivate.h> /* Atoms */
+#include <H5Bprivate.h> /* B-tree subclass names */
+#include <H5Cprivate.h> /* Template information */
+#include <H5Dprivate.h> /* Datasets */
+#include <H5Eprivate.h> /* Error handling */
+#include <H5MMprivate.h> /* Memory management */
-#define PABLO_MASK H5C_mask
+#define PABLO_MASK H5C_mask
/* Is the interface initialized? */
-static hbool_t interface_initialize_g = FALSE;
+static hbool_t interface_initialize_g = FALSE;
#define INTERFACE_INIT H5C_init_interface
-static herr_t H5C_init_interface(void);
+static herr_t H5C_init_interface(void);
/* PRIVATE PROTOTYPES */
-static void H5C_term_interface (void);
+static void H5C_term_interface(void);
/*--------------------------------------------------------------------------
NAME
@@ -50,39 +50,38 @@ DESCRIPTION
--------------------------------------------------------------------------*/
static herr_t
-H5C_init_interface (void)
+H5C_init_interface(void)
{
- herr_t ret_value = SUCCEED;
- intn i;
- herr_t status;
-
- FUNC_ENTER (H5C_init_interface, FAIL);
-
- assert (H5C_NCLASSES <= H5_TEMPLATE_MAX-H5_TEMPLATE_0);
-
- /*
- * Initialize the mappings between template classes and atom groups. We
- * keep the two separate because template classes are publicly visible but
- * atom groups aren't.
- */
- for (i=0; i<H5C_NCLASSES; i++) {
- status = H5Ainit_group (H5_TEMPLATE_0+i, H5A_TEMPID_HASHSIZE, 0, NULL);
- if (status<0) ret_value = FAIL;
- }
- if (ret_value<0) {
- HRETURN_ERROR (H5E_ATOM, H5E_CANTINIT, FAIL,
- "unable to initialize atom group");
- }
-
- /*
- * Register cleanup function.
- */
- if (H5_add_exit (H5C_term_interface)<0) {
- HRETURN_ERROR (H5E_INTERNAL, H5E_CANTINIT, FAIL,
- "unable to install atexit function");
- }
-
- FUNC_LEAVE(ret_value);
+ herr_t ret_value = SUCCEED;
+ intn i;
+ herr_t status;
+
+ FUNC_ENTER(H5C_init_interface, FAIL);
+
+ assert(H5C_NCLASSES <= H5_TEMPLATE_MAX - H5_TEMPLATE_0);
+
+ /*
+ * Initialize the mappings between template classes and atom groups. We
+ * keep the two separate because template classes are publicly visible but
+ * atom groups aren't.
+ */
+ for (i = 0; i < H5C_NCLASSES; i++) {
+ status = H5Ainit_group(H5_TEMPLATE_0 + i, H5A_TEMPID_HASHSIZE, 0, NULL);
+ if (status < 0)
+ ret_value = FAIL;
+ }
+ if (ret_value < 0) {
+ HRETURN_ERROR(H5E_ATOM, H5E_CANTINIT, FAIL,
+ "unable to initialize atom group");
+ }
+ /*
+ * Register cleanup function.
+ */
+ if (H5_add_exit(H5C_term_interface) < 0) {
+ HRETURN_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL,
+ "unable to install atexit function");
+ }
+ FUNC_LEAVE(ret_value);
}
/*--------------------------------------------------------------------------
@@ -103,13 +102,13 @@ H5C_init_interface (void)
REVISION LOG
--------------------------------------------------------------------------*/
static void
-H5C_term_interface (void)
+H5C_term_interface(void)
{
- intn i;
+ intn i;
- for (i=0; i<H5C_NCLASSES; i++) {
- H5Adestroy_group (H5_TEMPLATE_0+i);
- }
+ for (i = 0; i < H5C_NCLASSES; i++) {
+ H5Adestroy_group(H5_TEMPLATE_0 + i);
+ }
}
/*--------------------------------------------------------------------------
@@ -119,7 +118,7 @@ H5C_term_interface (void)
Returns a copy of the default template for some class of templates.
USAGE
herr_t H5Ccreate (type)
- H5C_class_t type; IN: Template class whose default is desired.
+ H5C_class_t type; IN: Template class whose default is desired.
RETURNS
Template ID or FAIL
@@ -132,61 +131,59 @@ H5C_term_interface (void)
Returns a copy of the default template for some class of templates.
--------------------------------------------------------------------------*/
hid_t
-H5Ccreate (H5C_class_t type)
+H5Ccreate(H5C_class_t type)
{
- hid_t ret_value = FAIL;
- void *tmpl = NULL;
-
- FUNC_ENTER (H5Ccreate, FAIL);
-
- /* Allocate a new template and initialize it with default values */
- switch (type) {
- case H5C_FILE_CREATE:
- tmpl = H5MM_xmalloc (sizeof(H5F_create_t));
- memcpy (tmpl, &H5F_create_dflt, sizeof(H5F_create_t));
- break;
-
- case H5C_FILE_ACCESS:
- HRETURN_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, FAIL,
- "not implemented yet");
-
- case H5C_DATASET_CREATE:
- tmpl = H5MM_xmalloc (sizeof(H5D_create_t));
- memcpy (tmpl, &H5D_create_dflt, sizeof(H5D_create_t));
- break;
-
- case H5C_DATASET_XFER:
- tmpl = H5MM_xmalloc (sizeof(H5D_xfer_t));
- memcpy (tmpl, &H5D_xfer_dflt, sizeof(H5D_xfer_t));
- break;
-
- default:
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,
- "unknown template class");
- }
-
- /* Atomize the new template */
- if ((ret_value = H5C_create (type, tmpl))<0) {
- HRETURN_ERROR (H5E_ATOM, H5E_CANTINIT, FAIL,
- "can't register template");
- }
-
- FUNC_LEAVE (ret_value);
+ hid_t ret_value = FAIL;
+ void *tmpl = NULL;
+
+ FUNC_ENTER(H5Ccreate, FAIL);
+
+ /* Allocate a new template and initialize it with default values */
+ switch (type) {
+ case H5C_FILE_CREATE:
+ tmpl = H5MM_xmalloc(sizeof(H5F_create_t));
+ memcpy(tmpl, &H5F_create_dflt, sizeof(H5F_create_t));
+ break;
+
+ case H5C_FILE_ACCESS:
+ HRETURN_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL,
+ "not implemented yet");
+
+ case H5C_DATASET_CREATE:
+ tmpl = H5MM_xmalloc(sizeof(H5D_create_t));
+ memcpy(tmpl, &H5D_create_dflt, sizeof(H5D_create_t));
+ break;
+
+ case H5C_DATASET_XFER:
+ tmpl = H5MM_xmalloc(sizeof(H5D_xfer_t));
+ memcpy(tmpl, &H5D_xfer_dflt, sizeof(H5D_xfer_t));
+ break;
+
+ default:
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
+ "unknown template class");
+ }
+
+ /* Atomize the new template */
+ if ((ret_value = H5C_create(type, tmpl)) < 0) {
+ HRETURN_ERROR(H5E_ATOM, H5E_CANTINIT, FAIL,
+ "can't register template");
+ }
+ FUNC_LEAVE(ret_value);
}
-
/*-------------------------------------------------------------------------
- * Function: H5C_create
+ * Function: H5C_create
*
- * Purpose: Given a pointer to some template struct, atomize the template
- * and return its ID. The template memory is not copied, so the
- * caller should not free it; it will be freed by H5C_release().
+ * Purpose: Given a pointer to some template struct, atomize the template
+ * and return its ID. The template memory is not copied, so the
+ * caller should not free it; it will be freed by H5C_release().
*
- * Return: Success: A new template ID.
+ * Return: Success: A new template ID.
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, December 3, 1997
*
* Modifications:
@@ -194,25 +191,24 @@ H5Ccreate (H5C_class_t type)
*-------------------------------------------------------------------------
*/
hid_t
-H5C_create (H5C_class_t type, void *tmpl)
+H5C_create(H5C_class_t type, void *tmpl)
{
- hid_t ret_value = FAIL;
-
- FUNC_ENTER (H5C_create, FAIL);
+ hid_t ret_value = FAIL;
- /* check args */
- assert (type>=0 && type<H5C_NCLASSES);
- assert (tmpl);
+ FUNC_ENTER(H5C_create, FAIL);
- /* Atomize the new template */
- if ((ret_value = H5Aregister_atom (H5_TEMPLATE_0+type, tmpl))<0) {
- HRETURN_ERROR (H5E_ATOM, H5E_CANTINIT, FAIL,
- "can't register template");
- }
+ /* check args */
+ assert(type >= 0 && type < H5C_NCLASSES);
+ assert(tmpl);
- FUNC_LEAVE (ret_value);
+ /* Atomize the new template */
+ if ((ret_value = H5Aregister_atom(H5_TEMPLATE_0 + type, tmpl)) < 0) {
+ HRETURN_ERROR(H5E_ATOM, H5E_CANTINIT, FAIL,
+ "can't register template");
+ }
+ FUNC_LEAVE(ret_value);
}
-
+
/*--------------------------------------------------------------------------
NAME
H5Cclose
@@ -227,32 +223,31 @@ H5C_create (H5C_class_t type, void *tmpl)
This function releases access to a template object
--------------------------------------------------------------------------*/
herr_t
-H5Cclose (hid_t template)
+H5Cclose(hid_t template)
{
- void *tmpl=NULL;
+ void *tmpl = NULL;
- FUNC_ENTER (H5Cclose, FAIL);
+ FUNC_ENTER(H5Cclose, FAIL);
- /* Chuck the object! :-) */
- if (NULL==(tmpl=H5Aremove_atom (template))) {
- HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "unable to remove atom");
- }
- H5MM_xfree (tmpl);
+ /* Chuck the object! :-) */
+ if (NULL == (tmpl = H5Aremove_atom(template))) {
+ HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "unable to remove atom");
+ }
+ H5MM_xfree(tmpl);
- FUNC_LEAVE (SUCCEED);
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Cget_class
+ * Function: H5Cget_class
*
- * Purpose: Returns the class identifier for a template.
+ * Purpose: Returns the class identifier for a template.
*
- * Return: Success: A template class
+ * Return: Success: A template class
*
- * Failure: H5C_NO_CLASS (-1)
+ * Failure: H5C_NO_CLASS (-1)
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, December 3, 1997
*
* Modifications:
@@ -260,46 +255,44 @@ H5Cclose (hid_t template)
*-------------------------------------------------------------------------
*/
H5C_class_t
-H5Cget_class (hid_t template)
+H5Cget_class(hid_t template)
{
- group_t group;
- H5C_class_t ret_value = H5C_NO_CLASS;
-
- FUNC_ENTER (H5Cget_class, H5C_NO_CLASS);
-
- if ((group = H5Aatom_group (template))<0 ||
+ group_t group;
+ H5C_class_t ret_value = H5C_NO_CLASS;
+
+ FUNC_ENTER(H5Cget_class, H5C_NO_CLASS);
+
+ if ((group = H5Aatom_group(template)) < 0 ||
#ifndef NDEBUG
- group>=H5_TEMPLATE_MAX ||
+ group >= H5_TEMPLATE_MAX ||
#endif
- group<H5_TEMPLATE_0) {
- HRETURN_ERROR (H5E_ATOM, H5E_BADATOM, H5C_NO_CLASS, "not a template");
- }
-
- ret_value = group - H5_TEMPLATE_0;
- FUNC_LEAVE (ret_value);
+ group < H5_TEMPLATE_0) {
+ HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, H5C_NO_CLASS, "not a template");
+ }
+ ret_value = group - H5_TEMPLATE_0;
+ FUNC_LEAVE(ret_value);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Cget_version
+ * Function: H5Cget_version
*
- * Purpose: Retrieves version information for various parts of a file.
+ * Purpose: Retrieves version information for various parts of a file.
*
- * BOOT: The file boot block.
- * HEAP: The global heap.
- * FREELIST: The global free list.
- * STAB: The root symbol table entry.
- * SHHDR: Shared object headers.
+ * BOOT: The file boot block.
+ * HEAP: The global heap.
+ * FREELIST: The global free list.
+ * STAB: The root symbol table entry.
+ * SHHDR: Shared object headers.
*
- * Any (or even all) of the output arguments can be null
- * pointers.
+ * Any (or even all) of the output arguments can be null
+ * pointers.
*
- * Return: Success: SUCCEED, version information is returned
- * through the arguments.
+ * Return: Success: SUCCEED, version information is returned
+ * through the arguments.
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
@@ -307,41 +300,44 @@ H5Cget_class (hid_t template)
*-------------------------------------------------------------------------
*/
herr_t
-H5Cget_version (hid_t template, int *boot/*out*/, int *heap/*out*/,
- int *freelist/*out*/, int *stab/*out*/, int *shhdr/*out*/)
+H5Cget_version(hid_t template, int *boot /*out */ , int *heap /*out */ ,
+ int *freelist /*out */ , int *stab /*out */ , int *shhdr /*out */ )
{
- H5F_create_t *tmpl = NULL;
-
- FUNC_ENTER (H5Cget_version, FAIL);
-
- /* Check arguments */
- if (H5C_FILE_CREATE!=H5Cget_class (template) ||
- NULL==(tmpl=H5Aatom_object (template))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL,
- "not a file creation template");
- }
-
- /* Get values */
- if (boot) *boot = tmpl->bootblock_ver;
- if (heap) *heap = tmpl->smallobject_ver;
- if (freelist) *freelist = tmpl->freespace_ver;
- if (stab) *stab = tmpl->objectdir_ver;
- if (shhdr) *shhdr = tmpl->sharedheader_ver;
-
- FUNC_LEAVE (SUCCEED);
+ H5F_create_t *tmpl = NULL;
+
+ FUNC_ENTER(H5Cget_version, FAIL);
+
+ /* Check arguments */
+ if (H5C_FILE_CREATE != H5Cget_class(template) ||
+ NULL == (tmpl = H5Aatom_object(template))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ "not a file creation template");
+ }
+ /* Get values */
+ if (boot)
+ *boot = tmpl->bootblock_ver;
+ if (heap)
+ *heap = tmpl->smallobject_ver;
+ if (freelist)
+ *freelist = tmpl->freespace_ver;
+ if (stab)
+ *stab = tmpl->objectdir_ver;
+ if (shhdr)
+ *shhdr = tmpl->sharedheader_ver;
+
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Cset_userblock
+ * Function: H5Cset_userblock
*
- * Purpose: Sets the userblock size field of a file creation template.
+ * Purpose: Sets the userblock size field of a file creation template.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Tuesday, January 6, 1998
*
* Modifications:
@@ -349,45 +345,44 @@ H5Cget_version (hid_t template, int *boot/*out*/, int *heap/*out*/,
*-------------------------------------------------------------------------
*/
herr_t
-H5Cset_userblock (hid_t template, size_t size)
+H5Cset_userblock(hid_t template, size_t size)
{
- intn i;
- H5F_create_t *tmpl = NULL;
-
- FUNC_ENTER (H5Cset_userblock, FAIL);
-
- /* Check arguments */
- if (H5C_FILE_CREATE!=H5Cget_class (template) ||
- NULL==(tmpl=H5Aatom_object (template))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL,
- "not a file creation template");
- }
- for (i=8; i<8*sizeof(int); i++) {
- uintn p2 = 8==i ? 0 :1<<i;
- if (size==p2) break;
- }
- if (i>=8*sizeof(int)) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,
- "userblock size is not valid");
- }
-
- /* Set value */
- tmpl->userblock_size = size;
-
- FUNC_LEAVE (SUCCEED);
+ intn i;
+ H5F_create_t *tmpl = NULL;
+
+ FUNC_ENTER(H5Cset_userblock, FAIL);
+
+ /* Check arguments */
+ if (H5C_FILE_CREATE != H5Cget_class(template) ||
+ NULL == (tmpl = H5Aatom_object(template))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ "not a file creation template");
+ }
+ for (i = 8; i < 8 * sizeof(int); i++) {
+ uintn p2 = 8 == i ? 0 : 1 << i;
+ if (size == p2)
+ break;
+ }
+ if (i >= 8 * sizeof(int)) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
+ "userblock size is not valid");
+ }
+ /* Set value */
+ tmpl->userblock_size = size;
+
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Cget_userblock
+ * Function: H5Cget_userblock
*
- * Purpose: Queries the size of a user block in a file creation template.
+ * Purpose: Queries the size of a user block in a file creation template.
*
- * Return: Success: SUCCEED, size returned through SIZE argument.
+ * Return: Success: SUCCEED, size returned through SIZE argument.
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
@@ -395,38 +390,37 @@ H5Cset_userblock (hid_t template, size_t size)
*-------------------------------------------------------------------------
*/
herr_t
-H5Cget_userblock (hid_t template, size_t *size)
+H5Cget_userblock(hid_t template, size_t *size)
{
- H5F_create_t *tmpl = NULL;
-
- FUNC_ENTER (H5Cget_userblock, FAIL);
+ H5F_create_t *tmpl = NULL;
- /* Check args */
- if (H5C_FILE_CREATE!=H5Cget_class (template) ||
- NULL==(tmpl=H5Aatom_object (template))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL,
- "not a file creation template");
- }
+ FUNC_ENTER(H5Cget_userblock, FAIL);
- /* Get value */
- if (size) *size = tmpl->userblock_size;
+ /* Check args */
+ if (H5C_FILE_CREATE != H5Cget_class(template) ||
+ NULL == (tmpl = H5Aatom_object(template))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ "not a file creation template");
+ }
+ /* Get value */
+ if (size)
+ *size = tmpl->userblock_size;
- FUNC_LEAVE (SUCCEED);
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Cset_sizes
+ * Function: H5Cset_sizes
*
- * Purpose: Sets file size-of addresses and sizes. TEMPLATE
- * should be a file creation template. A value of zero causes
- * the property to not change.
+ * Purpose: Sets file size-of addresses and sizes. TEMPLATE
+ * should be a file creation template. A value of zero causes
+ * the property to not change.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Tuesday, January 6, 1998
*
* Modifications:
@@ -434,53 +428,53 @@ H5Cget_userblock (hid_t template, size_t *size)
*-------------------------------------------------------------------------
*/
herr_t
-H5Cset_sizes (hid_t template, size_t sizeof_addr, size_t sizeof_size)
+H5Cset_sizes(hid_t template, size_t sizeof_addr, size_t sizeof_size)
{
- H5F_create_t *tmpl = NULL;
-
- FUNC_ENTER (H5Cset_sizeof_addr, FAIL);
-
- /* Check arguments */
- if (H5C_FILE_CREATE!=H5Cget_class (template) ||
- NULL==(tmpl=H5Aatom_object (template))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL,
- "not a file creation template");
- }
- if (sizeof_addr) {
- if (sizeof_addr!=2 && sizeof_addr!=4 &&
- sizeof_addr!=8 && sizeof_addr!=16) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,
- "file haddr_t size is not valid");
- }
- }
- if (sizeof_size) {
- if (sizeof_size!=2 && sizeof_size!=4 &&
- sizeof_size!=8 && sizeof_size!=16) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,
- "file size_t size is not valid");
- }
- }
-
- /* Set value */
- if (sizeof_addr) tmpl->sizeof_addr = sizeof_addr;
- if (sizeof_size) tmpl->sizeof_size = sizeof_size;
-
- FUNC_LEAVE (SUCCEED);
+ H5F_create_t *tmpl = NULL;
+
+ FUNC_ENTER(H5Cset_sizeof_addr, FAIL);
+
+ /* Check arguments */
+ if (H5C_FILE_CREATE != H5Cget_class(template) ||
+ NULL == (tmpl = H5Aatom_object(template))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ "not a file creation template");
+ }
+ if (sizeof_addr) {
+ if (sizeof_addr != 2 && sizeof_addr != 4 &&
+ sizeof_addr != 8 && sizeof_addr != 16) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
+ "file haddr_t size is not valid");
+ }
+ }
+ if (sizeof_size) {
+ if (sizeof_size != 2 && sizeof_size != 4 &&
+ sizeof_size != 8 && sizeof_size != 16) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
+ "file size_t size is not valid");
+ }
+ }
+ /* Set value */
+ if (sizeof_addr)
+ tmpl->sizeof_addr = sizeof_addr;
+ if (sizeof_size)
+ tmpl->sizeof_size = sizeof_size;
+
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Cget_sizes
+ * Function: H5Cget_sizes
*
- * Purpose: Returns the size of address and size quantities stored in a
- * file according to a file creation template. Either (or even
- * both) SIZEOF_ADDR and SIZEOF_SIZE may be null pointers.
+ * Purpose: Returns the size of address and size quantities stored in a
+ * file according to a file creation template. Either (or even
+ * both) SIZEOF_ADDR and SIZEOF_SIZE may be null pointers.
*
- * Return: Success: SUCCEED, sizes returned through arguments.
+ * Return: Success: SUCCEED, sizes returned through arguments.
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
@@ -488,51 +482,51 @@ H5Cset_sizes (hid_t template, size_t sizeof_addr, size_t sizeof_size)
*-------------------------------------------------------------------------
*/
herr_t
-H5Cget_sizes (hid_t template,
- size_t *sizeof_addr/*out*/, size_t *sizeof_size/*out*/)
+H5Cget_sizes(hid_t template,
+ size_t *sizeof_addr /*out */ , size_t *sizeof_size /*out */ )
{
- H5F_create_t *tmpl = NULL;
-
- FUNC_ENTER (H5Cget_sizes, FAIL);
-
- /* Check args */
- if (H5C_FILE_CREATE!=H5Cget_class (template) ||
- NULL==(tmpl=H5Aatom_object (template))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL,
- "not a file creation template");
- }
-
- /* Get values */
- if (sizeof_addr) *sizeof_addr = tmpl->sizeof_addr;
- if (sizeof_size) *sizeof_size = tmpl->sizeof_size;
-
- FUNC_LEAVE (SUCCEED);
+ H5F_create_t *tmpl = NULL;
+
+ FUNC_ENTER(H5Cget_sizes, FAIL);
+
+ /* Check args */
+ if (H5C_FILE_CREATE != H5Cget_class(template) ||
+ NULL == (tmpl = H5Aatom_object(template))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ "not a file creation template");
+ }
+ /* Get values */
+ if (sizeof_addr)
+ *sizeof_addr = tmpl->sizeof_addr;
+ if (sizeof_size)
+ *sizeof_size = tmpl->sizeof_size;
+
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Cset_sym_k
+ * Function: H5Cset_sym_k
*
- * Purpose: IK is one half the rank of a tree that stores a symbol
- * table for a group. Internal nodes of the symbol table are on
- * average 75% full. That is, the average rank of the tree is
- * 1.5 times the value of IK.
+ * Purpose: IK is one half the rank of a tree that stores a symbol
+ * table for a group. Internal nodes of the symbol table are on
+ * average 75% full. That is, the average rank of the tree is
+ * 1.5 times the value of IK.
*
- * LK is one half of the number of symbols that can be stored in
- * a symbol table node. A symbol table node is the leaf of a
- * symbol table tree which is used to store a group. When
- * symbols are inserted randomly into a group, the group's
- * symbol table nodes are 75% full on average. That is, they
- * contain 1.5 times the number of symbols specified by LK.
+ * LK is one half of the number of symbols that can be stored in
+ * a symbol table node. A symbol table node is the leaf of a
+ * symbol table tree which is used to store a group. When
+ * symbols are inserted randomly into a group, the group's
+ * symbol table nodes are 75% full on average. That is, they
+ * contain 1.5 times the number of symbols specified by LK.
*
- * Either (or even both) of IK and LK can be zero in which case
- * that value is left unchanged.
+ * Either (or even both) of IK and LK can be zero in which case
+ * that value is left unchanged.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Tuesday, January 6, 1998
*
* Modifications:
@@ -540,45 +534,41 @@ H5Cget_sizes (hid_t template,
*-------------------------------------------------------------------------
*/
herr_t
-H5Cset_sym_k (hid_t template, int ik, int lk)
+H5Cset_sym_k(hid_t template, int ik, int lk)
{
- H5F_create_t *tmpl = NULL;
-
- FUNC_ENTER (H5Cset_sym_k, FAIL);
-
- /* Check arguments */
- if (H5C_FILE_CREATE!=H5Cget_class (template) ||
- NULL==(tmpl=H5Aatom_object (template))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL,
- "not a file creation template");
- }
-
- /* Set values */
- if (ik>0) {
- tmpl->btree_k[H5B_SNODE_ID] = ik;
- }
- if (lk>0) {
- tmpl->sym_leaf_k = lk;
- }
-
-
- FUNC_LEAVE (SUCCEED);
+ H5F_create_t *tmpl = NULL;
+
+ FUNC_ENTER(H5Cset_sym_k, FAIL);
+
+ /* Check arguments */
+ if (H5C_FILE_CREATE != H5Cget_class(template) ||
+ NULL == (tmpl = H5Aatom_object(template))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ "not a file creation template");
+ }
+ /* Set values */
+ if (ik > 0) {
+ tmpl->btree_k[H5B_SNODE_ID] = ik;
+ }
+ if (lk > 0) {
+ tmpl->sym_leaf_k = lk;
+ }
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Cget_sym_k
+ * Function: H5Cget_sym_k
*
- * Purpose: Retrieves the symbol table B-tree 1/2 rank (IK) and the
- * symbol table leaf node 1/2 size (LK). See H5Cset_sym_k() for
- * details. Either (or even both) IK and LK may be null
- * pointers.
+ * Purpose: Retrieves the symbol table B-tree 1/2 rank (IK) and the
+ * symbol table leaf node 1/2 size (LK). See H5Cset_sym_k() for
+ * details. Either (or even both) IK and LK may be null
+ * pointers.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
@@ -586,39 +576,39 @@ H5Cset_sym_k (hid_t template, int ik, int lk)
*-------------------------------------------------------------------------
*/
herr_t
-H5Cget_sym_k (hid_t template, int *ik/*out*/, int *lk/*out*/)
+H5Cget_sym_k(hid_t template, int *ik /*out */ , int *lk /*out */ )
{
- H5F_create_t *tmpl = NULL;
-
- FUNC_ENTER (H5Cget_sym_k, FAIL);
-
- /* Check arguments */
- if (H5C_FILE_CREATE!=H5Cget_class (template) ||
- NULL==(tmpl=H5Aatom_object (template))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL,
- "not a file creation template");
- }
-
- /* Get values */
- if (ik) *ik = tmpl->btree_k[H5B_SNODE_ID];
- if (lk) *lk = tmpl->sym_leaf_k;
-
- FUNC_LEAVE (SUCCEED);
+ H5F_create_t *tmpl = NULL;
+
+ FUNC_ENTER(H5Cget_sym_k, FAIL);
+
+ /* Check arguments */
+ if (H5C_FILE_CREATE != H5Cget_class(template) ||
+ NULL == (tmpl = H5Aatom_object(template))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ "not a file creation template");
+ }
+ /* Get values */
+ if (ik)
+ *ik = tmpl->btree_k[H5B_SNODE_ID];
+ if (lk)
+ *lk = tmpl->sym_leaf_k;
+
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Cset_istore_k
+ * Function: H5Cset_istore_k
*
- * Purpose: IK is one half the rank of a tree that stores chunked raw
- * data. On average, such a tree will be 75% full, or have an
- * average rank of 1.5 times the value of IK.
+ * Purpose: IK is one half the rank of a tree that stores chunked raw
+ * data. On average, such a tree will be 75% full, or have an
+ * average rank of 1.5 times the value of IK.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Tuesday, January 6, 1998
*
* Modifications:
@@ -626,42 +616,40 @@ H5Cget_sym_k (hid_t template, int *ik/*out*/, int *lk/*out*/)
*-------------------------------------------------------------------------
*/
herr_t
-H5Cset_istore_k (hid_t template, int ik)
+H5Cset_istore_k(hid_t template, int ik)
{
- H5F_create_t *tmpl = NULL;
-
- FUNC_ENTER (H5Cset_istore_k, FAIL);
-
- /* Check arguments */
- if (H5C_FILE_CREATE!=H5Cget_class (template) ||
- NULL==(tmpl=H5Aatom_object (template))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL,
- "not a file creation template");
- }
- if (ik<=0) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,
- "istore IK value must be positive");
- }
-
- /* Set value */
- tmpl->btree_k[H5B_ISTORE_ID] = ik;
-
- FUNC_LEAVE (SUCCEED);
+ H5F_create_t *tmpl = NULL;
+
+ FUNC_ENTER(H5Cset_istore_k, FAIL);
+
+ /* Check arguments */
+ if (H5C_FILE_CREATE != H5Cget_class(template) ||
+ NULL == (tmpl = H5Aatom_object(template))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ "not a file creation template");
+ }
+ if (ik <= 0) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
+ "istore IK value must be positive");
+ }
+ /* Set value */
+ tmpl->btree_k[H5B_ISTORE_ID] = ik;
+
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Cget_istore_k
+ * Function: H5Cget_istore_k
*
- * Purpose: Queries the 1/2 rank of an indexed storage B-tree. See
- * H5Cset_istore_k() for details. The argument IK may be the
- * null pointer.
+ * Purpose: Queries the 1/2 rank of an indexed storage B-tree. See
+ * H5Cset_istore_k() for details. The argument IK may be the
+ * null pointer.
*
- * Return: Success: SUCCEED, size returned through IK
+ * Return: Success: SUCCEED, size returned through IK
*
- * Failure:
+ * Failure:
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
@@ -669,36 +657,35 @@ H5Cset_istore_k (hid_t template, int ik)
*-------------------------------------------------------------------------
*/
herr_t
-H5Cget_istore_k (hid_t template, int *ik/*out*/)
+H5Cget_istore_k(hid_t template, int *ik /*out */ )
{
- H5F_create_t *tmpl = NULL;
-
- FUNC_ENTER (H5Cget_istore_k, FAIL);
-
- /* Check arguments */
- if (H5C_FILE_CREATE!=H5Cget_class (template) ||
- NULL==(tmpl=H5Aatom_object (template))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL,
- "not a file creation template");
- }
+ H5F_create_t *tmpl = NULL;
- /* Get value */
- if (ik) *ik = tmpl->btree_k[H5B_ISTORE_ID];
+ FUNC_ENTER(H5Cget_istore_k, FAIL);
- FUNC_LEAVE (SUCCEED);
-}
+ /* Check arguments */
+ if (H5C_FILE_CREATE != H5Cget_class(template) ||
+ NULL == (tmpl = H5Aatom_object(template))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ "not a file creation template");
+ }
+ /* Get value */
+ if (ik)
+ *ik = tmpl->btree_k[H5B_ISTORE_ID];
+ FUNC_LEAVE(SUCCEED);
+}
/*-------------------------------------------------------------------------
- * Function: H5Cset_layout
+ * Function: H5Cset_layout
*
- * Purpose: Sets the layout of raw data in the file.
+ * Purpose: Sets the layout of raw data in the file.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Tuesday, January 6, 1998
*
* Modifications:
@@ -706,40 +693,38 @@ H5Cget_istore_k (hid_t template, int *ik/*out*/)
*-------------------------------------------------------------------------
*/
herr_t
-H5Cset_layout (hid_t template, H5D_layout_t layout)
+H5Cset_layout(hid_t template, H5D_layout_t layout)
{
- H5D_create_t *tmpl = NULL;
-
- FUNC_ENTER (H5Cset_layout, FAIL);
-
- /* Check arguments */
- if (H5C_DATASET_CREATE!=H5Cget_class (template) ||
- NULL==(tmpl=H5Aatom_object (template))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL,
- "not a dataset creation template");
- }
- if (layout<0 || layout>=H5D_NLAYOUTS) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL,
- "raw data layout method is not valid");
- }
-
- /* Set value */
- tmpl->layout = layout;
-
- FUNC_LEAVE (SUCCEED);
+ H5D_create_t *tmpl = NULL;
+
+ FUNC_ENTER(H5Cset_layout, FAIL);
+
+ /* Check arguments */
+ if (H5C_DATASET_CREATE != H5Cget_class(template) ||
+ NULL == (tmpl = H5Aatom_object(template))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ "not a dataset creation template");
+ }
+ if (layout < 0 || layout >= H5D_NLAYOUTS) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL,
+ "raw data layout method is not valid");
+ }
+ /* Set value */
+ tmpl->layout = layout;
+
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Cget_layout
+ * Function: H5Cget_layout
*
- * Purpose: Retrieves layout type of a dataset creation template.
+ * Purpose: Retrieves layout type of a dataset creation template.
*
- * Return: Success: The layout type
+ * Return: Success: The layout type
*
- * Failure: H5D_LAYOUT_ERROR (-1, same as FAIL)
+ * Failure: H5D_LAYOUT_ERROR (-1, same as FAIL)
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
@@ -747,38 +732,36 @@ H5Cset_layout (hid_t template, H5D_layout_t layout)
*-------------------------------------------------------------------------
*/
H5D_layout_t
-H5Cget_layout (hid_t template)
+H5Cget_layout(hid_t template)
{
- H5D_create_t *tmpl = NULL;
-
- FUNC_ENTER (H5Cget_layout, H5D_LAYOUT_ERROR);
-
- /* Check arguments */
- if (H5C_DATASET_CREATE!=H5Cget_class (template) ||
- NULL==(tmpl=H5Aatom_object (template))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, H5D_LAYOUT_ERROR,
- "not a dataset creation template");
- }
-
- FUNC_LEAVE (tmpl->layout);
-}
+ H5D_create_t *tmpl = NULL;
+
+ FUNC_ENTER(H5Cget_layout, H5D_LAYOUT_ERROR);
+ /* Check arguments */
+ if (H5C_DATASET_CREATE != H5Cget_class(template) ||
+ NULL == (tmpl = H5Aatom_object(template))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, H5D_LAYOUT_ERROR,
+ "not a dataset creation template");
+ }
+ FUNC_LEAVE(tmpl->layout);
+}
/*-------------------------------------------------------------------------
- * Function: H5Cset_chunk
+ * Function: H5Cset_chunk
*
- * Purpose: Sets the number of dimensions and the size of each chunk to
- * the values specified. The dimensionality of the chunk should
- * match the dimensionality of the data space.
+ * Purpose: Sets the number of dimensions and the size of each chunk to
+ * the values specified. The dimensionality of the chunk should
+ * match the dimensionality of the data space.
*
- * As a side effect, the layout method is changed to
- * H5D_CHUNKED.
+ * As a side effect, the layout method is changed to
+ * H5D_CHUNKED.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Tuesday, January 6, 1998
*
* Modifications:
@@ -786,60 +769,60 @@ H5Cget_layout (hid_t template)
*-------------------------------------------------------------------------
*/
herr_t
-H5Cset_chunk (hid_t template, int ndims, size_t dim[])
+H5Cset_chunk(hid_t template, int ndims, size_t dim[])
{
- int i;
- H5D_create_t *tmpl = NULL;
-
- FUNC_ENTER (H5Cset_chunk, FAIL);
-
- /* Check arguments */
- if (H5C_DATASET_CREATE!=H5Cget_class (template) ||
- NULL==(tmpl=H5Aatom_object (template))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL,
- "not a dataset creation template");
- }
- if (ndims<=0) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL,
- "chunk dimensionality must be positive");
- }
- if (ndims>NELMTS (tmpl->chunk_size)) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL,
- "chunk dimensionality is too large");
- }
- if (!dim) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,
- "no chunk dimensions specified");
- }
- for (i=0; i<ndims; i++) {
- if (dim[i]<=0) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL,
- "all chunk dimensions must be positive");
- }
- }
-
- /* Set value */
- tmpl->layout = H5D_CHUNKED;
- tmpl->chunk_ndims = ndims;
- for (i=0; i<ndims; i++) tmpl->chunk_size[i] = dim[i];
-
- FUNC_LEAVE (SUCCEED);
+ int i;
+ H5D_create_t *tmpl = NULL;
+
+ FUNC_ENTER(H5Cset_chunk, FAIL);
+
+ /* Check arguments */
+ if (H5C_DATASET_CREATE != H5Cget_class(template) ||
+ NULL == (tmpl = H5Aatom_object(template))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ "not a dataset creation template");
+ }
+ if (ndims <= 0) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL,
+ "chunk dimensionality must be positive");
+ }
+ if (ndims > NELMTS(tmpl->chunk_size)) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL,
+ "chunk dimensionality is too large");
+ }
+ if (!dim) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
+ "no chunk dimensions specified");
+ }
+ for (i = 0; i < ndims; i++) {
+ if (dim[i] <= 0) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL,
+ "all chunk dimensions must be positive");
+ }
+ }
+
+ /* Set value */
+ tmpl->layout = H5D_CHUNKED;
+ tmpl->chunk_ndims = ndims;
+ for (i = 0; i < ndims; i++)
+ tmpl->chunk_size[i] = dim[i];
+
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Cget_chunk
+ * Function: H5Cget_chunk
*
- * Purpose: Retrieves the chunk size of chunked layout. The chunk
- * dimensionality is returned and the chunk size in each
- * dimension is returned through the DIM argument. At most
- * MAX_NDIMS elements of DIM will be initialized.
+ * Purpose: Retrieves the chunk size of chunked layout. The chunk
+ * dimensionality is returned and the chunk size in each
+ * dimension is returned through the DIM argument. At most
+ * MAX_NDIMS elements of DIM will be initialized.
*
- * Return: Success: Positive Chunk dimensionality.
+ * Return: Success: Positive Chunk dimensionality.
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
@@ -847,29 +830,28 @@ H5Cset_chunk (hid_t template, int ndims, size_t dim[])
*-------------------------------------------------------------------------
*/
int
-H5Cget_chunk (hid_t template, int max_ndims, size_t dim[]/*out*/)
+H5Cget_chunk(hid_t template, int max_ndims, size_t dim[] /*out */ )
{
- int i;
- H5D_create_t *tmpl = NULL;
-
- FUNC_ENTER (H5Cget_chunk, FAIL);
-
- /* Check arguments */
- if (H5C_DATASET_CREATE!=H5Cget_class (template) ||
- NULL==(tmpl=H5Aatom_object (template))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL,
- "not a dataset creation template");
- }
- if (H5D_CHUNKED!=tmpl->layout) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,
- "not a chunked storage layout");
- }
-
- for (i=0; i<tmpl->chunk_ndims && i<max_ndims && dim; i++) {
- dim[i] = tmpl->chunk_size[i];
- }
-
- FUNC_LEAVE (tmpl->chunk_ndims);
+ int i;
+ H5D_create_t *tmpl = NULL;
+
+ FUNC_ENTER(H5Cget_chunk, FAIL);
+
+ /* Check arguments */
+ if (H5C_DATASET_CREATE != H5Cget_class(template) ||
+ NULL == (tmpl = H5Aatom_object(template))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ "not a dataset creation template");
+ }
+ if (H5D_CHUNKED != tmpl->layout) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
+ "not a chunked storage layout");
+ }
+ for (i = 0; i < tmpl->chunk_ndims && i < max_ndims && dim; i++) {
+ dim[i] = tmpl->chunk_size[i];
+ }
+
+ FUNC_LEAVE(tmpl->chunk_ndims);
}
/*--------------------------------------------------------------------------
@@ -896,58 +878,56 @@ H5Cget_chunk (hid_t template, int max_ndims, size_t dim[]/*out*/)
settings.
--------------------------------------------------------------------------*/
hid_t
-H5Ccopy (hid_t template)
+H5Ccopy(hid_t template)
{
- const void *tmpl = NULL;
- void *new_tmpl = NULL;
- H5C_class_t type;
- size_t size;
- hid_t ret_value = FAIL;
- group_t group;
-
- FUNC_ENTER (H5Ccopy, FAIL);
- H5ECLEAR;
-
- /* check args */
- if (NULL==(tmpl=H5Aatom_object (template)) ||
- (type=H5Cget_class (template))<0 ||
- (group=H5Aatom_group (template))<0) {
- HRETURN_ERROR (H5E_ATOM, H5E_BADATOM, FAIL,
- "can't unatomize template");
- }
-
- /* How big is the template */
- switch (type) {
- case H5C_FILE_CREATE:
- size = sizeof(H5F_create_t);
- break;
-
- case H5C_FILE_ACCESS:
- HRETURN_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, FAIL,
- "file access properties are not implemented yet");
-
- case H5C_DATASET_CREATE:
- size = sizeof(H5D_create_t);
- break;
-
- case H5C_DATASET_XFER:
- size = sizeof(H5D_xfer_t);
- break;
-
- default:
- HRETURN_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL,
- "unknown template class");
- }
-
- /* Create the new template */
- new_tmpl = H5MM_xmalloc (size);
- HDmemcpy (new_tmpl, tmpl, size);
-
- /* Register the atom for the new template */
- if ((ret_value=H5Aregister_atom (group, new_tmpl))<0) {
- HRETURN_ERROR (H5E_ATOM, H5E_CANTREGISTER, FAIL,
- "unable to atomize template pointer");
- }
-
- FUNC_LEAVE (ret_value);
+ const void *tmpl = NULL;
+ void *new_tmpl = NULL;
+ H5C_class_t type;
+ size_t size;
+ hid_t ret_value = FAIL;
+ group_t group;
+
+ FUNC_ENTER(H5Ccopy, FAIL);
+ H5ECLEAR;
+
+ /* check args */
+ if (NULL == (tmpl = H5Aatom_object(template)) ||
+ (type = H5Cget_class(template)) < 0 ||
+ (group = H5Aatom_group(template)) < 0) {
+ HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, FAIL,
+ "can't unatomize template");
+ }
+ /* How big is the template */
+ switch (type) {
+ case H5C_FILE_CREATE:
+ size = sizeof(H5F_create_t);
+ break;
+
+ case H5C_FILE_ACCESS:
+ HRETURN_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL,
+ "file access properties are not implemented yet");
+
+ case H5C_DATASET_CREATE:
+ size = sizeof(H5D_create_t);
+ break;
+
+ case H5C_DATASET_XFER:
+ size = sizeof(H5D_xfer_t);
+ break;
+
+ default:
+ HRETURN_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL,
+ "unknown template class");
+ }
+
+ /* Create the new template */
+ new_tmpl = H5MM_xmalloc(size);
+ HDmemcpy(new_tmpl, tmpl, size);
+
+ /* Register the atom for the new template */
+ if ((ret_value = H5Aregister_atom(group, new_tmpl)) < 0) {
+ HRETURN_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL,
+ "unable to atomize template pointer");
+ }
+ FUNC_LEAVE(ret_value);
}
diff --git a/src/H5Cprivate.h b/src/H5Cprivate.h
index 7a184f6..b6614a2 100644
--- a/src/H5Cprivate.h
+++ b/src/H5Cprivate.h
@@ -24,6 +24,6 @@
#include <H5private.h>
#include <H5Fprivate.h>
-hid_t H5C_create (H5C_class_t type, void *tmpl);
+hid_t H5C_create(H5C_class_t type, void *tmpl);
#endif
diff --git a/src/H5Cpublic.h b/src/H5Cpublic.h
index b7c5dcf..e3cef4d 100644
--- a/src/H5Cpublic.h
+++ b/src/H5Cpublic.h
@@ -1,13 +1,13 @@
/****************************************************************************
- * NCSA HDF *
- * Software Development Group *
- * National Center for Supercomputing Applications *
- * University of Illinois at Urbana-Champaign *
- * 605 E. Springfield, Champaign IL 61820 *
- * *
- * For conditions of distribution and use, see the accompanying *
- * hdf/COPYING file. *
- * *
+ * NCSA HDF *
+ * Software Development Group *
+ * National Center for Supercomputing Applications *
+ * University of Illinois at Urbana-Champaign *
+ * 605 E. Springfield, Champaign IL 61820 *
+ * *
+ * For conditions of distribution and use, see the accompanying *
+ * hdf/COPYING file. *
+ * *
****************************************************************************/
/*
@@ -18,7 +18,7 @@
#define _H5Cpublic_H
/* Default Template for creation, access, etc. templates */
-#define H5C_DEFAULT (-2)
+#define H5C_DEFAULT (-2)
/* Public headers needed by this file */
#include <H5public.h>
@@ -27,53 +27,51 @@
/* Template classes */
typedef enum H5C_class_t {
- H5C_NO_CLASS =-1, /* Error return value */
- H5C_FILE_CREATE =0, /* File creation template */
- H5C_FILE_ACCESS =1, /* File access template */
- H5C_DATASET_CREATE =2, /* Dataset creation template */
- H5C_DATASET_XFER =3, /* Dataset transfer template */
+ H5C_NO_CLASS = -1, /* Error return value */
+ H5C_FILE_CREATE = 0, /* File creation template */
+ H5C_FILE_ACCESS = 1, /* File access template */
+ H5C_DATASET_CREATE = 2, /* Dataset creation template */
+ H5C_DATASET_XFER = 3, /* Dataset transfer template */
- H5C_NCLASSES =4 /* This must be last! */
+ H5C_NCLASSES = 4 /* This must be last! */
} H5C_class_t;
-
#ifdef __cplusplus
-extern "C" {
+extern "C" {
#endif
-
-/* Public functions */
-hid_t H5Ccreate (H5C_class_t type);
-herr_t H5Cclose (hid_t template);
-hid_t H5Ccopy (hid_t template);
-H5C_class_t H5Cget_class (hid_t template);
+/* Public functions */
+ hid_t H5Ccreate(H5C_class_t type);
+ herr_t H5Cclose(hid_t template);
+ hid_t H5Ccopy(hid_t template);
-herr_t H5Cget_version (hid_t template, int *boot/*out*/, int *heap/*out*/,
- int *freelist/*out*/, int *stab/*out*/,
- int *shhdr/*out*/);
+ H5C_class_t H5Cget_class(hid_t template);
-herr_t H5Cset_userblock (hid_t template, size_t size);
-herr_t H5Cget_userblock (hid_t template, size_t *size);
+ herr_t H5Cget_version(hid_t template, int *boot /*out */ , int *heap /*out */ ,
+ int *freelist /*out */ , int *stab /*out */ ,
+ int *shhdr /*out */ );
-herr_t H5Cset_sizes (hid_t template, size_t sizeof_addr, size_t sizeof_size);
-herr_t H5Cget_sizes (hid_t template, size_t *sizeof_addr/*out*/,
- size_t *sizeof_size/*out*/);
+ herr_t H5Cset_userblock(hid_t template, size_t size);
+ herr_t H5Cget_userblock(hid_t template, size_t *size);
-herr_t H5Cset_sym_k (hid_t template, int ik, int lk);
-herr_t H5Cget_sym_k (hid_t template, int *ik/*out*/, int *lk/*out*/);
+ herr_t H5Cset_sizes(hid_t template, size_t sizeof_addr, size_t sizeof_size);
+ herr_t H5Cget_sizes(hid_t template, size_t *sizeof_addr /*out */ ,
+ size_t *sizeof_size /*out */ );
-herr_t H5Cset_istore_k (hid_t template, int ik);
-herr_t H5Cget_istore_k (hid_t template, int *ik/*out*/);
+ herr_t H5Cset_sym_k(hid_t template, int ik, int lk);
+ herr_t H5Cget_sym_k(hid_t template, int *ik /*out */ , int *lk /*out */ );
-herr_t H5Cset_layout (hid_t template, H5D_layout_t layout);
-H5D_layout_t H5Cget_layout (hid_t template);
+ herr_t H5Cset_istore_k(hid_t template, int ik);
+ herr_t H5Cget_istore_k(hid_t template, int *ik /*out */ );
-herr_t H5Cset_chunk (hid_t template, int ndims, size_t dim[]);
-int H5Cget_chunk (hid_t template, int max_ndims, size_t dim[]/*out*/);
+ herr_t H5Cset_layout(hid_t template, H5D_layout_t layout);
+ H5D_layout_t H5Cget_layout(hid_t template);
+ herr_t H5Cset_chunk(hid_t template, int ndims, size_t dim[]);
+ int H5Cget_chunk(hid_t template, int max_ndims, size_t dim[] /*out */ );
#ifdef __cplusplus
}
-#endif
#endif
+#endif
diff --git a/src/H5D.c b/src/H5D.c
index b200e2e..1a72e38 100644
--- a/src/H5D.c
+++ b/src/H5D.c
@@ -1,70 +1,69 @@
/****************************************************************************
-* NCSA HDF *
-* Software Development Group *
-* National Center for Supercomputing Applications *
-* University of Illinois at Urbana-Champaign *
-* 605 E. Springfield, Champaign IL 61820 *
-* *
-* For conditions of distribution and use, see the accompanying *
-* hdf/COPYING file. *
-* *
+* NCSA HDF *
+* Software Development Group *
+* National Center for Supercomputing Applications *
+* University of Illinois at Urbana-Champaign *
+* 605 E. Springfield, Champaign IL 61820 *
+* *
+* For conditions of distribution and use, see the accompanying *
+* hdf/COPYING file. *
+* *
****************************************************************************/
#ifdef RCSID
-static char RcsId[] = "@(#)$Revision$";
+static char RcsId[] = "@(#)$Revision$";
#endif
/* $Id$ */
-
-#include <H5private.h> /* Generic Functions */
-#include <H5Aprivate.h> /* Atoms */
-#include <H5ACprivate.h> /* Cache */
-#include <H5Cprivate.h> /* Templates */
-#include <H5Dprivate.h> /* Dataset functions */
-#include <H5Eprivate.h> /* Error handling */
-#include <H5Gprivate.h> /* Group headers */
-#include <H5Mprivate.h> /* Meta data */
-#include <H5MFprivate.h> /* File space allocation header */
-#include <H5MMprivate.h> /* Memory management */
-#include <H5Mprivate.h> /* Meta-Object API */
-#include <H5Oprivate.h> /* Object headers */
-
-#define PABLO_MASK H5D_mask
+#include <H5private.h> /* Generic Functions */
+#include <H5Aprivate.h> /* Atoms */
+#include <H5ACprivate.h> /* Cache */
+#include <H5Cprivate.h> /* Templates */
+#include <H5Dprivate.h> /* Dataset functions */
+#include <H5Eprivate.h> /* Error handling */
+#include <H5Gprivate.h> /* Group headers */
+#include <H5Mprivate.h> /* Meta data */
+#include <H5MFprivate.h> /* File space allocation header */
+#include <H5MMprivate.h> /* Memory management */
+#include <H5Mprivate.h> /* Meta-Object API */
+#include <H5Oprivate.h> /* Object headers */
+
+#define PABLO_MASK H5D_mask
/*
* A dataset is the following struct.
*/
struct H5D_t {
- H5G_entry_t ent; /*cached object header stuff */
- H5T_t *type; /*datatype of this dataset */
- H5P_t *space; /*dataspace of this dataset */
- H5D_create_t create_parms; /*creation parameters */
- H5O_layout_t layout; /*data layout */
+ H5G_entry_t ent; /*cached object header stuff */
+ H5T_t *type; /*datatype of this dataset */
+ H5P_t *space; /*dataspace of this dataset */
+ H5D_create_t create_parms; /*creation parameters */
+ H5O_layout_t layout; /*data layout */
};
/* Default dataset creation template */
-const H5D_create_t H5D_create_dflt = {
- H5D_CONTIGUOUS, /* Layout */
- 1, /* Chunk dimensions */
- {1, 1, 1, 1, 1, 1, 1, 1, /* Chunk size. These default values....*/
- 1, 1, 1, 1, 1, 1, 1, 1, /*...are quite useless. Larger chunks..*/
- 1, 1, 1, 1, 1, 1, 1, 1, /*...produce fewer, but larger I/O......*/
- 1, 1, 1, 1, 1, 1, 1, 1}, /*...requests. */
+const H5D_create_t H5D_create_dflt =
+{
+ H5D_CONTIGUOUS, /* Layout */
+ 1, /* Chunk dimensions */
+ {1, 1, 1, 1, 1, 1, 1, 1, /* Chunk size. These default values.... */
+ 1, 1, 1, 1, 1, 1, 1, 1, /*...are quite useless. Larger chunks.. */
+ 1, 1, 1, 1, 1, 1, 1, 1, /*...produce fewer, but larger I/O...... */
+ 1, 1, 1, 1, 1, 1, 1, 1}, /*...requests. */
};
/* Default dataset transfer template */
-const H5D_xfer_t H5D_xfer_dflt = {
- 0, /* Place holder - remove this later */
+const H5D_xfer_t H5D_xfer_dflt =
+{
+ 0, /* Place holder - remove this later */
};
-
/* Interface initialization? */
-static hbool_t interface_initialize_g = FALSE;
+static hbool_t interface_initialize_g = FALSE;
#define INTERFACE_INIT H5D_init_interface
-static herr_t H5D_init_interface(void);
-static void H5D_term_interface (void);
-
+static herr_t H5D_init_interface(void);
+static void H5D_term_interface(void);
/*--------------------------------------------------------------------------
NAME
@@ -79,19 +78,18 @@ DESCRIPTION
--------------------------------------------------------------------------*/
static herr_t
-H5D_init_interface (void)
+H5D_init_interface(void)
{
- herr_t ret_value = SUCCEED;
- FUNC_ENTER (H5D_init_interface, FAIL);
-
- /* Initialize the atom group for the dataset IDs */
- if ((ret_value=H5Ainit_group (H5_DATASET, H5A_DATASETID_HASHSIZE,
- H5D_RESERVED_ATOMS,
- (herr_t (*)(void*))H5D_close))!=FAIL) {
- ret_value = H5_add_exit (H5D_term_interface);
- }
-
- FUNC_LEAVE (ret_value);
+ herr_t ret_value = SUCCEED;
+ FUNC_ENTER(H5D_init_interface, FAIL);
+
+ /* Initialize the atom group for the dataset IDs */
+ if ((ret_value = H5Ainit_group(H5_DATASET, H5A_DATASETID_HASHSIZE,
+ H5D_RESERVED_ATOMS,
+ (herr_t (*)(void *)) H5D_close)) != FAIL) {
+ ret_value = H5_add_exit(H5D_term_interface);
+ }
+ FUNC_LEAVE(ret_value);
}
/*--------------------------------------------------------------------------
@@ -112,126 +110,122 @@ H5D_init_interface (void)
REVISION LOG
--------------------------------------------------------------------------*/
static void
-H5D_term_interface (void)
+H5D_term_interface(void)
{
- H5Adestroy_group (H5_DATASET);
+ H5Adestroy_group(H5_DATASET);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Dcreate
+ * Function: H5Dcreate
*
- * Purpose: Creates a new dataset named NAME in file FILE_ID, opens the
- * dataset for access, and associates with that dataset constant
- * and initial persistent properties including the type of each
- * datapoint as stored in the file (TYPE_ID), the size of the
- * dataset (SPACE_ID), and other initial miscellaneous
- * properties (CREATE_PARMS_ID).
+ * Purpose: Creates a new dataset named NAME in file FILE_ID, opens the
+ * dataset for access, and associates with that dataset constant
+ * and initial persistent properties including the type of each
+ * datapoint as stored in the file (TYPE_ID), the size of the
+ * dataset (SPACE_ID), and other initial miscellaneous
+ * properties (CREATE_PARMS_ID).
*
- * All arguments are copied into the dataset, so the caller is
- * allowed to derive new types, data spaces, and creation
- * parameters from the old ones and reuse them in calls to
- * create other datasets.
+ * All arguments are copied into the dataset, so the caller is
+ * allowed to derive new types, data spaces, and creation
+ * parameters from the old ones and reuse them in calls to
+ * create other datasets.
*
- * Return: Success: The object ID of the new dataset. At this
- * point, the dataset is ready to receive its
- * raw data. Attempting to read raw data from
- * the dataset will probably return the fill
- * value. The dataset should be closed when
- * the caller is no longer interested in it.
+ * Return: Success: The object ID of the new dataset. At this
+ * point, the dataset is ready to receive its
+ * raw data. Attempting to read raw data from
+ * the dataset will probably return the fill
+ * value. The dataset should be closed when
+ * the caller is no longer interested in it.
*
- * Failure: FAIL
+ * Failure: FAIL
*
* Errors:
- * ARGS BADTYPE Not a data space.
- * ARGS BADTYPE Not a dataset creation template.
- * ARGS BADTYPE Not a file.
- * ARGS BADTYPE Not a type.
- * ARGS BADVALUE No name.
- * DATASET CANTINIT Can't create dataset.
- * DATASET CANTREGISTER Can't register dataset.
+ * ARGS BADTYPE Not a data space.
+ * ARGS BADTYPE Not a dataset creation template.
+ * ARGS BADTYPE Not a file.
+ * ARGS BADTYPE Not a type.
+ * ARGS BADVALUE No name.
+ * DATASET CANTINIT Can't create dataset.
+ * DATASET CANTREGISTER Can't register dataset.
*
- * Programmer: Robb Matzke
- * Wednesday, December 3, 1997
+ * Programmer: Robb Matzke
+ * Wednesday, December 3, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
hid_t
-H5Dcreate (hid_t file_id, const char *name, hid_t type_id, hid_t space_id,
- hid_t create_parms_id)
+H5Dcreate(hid_t file_id, const char *name, hid_t type_id, hid_t space_id,
+ hid_t create_parms_id)
{
- H5F_t *f = NULL;
- H5T_t *type = NULL;
- H5P_t *space = NULL;
- H5D_t *new_dset = NULL;
- hid_t ret_value = FAIL;
- const H5D_create_t *create_parms = NULL;
-
- FUNC_ENTER (H5Dcreate, FAIL);
- H5ECLEAR;
-
- /* check arguments */
- if (H5_FILE!=H5Aatom_group (file_id) ||
- NULL==(f=H5Aatom_object (file_id))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a file");
- }
- if (!name || !*name) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no name");
- }
- if (H5_DATATYPE!=H5Aatom_group (type_id) ||
- NULL==(type=H5Aatom_object (type_id))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a type");
- }
- if (H5_DATASPACE!=H5Aatom_group (space_id) ||
- NULL==(space=H5Aatom_object (space_id))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
- }
- if (create_parms_id>=0) {
- if (H5C_DATASET_CREATE!=H5Cget_class (create_parms_id) ||
- NULL==(create_parms=H5Aatom_object (create_parms_id))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL,
- "not a dataset creation template");
- }
- } else {
- create_parms = &H5D_create_dflt;
- }
-
- /* build and open the new dataset */
- if (NULL==(new_dset=H5D_create (f, name, type, space, create_parms))) {
- HRETURN_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "can't create dataset");
- }
-
- /* Register the new datatype and get an ID for it */
- if ((ret_value=H5Aregister_atom (H5_DATASET, new_dset))<0) {
- H5D_close (new_dset);
- HRETURN_ERROR (H5E_DATASET, H5E_CANTREGISTER, FAIL,
- "can't register dataset");
- }
-
- FUNC_LEAVE (ret_value);
+ H5F_t *f = NULL;
+ H5T_t *type = NULL;
+ H5P_t *space = NULL;
+ H5D_t *new_dset = NULL;
+ hid_t ret_value = FAIL;
+ const H5D_create_t *create_parms = NULL;
+
+ FUNC_ENTER(H5Dcreate, FAIL);
+ H5ECLEAR;
+
+ /* check arguments */
+ if (H5_FILE != H5Aatom_group(file_id) ||
+ NULL == (f = H5Aatom_object(file_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file");
+ }
+ if (!name || !*name) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name");
+ }
+ if (H5_DATATYPE != H5Aatom_group(type_id) ||
+ NULL == (type = H5Aatom_object(type_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a type");
+ }
+ if (H5_DATASPACE != H5Aatom_group(space_id) ||
+ NULL == (space = H5Aatom_object(space_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
+ }
+ if (create_parms_id >= 0) {
+ if (H5C_DATASET_CREATE != H5Cget_class(create_parms_id) ||
+ NULL == (create_parms = H5Aatom_object(create_parms_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ "not a dataset creation template");
+ }
+ } else {
+ create_parms = &H5D_create_dflt;
+ }
+
+ /* build and open the new dataset */
+ if (NULL == (new_dset = H5D_create(f, name, type, space, create_parms))) {
+ HRETURN_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't create dataset");
+ }
+ /* Register the new datatype and get an ID for it */
+ if ((ret_value = H5Aregister_atom(H5_DATASET, new_dset)) < 0) {
+ H5D_close(new_dset);
+ HRETURN_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL,
+ "can't register dataset");
+ }
+ FUNC_LEAVE(ret_value);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Dopen
+ * Function: H5Dopen
*
- * Purpose: Finds a dataset named NAME in file FILE_ID, opens it, and
- * returns its ID. The dataset should be close when the caller
- * is no longer interested in it.
+ * Purpose: Finds a dataset named NAME in file FILE_ID, opens it, and
+ * returns its ID. The dataset should be close when the caller
+ * is no longer interested in it.
*
- * Return: Success: A new dataset ID
+ * Return: Success: A new dataset ID
*
- * Failure: FAIL
+ * Failure: FAIL
*
* Errors:
- * ARGS BADTYPE Not a file.
- * ARGS BADVALUE No name.
- * DATASET CANTREGISTER Can't register dataset.
- * DATASET NOTFOUND Dataset not found.
+ * ARGS BADTYPE Not a file.
+ * ARGS BADVALUE No name.
+ * DATASET CANTREGISTER Can't register dataset.
+ * DATASET NOTFOUND Dataset not found.
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Thursday, December 4, 1997
*
* Modifications:
@@ -239,56 +233,52 @@ H5Dcreate (hid_t file_id, const char *name, hid_t type_id, hid_t space_id,
*-------------------------------------------------------------------------
*/
hid_t
-H5Dopen (hid_t file_id, const char *name)
+H5Dopen(hid_t file_id, const char *name)
{
- H5F_t *file = NULL; /*file holding the dataset */
- H5D_t *dataset = NULL; /*the dataset */
- hid_t ret_value = FAIL;
-
- FUNC_ENTER (H5Dopen, FAIL);
- H5ECLEAR;
-
- /* Check args */
- if (H5_FILE!=H5Aatom_group (file_id) ||
- NULL==(file=H5Aatom_object (file_id))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a file");
- }
- if (!name || !*name) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no name");
- }
-
- /* Find the dataset */
- if (NULL==(dataset=H5D_open (file, name))) {
- HRETURN_ERROR (H5E_DATASET, H5E_NOTFOUND, FAIL, "dataset not found");
- }
-
- /* Create an atom for the dataset */
- if ((ret_value=H5Aregister_atom (H5_DATASET, dataset))<0) {
- H5D_close (dataset);
- HRETURN_ERROR (H5E_DATASET, H5E_CANTREGISTER, FAIL,
- "can't register dataset");
- }
-
- FUNC_LEAVE (ret_value);
+ H5F_t *file = NULL; /*file holding the dataset */
+ H5D_t *dataset = NULL; /*the dataset */
+ hid_t ret_value = FAIL;
+
+ FUNC_ENTER(H5Dopen, FAIL);
+ H5ECLEAR;
+
+ /* Check args */
+ if (H5_FILE != H5Aatom_group(file_id) ||
+ NULL == (file = H5Aatom_object(file_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file");
+ }
+ if (!name || !*name) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name");
+ }
+ /* Find the dataset */
+ if (NULL == (dataset = H5D_open(file, name))) {
+ HRETURN_ERROR(H5E_DATASET, H5E_NOTFOUND, FAIL, "dataset not found");
+ }
+ /* Create an atom for the dataset */
+ if ((ret_value = H5Aregister_atom(H5_DATASET, dataset)) < 0) {
+ H5D_close(dataset);
+ HRETURN_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL,
+ "can't register dataset");
+ }
+ FUNC_LEAVE(ret_value);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Dclose
+ * Function: H5Dclose
*
- * Purpose: Closes access to a dataset (DATASET_ID) and releases
- * resources used by it. It is illegal to subsequently use that
- * same dataset ID in calls to other dataset functions.
+ * Purpose: Closes access to a dataset (DATASET_ID) and releases
+ * resources used by it. It is illegal to subsequently use that
+ * same dataset ID in calls to other dataset functions.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
* Errors:
- * ARGS BADTYPE Not a dataset.
- * DATASET CANTINIT Can't free.
+ * ARGS BADTYPE Not a dataset.
+ * DATASET CANTINIT Can't free.
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Thursday, December 4, 1997
*
* Modifications:
@@ -296,68 +286,65 @@ H5Dopen (hid_t file_id, const char *name)
*-------------------------------------------------------------------------
*/
herr_t
-H5Dclose (hid_t dataset_id)
+H5Dclose(hid_t dataset_id)
{
- H5D_t *dataset = NULL; /* dataset object to release */
-
- FUNC_ENTER (H5Dclose, FAIL);
- H5ECLEAR;
-
- /* Check args */
- if (H5_DATASET!=H5Aatom_group (dataset_id) ||
- NULL==(dataset=H5Aatom_object (dataset_id)) ||
- NULL==dataset->ent.file) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset");
- }
-
- /*
- * Decrement the counter on the dataset. It will be freed if the count
- * reaches zero.
- */
- if (H5A_dec_ref (dataset_id)<0) {
- HRETURN_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL, "can't free");
- }
-
- FUNC_LEAVE (SUCCEED);
+ H5D_t *dataset = NULL; /* dataset object to release */
+
+ FUNC_ENTER(H5Dclose, FAIL);
+ H5ECLEAR;
+
+ /* Check args */
+ if (H5_DATASET != H5Aatom_group(dataset_id) ||
+ NULL == (dataset = H5Aatom_object(dataset_id)) ||
+ NULL == dataset->ent.file) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset");
+ }
+ /*
+ * Decrement the counter on the dataset. It will be freed if the count
+ * reaches zero.
+ */
+ if (H5A_dec_ref(dataset_id) < 0) {
+ HRETURN_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't free");
+ }
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Dread
+ * Function: H5Dread
*
- * Purpose: Reads (part of) a DATASET from the file into application
- * memory BUF. The part of the dataset to read is defined with
- * MEM_SPACE_ID and FILE_SPACE_ID. The data points are
- * converted from their file type to the MEM_TYPE_ID specified.
- * Additional miscellaneous data transfer properties can be
- * passed to this function with the XFER_PARMS_ID argument.
+ * Purpose: Reads (part of) a DATASET from the file into application
+ * memory BUF. The part of the dataset to read is defined with
+ * MEM_SPACE_ID and FILE_SPACE_ID. The data points are
+ * converted from their file type to the MEM_TYPE_ID specified.
+ * Additional miscellaneous data transfer properties can be
+ * passed to this function with the XFER_PARMS_ID argument.
*
- * The FILE_SPACE_ID can be the constant H5P_ALL which indicates
- * that the entire file data space is to be referenced.
+ * The FILE_SPACE_ID can be the constant H5P_ALL which indicates
+ * that the entire file data space is to be referenced.
*
- * The MEM_SPACE_ID can be the constant H5P_ALL in which case
- * the memory data space is the same as the file data space
- * defined when the dataset was created.
+ * The MEM_SPACE_ID can be the constant H5P_ALL in which case
+ * the memory data space is the same as the file data space
+ * defined when the dataset was created.
*
- * The number of elements in the memory data space must match
- * the number of elements in the file data space.
+ * The number of elements in the memory data space must match
+ * the number of elements in the file data space.
*
- * The XFER_PARMS_ID can be the constant H5C_DEFAULT in which
- * case the default data transfer properties are used.
+ * The XFER_PARMS_ID can be the constant H5C_DEFAULT in which
+ * case the default data transfer properties are used.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
* Errors:
- * ARGS BADTYPE Not a data space.
- * ARGS BADTYPE Not a data type.
- * ARGS BADTYPE Not a dataset.
- * ARGS BADTYPE Not xfer parms.
- * ARGS BADVALUE No output buffer.
- * DATASET READERROR Can't read data.
- *
- * Programmer: Robb Matzke
+ * ARGS BADTYPE Not a data space.
+ * ARGS BADTYPE Not a data type.
+ * ARGS BADTYPE Not a dataset.
+ * ARGS BADTYPE Not xfer parms.
+ * ARGS BADVALUE No output buffer.
+ * DATASET READERROR Can't read data.
+ *
+ * Programmer: Robb Matzke
* Thursday, December 4, 1997
*
* Modifications:
@@ -365,91 +352,88 @@ H5Dclose (hid_t dataset_id)
*-------------------------------------------------------------------------
*/
herr_t
-H5Dread (hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id,
- hid_t file_space_id, hid_t xfer_parms_id, void *buf/*out*/)
+H5Dread(hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id,
+ hid_t file_space_id, hid_t xfer_parms_id, void *buf /*out */ )
{
- H5D_t *dataset = NULL;
- const H5T_t *mem_type = NULL;
- const H5P_t *mem_space = NULL;
- const H5P_t *file_space = NULL;
- const H5D_xfer_t *xfer_parms = NULL;
-
- FUNC_ENTER (H5Dread, FAIL);
- H5ECLEAR;
-
- /* check arguments */
- if (H5_DATASET!=H5Aatom_group (dataset_id) ||
- NULL==(dataset=H5Aatom_object (dataset_id)) ||
- NULL==dataset->ent.file) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset");
- }
- if (H5_DATATYPE!=H5Aatom_group (mem_type_id) ||
- NULL==(mem_type=H5Aatom_object (mem_type_id))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
- }
- if (H5P_ALL!=mem_space_id) {
- if (H5_DATASPACE!=H5Aatom_group (mem_space_id) ||
- NULL==(mem_space=H5Aatom_object (mem_space_id))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
- }
- }
- if (H5P_ALL!=file_space_id) {
- if (H5_DATASPACE!=H5Aatom_group (file_space_id) ||
- NULL==(file_space=H5Aatom_object (file_space_id))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
- }
- }
- if (H5C_DEFAULT==xfer_parms_id) {
- xfer_parms = &H5D_xfer_dflt;
- } else if (H5C_DATASET_XFER!=H5Cget_class (xfer_parms_id) ||
- NULL==(xfer_parms=H5Aatom_object (xfer_parms_id))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms");
- }
- if (!buf) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no output buffer");
- }
-
- /* read raw data */
- if (H5D_read (dataset, mem_type, mem_space, file_space, xfer_parms,
- buf/*out*/)<0) {
- HRETURN_ERROR (H5E_DATASET, H5E_READERROR, FAIL, "can't read data");
- }
-
- FUNC_LEAVE (SUCCEED);
+ H5D_t *dataset = NULL;
+ const H5T_t *mem_type = NULL;
+ const H5P_t *mem_space = NULL;
+ const H5P_t *file_space = NULL;
+ const H5D_xfer_t *xfer_parms = NULL;
+
+ FUNC_ENTER(H5Dread, FAIL);
+ H5ECLEAR;
+
+ /* check arguments */
+ if (H5_DATASET != H5Aatom_group(dataset_id) ||
+ NULL == (dataset = H5Aatom_object(dataset_id)) ||
+ NULL == dataset->ent.file) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset");
+ }
+ if (H5_DATATYPE != H5Aatom_group(mem_type_id) ||
+ NULL == (mem_type = H5Aatom_object(mem_type_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ }
+ if (H5P_ALL != mem_space_id) {
+ if (H5_DATASPACE != H5Aatom_group(mem_space_id) ||
+ NULL == (mem_space = H5Aatom_object(mem_space_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
+ }
+ }
+ if (H5P_ALL != file_space_id) {
+ if (H5_DATASPACE != H5Aatom_group(file_space_id) ||
+ NULL == (file_space = H5Aatom_object(file_space_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
+ }
+ }
+ if (H5C_DEFAULT == xfer_parms_id) {
+ xfer_parms = &H5D_xfer_dflt;
+ } else if (H5C_DATASET_XFER != H5Cget_class(xfer_parms_id) ||
+ NULL == (xfer_parms = H5Aatom_object(xfer_parms_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms");
+ }
+ if (!buf) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no output buffer");
+ }
+ /* read raw data */
+ if (H5D_read(dataset, mem_type, mem_space, file_space, xfer_parms,
+ buf /*out */ ) < 0) {
+ HRETURN_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read data");
+ }
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Dwrite
+ * Function: H5Dwrite
*
- * Purpose: Writes (part of) a DATASET from application memory BUF to the
- * file. The part of the dataset to write is defined with the
- * MEM_SPACE_ID and FILE_SPACE_ID arguments. The data points
- * are converted from their current type (MEM_TYPE_ID) to their
- * file data type. Additional miscellaneous data transfer
- * properties can be passed to this function with the
- * XFER_PARMS_ID argument.
+ * Purpose: Writes (part of) a DATASET from application memory BUF to the
+ * file. The part of the dataset to write is defined with the
+ * MEM_SPACE_ID and FILE_SPACE_ID arguments. The data points
+ * are converted from their current type (MEM_TYPE_ID) to their
+ * file data type. Additional miscellaneous data transfer
+ * properties can be passed to this function with the
+ * XFER_PARMS_ID argument.
*
- * The FILE_SPACE_ID can be the constant H5P_ALL which indicates
- * that the entire file data space is to be referenced.
+ * The FILE_SPACE_ID can be the constant H5P_ALL which indicates
+ * that the entire file data space is to be referenced.
*
- * The MEM_SPACE_ID can be the constant H5P_ALL in which case
- * the memory data space is the same as the file data space
- * defined when the dataset was created.
+ * The MEM_SPACE_ID can be the constant H5P_ALL in which case
+ * the memory data space is the same as the file data space
+ * defined when the dataset was created.
*
- * The number of elements in the memory data space must match
- * the number of elements in the file data space.
+ * The number of elements in the memory data space must match
+ * the number of elements in the file data space.
*
- * The XFER_PARMS_ID can be the constant H5C_DEFAULT in which
- * case the default data transfer properties are used.
+ * The XFER_PARMS_ID can be the constant H5C_DEFAULT in which
+ * case the default data transfer properties are used.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
* Errors:
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Thursday, December 4, 1997
*
* Modifications:
@@ -457,79 +441,71 @@ H5Dread (hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id,
*-------------------------------------------------------------------------
*/
herr_t
-H5Dwrite (hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id,
- hid_t file_space_id, hid_t xfer_parms_id, const void *buf)
+H5Dwrite(hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id,
+ hid_t file_space_id, hid_t xfer_parms_id, const void *buf)
{
- H5D_t *dataset = NULL;
- const H5T_t *mem_type = NULL;
- const H5P_t *mem_space = NULL;
- const H5P_t *file_space = NULL;
- const H5D_xfer_t *xfer_parms = NULL;
-
- FUNC_ENTER (H5Dwrite, FAIL);
- H5ECLEAR;
-
- /* check arguments */
- if (H5_DATASET!=H5Aatom_group (dataset_id) ||
- NULL==(dataset=H5Aatom_object (dataset_id)) ||
- NULL==dataset->ent.file) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset");
- }
- if (H5_DATATYPE!=H5Aatom_group (mem_type_id) ||
- NULL==(mem_type=H5Aatom_object (mem_type_id))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
- }
- if (H5P_ALL!=mem_space_id) {
- if (H5_DATASPACE!=H5Aatom_group (mem_space_id) ||
- NULL==(mem_space=H5Aatom_object (mem_space_id))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
- }
- }
- if (H5P_ALL!=file_space_id) {
- if (H5_DATASPACE!=H5Aatom_group (file_space_id) ||
- NULL==(file_space=H5Aatom_object (file_space_id))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
- }
- }
- if (H5C_DEFAULT==xfer_parms_id) {
- xfer_parms = &H5D_xfer_dflt;
- } else if (H5C_DATASET_XFER!=H5Cget_class (xfer_parms_id) ||
- NULL==(xfer_parms=H5Aatom_object (xfer_parms_id))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms");
- }
- if (!buf) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no output buffer");
- }
-
- /* write raw data */
- if (H5D_write (dataset, mem_type, mem_space, file_space, xfer_parms,
- buf)<0) {
- HRETURN_ERROR (H5E_DATASET, H5E_READERROR, FAIL, "can't write data");
- }
-
- FUNC_LEAVE (SUCCEED);
+ H5D_t *dataset = NULL;
+ const H5T_t *mem_type = NULL;
+ const H5P_t *mem_space = NULL;
+ const H5P_t *file_space = NULL;
+ const H5D_xfer_t *xfer_parms = NULL;
+
+ FUNC_ENTER(H5Dwrite, FAIL);
+ H5ECLEAR;
+
+ /* check arguments */
+ if (H5_DATASET != H5Aatom_group(dataset_id) ||
+ NULL == (dataset = H5Aatom_object(dataset_id)) ||
+ NULL == dataset->ent.file) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset");
+ }
+ if (H5_DATATYPE != H5Aatom_group(mem_type_id) ||
+ NULL == (mem_type = H5Aatom_object(mem_type_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ }
+ if (H5P_ALL != mem_space_id) {
+ if (H5_DATASPACE != H5Aatom_group(mem_space_id) ||
+ NULL == (mem_space = H5Aatom_object(mem_space_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
+ }
+ }
+ if (H5P_ALL != file_space_id) {
+ if (H5_DATASPACE != H5Aatom_group(file_space_id) ||
+ NULL == (file_space = H5Aatom_object(file_space_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
+ }
+ }
+ if (H5C_DEFAULT == xfer_parms_id) {
+ xfer_parms = &H5D_xfer_dflt;
+ } else if (H5C_DATASET_XFER != H5Cget_class(xfer_parms_id) ||
+ NULL == (xfer_parms = H5Aatom_object(xfer_parms_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms");
+ }
+ if (!buf) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no output buffer");
+ }
+ /* write raw data */
+ if (H5D_write(dataset, mem_type, mem_space, file_space, xfer_parms,
+ buf) < 0) {
+ HRETURN_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't write data");
+ }
+ FUNC_LEAVE(SUCCEED);
}
-
-
-
-
-
-
/*-------------------------------------------------------------------------
- * Function: H5D_find_name
+ * Function: H5D_find_name
*
- * Purpose: This is a callback for H5Mfind_name(). It does the same
- * thing as H5Dopen() except it takes an extra argument which
- * isn't used.
+ * Purpose: This is a callback for H5Mfind_name(). It does the same
+ * thing as H5Dopen() except it takes an extra argument which
+ * isn't used.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
* Errors:
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Thursday, December 4, 1997
*
* Modifications:
@@ -537,267 +513,251 @@ H5Dwrite (hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id,
*-------------------------------------------------------------------------
*/
hid_t
-H5D_find_name (hid_t file_id, group_t UNUSED, const char *name)
+H5D_find_name(hid_t file_id, group_t UNUSED, const char *name)
{
- return H5Dopen (file_id, name);
+ return H5Dopen(file_id, name);
}
-
-
-
-
-
-
-
-
/*-------------------------------------------------------------------------
- * Function: H5D_create
+ * Function: H5D_create
*
- * Purpose: Creates a new dataset with name NAME in file F and associates
- * with it a datatype TYPE for each element as stored in the
- * file, dimensionality information or dataspace SPACE, and
- * other miscellaneous properties CREATE_PARMS. All arguments
- * are deep-copied before being associated with the new dataset,
- * so the caller is free to subsequently modify them without
- * affecting the dataset.
+ * Purpose: Creates a new dataset with name NAME in file F and associates
+ * with it a datatype TYPE for each element as stored in the
+ * file, dimensionality information or dataspace SPACE, and
+ * other miscellaneous properties CREATE_PARMS. All arguments
+ * are deep-copied before being associated with the new dataset,
+ * so the caller is free to subsequently modify them without
+ * affecting the dataset.
*
- * Return: Success: Pointer to a new dataset
+ * Return: Success: Pointer to a new dataset
*
- * Failure: NULL
+ * Failure: NULL
*
* Errors:
- * DATASET CANTINIT Can't update dataset header.
- * DATASET CANTINIT Problem with the dataset name.
+ * DATASET CANTINIT Can't update dataset header.
+ * DATASET CANTINIT Problem with the dataset name.
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Thursday, December 4, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-H5D_t *
-H5D_create (H5F_t *f, const char *name, const H5T_t *type, const H5P_t *space,
- const H5D_create_t *create_parms)
+H5D_t *
+H5D_create(H5F_t *f, const char *name, const H5T_t *type, const H5P_t *space,
+ const H5D_create_t *create_parms)
{
- H5D_t *new_dset = NULL;
- H5D_t *ret_value = NULL;
- size_t nbytes;
- intn i;
-
- FUNC_ENTER (H5D_create, NULL);
-
- /* check args */
- assert (f);
- assert (name && *name);
- assert (type);
- assert (space);
- assert (create_parms);
-
- /* Initialize the dataset object */
- new_dset = H5MM_xcalloc (1, sizeof(H5D_t));
- H5F_addr_undef (&(new_dset->ent.header));
- new_dset->type = H5T_copy (type);
- new_dset->space = H5P_copy (space);
- new_dset->create_parms = *create_parms;
-
- /*
- * Create (open for write access) an object header.
- */
- if (H5O_create (f, 0, &(new_dset->ent))<0) {
- HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL,
- "unable to create dataset object header");
- }
-
- /* Update the type and space header messages */
- if (H5O_modify (&(new_dset->ent), H5O_DTYPE, 0, 0, new_dset->type)<0 ||
- H5P_modify (f, &(new_dset->ent), new_dset->space)<0) {
- HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL,
- "can't update type or space header messages");
- }
-
- /* Total raw data size */
- nbytes = H5T_get_size (type) * H5P_get_npoints (space);
- new_dset->layout.type = new_dset->create_parms.layout;
- new_dset->layout.ndims = H5P_get_ndims (space) + 1;
- assert (new_dset->layout.ndims<=NELMTS (new_dset->layout.dim));
- new_dset->layout.dim[new_dset->layout.ndims-1] = H5T_get_size (type);
-
- switch (new_dset->create_parms.layout) {
- case H5D_CONTIGUOUS:
- if (H5P_get_dims (space, new_dset->layout.dim)<0) {
- HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL,
- "unable to initialize contiguous storage");
- }
- break;
-
- case H5D_CHUNKED:
- if (new_dset->create_parms.chunk_ndims != H5P_get_ndims (space)) {
- HGOTO_ERROR (H5E_DATASET, H5E_BADVALUE, NULL,
- "dimensionality of chunks doesn't match the data space");
- }
- for (i=0; i<new_dset->layout.ndims-1; i++) {
- new_dset->layout.dim[i] = new_dset->create_parms.chunk_size[i];
- }
- break;
-
- default:
- HGOTO_ERROR (H5E_DATASET, H5E_UNSUPPORTED, NULL, "not implemented yet");
- }
-
- /*
- * Initialize storage
- */
- if (H5F_arr_create (f, &(new_dset->layout))<0 ||
- H5O_modify (&(new_dset->ent), H5O_LAYOUT, 0, 0,
- &(new_dset->layout))<0) {
- HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL,
- "unable to initialize storage");
- }
-
- /* Give the dataset a name */
- if (H5G_insert (name, &(new_dset->ent))<0) {
- HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL, "unable to name dataset");
- }
-
- /* Success */
- ret_value = new_dset;
-
-
- done:
- if (!ret_value && new_dset) {
- if (new_dset->type) H5T_close (new_dset->type);
- if (new_dset->space) H5P_close (new_dset->space);
- if (H5F_addr_defined (&(new_dset->ent.header))) {
- H5O_close (&(new_dset->ent));
- }
- new_dset->ent.file = NULL;
- H5MM_xfree (new_dset);
- }
-
- FUNC_LEAVE (ret_value);
+ H5D_t *new_dset = NULL;
+ H5D_t *ret_value = NULL;
+ size_t nbytes;
+ intn i;
+
+ FUNC_ENTER(H5D_create, NULL);
+
+ /* check args */
+ assert(f);
+ assert(name && *name);
+ assert(type);
+ assert(space);
+ assert(create_parms);
+
+ /* Initialize the dataset object */
+ new_dset = H5MM_xcalloc(1, sizeof(H5D_t));
+ H5F_addr_undef(&(new_dset->ent.header));
+ new_dset->type = H5T_copy(type);
+ new_dset->space = H5P_copy(space);
+ new_dset->create_parms = *create_parms;
+
+ /*
+ * Create (open for write access) an object header.
+ */
+ if (H5O_create(f, 0, &(new_dset->ent)) < 0) {
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL,
+ "unable to create dataset object header");
+ }
+ /* Update the type and space header messages */
+ if (H5O_modify(&(new_dset->ent), H5O_DTYPE, 0, 0, new_dset->type) < 0 ||
+ H5P_modify(f, &(new_dset->ent), new_dset->space) < 0) {
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL,
+ "can't update type or space header messages");
+ }
+ /* Total raw data size */
+ nbytes = H5T_get_size(type) * H5P_get_npoints(space);
+ new_dset->layout.type = new_dset->create_parms.layout;
+ new_dset->layout.ndims = H5P_get_ndims(space) + 1;
+ assert(new_dset->layout.ndims <= NELMTS(new_dset->layout.dim));
+ new_dset->layout.dim[new_dset->layout.ndims - 1] = H5T_get_size(type);
+
+ switch (new_dset->create_parms.layout) {
+ case H5D_CONTIGUOUS:
+ if (H5P_get_dims(space, new_dset->layout.dim) < 0) {
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL,
+ "unable to initialize contiguous storage");
+ }
+ break;
+
+ case H5D_CHUNKED:
+ if (new_dset->create_parms.chunk_ndims != H5P_get_ndims(space)) {
+ HGOTO_ERROR(H5E_DATASET, H5E_BADVALUE, NULL,
+ "dimensionality of chunks doesn't match the data space");
+ }
+ for (i = 0; i < new_dset->layout.ndims - 1; i++) {
+ new_dset->layout.dim[i] = new_dset->create_parms.chunk_size[i];
+ }
+ break;
+
+ default:
+ HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, NULL, "not implemented yet");
+ }
+
+ /*
+ * Initialize storage
+ */
+ if (H5F_arr_create(f, &(new_dset->layout)) < 0 ||
+ H5O_modify(&(new_dset->ent), H5O_LAYOUT, 0, 0,
+ &(new_dset->layout)) < 0) {
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL,
+ "unable to initialize storage");
+ }
+ /* Give the dataset a name */
+ if (H5G_insert(name, &(new_dset->ent)) < 0) {
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to name dataset");
+ }
+ /* Success */
+ ret_value = new_dset;
+
+ done:
+ if (!ret_value && new_dset) {
+ if (new_dset->type)
+ H5T_close(new_dset->type);
+ if (new_dset->space)
+ H5P_close(new_dset->space);
+ if (H5F_addr_defined(&(new_dset->ent.header))) {
+ H5O_close(&(new_dset->ent));
+ }
+ new_dset->ent.file = NULL;
+ H5MM_xfree(new_dset);
+ }
+ FUNC_LEAVE(ret_value);
}
-
/*-------------------------------------------------------------------------
- * Function: H5D_open
+ * Function: H5D_open
*
- * Purpose: Finds a dataset named NAME in file F and builds a descriptor
- * for it, opening it for access.
+ * Purpose: Finds a dataset named NAME in file F and builds a descriptor
+ * for it, opening it for access.
*
- * Return: Success: Pointer to a new dataset descriptor.
+ * Return: Success: Pointer to a new dataset descriptor.
*
- * Failure: NULL
+ * Failure: NULL
*
* Errors:
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Thursday, December 4, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-H5D_t *
-H5D_open (H5F_t *f, const char *name)
+H5D_t *
+H5D_open(H5F_t *f, const char *name)
{
- H5D_t *dataset = NULL; /*the dataset which was found */
- H5D_t *ret_value = NULL; /*return value */
- intn i;
-
- FUNC_ENTER (H5D_open, NULL);
-
- /* check args */
- assert (f);
- assert (name && *name);
-
- dataset = H5MM_xcalloc (1, sizeof(H5D_t));
- dataset->create_parms = H5D_create_dflt;
- H5F_addr_undef (&(dataset->ent.header));
-
- /* Open the dataset object */
- if (H5G_find (f, name, NULL, &(dataset->ent))<0) {
- HGOTO_ERROR (H5E_DATASET, H5E_NOTFOUND, NULL, "not found");
- }
- if (H5O_open (f, &(dataset->ent))<0) {
- HGOTO_ERROR (H5E_DATASET, H5E_CANTOPENOBJ, NULL, "unable to open");
- }
-
- /* Get the type and space */
- if (NULL==(dataset->type=H5O_read (&(dataset->ent), H5O_DTYPE, 0, NULL)) ||
- NULL==(dataset->space=H5P_read (f, &(dataset->ent)))) {
- HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL,
- "can't load type of space info from dataset header");
- }
-
- /*
- * Get the raw data layout info. It's actually stored in two locations:
- * the storage message of the dataset (dataset->storage) and certain
- * values are copied to the dataset create template so the user can query
- * them.
- */
- if (H5O_read (&(dataset->ent), H5O_LAYOUT, 0, &(dataset->layout))<0) {
- HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, NULL,
- "unable to read data layout message");
- }
- switch (dataset->layout.type) {
- case H5D_CONTIGUOUS:
- dataset->create_parms.layout = H5D_CONTIGUOUS;
- break;
-
- case H5D_CHUNKED:
- /*
- * Chunked storage. The creation template's dimension is one less than
- * the chunk dimension because the chunk includes a dimension for the
- * individual bytes of the data type.
- */
- dataset->create_parms.layout = H5D_CHUNKED;
- dataset->create_parms.chunk_ndims = dataset->layout.ndims - 1;
- for (i=0; i<dataset->layout.ndims-1; i++) {
- dataset->create_parms.chunk_size[i] = dataset->layout.dim[i];
- }
- break;
-
- default:
- assert ("not implemented yet" && 0);
- HGOTO_ERROR (H5E_DATASET, H5E_UNSUPPORTED, NULL, "not implemented yet");
- }
-
- /* Success */
- ret_value = dataset;
-
-
- done:
- if (!ret_value && dataset) {
- if (H5F_addr_defined (&(dataset->ent.header))) {
- H5O_close (&(dataset->ent));
- }
- if (dataset->type) H5T_close (dataset->type);
- if (dataset->space) H5P_close (dataset->space);
- dataset->ent.file = NULL;
- H5MM_xfree (dataset);
- }
-
- FUNC_LEAVE (ret_value);
+ H5D_t *dataset = NULL; /*the dataset which was found */
+ H5D_t *ret_value = NULL; /*return value */
+ intn i;
+
+ FUNC_ENTER(H5D_open, NULL);
+
+ /* check args */
+ assert(f);
+ assert(name && *name);
+
+ dataset = H5MM_xcalloc(1, sizeof(H5D_t));
+ dataset->create_parms = H5D_create_dflt;
+ H5F_addr_undef(&(dataset->ent.header));
+
+ /* Open the dataset object */
+ if (H5G_find(f, name, NULL, &(dataset->ent)) < 0) {
+ HGOTO_ERROR(H5E_DATASET, H5E_NOTFOUND, NULL, "not found");
+ }
+ if (H5O_open(f, &(dataset->ent)) < 0) {
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, NULL, "unable to open");
+ }
+ /* Get the type and space */
+ if (NULL == (dataset->type = H5O_read(&(dataset->ent), H5O_DTYPE, 0, NULL)) ||
+ NULL == (dataset->space = H5P_read(f, &(dataset->ent)))) {
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL,
+ "can't load type of space info from dataset header");
+ }
+ /*
+ * Get the raw data layout info. It's actually stored in two locations:
+ * the storage message of the dataset (dataset->storage) and certain
+ * values are copied to the dataset create template so the user can query
+ * them.
+ */
+ if (H5O_read(&(dataset->ent), H5O_LAYOUT, 0, &(dataset->layout)) < 0) {
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL,
+ "unable to read data layout message");
+ }
+ switch (dataset->layout.type) {
+ case H5D_CONTIGUOUS:
+ dataset->create_parms.layout = H5D_CONTIGUOUS;
+ break;
+
+ case H5D_CHUNKED:
+ /*
+ * Chunked storage. The creation template's dimension is one less than
+ * the chunk dimension because the chunk includes a dimension for the
+ * individual bytes of the data type.
+ */
+ dataset->create_parms.layout = H5D_CHUNKED;
+ dataset->create_parms.chunk_ndims = dataset->layout.ndims - 1;
+ for (i = 0; i < dataset->layout.ndims - 1; i++) {
+ dataset->create_parms.chunk_size[i] = dataset->layout.dim[i];
+ }
+ break;
+
+ default:
+ assert("not implemented yet" && 0);
+ HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, NULL, "not implemented yet");
+ }
+
+ /* Success */
+ ret_value = dataset;
+
+ done:
+ if (!ret_value && dataset) {
+ if (H5F_addr_defined(&(dataset->ent.header))) {
+ H5O_close(&(dataset->ent));
+ }
+ if (dataset->type)
+ H5T_close(dataset->type);
+ if (dataset->space)
+ H5P_close(dataset->space);
+ dataset->ent.file = NULL;
+ H5MM_xfree(dataset);
+ }
+ FUNC_LEAVE(ret_value);
}
-
/*-------------------------------------------------------------------------
- * Function: H5D_close
+ * Function: H5D_close
*
- * Purpose: Insures that all data has been saved to the file, closes the
- * dataset object header, and frees all resources used by the
- * descriptor.
+ * Purpose: Insures that all data has been saved to the file, closes the
+ * dataset object header, and frees all resources used by the
+ * descriptor.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
* Errors:
- * DATASET CANTINIT Couldn't free the type or space,
- * but the dataset was freed anyway.
+ * DATASET CANTINIT Couldn't free the type or space,
+ * but the dataset was freed anyway.
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Thursday, December 4, 1997
*
* Modifications:
@@ -805,55 +765,53 @@ H5D_open (H5F_t *f, const char *name)
*-------------------------------------------------------------------------
*/
herr_t
-H5D_close (H5D_t *dataset)
+H5D_close(H5D_t *dataset)
{
- hbool_t free_failed;
-
- FUNC_ENTER (H5D_close, FAIL);
-
- /* check args */
- assert (dataset && dataset->ent.file);
-
- /* Close the dataset object */
- H5O_close (&(dataset->ent));
-
- /*
- * Release dataset type and space - there isn't much we can do if one of
- * these fails, so we just continue.
- */
- free_failed = (H5T_close (dataset->type)<0 ||
- H5P_close (dataset->space)<0);
-
- /*
- * Free memory. Before freeing the memory set the file pointer to NULL.
- * We always check for a null file pointer in other H5D functions to be
- * sure we're not accessing an already freed dataset (see the assert()
- * above).
- */
- dataset->ent.file = NULL;
- H5MM_xfree (dataset);
-
- if (free_failed) {
- HRETURN_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL,
- "couldn't free the type or space, but the dataset was "
- "freed anyway.");
- }
-
- FUNC_LEAVE (SUCCEED);
+ hbool_t free_failed;
+
+ FUNC_ENTER(H5D_close, FAIL);
+
+ /* check args */
+ assert(dataset && dataset->ent.file);
+
+ /* Close the dataset object */
+ H5O_close(&(dataset->ent));
+
+ /*
+ * Release dataset type and space - there isn't much we can do if one of
+ * these fails, so we just continue.
+ */
+ free_failed = (H5T_close(dataset->type) < 0 ||
+ H5P_close(dataset->space) < 0);
+
+ /*
+ * Free memory. Before freeing the memory set the file pointer to NULL.
+ * We always check for a null file pointer in other H5D functions to be
+ * sure we're not accessing an already freed dataset (see the assert()
+ * above).
+ */
+ dataset->ent.file = NULL;
+ H5MM_xfree(dataset);
+
+ if (free_failed) {
+ HRETURN_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL,
+ "couldn't free the type or space, but the dataset was "
+ "freed anyway.");
+ }
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5D_read
+ * Function: H5D_read
*
- * Purpose: Reads (part of) a DATASET into application memory BUF. See
- * H5Dread() for complete details.
+ * Purpose: Reads (part of) a DATASET into application memory BUF. See
+ * H5Dread() for complete details.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Thursday, December 4, 1997
*
* Modifications:
@@ -861,100 +819,95 @@ H5D_close (H5D_t *dataset)
*-------------------------------------------------------------------------
*/
herr_t
-H5D_read (H5D_t *dataset, const H5T_t *mem_type, const H5P_t *mem_space,
- const H5P_t *file_space, const H5D_xfer_t *xfer_parms,
- void *buf/*out*/)
+H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5P_t *mem_space,
+ const H5P_t *file_space, const H5D_xfer_t *xfer_parms,
+ void *buf /*out */ )
{
- size_t nelmts, src_size, dst_size;
- size_t offset[H5O_LAYOUT_NDIMS];
- size_t size[H5O_LAYOUT_NDIMS];
- intn i;
- herr_t ret_value = FAIL;
- uint8 *conv_buf = NULL; /*data type conv buffer */
- H5T_conv_t conv_func = NULL; /*conversion function */
- hid_t src_id=-1, dst_id=-1; /*temporary type atoms */
-
- FUNC_ENTER (H5D_read, FAIL);
-
- /* check args */
- assert (dataset && dataset->ent.file);
- assert (mem_type);
- assert (xfer_parms);
- assert (buf);
-
- if ((mem_space && H5P_cmp (mem_space, dataset->space)) ||
- (file_space && H5P_cmp (file_space, dataset->space))) {
- HGOTO_ERROR (H5E_DATASET, H5E_UNSUPPORTED, FAIL,
- "space conversion not supported yet");
- }
-
-
- /*
- * Convert data types to atoms because the conversion functions are
- * application-level functions.
- */
- if ((src_id=H5Aregister_atom (H5_DATATYPE, H5T_copy (dataset->type)))<0 ||
- (dst_id=H5Aregister_atom (H5_DATATYPE, H5T_copy (mem_type)))<0) {
- HGOTO_ERROR (H5E_DATASET, H5E_CANTREGISTER, FAIL,
- "unable to register types for conversion");
- }
-
- /* Compute the size of the request and allocate scratch buffers */
- nelmts = H5P_get_npoints (dataset->space);
- src_size = nelmts * H5T_get_size (dataset->type);
- dst_size = nelmts * H5T_get_size (mem_type);
- conv_buf = H5MM_xmalloc (MAX (src_size, dst_size));
- if (NULL==(conv_func=H5T_find (dataset->type, mem_type))) {
- HGOTO_ERROR (H5E_DATASET, H5E_UNSUPPORTED, FAIL,
- "unable to convert between src and dest data types");
- }
-
- /*
- * Read data into the data type conversion buffer.
- * (We only support complete reads currently)
- */
- for (i=0; i<dataset->layout.ndims; i++) {
- offset[i] = 0;
- size[i] = dataset->layout.dim[i];
- }
- if (H5F_arr_read (dataset->ent.file, &(dataset->layout), offset, size,
- conv_buf)<0) {
- HGOTO_ERROR (H5E_IO, H5E_READERROR, FAIL, "read failed");
- }
-
- /*
- * Perform data type conversion.
- */
- if ((conv_func)(src_id, dst_id, nelmts, conv_buf, NULL)<0) {
- HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL,
- "data type conversion failed");
- }
-
- /*
- * Copy conversion buffer into destination.
- */
- HDmemcpy (buf, conv_buf, dst_size);
-
- ret_value = SUCCEED;
- done:
- if (src_id>=0) H5A_dec_ref (src_id);
- if (dst_id>=0) H5A_dec_ref (dst_id);
- conv_buf = H5MM_xfree (conv_buf);
- FUNC_LEAVE (ret_value);
+ size_t nelmts, src_size, dst_size;
+ size_t offset[H5O_LAYOUT_NDIMS];
+ size_t size[H5O_LAYOUT_NDIMS];
+ intn i;
+ herr_t ret_value = FAIL;
+ uint8 *conv_buf = NULL; /*data type conv buffer */
+ H5T_conv_t conv_func = NULL; /*conversion function */
+ hid_t src_id = -1, dst_id = -1; /*temporary type atoms */
+
+ FUNC_ENTER(H5D_read, FAIL);
+
+ /* check args */
+ assert(dataset && dataset->ent.file);
+ assert(mem_type);
+ assert(xfer_parms);
+ assert(buf);
+
+ if ((mem_space && H5P_cmp(mem_space, dataset->space)) ||
+ (file_space && H5P_cmp(file_space, dataset->space))) {
+ HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL,
+ "space conversion not supported yet");
+ }
+ /*
+ * Convert data types to atoms because the conversion functions are
+ * application-level functions.
+ */
+ if ((src_id = H5Aregister_atom(H5_DATATYPE, H5T_copy(dataset->type))) < 0 ||
+ (dst_id = H5Aregister_atom(H5_DATATYPE, H5T_copy(mem_type))) < 0) {
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL,
+ "unable to register types for conversion");
+ }
+ /* Compute the size of the request and allocate scratch buffers */
+ nelmts = H5P_get_npoints(dataset->space);
+ src_size = nelmts * H5T_get_size(dataset->type);
+ dst_size = nelmts * H5T_get_size(mem_type);
+ conv_buf = H5MM_xmalloc(MAX(src_size, dst_size));
+ if (NULL == (conv_func = H5T_find(dataset->type, mem_type))) {
+ HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL,
+ "unable to convert between src and dest data types");
+ }
+ /*
+ * Read data into the data type conversion buffer.
+ * (We only support complete reads currently)
+ */
+ for (i = 0; i < dataset->layout.ndims; i++) {
+ offset[i] = 0;
+ size[i] = dataset->layout.dim[i];
+ }
+ if (H5F_arr_read(dataset->ent.file, &(dataset->layout), offset, size,
+ conv_buf) < 0) {
+ HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL, "read failed");
+ }
+ /*
+ * Perform data type conversion.
+ */
+ if ((conv_func) (src_id, dst_id, nelmts, conv_buf, NULL) < 0) {
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL,
+ "data type conversion failed");
+ }
+ /*
+ * Copy conversion buffer into destination.
+ */
+ HDmemcpy(buf, conv_buf, dst_size);
+
+ ret_value = SUCCEED;
+ done:
+ if (src_id >= 0)
+ H5A_dec_ref(src_id);
+ if (dst_id >= 0)
+ H5A_dec_ref(dst_id);
+ conv_buf = H5MM_xfree(conv_buf);
+ FUNC_LEAVE(ret_value);
}
-
/*-------------------------------------------------------------------------
- * Function: H5D_write
+ * Function: H5D_write
*
- * Purpose: Writes (part of) a DATASET to a file from application memory
- * BUF. See H5Dwrite() for complete details.
+ * Purpose: Writes (part of) a DATASET to a file from application memory
+ * BUF. See H5Dwrite() for complete details.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Thursday, December 4, 1997
*
* Modifications:
@@ -962,90 +915,84 @@ H5D_read (H5D_t *dataset, const H5T_t *mem_type, const H5P_t *mem_space,
*-------------------------------------------------------------------------
*/
herr_t
-H5D_write (H5D_t *dataset, const H5T_t *mem_type, const H5P_t *mem_space,
- const H5P_t *file_space, const H5D_xfer_t *xfer_parms,
- const void *buf)
+H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5P_t *mem_space,
+ const H5P_t *file_space, const H5D_xfer_t *xfer_parms,
+ const void *buf)
{
- size_t nelmts, src_size, dst_size;
- size_t offset[H5O_LAYOUT_NDIMS];
- size_t size[H5O_LAYOUT_NDIMS];
- intn i;
- herr_t ret_value = FAIL;
- uint8 *conv_buf = NULL; /*data type conversion buffer */
- H5T_conv_t conv_func = NULL; /*data type conversion function */
- hid_t src_id=-1, dst_id=-1; /*temporary type atoms */
-
- FUNC_ENTER (H5D_write, FAIL);
-
- /* check args */
- assert (dataset && dataset->ent.file);
- assert (mem_type);
- assert (xfer_parms);
- assert (buf);
-
- if (H5D_CONTIGUOUS!=dataset->create_parms.layout) {
- HRETURN_ERROR (H5E_DATASET, H5E_UNSUPPORTED, FAIL,
- "layout is not supported yet");
- }
- if ((mem_space && H5P_cmp (mem_space, dataset->space)) ||
- (file_space && H5P_cmp (file_space, dataset->space))) {
- HRETURN_ERROR (H5E_DATASET, H5E_UNSUPPORTED, FAIL,
- "space conversion not supported yet");
- }
-
- /*
- * Convert data types to atoms because the conversion functions are
- * application-level functions.
- */
- if ((src_id=H5Aregister_atom (H5_DATATYPE, H5T_copy (mem_type)))<0 ||
- (dst_id=H5Aregister_atom (H5_DATATYPE, H5T_copy (dataset->type)))<0) {
- HGOTO_ERROR (H5E_DATASET, H5E_CANTREGISTER, FAIL,
- "unable to register types for conversion");
- }
-
-
- /* Compute the size of the request and allocate scratch buffers */
- nelmts = H5P_get_npoints (dataset->space);
- src_size = nelmts * H5T_get_size (mem_type);
- dst_size = nelmts * H5T_get_size (dataset->type);
- conv_buf = H5MM_xmalloc (MAX (src_size, dst_size));
- if (NULL==(conv_func=H5T_find (mem_type, dataset->type))) {
- HGOTO_ERROR (H5E_DATASET, H5E_UNSUPPORTED, FAIL,
- "unable to convert between src and dest data types");
- }
-
-
- /*
- * Read data into the data type conversion buffer.
- */
- HDmemcpy (conv_buf, buf, src_size);
-
- /*
- * Perform data type conversion.
- */
- if ((conv_func)(src_id, dst_id, nelmts, conv_buf, NULL)<0) {
- HGOTO_ERROR (H5E_DATASET, H5E_CANTINIT, FAIL,
- "data type conversion failed");
- }
-
- /*
- * Write data into the file.
- * (We only support complete writes currently.)
- */
- for (i=0; i<dataset->layout.ndims; i++) {
- offset[i] = 0;
- size[i] = dataset->layout.dim[i];
- }
- if (H5F_arr_write (dataset->ent.file, &(dataset->layout), offset, size,
- conv_buf)<0) {
- HGOTO_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "write failed");
- }
-
- ret_value = SUCCEED;
- done:
- if (src_id>=0) H5A_dec_ref (src_id);
- if (dst_id>=0) H5A_dec_ref (dst_id);
- conv_buf = H5MM_xfree (conv_buf);
- FUNC_LEAVE (ret_value);
+ size_t nelmts, src_size, dst_size;
+ size_t offset[H5O_LAYOUT_NDIMS];
+ size_t size[H5O_LAYOUT_NDIMS];
+ intn i;
+ herr_t ret_value = FAIL;
+ uint8 *conv_buf = NULL; /*data type conversion buffer */
+ H5T_conv_t conv_func = NULL; /*data type conversion function */
+ hid_t src_id = -1, dst_id = -1; /*temporary type atoms */
+
+ FUNC_ENTER(H5D_write, FAIL);
+
+ /* check args */
+ assert(dataset && dataset->ent.file);
+ assert(mem_type);
+ assert(xfer_parms);
+ assert(buf);
+
+ if (H5D_CONTIGUOUS != dataset->create_parms.layout) {
+ HRETURN_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL,
+ "layout is not supported yet");
+ }
+ if ((mem_space && H5P_cmp(mem_space, dataset->space)) ||
+ (file_space && H5P_cmp(file_space, dataset->space))) {
+ HRETURN_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL,
+ "space conversion not supported yet");
+ }
+ /*
+ * Convert data types to atoms because the conversion functions are
+ * application-level functions.
+ */
+ if ((src_id = H5Aregister_atom(H5_DATATYPE, H5T_copy(mem_type))) < 0 ||
+ (dst_id = H5Aregister_atom(H5_DATATYPE, H5T_copy(dataset->type))) < 0) {
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL,
+ "unable to register types for conversion");
+ }
+ /* Compute the size of the request and allocate scratch buffers */
+ nelmts = H5P_get_npoints(dataset->space);
+ src_size = nelmts * H5T_get_size(mem_type);
+ dst_size = nelmts * H5T_get_size(dataset->type);
+ conv_buf = H5MM_xmalloc(MAX(src_size, dst_size));
+ if (NULL == (conv_func = H5T_find(mem_type, dataset->type))) {
+ HGOTO_ERROR(H5E_DATASET, H5E_UNSUPPORTED, FAIL,
+ "unable to convert between src and dest data types");
+ }
+ /*
+ * Read data into the data type conversion buffer.
+ */
+ HDmemcpy(conv_buf, buf, src_size);
+
+ /*
+ * Perform data type conversion.
+ */
+ if ((conv_func) (src_id, dst_id, nelmts, conv_buf, NULL) < 0) {
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL,
+ "data type conversion failed");
+ }
+ /*
+ * Write data into the file.
+ * (We only support complete writes currently.)
+ */
+ for (i = 0; i < dataset->layout.ndims; i++) {
+ offset[i] = 0;
+ size[i] = dataset->layout.dim[i];
+ }
+ if (H5F_arr_write(dataset->ent.file, &(dataset->layout), offset, size,
+ conv_buf) < 0) {
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "write failed");
+ }
+ ret_value = SUCCEED;
+ done:
+ if (src_id >= 0)
+ H5A_dec_ref(src_id);
+ if (dst_id >= 0)
+ H5A_dec_ref(dst_id);
+ conv_buf = H5MM_xfree(conv_buf);
+ FUNC_LEAVE(ret_value);
}
-
diff --git a/src/H5Distore.c b/src/H5Distore.c
index fa53b91..10f9eae 100644
--- a/src/H5Distore.c
+++ b/src/H5Distore.c
@@ -15,47 +15,45 @@
#include <H5Vprivate.h>
typedef enum H5F_isop_t {
- H5F_ISTORE_READ, /*read from file to memory */
- H5F_ISTORE_WRITE /*write from memory to file */
+ H5F_ISTORE_READ, /*read from file to memory */
+ H5F_ISTORE_WRITE /*write from memory to file */
} H5F_isop_t;
/* Does the array domain include negative indices? */
#undef H5F_ISTORE_NEGATIVE_DOMAIN
-
-#define PABLO_MASK H5F_istore_mask
+#define PABLO_MASK H5F_istore_mask
/* Interface initialization */
-static hbool_t interface_initialize_g = FALSE;
+static hbool_t interface_initialize_g = FALSE;
#define INTERFACE_INIT NULL
/* PRIVATE PROTOTYPES */
-static size_t H5F_istore_sizeof_rkey (H5F_t *f, const void *_udata);
-static herr_t H5F_istore_new_node (H5F_t *f, H5B_ins_t, void *_lt_key,
- void *_udata, void *_rt_key, haddr_t*);
-static intn H5F_istore_cmp2 (H5F_t *f, void *_lt_key, void *_udata,
- void *_rt_key);
-static intn H5F_istore_cmp3 (H5F_t *f, void *_lt_key, void *_udata,
- void *_rt_key);
-static herr_t H5F_istore_found (H5F_t *f, const haddr_t *addr,
- const void *_lt_key, void *_udata,
- const void *_rt_key);
-static H5B_ins_t H5F_istore_insert (H5F_t *f, const haddr_t *addr,
- void *_lt_key, hbool_t *lt_key_changed,
- void *_md_key, void *_udata,
- void *_rt_key, hbool_t *rt_key_changed,
- haddr_t*);
-static herr_t H5F_istore_decode_key (H5F_t *f, H5B_t *bt, uint8 *raw,
- void *_key);
-static herr_t H5F_istore_encode_key (H5F_t *f, H5B_t *bt, uint8 *raw,
- void *_key);
-static herr_t H5F_istore_copy_hyperslab (H5F_t *f, const H5O_layout_t *layout,
- H5F_isop_t op,
- const size_t offset_f[],
- const size_t size[],
- const size_t offset_m[],
- const size_t size_m[], void *buf);
-
+static size_t H5F_istore_sizeof_rkey(H5F_t *f, const void *_udata);
+static herr_t H5F_istore_new_node(H5F_t *f, H5B_ins_t, void *_lt_key,
+ void *_udata, void *_rt_key, haddr_t *);
+static intn H5F_istore_cmp2(H5F_t *f, void *_lt_key, void *_udata,
+ void *_rt_key);
+static intn H5F_istore_cmp3(H5F_t *f, void *_lt_key, void *_udata,
+ void *_rt_key);
+static herr_t H5F_istore_found(H5F_t *f, const haddr_t *addr,
+ const void *_lt_key, void *_udata,
+ const void *_rt_key);
+static H5B_ins_t H5F_istore_insert(H5F_t *f, const haddr_t *addr,
+ void *_lt_key, hbool_t *lt_key_changed,
+ void *_md_key, void *_udata,
+ void *_rt_key, hbool_t *rt_key_changed,
+ haddr_t *);
+static herr_t H5F_istore_decode_key(H5F_t *f, H5B_t *bt, uint8 *raw,
+ void *_key);
+static herr_t H5F_istore_encode_key(H5F_t *f, H5B_t *bt, uint8 *raw,
+ void *_key);
+static herr_t H5F_istore_copy_hyperslab(H5F_t *f, const H5O_layout_t *layout,
+ H5F_isop_t op,
+ const size_t offset_f[],
+ const size_t size[],
+ const size_t offset_m[],
+ const size_t size_m[], void *buf);
/*
* B-tree key. A key contains the minimum logical N-dimensional address and
@@ -72,49 +70,49 @@ static herr_t H5F_istore_copy_hyperslab (H5F_t *f, const H5O_layout_t *layout,
* The storage file address is part of the B-tree and not part of the key.
*/
typedef struct H5F_istore_key_t {
- uintn file_number; /*external file number */
- size_t offset[H5O_LAYOUT_NDIMS]; /*logical offset to start*/
- size_t size[H5O_LAYOUT_NDIMS]; /*logical chunk size */
+ uintn file_number; /*external file number */
+ size_t offset[H5O_LAYOUT_NDIMS]; /*logical offset to start */
+ size_t size[H5O_LAYOUT_NDIMS]; /*logical chunk size */
} H5F_istore_key_t;
typedef struct H5F_istore_ud1_t {
- H5F_istore_key_t key; /*key values */
- haddr_t addr; /*file address of chunk */
- H5O_layout_t mesg; /*layout message */
+ H5F_istore_key_t key; /*key values */
+ haddr_t addr; /*file address of chunk */
+ H5O_layout_t mesg; /*layout message */
} H5F_istore_ud1_t;
-
-/* inherits B-tree like properties from H5B */
-H5B_class_t H5B_ISTORE[1] = {{
- H5B_ISTORE_ID, /*id */
- sizeof (H5F_istore_key_t), /*sizeof_nkey */
- H5F_istore_sizeof_rkey, /*get_sizeof_rkey */
- H5F_istore_new_node, /*new */
- H5F_istore_cmp2, /*cmp2 */
- H5F_istore_cmp3, /*cmp3 */
- H5F_istore_found, /*found */
- H5F_istore_insert, /*insert */
- FALSE, /*follow min branch? */
- FALSE, /*follow max branch? */
- NULL, /*list */
- H5F_istore_decode_key, /*decode */
- H5F_istore_encode_key, /*encode */
-}};
-
+/* inherits B-tree like properties from H5B */
+H5B_class_t H5B_ISTORE[1] =
+{
+ {
+ H5B_ISTORE_ID, /*id */
+ sizeof(H5F_istore_key_t), /*sizeof_nkey */
+ H5F_istore_sizeof_rkey, /*get_sizeof_rkey */
+ H5F_istore_new_node, /*new */
+ H5F_istore_cmp2, /*cmp2 */
+ H5F_istore_cmp3, /*cmp3 */
+ H5F_istore_found, /*found */
+ H5F_istore_insert, /*insert */
+ FALSE, /*follow min branch? */
+ FALSE, /*follow max branch? */
+ NULL, /*list */
+ H5F_istore_decode_key, /*decode */
+ H5F_istore_encode_key, /*encode */
+ }};
/*-------------------------------------------------------------------------
- * Function: H5F_istore_sizeof_rkey
+ * Function: H5F_istore_sizeof_rkey
*
- * Purpose: Returns the size of a raw key for the specified UDATA. The
- * size of the key is dependent on the number of dimensions for
- * the object to which this B-tree points. The dimensionality
- * of the UDATA is the only portion that's referenced here.
+ * Purpose: Returns the size of a raw key for the specified UDATA. The
+ * size of the key is dependent on the number of dimensions for
+ * the object to which this B-tree points. The dimensionality
+ * of the UDATA is the only portion that's referenced here.
*
- * Return: Success: Size of raw key in bytes.
+ * Return: Success: Size of raw key in bytes.
*
- * Failure: abort()
+ * Failure: abort()
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, October 8, 1997
*
* Modifications:
@@ -122,33 +120,31 @@ H5B_class_t H5B_ISTORE[1] = {{
*-------------------------------------------------------------------------
*/
static size_t
-H5F_istore_sizeof_rkey (H5F_t *f, const void *_udata)
+H5F_istore_sizeof_rkey(H5F_t *f, const void *_udata)
{
- const H5F_istore_ud1_t *udata = (const H5F_istore_ud1_t *)_udata;
- size_t nbytes;
+ const H5F_istore_ud1_t *udata = (const H5F_istore_ud1_t *) _udata;
+ size_t nbytes;
- assert (udata);
- assert (udata->mesg.ndims>0 && udata->mesg.ndims<=H5O_LAYOUT_NDIMS);
-
- nbytes = 4 + /*external file number */
- udata->mesg.ndims * 4 + /*dimension indices */
- udata->mesg.ndims * 4; /*dimension sizes */
-
- return nbytes;
-}
+ assert(udata);
+ assert(udata->mesg.ndims > 0 && udata->mesg.ndims <= H5O_LAYOUT_NDIMS);
+ nbytes = 4 + /*external file number */
+ udata->mesg.ndims * 4 + /*dimension indices */
+ udata->mesg.ndims * 4; /*dimension sizes */
+ return nbytes;
+}
/*-------------------------------------------------------------------------
- * Function: H5F_istore_decode_key
+ * Function: H5F_istore_decode_key
*
- * Purpose: Decodes a raw key into a native key for the B-tree
+ * Purpose: Decodes a raw key into a native key for the B-tree
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, October 10, 1997
*
* Modifications:
@@ -156,44 +152,43 @@ H5F_istore_sizeof_rkey (H5F_t *f, const void *_udata)
*-------------------------------------------------------------------------
*/
static herr_t
-H5F_istore_decode_key (H5F_t *f, H5B_t *bt, uint8 *raw, void *_key)
+H5F_istore_decode_key(H5F_t *f, H5B_t *bt, uint8 *raw, void *_key)
{
- H5F_istore_key_t *key = (H5F_istore_key_t *)_key;
- int i;
- int ndims = bt->sizeof_rkey / 8;
+ H5F_istore_key_t *key = (H5F_istore_key_t *) _key;
+ int i;
+ int ndims = bt->sizeof_rkey / 8;
- FUNC_ENTER (H5F_istore_decode_key, FAIL);
+ FUNC_ENTER(H5F_istore_decode_key, FAIL);
- /* check args */
- assert (f);
- assert (bt);
- assert (raw);
- assert (key);
- assert (ndims>0 && ndims<=H5O_LAYOUT_NDIMS);
+ /* check args */
+ assert(f);
+ assert(bt);
+ assert(raw);
+ assert(key);
+ assert(ndims > 0 && ndims <= H5O_LAYOUT_NDIMS);
- /* decode */
- UINT32DECODE (raw, key->file_number);
- assert (0==key->file_number);
- for (i=0; i<ndims; i++) {
- UINT32DECODE (raw, key->offset[i]);
- UINT32DECODE (raw, key->size[i]);
- }
+ /* decode */
+ UINT32DECODE(raw, key->file_number);
+ assert(0 == key->file_number);
+ for (i = 0; i < ndims; i++) {
+ UINT32DECODE(raw, key->offset[i]);
+ UINT32DECODE(raw, key->size[i]);
+ }
- FUNC_LEAVE (SUCCEED);
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5F_istore_encode_key
+ * Function: H5F_istore_encode_key
*
- * Purpose: Encode a key from native format to raw format.
+ * Purpose: Encode a key from native format to raw format.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, October 10, 1997
*
* Modifications:
@@ -201,48 +196,47 @@ H5F_istore_decode_key (H5F_t *f, H5B_t *bt, uint8 *raw, void *_key)
*-------------------------------------------------------------------------
*/
static herr_t
-H5F_istore_encode_key (H5F_t *f, H5B_t *bt, uint8 *raw, void *_key)
+H5F_istore_encode_key(H5F_t *f, H5B_t *bt, uint8 *raw, void *_key)
{
- H5F_istore_key_t *key = (H5F_istore_key_t *)_key;
- intn ndims = bt->sizeof_rkey / 8;
- intn i;
-
- FUNC_ENTER (H5F_istore_encode_key, FAIL);
-
- /* check args */
- assert (f);
- assert (bt);
- assert (raw);
- assert (key);
- assert (ndims>0 && ndims<=H5O_LAYOUT_NDIMS);
-
- /* encode */
- UINT32ENCODE (raw, key->file_number);
- assert (0==key->file_number);
- for (i=0; i<ndims; i++) {
- UINT32ENCODE (raw, key->offset[i]);
- UINT32ENCODE (raw, key->size[i]);
- }
-
- FUNC_LEAVE (SUCCEED);
+ H5F_istore_key_t *key = (H5F_istore_key_t *) _key;
+ intn ndims = bt->sizeof_rkey / 8;
+ intn i;
+
+ FUNC_ENTER(H5F_istore_encode_key, FAIL);
+
+ /* check args */
+ assert(f);
+ assert(bt);
+ assert(raw);
+ assert(key);
+ assert(ndims > 0 && ndims <= H5O_LAYOUT_NDIMS);
+
+ /* encode */
+ UINT32ENCODE(raw, key->file_number);
+ assert(0 == key->file_number);
+ for (i = 0; i < ndims; i++) {
+ UINT32ENCODE(raw, key->offset[i]);
+ UINT32ENCODE(raw, key->size[i]);
+ }
+
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5F_istore_cmp2
+ * Function: H5F_istore_cmp2
*
- * Purpose: Compares two keys sort of like strcmp(). The UDATA pointer
- * is only to supply extra information not carried in the keys
- * (in this case, the dimensionality) and is not compared
- * against the keys.
+ * Purpose: Compares two keys sort of like strcmp(). The UDATA pointer
+ * is only to supply extra information not carried in the keys
+ * (in this case, the dimensionality) and is not compared
+ * against the keys.
*
- * Return: Success: -1 if LT_KEY is less than RT_KEY;
- * 1 if LT_KEY is greater than RT_KEY;
- * 0 if LT_KEY and RT_KEY are equal.
+ * Return: Success: -1 if LT_KEY is less than RT_KEY;
+ * 1 if LT_KEY is greater than RT_KEY;
+ * 0 if LT_KEY and RT_KEY are equal.
*
- * Failure: FAIL (same as LT_KEY<RT_KEY)
+ * Failure: FAIL (same as LT_KEY<RT_KEY)
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Thursday, November 6, 1997
*
* Modifications:
@@ -250,50 +244,49 @@ H5F_istore_encode_key (H5F_t *f, H5B_t *bt, uint8 *raw, void *_key)
*-------------------------------------------------------------------------
*/
static intn
-H5F_istore_cmp2 (H5F_t *f, void *_lt_key, void *_udata, void *_rt_key)
+H5F_istore_cmp2(H5F_t *f, void *_lt_key, void *_udata, void *_rt_key)
{
- H5F_istore_key_t *lt_key = (H5F_istore_key_t *)_lt_key;
- H5F_istore_key_t *rt_key = (H5F_istore_key_t *)_rt_key;
- H5F_istore_ud1_t *udata = (H5F_istore_ud1_t *)_udata;
- intn cmp;
+ H5F_istore_key_t *lt_key = (H5F_istore_key_t *) _lt_key;
+ H5F_istore_key_t *rt_key = (H5F_istore_key_t *) _rt_key;
+ H5F_istore_ud1_t *udata = (H5F_istore_ud1_t *) _udata;
+ intn cmp;
- FUNC_ENTER (H5F_istore_cmp2, FAIL);
+ FUNC_ENTER(H5F_istore_cmp2, FAIL);
- assert (lt_key);
- assert (rt_key);
- assert (udata);
- assert (udata->mesg.ndims>0 && udata->mesg.ndims<=H5O_LAYOUT_NDIMS);
+ assert(lt_key);
+ assert(rt_key);
+ assert(udata);
+ assert(udata->mesg.ndims > 0 && udata->mesg.ndims <= H5O_LAYOUT_NDIMS);
- /* Compare the offsets but ignore the other fields */
- cmp = H5V_vector_cmp (udata->mesg.ndims, lt_key->offset, rt_key->offset);
+ /* Compare the offsets but ignore the other fields */
+ cmp = H5V_vector_cmp(udata->mesg.ndims, lt_key->offset, rt_key->offset);
- FUNC_LEAVE (cmp);
+ FUNC_LEAVE(cmp);
}
-
/*-------------------------------------------------------------------------
- * Function: H5F_istore_cmp3
+ * Function: H5F_istore_cmp3
*
- * Purpose: Compare the requested datum UDATA with the left and right
- * keys of the B-tree.
+ * Purpose: Compare the requested datum UDATA with the left and right
+ * keys of the B-tree.
*
- * Return: Success: negative if the min_corner of UDATA is less
- * than the min_corner of LT_KEY.
+ * Return: Success: negative if the min_corner of UDATA is less
+ * than the min_corner of LT_KEY.
*
- * positive if the min_corner of UDATA is
- * greater than or equal the min_corner of
- * RT_KEY.
+ * positive if the min_corner of UDATA is
+ * greater than or equal the min_corner of
+ * RT_KEY.
*
- * zero otherwise. The min_corner of UDATA is
- * not necessarily contained within the address
- * space represented by LT_KEY, but a key that
- * would describe the UDATA min_corner address
- * would fall lexicographically between LT_KEY
- * and RT_KEY.
- *
- * Failure: FAIL (same as UDATA < LT_KEY)
+ * zero otherwise. The min_corner of UDATA is
+ * not necessarily contained within the address
+ * space represented by LT_KEY, but a key that
+ * would describe the UDATA min_corner address
+ * would fall lexicographically between LT_KEY
+ * and RT_KEY.
+ *
+ * Failure: FAIL (same as UDATA < LT_KEY)
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, October 8, 1997
*
* Modifications:
@@ -301,45 +294,43 @@ H5F_istore_cmp2 (H5F_t *f, void *_lt_key, void *_udata, void *_rt_key)
*-------------------------------------------------------------------------
*/
static intn
-H5F_istore_cmp3 (H5F_t *f, void *_lt_key, void *_udata, void *_rt_key)
+H5F_istore_cmp3(H5F_t *f, void *_lt_key, void *_udata, void *_rt_key)
{
- H5F_istore_key_t *lt_key = (H5F_istore_key_t *)_lt_key;
- H5F_istore_key_t *rt_key = (H5F_istore_key_t *)_rt_key;
- H5F_istore_ud1_t *udata = (H5F_istore_ud1_t *)_udata;
- intn cmp = 0;
-
- FUNC_ENTER (H5F_istore_cmp3, FAIL);
-
- assert (lt_key);
- assert (rt_key);
- assert (udata);
- assert (udata->mesg.ndims>0 && udata->mesg.ndims<=H5O_LAYOUT_NDIMS);
-
- if (H5V_vector_lt (udata->mesg.ndims, udata->key.offset, lt_key->offset)) {
- cmp = -1;
- } else if (H5V_vector_ge (udata->mesg.ndims, udata->key.offset,
- rt_key->offset)) {
- cmp = 1;
- }
-
- FUNC_LEAVE (cmp);
+ H5F_istore_key_t *lt_key = (H5F_istore_key_t *) _lt_key;
+ H5F_istore_key_t *rt_key = (H5F_istore_key_t *) _rt_key;
+ H5F_istore_ud1_t *udata = (H5F_istore_ud1_t *) _udata;
+ intn cmp = 0;
+
+ FUNC_ENTER(H5F_istore_cmp3, FAIL);
+
+ assert(lt_key);
+ assert(rt_key);
+ assert(udata);
+ assert(udata->mesg.ndims > 0 && udata->mesg.ndims <= H5O_LAYOUT_NDIMS);
+
+ if (H5V_vector_lt(udata->mesg.ndims, udata->key.offset, lt_key->offset)) {
+ cmp = -1;
+ } else if (H5V_vector_ge(udata->mesg.ndims, udata->key.offset,
+ rt_key->offset)) {
+ cmp = 1;
+ }
+ FUNC_LEAVE(cmp);
}
-
/*-------------------------------------------------------------------------
- * Function: H5F_istore_new_node
+ * Function: H5F_istore_new_node
*
- * Purpose: Adds a new entry to an i-storage B-tree. We can assume that
- * the domain represented by UDATA doesn't intersect the domain
- * already represented by the B-tree.
+ * Purpose: Adds a new entry to an i-storage B-tree. We can assume that
+ * the domain represented by UDATA doesn't intersect the domain
+ * already represented by the B-tree.
*
- * Return: Success: SUCCEED. The address of leaf is returned
- * through the ADDR argument. It is also added
- * to the UDATA.
+ * Return: Success: SUCCEED. The address of leaf is returned
+ * through the ADDR argument. It is also added
+ * to the UDATA.
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Tuesday, October 14, 1997
*
* Modifications:
@@ -347,78 +338,78 @@ H5F_istore_cmp3 (H5F_t *f, void *_lt_key, void *_udata, void *_rt_key)
*-------------------------------------------------------------------------
*/
static herr_t
-H5F_istore_new_node (H5F_t *f, H5B_ins_t op,
- void *_lt_key, void *_udata, void *_rt_key,
- haddr_t *addr/*out*/)
+H5F_istore_new_node(H5F_t *f, H5B_ins_t op,
+ void *_lt_key, void *_udata, void *_rt_key,
+ haddr_t *addr /*out */ )
{
- H5F_istore_key_t *lt_key = (H5F_istore_key_t *)_lt_key;
- H5F_istore_key_t *rt_key = (H5F_istore_key_t *)_rt_key;
- H5F_istore_ud1_t *udata = (H5F_istore_ud1_t *)_udata;
- size_t nbytes;
- intn i;
-
- FUNC_ENTER (H5F_istore_new_node, FAIL);
-
- /* check args */
- assert (f);
- assert (lt_key);
- assert (rt_key);
- assert (udata);
- assert (udata->mesg.ndims>=0 && udata->mesg.ndims<H5O_LAYOUT_NDIMS);
- assert (addr);
-
- /* Allocate new storage */
- nbytes = H5V_vector_reduce_product (udata->mesg.ndims, udata->key.size);
- assert (nbytes>0);
- if (H5MF_alloc (f, H5MF_RAW, nbytes, addr/*out*/)<0) {
- HRETURN_ERROR (H5E_IO, H5E_CANTINIT, FAIL,
- "couldn't allocate new file storage");
- }
- udata->addr = *addr;
- udata->key.file_number = 0;
- lt_key->file_number = udata->key.file_number;
- if (H5B_INS_LEFT!=op) rt_key->file_number = 0;
-
- /* Initialize the key(s) */
- for (i=0; i<udata->mesg.ndims; i++) {
- /*
- * The left key describes the storage of the UDATA chunk being inserted
- * into the tree.
- */
- assert (udata->key.size[i]>0);
- lt_key->offset[i] = udata->key.offset[i];
- lt_key->size[i] = udata->key.size[i];
-
- /*
- * The right key might already be present. If not, then add
- * a zero-width chunk.
- */
- if (H5B_INS_LEFT!=op) {
- rt_key->offset[i] = udata->key.offset[i] + udata->key.size[i];
- rt_key->size[i] = 0;
- }
- }
-
- FUNC_LEAVE (SUCCEED);
+ H5F_istore_key_t *lt_key = (H5F_istore_key_t *) _lt_key;
+ H5F_istore_key_t *rt_key = (H5F_istore_key_t *) _rt_key;
+ H5F_istore_ud1_t *udata = (H5F_istore_ud1_t *) _udata;
+ size_t nbytes;
+ intn i;
+
+ FUNC_ENTER(H5F_istore_new_node, FAIL);
+
+ /* check args */
+ assert(f);
+ assert(lt_key);
+ assert(rt_key);
+ assert(udata);
+ assert(udata->mesg.ndims >= 0 && udata->mesg.ndims < H5O_LAYOUT_NDIMS);
+ assert(addr);
+
+ /* Allocate new storage */
+ nbytes = H5V_vector_reduce_product(udata->mesg.ndims, udata->key.size);
+ assert(nbytes > 0);
+ if (H5MF_alloc(f, H5MF_RAW, nbytes, addr /*out */ ) < 0) {
+ HRETURN_ERROR(H5E_IO, H5E_CANTINIT, FAIL,
+ "couldn't allocate new file storage");
+ }
+ udata->addr = *addr;
+ udata->key.file_number = 0;
+ lt_key->file_number = udata->key.file_number;
+ if (H5B_INS_LEFT != op)
+ rt_key->file_number = 0;
+
+ /* Initialize the key(s) */
+ for (i = 0; i < udata->mesg.ndims; i++) {
+ /*
+ * The left key describes the storage of the UDATA chunk being inserted
+ * into the tree.
+ */
+ assert(udata->key.size[i] > 0);
+ lt_key->offset[i] = udata->key.offset[i];
+ lt_key->size[i] = udata->key.size[i];
+
+ /*
+ * The right key might already be present. If not, then add
+ * a zero-width chunk.
+ */
+ if (H5B_INS_LEFT != op) {
+ rt_key->offset[i] = udata->key.offset[i] + udata->key.size[i];
+ rt_key->size[i] = 0;
+ }
+ }
+
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5F_istore_found
+ * Function: H5F_istore_found
*
- * Purpose: This function is called when the B-tree search engine has
- * found the leaf entry that points to a chunk of storage that
- * contains the beginning of the logical address space
- * represented by UDATA. The LT_KEY is the left key (the one
- * that describes the chunk) and RT_KEY is the right key (the
- * one that describes the next or last chunk).
+ * Purpose: This function is called when the B-tree search engine has
+ * found the leaf entry that points to a chunk of storage that
+ * contains the beginning of the logical address space
+ * represented by UDATA. The LT_KEY is the left key (the one
+ * that describes the chunk) and RT_KEY is the right key (the
+ * one that describes the next or last chunk).
*
- * Return: Success: SUCCEED with information about the chunk
- * returned through the UDATA argument.
+ * Return: Success: SUCCEED with information about the chunk
+ * returned through the UDATA argument.
*
- * Failure: FAIL if not found.
+ * Failure: FAIL if not found.
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Thursday, October 9, 1997
*
* Modifications:
@@ -426,59 +417,58 @@ H5F_istore_new_node (H5F_t *f, H5B_ins_t op,
*-------------------------------------------------------------------------
*/
static herr_t
-H5F_istore_found (H5F_t *f, const haddr_t *addr, const void *_lt_key,
- void *_udata, const void *_rt_key)
+H5F_istore_found(H5F_t *f, const haddr_t *addr, const void *_lt_key,
+ void *_udata, const void *_rt_key)
{
- H5F_istore_ud1_t *udata = (H5F_istore_ud1_t *)_udata;
- const H5F_istore_key_t *lt_key = (const H5F_istore_key_t *)_lt_key;
- int i;
-
- FUNC_ENTER (H5F_istore_found, FAIL);
-
- /* Check arguments */
- assert (f);
- assert (addr && H5F_addr_defined (addr));
- assert (udata);
- assert (lt_key);
-
- /* Initialize return values */
- udata->addr = *addr;
- udata->key.file_number = lt_key->file_number;
- assert (0==lt_key->file_number);
- for (i=0; i<udata->mesg.ndims; i++) {
- udata->key.offset[i] = lt_key->offset[i];
- udata->key.size[i] = lt_key->size[i];
- assert (lt_key->size[i]>0);
- }
-
- FUNC_LEAVE (SUCCEED);
+ H5F_istore_ud1_t *udata = (H5F_istore_ud1_t *) _udata;
+ const H5F_istore_key_t *lt_key = (const H5F_istore_key_t *) _lt_key;
+ int i;
+
+ FUNC_ENTER(H5F_istore_found, FAIL);
+
+ /* Check arguments */
+ assert(f);
+ assert(addr && H5F_addr_defined(addr));
+ assert(udata);
+ assert(lt_key);
+
+ /* Initialize return values */
+ udata->addr = *addr;
+ udata->key.file_number = lt_key->file_number;
+ assert(0 == lt_key->file_number);
+ for (i = 0; i < udata->mesg.ndims; i++) {
+ udata->key.offset[i] = lt_key->offset[i];
+ udata->key.size[i] = lt_key->size[i];
+ assert(lt_key->size[i] > 0);
+ }
+
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5F_istore_insert
+ * Function: H5F_istore_insert
*
- * Purpose: This function is called when the B-tree insert engine finds
- * the node to use to insert new data. The UDATA argument
- * points to a struct that describes the logical addresses being
- * added to the file. This function allocates space for the
- * data and returns information through UDATA describing a
- * file chunk to receive (part of) the data.
+ * Purpose: This function is called when the B-tree insert engine finds
+ * the node to use to insert new data. The UDATA argument
+ * points to a struct that describes the logical addresses being
+ * added to the file. This function allocates space for the
+ * data and returns information through UDATA describing a
+ * file chunk to receive (part of) the data.
*
- * The LT_KEY is always the key describing the chunk of file
- * memory at address ADDR. On entry, UDATA describes the logical
- * addresses for which storage is being requested (through the
- * `offset' and `size' fields). On return, UDATA describes the
- * logical addresses contained in a chunk on disk.
+ * The LT_KEY is always the key describing the chunk of file
+ * memory at address ADDR. On entry, UDATA describes the logical
+ * addresses for which storage is being requested (through the
+ * `offset' and `size' fields). On return, UDATA describes the
+ * logical addresses contained in a chunk on disk.
*
- * Return: Success: An insertion command for the caller, one of
- * the H5B_INS_* constants. The address of the
- * new chunk is returned through the NEW_NODE
- * argument.
+ * Return: Success: An insertion command for the caller, one of
+ * the H5B_INS_* constants. The address of the
+ * new chunk is returned through the NEW_NODE
+ * argument.
*
- * Failure: H5B_INS_ERROR
+ * Failure: H5B_INS_ERROR
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Thursday, October 9, 1997
*
* Modifications:
@@ -486,117 +476,116 @@ H5F_istore_found (H5F_t *f, const haddr_t *addr, const void *_lt_key,
*-------------------------------------------------------------------------
*/
static H5B_ins_t
-H5F_istore_insert (H5F_t *f, const haddr_t *addr,
- void *_lt_key, hbool_t *lt_key_changed,
- void *_md_key, void *_udata,
- void *_rt_key, hbool_t *rt_key_changed,
- haddr_t *new_node/*out*/)
+H5F_istore_insert(H5F_t *f, const haddr_t *addr,
+ void *_lt_key, hbool_t *lt_key_changed,
+ void *_md_key, void *_udata,
+ void *_rt_key, hbool_t *rt_key_changed,
+ haddr_t *new_node /*out */ )
{
- H5F_istore_key_t *lt_key = (H5F_istore_key_t *)_lt_key;
- H5F_istore_key_t *md_key = (H5F_istore_key_t *)_md_key;
- H5F_istore_key_t *rt_key = (H5F_istore_key_t *)_rt_key;
- H5F_istore_ud1_t *udata = (H5F_istore_ud1_t *)_udata;
- intn i, cmp;
- H5B_ins_t ret_value = H5B_INS_ERROR;
- size_t nbytes;
-
- FUNC_ENTER (H5F_istore_insert, FAIL);
-
- /* check args */
- assert (f);
- assert (addr && H5F_addr_defined (addr));
- assert (lt_key);
- assert (lt_key_changed);
- assert (md_key);
- assert (udata);
- assert (rt_key);
- assert (rt_key_changed);
- assert (new_node);
-
- cmp = H5F_istore_cmp3 (f, lt_key, udata, rt_key);
- assert (cmp<=0);
-
- if (cmp<0) {
- /* Negative indices not supported yet */
- assert ("HDF5 INTERNAL ERROR -- see rpm" && 0);
- HRETURN_ERROR (H5E_STORAGE, H5E_UNSUPPORTED, FAIL, "internal error");
-
- } else if (H5V_hyper_eq (udata->mesg.ndims,
- udata->key.offset, udata->key.size,
- lt_key->offset, lt_key->size)) {
- /*
- * Already exists. Just return the info.
- */
- udata->addr = *addr;
- udata->key.file_number = lt_key->file_number;
- ret_value = H5B_INS_NOOP;
-
- } else if (H5V_hyper_disjointp (udata->mesg.ndims,
- lt_key->offset, lt_key->size,
- udata->key.offset, udata->key.size)) {
- assert (H5V_hyper_disjointp (udata->mesg.ndims,
- rt_key->offset, rt_key->size,
- udata->key.offset, udata->key.size));
-
- /*
- * Split this node, inserting the new new node to the right of the
- * current node. The MD_KEY is where the split occurs.
- */
- md_key->file_number = udata->key.file_number;
- for (i=0, nbytes=1; i<udata->mesg.ndims; i++) {
- assert (0==udata->key.offset[i] % udata->mesg.dim[i]);
- assert (udata->key.size[i] == udata->mesg.dim[i]);
- md_key->offset[i] = udata->key.offset[i];
- md_key->size[i] = udata->key.size[i];
- nbytes *= udata->key.size[i];
- }
-
- /*
- * Allocate storage for the new chunk
- */
- if (H5MF_alloc (f, H5MF_RAW, nbytes, new_node/*out*/)<0) {
- HRETURN_ERROR (H5E_IO, H5E_CANTINIT, FAIL,
- "file allocation failed");
- }
- udata->addr = *new_node;
- udata->key.file_number = 0;
- ret_value = H5B_INS_RIGHT;
-
- } else {
- assert ("HDF5 INTERNAL ERROR -- see rpm" && 0);
- HRETURN_ERROR (H5E_IO, H5E_UNSUPPORTED, FAIL, "internal error");
- }
-
- FUNC_LEAVE (ret_value);
+ H5F_istore_key_t *lt_key = (H5F_istore_key_t *) _lt_key;
+ H5F_istore_key_t *md_key = (H5F_istore_key_t *) _md_key;
+ H5F_istore_key_t *rt_key = (H5F_istore_key_t *) _rt_key;
+ H5F_istore_ud1_t *udata = (H5F_istore_ud1_t *) _udata;
+ intn i, cmp;
+ H5B_ins_t ret_value = H5B_INS_ERROR;
+ size_t nbytes;
+
+ FUNC_ENTER(H5F_istore_insert, FAIL);
+
+ /* check args */
+ assert(f);
+ assert(addr && H5F_addr_defined(addr));
+ assert(lt_key);
+ assert(lt_key_changed);
+ assert(md_key);
+ assert(udata);
+ assert(rt_key);
+ assert(rt_key_changed);
+ assert(new_node);
+
+ cmp = H5F_istore_cmp3(f, lt_key, udata, rt_key);
+ assert(cmp <= 0);
+
+ if (cmp < 0) {
+ /* Negative indices not supported yet */
+ assert("HDF5 INTERNAL ERROR -- see rpm" && 0);
+ HRETURN_ERROR(H5E_STORAGE, H5E_UNSUPPORTED, FAIL, "internal error");
+
+ } else if (H5V_hyper_eq(udata->mesg.ndims,
+ udata->key.offset, udata->key.size,
+ lt_key->offset, lt_key->size)) {
+ /*
+ * Already exists. Just return the info.
+ */
+ udata->addr = *addr;
+ udata->key.file_number = lt_key->file_number;
+ ret_value = H5B_INS_NOOP;
+
+ } else if (H5V_hyper_disjointp(udata->mesg.ndims,
+ lt_key->offset, lt_key->size,
+ udata->key.offset, udata->key.size)) {
+ assert(H5V_hyper_disjointp(udata->mesg.ndims,
+ rt_key->offset, rt_key->size,
+ udata->key.offset, udata->key.size));
+
+ /*
+ * Split this node, inserting the new new node to the right of the
+ * current node. The MD_KEY is where the split occurs.
+ */
+ md_key->file_number = udata->key.file_number;
+ for (i = 0, nbytes = 1; i < udata->mesg.ndims; i++) {
+ assert(0 == udata->key.offset[i] % udata->mesg.dim[i]);
+ assert(udata->key.size[i] == udata->mesg.dim[i]);
+ md_key->offset[i] = udata->key.offset[i];
+ md_key->size[i] = udata->key.size[i];
+ nbytes *= udata->key.size[i];
+ }
+
+ /*
+ * Allocate storage for the new chunk
+ */
+ if (H5MF_alloc(f, H5MF_RAW, nbytes, new_node /*out */ ) < 0) {
+ HRETURN_ERROR(H5E_IO, H5E_CANTINIT, FAIL,
+ "file allocation failed");
+ }
+ udata->addr = *new_node;
+ udata->key.file_number = 0;
+ ret_value = H5B_INS_RIGHT;
+
+ } else {
+ assert("HDF5 INTERNAL ERROR -- see rpm" && 0);
+ HRETURN_ERROR(H5E_IO, H5E_UNSUPPORTED, FAIL, "internal error");
+ }
+
+ FUNC_LEAVE(ret_value);
}
-
/*-------------------------------------------------------------------------
- * Function: H5F_istore_copy_hyperslab
+ * Function: H5F_istore_copy_hyperslab
*
- * Purpose: Reads or writes a hyperslab to disk depending on whether OP
- * is H5F_ISTORE_READ or H5F_ISTORE_WRITE. The hyperslab
- * storage is described with ISTORE and exists in file F. The
- * file hyperslab begins at location OFFSET_F[] (an N-dimensional
- * point in the domain in terms of elements) in the file and
- * OFFSET_M[] in memory pointed to by BUF. Its size is SIZE[]
- * elements. The dimensionality of memory is assumed to be the
- * same as the file and the total size of the multi-dimensional
- * memory buffer is SIZE_M[].
+ * Purpose: Reads or writes a hyperslab to disk depending on whether OP
+ * is H5F_ISTORE_READ or H5F_ISTORE_WRITE. The hyperslab
+ * storage is described with ISTORE and exists in file F. The
+ * file hyperslab begins at location OFFSET_F[] (an N-dimensional
+ * point in the domain in terms of elements) in the file and
+ * OFFSET_M[] in memory pointed to by BUF. Its size is SIZE[]
+ * elements. The dimensionality of memory is assumed to be the
+ * same as the file and the total size of the multi-dimensional
+ * memory buffer is SIZE_M[].
*
- * The slowest varying dimension is always listed first in the
- * various offset and size arrays.
+ * The slowest varying dimension is always listed first in the
+ * various offset and size arrays.
*
- * A `chunk' is a hyperslab of the disk array which is stored
- * contiguously. I/O occurs in units of chunks where the size of
- * a chunk is determined by the alignment constraints specified
- * in ISTORE.
+ * A `chunk' is a hyperslab of the disk array which is stored
+ * contiguously. I/O occurs in units of chunks where the size of
+ * a chunk is determined by the alignment constraints specified
+ * in ISTORE.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, October 17, 1997
*
* Modifications:
@@ -604,159 +593,159 @@ H5F_istore_insert (H5F_t *f, const haddr_t *addr,
*-------------------------------------------------------------------------
*/
static herr_t
-H5F_istore_copy_hyperslab (H5F_t *f, const H5O_layout_t *layout, H5F_isop_t op,
- const size_t offset_f[], const size_t size[],
- const size_t offset_m[], const size_t size_m[],
- void *buf)
+H5F_istore_copy_hyperslab(H5F_t *f, const H5O_layout_t *layout, H5F_isop_t op,
+ const size_t offset_f[], const size_t size[],
+ const size_t offset_m[], const size_t size_m[],
+ void *buf)
{
- intn i, carry;
- size_t idx_cur[H5O_LAYOUT_NDIMS];
- size_t idx_min[H5O_LAYOUT_NDIMS];
- size_t idx_max[H5O_LAYOUT_NDIMS];
- size_t sub_size[H5O_LAYOUT_NDIMS];
- size_t offset_wrt_chunk[H5O_LAYOUT_NDIMS];
- size_t sub_offset_m[H5O_LAYOUT_NDIMS];
- size_t chunk_size;
- uint8 *chunk=NULL;
- H5F_istore_ud1_t udata;
- herr_t status;
- herr_t ret_value = FAIL;
-
- FUNC_ENTER (H5F_istore_copy_hyperslab, FAIL);
-
- /* check args */
- assert (f);
- assert (layout && H5D_CHUNKED==layout->type);
- assert (H5F_addr_defined (&(layout->addr)));
- assert (layout->ndims>0 && layout->ndims<=H5O_LAYOUT_NDIMS);
- assert (H5F_ISTORE_READ==op || H5F_ISTORE_WRITE==op);
- assert (size);
- assert (size_m);
- assert (buf);
+ intn i, carry;
+ size_t idx_cur[H5O_LAYOUT_NDIMS];
+ size_t idx_min[H5O_LAYOUT_NDIMS];
+ size_t idx_max[H5O_LAYOUT_NDIMS];
+ size_t sub_size[H5O_LAYOUT_NDIMS];
+ size_t offset_wrt_chunk[H5O_LAYOUT_NDIMS];
+ size_t sub_offset_m[H5O_LAYOUT_NDIMS];
+ size_t chunk_size;
+ uint8 *chunk = NULL;
+ H5F_istore_ud1_t udata;
+ herr_t status;
+ herr_t ret_value = FAIL;
+
+ FUNC_ENTER(H5F_istore_copy_hyperslab, FAIL);
+
+ /* check args */
+ assert(f);
+ assert(layout && H5D_CHUNKED == layout->type);
+ assert(H5F_addr_defined(&(layout->addr)));
+ assert(layout->ndims > 0 && layout->ndims <= H5O_LAYOUT_NDIMS);
+ assert(H5F_ISTORE_READ == op || H5F_ISTORE_WRITE == op);
+ assert(size);
+ assert(size_m);
+ assert(buf);
#ifndef NDEBUG
- for (i=0; i<layout->ndims; i++) {
- assert (!offset_f || offset_f[i]>=0);/*neg domains unsupported */
- assert (!offset_m || offset_m[i]>=0);/*mem array offset never neg */
- assert (size[i]>=0); /*size may be zero, implies no-op */
- assert (size_m[i]>0); /*destination must exist */
- /*hyperslab must fit in BUF*/
- assert ((offset_m?offset_m[i]:0)+size[i]<=size_m[i]);
- assert (layout->dim[i]>0);
- }
+ for (i = 0; i < layout->ndims; i++) {
+ assert(!offset_f || offset_f[i] >= 0); /*neg domains unsupported */
+ assert(!offset_m || offset_m[i] >= 0); /*mem array offset never neg */
+ assert(size[i] >= 0); /*size may be zero, implies no-op */
+ assert(size_m[i] > 0); /*destination must exist */
+ /*hyperslab must fit in BUF */
+ assert((offset_m ? offset_m[i] : 0) + size[i] <= size_m[i]);
+ assert(layout->dim[i] > 0);
+ }
#endif
- /* Initialize indices */
- for (i=0; i<layout->ndims; i++) {
- idx_min[i] = (offset_f?offset_f[i]:0) / layout->dim[i];
- idx_max[i] = ((offset_f?offset_f[i]:0)+size[i]-1)/layout->dim[i]+1;
- idx_cur[i] = idx_min[i];
- }
-
- /* Allocate buffers */
- for (i=0, chunk_size=1; i<layout->ndims; i++) {
- chunk_size *= layout->dim[i];
- }
- chunk = H5MM_xmalloc (chunk_size);
-
- /* Initialize non-changing part of udata */
- udata.mesg = *layout;
-
- /* Loop over all chunks */
- while (1) {
-
- /* Read/Write chunk or create it if it doesn't exist */
- udata.mesg.ndims = layout->ndims;
- H5F_addr_undef (&(udata.addr));
- udata.key.file_number = 0;
-
- for (i=0; i<layout->ndims; i++) {
-
- /* The location and size of the chunk being accessed */
- udata.key.offset[i] = idx_cur[i] * layout->dim[i];
- udata.key.size[i] = layout->dim[i];
-
- /* The offset and size wrt the chunk */
- offset_wrt_chunk[i] = MAX ((offset_f?offset_f[i]:0),
- udata.key.offset[i]) -
- udata.key.offset[i];
- sub_size[i] = MIN ((idx_cur[i]+1)*layout->dim[i],
- (offset_f?offset_f[i]:0)+size[i]) -
- (udata.key.offset[i]+offset_wrt_chunk[i]);
-
- /* Offset into mem buffer */
- sub_offset_m[i] = udata.key.offset[i] + offset_wrt_chunk[i] +
- (offset_m?offset_m[i]:0) -
- (offset_f?offset_f[i]:0);
- }
-
- if (H5F_ISTORE_WRITE==op) {
- status = H5B_insert (f, H5B_ISTORE, &(layout->addr), &udata);
- assert (status>=0);
- } else {
- status = H5B_find (f, H5B_ISTORE, &(layout->addr), &udata);
- }
-
- /*
- * If the operation is reading from the disk or if we are writing a
- * partial chunk then load the chunk from disk.
- */
- if (H5F_ISTORE_READ==op ||
- !H5V_vector_zerop (layout->ndims, offset_wrt_chunk) ||
- !H5V_vector_eq (layout->ndims, sub_size, udata.key.size)) {
- if (status>=0 && H5F_addr_defined (&(udata.addr))) {
- assert (0==udata.key.file_number);
- if (H5F_block_read (f, &(udata.addr), chunk_size, chunk)<0) {
- HGOTO_ERROR (H5E_IO, H5E_READERROR, FAIL,
- "unable to read raw storage chunk");
- }
- } else {
- HDmemset (chunk, 0, chunk_size);
- }
- }
-
- /* Transfer data to/from the chunk */
- if (H5F_ISTORE_WRITE==op) {
- H5V_hyper_copy (layout->ndims, sub_size,
- udata.key.size, offset_wrt_chunk, chunk,
- size_m, sub_offset_m, buf);
- assert (0==udata.key.file_number);
- if (H5F_block_write (f, &(udata.addr), chunk_size, chunk)<0) {
- HGOTO_ERROR (H5E_IO, H5E_WRITEERROR, FAIL,
- "unable to write raw storage chunk");
- }
- } else {
- H5V_hyper_copy (layout->ndims, sub_size,
- size_m, sub_offset_m, buf,
- udata.key.size, offset_wrt_chunk, chunk);
- }
-
- /* Increment indices */
- for (i=layout->ndims-1, carry=1; i>=0 && carry; --i) {
- if (++idx_cur[i]>=idx_max[i]) idx_cur[i] = idx_min[i];
- else carry = 0;
- }
- if (carry) break;
- }
- ret_value = SUCCEED;
-
-
- done:
- chunk = H5MM_xfree (chunk);
- FUNC_LEAVE (ret_value);
+ /* Initialize indices */
+ for (i = 0; i < layout->ndims; i++) {
+ idx_min[i] = (offset_f ? offset_f[i] : 0) / layout->dim[i];
+ idx_max[i] = ((offset_f ? offset_f[i] : 0) + size[i] - 1) / layout->dim[i] + 1;
+ idx_cur[i] = idx_min[i];
+ }
+
+ /* Allocate buffers */
+ for (i = 0, chunk_size = 1; i < layout->ndims; i++) {
+ chunk_size *= layout->dim[i];
+ }
+ chunk = H5MM_xmalloc(chunk_size);
+
+ /* Initialize non-changing part of udata */
+ udata.mesg = *layout;
+
+ /* Loop over all chunks */
+ while (1) {
+
+ /* Read/Write chunk or create it if it doesn't exist */
+ udata.mesg.ndims = layout->ndims;
+ H5F_addr_undef(&(udata.addr));
+ udata.key.file_number = 0;
+
+ for (i = 0; i < layout->ndims; i++) {
+
+ /* The location and size of the chunk being accessed */
+ udata.key.offset[i] = idx_cur[i] * layout->dim[i];
+ udata.key.size[i] = layout->dim[i];
+
+ /* The offset and size wrt the chunk */
+ offset_wrt_chunk[i] = MAX((offset_f ? offset_f[i] : 0),
+ udata.key.offset[i]) -
+ udata.key.offset[i];
+ sub_size[i] = MIN((idx_cur[i] + 1) * layout->dim[i],
+ (offset_f ? offset_f[i] : 0) + size[i]) -
+ (udata.key.offset[i] + offset_wrt_chunk[i]);
+
+ /* Offset into mem buffer */
+ sub_offset_m[i] = udata.key.offset[i] + offset_wrt_chunk[i] +
+ (offset_m ? offset_m[i] : 0) -
+ (offset_f ? offset_f[i] : 0);
+ }
+
+ if (H5F_ISTORE_WRITE == op) {
+ status = H5B_insert(f, H5B_ISTORE, &(layout->addr), &udata);
+ assert(status >= 0);
+ } else {
+ status = H5B_find(f, H5B_ISTORE, &(layout->addr), &udata);
+ }
+
+ /*
+ * If the operation is reading from the disk or if we are writing a
+ * partial chunk then load the chunk from disk.
+ */
+ if (H5F_ISTORE_READ == op ||
+ !H5V_vector_zerop(layout->ndims, offset_wrt_chunk) ||
+ !H5V_vector_eq(layout->ndims, sub_size, udata.key.size)) {
+ if (status >= 0 && H5F_addr_defined(&(udata.addr))) {
+ assert(0 == udata.key.file_number);
+ if (H5F_block_read(f, &(udata.addr), chunk_size, chunk) < 0) {
+ HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL,
+ "unable to read raw storage chunk");
+ }
+ } else {
+ HDmemset(chunk, 0, chunk_size);
+ }
+ }
+ /* Transfer data to/from the chunk */
+ if (H5F_ISTORE_WRITE == op) {
+ H5V_hyper_copy(layout->ndims, sub_size,
+ udata.key.size, offset_wrt_chunk, chunk,
+ size_m, sub_offset_m, buf);
+ assert(0 == udata.key.file_number);
+ if (H5F_block_write(f, &(udata.addr), chunk_size, chunk) < 0) {
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,
+ "unable to write raw storage chunk");
+ }
+ } else {
+ H5V_hyper_copy(layout->ndims, sub_size,
+ size_m, sub_offset_m, buf,
+ udata.key.size, offset_wrt_chunk, chunk);
+ }
+
+ /* Increment indices */
+ for (i = layout->ndims - 1, carry = 1; i >= 0 && carry; --i) {
+ if (++idx_cur[i] >= idx_max[i])
+ idx_cur[i] = idx_min[i];
+ else
+ carry = 0;
+ }
+ if (carry)
+ break;
+ }
+ ret_value = SUCCEED;
+
+ done:
+ chunk = H5MM_xfree(chunk);
+ FUNC_LEAVE(ret_value);
}
-
/*-------------------------------------------------------------------------
- * Function: H5F_istore_read
+ * Function: H5F_istore_read
*
- * Purpose: Reads a multi-dimensional buffer from (part of) an indexed raw
- * storage array.
+ * Purpose: Reads a multi-dimensional buffer from (part of) an indexed raw
+ * storage array.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, October 15, 1997
*
* Modifications:
@@ -764,39 +753,37 @@ H5F_istore_copy_hyperslab (H5F_t *f, const H5O_layout_t *layout, H5F_isop_t op,
*-------------------------------------------------------------------------
*/
herr_t
-H5F_istore_read (H5F_t *f, const H5O_layout_t *layout,
- const size_t offset[], const size_t size[], void *buf)
+H5F_istore_read(H5F_t *f, const H5O_layout_t *layout,
+ const size_t offset[], const size_t size[], void *buf)
{
- FUNC_ENTER (H5F_istore_read, FAIL);
-
- /* Check args */
- assert (f);
- assert (layout && H5D_CHUNKED==layout->type);
- assert (layout->ndims>0 && layout->ndims<=H5O_LAYOUT_NDIMS);
- assert (size);
- assert (buf);
-
- if (H5F_istore_copy_hyperslab (f, layout, H5F_ISTORE_READ,
- offset, size, H5V_ZERO, size, buf)<0) {
- HRETURN_ERROR (H5E_IO, H5E_READERROR, FAIL,
- "hyperslab output failure");
- }
-
- FUNC_LEAVE (SUCCEED);
+ FUNC_ENTER(H5F_istore_read, FAIL);
+
+ /* Check args */
+ assert(f);
+ assert(layout && H5D_CHUNKED == layout->type);
+ assert(layout->ndims > 0 && layout->ndims <= H5O_LAYOUT_NDIMS);
+ assert(size);
+ assert(buf);
+
+ if (H5F_istore_copy_hyperslab(f, layout, H5F_ISTORE_READ,
+ offset, size, H5V_ZERO, size, buf) < 0) {
+ HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL,
+ "hyperslab output failure");
+ }
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5F_istore_write
+ * Function: H5F_istore_write
*
- * Purpose: Writes a multi-dimensional buffer to (part of) an indexed raw
- * storage array.
+ * Purpose: Writes a multi-dimensional buffer to (part of) an indexed raw
+ * storage array.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, October 15, 1997
*
* Modifications:
@@ -804,46 +791,43 @@ H5F_istore_read (H5F_t *f, const H5O_layout_t *layout,
*-------------------------------------------------------------------------
*/
herr_t
-H5F_istore_write (H5F_t *f, const H5O_layout_t *layout,
- const size_t offset[], const size_t size[],
- const void *buf)
+H5F_istore_write(H5F_t *f, const H5O_layout_t *layout,
+ const size_t offset[], const size_t size[],
+ const void *buf)
{
- FUNC_ENTER (H5F_istore_write, FAIL);
-
- /* Check args */
- assert (f);
- assert (layout && H5D_CHUNKED==layout->type);
- assert (layout->ndims>0 && layout->ndims<=H5O_LAYOUT_NDIMS);
- assert (size);
- assert (buf);
-
- if (H5F_istore_copy_hyperslab (f, layout, H5F_ISTORE_WRITE,
- offset, size, H5V_ZERO, size, buf)<0) {
- HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL,
- "hyperslab output failure");
- }
-
- FUNC_LEAVE (SUCCEED);
+ FUNC_ENTER(H5F_istore_write, FAIL);
+
+ /* Check args */
+ assert(f);
+ assert(layout && H5D_CHUNKED == layout->type);
+ assert(layout->ndims > 0 && layout->ndims <= H5O_LAYOUT_NDIMS);
+ assert(size);
+ assert(buf);
+
+ if (H5F_istore_copy_hyperslab(f, layout, H5F_ISTORE_WRITE,
+ offset, size, H5V_ZERO, size, buf) < 0) {
+ HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,
+ "hyperslab output failure");
+ }
+ FUNC_LEAVE(SUCCEED);
}
-
-
/*-------------------------------------------------------------------------
- * Function: H5F_istore_create
+ * Function: H5F_istore_create
*
- * Purpose: Creates a new indexed-storage B-tree and initializes the
- * istore struct with information about the storage. The
- * struct should be immediately written to the object header.
+ * Purpose: Creates a new indexed-storage B-tree and initializes the
+ * istore struct with information about the storage. The
+ * struct should be immediately written to the object header.
*
- * This function must be called before passing ISTORE to any of
- * the other indexed storage functions!
+ * This function must be called before passing ISTORE to any of
+ * the other indexed storage functions!
*
- * Return: Success: SUCCEED with the ISTORE argument initialized
- * and ready to write to an object header.
+ * Return: Success: SUCCEED with the ISTORE argument initialized
+ * and ready to write to an object header.
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Tuesday, October 21, 1997
*
* Modifications:
@@ -851,27 +835,26 @@ H5F_istore_write (H5F_t *f, const H5O_layout_t *layout,
*-------------------------------------------------------------------------
*/
herr_t
-H5F_istore_create (H5F_t *f, H5O_layout_t *layout/*out*/)
+H5F_istore_create(H5F_t *f, H5O_layout_t *layout /*out */ )
{
- H5F_istore_ud1_t udata;
- int i;
-
- FUNC_ENTER (H5F_istore_create, FAIL);
-
- /* Check args */
- assert (f);
- assert (layout && H5D_CHUNKED==layout->type);
- assert (layout->ndims>0 && layout->ndims<=H5O_LAYOUT_NDIMS);
+ H5F_istore_ud1_t udata;
+ int i;
+
+ FUNC_ENTER(H5F_istore_create, FAIL);
+
+ /* Check args */
+ assert(f);
+ assert(layout && H5D_CHUNKED == layout->type);
+ assert(layout->ndims > 0 && layout->ndims <= H5O_LAYOUT_NDIMS);
#ifndef NDEBUG
- for (i=0; i<layout->ndims; i++) {
- assert (layout->dim[i]>0);
- }
+ for (i = 0; i < layout->ndims; i++) {
+ assert(layout->dim[i] > 0);
+ }
#endif
- udata.mesg.ndims = layout->ndims;
- if (H5B_create (f, H5B_ISTORE, &udata, &(layout->addr)/*out*/)<0) {
- HRETURN_ERROR (H5E_IO, H5E_CANTINIT, FAIL, "can't create B-tree");
- }
-
- FUNC_LEAVE (SUCCEED);
+ udata.mesg.ndims = layout->ndims;
+ if (H5B_create(f, H5B_ISTORE, &udata, &(layout->addr) /*out */ ) < 0) {
+ HRETURN_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "can't create B-tree");
+ }
+ FUNC_LEAVE(SUCCEED);
}
diff --git a/src/H5Dprivate.h b/src/H5Dprivate.h
index 07f6d9c..0e63a8d 100644
--- a/src/H5Dprivate.h
+++ b/src/H5Dprivate.h
@@ -22,11 +22,11 @@
/* Private headers needed by this file */
#include <H5private.h>
-#include <H5Fprivate.h> /* for the H5F_t type */
-#include <H5Gprivate.h> /* Symbol tables */
-#include <H5Tprivate.h> /* for the H5T_t type */
-#include <H5Pprivate.h> /* for the H5P_t type */
-#include <H5Oprivate.h> /* Object Headers */
+#include <H5Fprivate.h> /* for the H5F_t type */
+#include <H5Gprivate.h> /* Symbol tables */
+#include <H5Tprivate.h> /* for the H5T_t type */
+#include <H5Pprivate.h> /* for the H5P_t type */
+#include <H5Oprivate.h> /* Object Headers */
#define H5D_RESERVED_ATOMS 0
@@ -35,14 +35,14 @@
/* Dataset creation template */
typedef struct H5D_create_t {
- H5D_layout_t layout;
- intn chunk_ndims;
- size_t chunk_size[32];
+ H5D_layout_t layout;
+ intn chunk_ndims;
+ size_t chunk_size[32];
} H5D_create_t;
/* Dataset transfer template */
typedef struct H5D_xfer_t {
- int _placeholder; /*unused--delete this later*/
+ int _placeholder; /*unused--delete this later */
} H5D_xfer_t;
typedef struct H5D_t H5D_t;
@@ -51,20 +51,19 @@ extern const H5D_create_t H5D_create_dflt;
extern const H5D_xfer_t H5D_xfer_dflt;
/* Functions defined in H5D.c */
-H5D_t *H5D_create (H5F_t *f, const char *name, const H5T_t *type,
- const H5P_t *space, const H5D_create_t *create_parms);
-H5D_t *H5D_open (H5F_t *f, const char *name);
-herr_t H5D_close (H5D_t *dataset);
-herr_t H5D_read (H5D_t *dataset, const H5T_t *mem_type, const H5P_t *mem_space,
- const H5P_t *file_space, const H5D_xfer_t *xfer_parms,
- void *buf/*out*/);
-herr_t H5D_write (H5D_t *dataset, const H5T_t *mem_type,
- const H5P_t *mem_space, const H5P_t *file_space,
- const H5D_xfer_t *xfer_parms, const void *buf);
-hid_t H5D_find_name (hid_t file_id, group_t UNUSED, const char *name);
-
+H5D_t *H5D_create(H5F_t *f, const char *name, const H5T_t *type,
+ const H5P_t *space, const H5D_create_t *create_parms);
+H5D_t *H5D_open(H5F_t *f, const char *name);
+herr_t H5D_close(H5D_t *dataset);
+herr_t H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5P_t *mem_space,
+ const H5P_t *file_space, const H5D_xfer_t *xfer_parms,
+ void *buf /*out */ );
+herr_t H5D_write(H5D_t *dataset, const H5T_t *mem_type,
+ const H5P_t *mem_space, const H5P_t *file_space,
+ const H5D_xfer_t *xfer_parms, const void *buf);
+hid_t H5D_find_name(hid_t file_id, group_t UNUSED, const char *name);
/* Functions defined in in H5Dconv.c */
-herr_t H5D_convert_buf(void *dst,const void *src,uintn len,uintn size);
+herr_t H5D_convert_buf(void *dst, const void *src, uintn len, uintn size);
#endif
diff --git a/src/H5Dpublic.h b/src/H5Dpublic.h
index 303a18d..5c6056f 100644
--- a/src/H5Dpublic.h
+++ b/src/H5Dpublic.h
@@ -25,30 +25,30 @@
/* Values for the H5D_LAYOUT property */
typedef enum H5D_layout_t {
- H5D_LAYOUT_ERROR =-1,
-
- H5D_COMPACT =0, /*raw data is very small */
- H5D_CONTIGUOUS =1, /*the default */
- H5D_CHUNKED =2, /*slow and fancy */
-
- H5D_NLAYOUTS =3 /*This one must be last! */
+ H5D_LAYOUT_ERROR = -1,
+
+ H5D_COMPACT = 0, /*raw data is very small */
+ H5D_CONTIGUOUS = 1, /*the default */
+ H5D_CHUNKED = 2, /*slow and fancy */
+
+ H5D_NLAYOUTS = 3 /*This one must be last! */
} H5D_layout_t;
#ifdef __cplusplus
-extern "C" {
+extern "C" {
#endif
-hid_t H5Dcreate (hid_t file_id, const char *name, hid_t type_id,
- hid_t space_id, hid_t create_parms_id);
-hid_t H5Dopen (hid_t file_id, const char *name);
-herr_t H5Dclose (hid_t dataset_id);
-herr_t H5Dread (hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id,
- hid_t file_space_id, hid_t xfer_parms_id, void *buf/*out*/);
-herr_t H5Dwrite (hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id,
- hid_t file_space_id, hid_t xfer_parms_id, const void *buf);
+ hid_t H5Dcreate(hid_t file_id, const char *name, hid_t type_id,
+ hid_t space_id, hid_t create_parms_id);
+ hid_t H5Dopen(hid_t file_id, const char *name);
+ herr_t H5Dclose(hid_t dataset_id);
+ herr_t H5Dread(hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id,
+ hid_t file_space_id, hid_t xfer_parms_id, void *buf /*out */ );
+ herr_t H5Dwrite(hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id,
+ hid_t file_space_id, hid_t xfer_parms_id, const void *buf);
#ifdef __cplusplus
}
-#endif
#endif
+#endif
diff --git a/src/H5E.c b/src/H5E.c
index f7d9fd2..680f152 100644
--- a/src/H5E.c
+++ b/src/H5E.c
@@ -1,113 +1,113 @@
/****************************************************************************
-* NCSA HDF *
-* Software Development Group *
-* National Center for Supercomputing Applications *
-* University of Illinois at Urbana-Champaign *
-* 605 E. Springfield, Champaign IL 61820 *
-* *
-* For conditions of distribution and use, see the accompanying *
-* hdf/COPYING file. *
+* NCSA HDF *
+* Software Development Group *
+* National Center for Supercomputing Applications *
+* University of Illinois at Urbana-Champaign *
+* 605 E. Springfield, Champaign IL 61820 *
+* *
+* For conditions of distribution and use, see the accompanying *
+* hdf/COPYING file. *
*
* Notes: It is safe to call HRETURN_ERROR(), HGOTO_ERROR(), HERROR(), and
- * H5ECLEAR within any of these functions except H5E_push() (see
- * comments in H5E_push()). However, some of the H5E API functions
- * don't call H5ECLEAR the the error stack on which they're operating
- * is the thread's global error stack. If the thread's global error
- * stack isn't defined yet, then HRETURN_ERROR(), HGOTO_ERROR(), and
- * HERROR() don't push an error message and H5ECLEAR just returns
- * without doing anything.
-* *
+ * H5ECLEAR within any of these functions except H5E_push() (see
+ * comments in H5E_push()). However, some of the H5E API functions
+ * don't call H5ECLEAR the the error stack on which they're operating
+ * is the thread's global error stack. If the thread's global error
+ * stack isn't defined yet, then HRETURN_ERROR(), HGOTO_ERROR(), and
+ * HERROR() don't push an error message and H5ECLEAR just returns
+ * without doing anything.
+* *
****************************************************************************/
#ifdef RCSID
-static char RcsId[] = "@(#)$Revision$";
+static char RcsId[] = "@(#)$Revision$";
#endif
/* $Id$ */
+#include <H5private.h> /* Generic Functions */
+#include <H5Aprivate.h> /* Atoms */
+#include <H5Eprivate.h> /* Private error routines */
+#include <H5MMprivate.h> /* Memory management */
-#include <H5private.h> /* Generic Functions */
-#include <H5Aprivate.h> /* Atoms */
-#include <H5Eprivate.h> /* Private error routines */
-#include <H5MMprivate.h> /* Memory management */
-
-#define PABLO_MASK H5E_mask
+#define PABLO_MASK H5E_mask
/*-------------------- Locally scoped variables -----------------------------*/
-static const H5E_major_mesg_t H5E_major_mesg_g[] = {
- {H5E_NONE_MAJOR, "No error"},
- {H5E_ARGS, "Invalid arguments to routine"},
- {H5E_RESOURCE, "Resource unavailable"},
- {H5E_INTERNAL, "Internal HDF5 error"},
- {H5E_FILE, "File Accessability"},
- {H5E_IO, "Low-level I/O"},
- {H5E_FUNC, "Function Entry/Exit"},
- {H5E_ATOM, "Object Atom"},
- {H5E_CACHE, "Object Cache"},
- {H5E_BTREE, "B-Tree Node"},
- {H5E_SYM, "Symbol Table"},
- {H5E_HEAP, "Heap"},
- {H5E_OHDR, "Object Header"},
- {H5E_DATATYPE, "Datatype"},
- {H5E_DATASPACE, "Dataspace"},
- {H5E_DATASET, "Dataset"},
- {H5E_STORAGE, "Data Storage"},
- {H5E_TEMPLATE, "Template"},
+static const H5E_major_mesg_t H5E_major_mesg_g[] =
+{
+ {H5E_NONE_MAJOR, "No error"},
+ {H5E_ARGS, "Invalid arguments to routine"},
+ {H5E_RESOURCE, "Resource unavailable"},
+ {H5E_INTERNAL, "Internal HDF5 error"},
+ {H5E_FILE, "File Accessability"},
+ {H5E_IO, "Low-level I/O"},
+ {H5E_FUNC, "Function Entry/Exit"},
+ {H5E_ATOM, "Object Atom"},
+ {H5E_CACHE, "Object Cache"},
+ {H5E_BTREE, "B-Tree Node"},
+ {H5E_SYM, "Symbol Table"},
+ {H5E_HEAP, "Heap"},
+ {H5E_OHDR, "Object Header"},
+ {H5E_DATATYPE, "Datatype"},
+ {H5E_DATASPACE, "Dataspace"},
+ {H5E_DATASET, "Dataset"},
+ {H5E_STORAGE, "Data Storage"},
+ {H5E_TEMPLATE, "Template"},
};
-static const H5E_minor_mesg_t H5E_minor_mesg_g[] = {
- {H5E_NONE_MINOR, "No error"},
+static const H5E_minor_mesg_t H5E_minor_mesg_g[] =
+{
+ {H5E_NONE_MINOR, "No error"},
{H5E_UNINITIALIZED, "Information is uninitialized"},
- {H5E_UNSUPPORTED, "Feature is unsupported"},
- {H5E_BADTYPE, "Incorrect type found"},
- {H5E_BADRANGE, "Argument out of range"},
- {H5E_BADVALUE, "Bad value for argument"},
- {H5E_NOSPACE, "No space available for allocation"},
- {H5E_FILEEXISTS, "File already exists"},
- {H5E_FILEOPEN, "File already open"},
- {H5E_CANTCREATE, "Can't create file"},
- {H5E_CANTOPENFILE, "Can't open file"},
- {H5E_CANTOPENOBJ, "Can't open object"},
- {H5E_NOTHDF5, "Not an HDF5 format file"},
- {H5E_BADFILE, "Bad file ID accessed"},
- {H5E_TRUNCATED, "File has been truncated"},
- {H5E_SEEKERROR, "Seek failed"},
- {H5E_READERROR, "Read failed"},
- {H5E_WRITEERROR, "Write failed"},
- {H5E_CLOSEERROR, "Close failed"},
- {H5E_CANTINIT, "Can't initialize interface"},
- {H5E_ALREADYINIT, "Object already initialized"},
- {H5E_BADATOM, "Can't find atom information"},
- {H5E_CANTREGISTER, "Can't register new atom"},
- {H5E_CANTFLUSH, "Can't flush object from cache"},
- {H5E_CANTLOAD, "Can't load object into cache"},
- {H5E_PROTECT, "Protected object error"},
- {H5E_NOTCACHED, "Object not currently cached"},
- {H5E_NOTFOUND, "Object not found"},
- {H5E_EXISTS, "Object already exists"},
- {H5E_CANTENCODE, "Can't encode value"},
- {H5E_CANTDECODE, "Can't decode value"},
- {H5E_CANTSPLIT, "Can't split node"},
- {H5E_CANTINSERT, "Can't insert object"},
- {H5E_CANTLIST, "Can't list node"},
- {H5E_LINKCOUNT, "Bad object header link count"},
- {H5E_VERSION, "Wrong version number"},
- {H5E_ALIGNMENT, "Alignment error"},
- {H5E_BADMESG, "Unrecognized message"},
- {H5E_COMPLEN, "Name component is too long"},
- {H5E_CWG, "Problem with current working group"},
- {H5E_LINK, "Link count failure"},
+ {H5E_UNSUPPORTED, "Feature is unsupported"},
+ {H5E_BADTYPE, "Incorrect type found"},
+ {H5E_BADRANGE, "Argument out of range"},
+ {H5E_BADVALUE, "Bad value for argument"},
+ {H5E_NOSPACE, "No space available for allocation"},
+ {H5E_FILEEXISTS, "File already exists"},
+ {H5E_FILEOPEN, "File already open"},
+ {H5E_CANTCREATE, "Can't create file"},
+ {H5E_CANTOPENFILE, "Can't open file"},
+ {H5E_CANTOPENOBJ, "Can't open object"},
+ {H5E_NOTHDF5, "Not an HDF5 format file"},
+ {H5E_BADFILE, "Bad file ID accessed"},
+ {H5E_TRUNCATED, "File has been truncated"},
+ {H5E_SEEKERROR, "Seek failed"},
+ {H5E_READERROR, "Read failed"},
+ {H5E_WRITEERROR, "Write failed"},
+ {H5E_CLOSEERROR, "Close failed"},
+ {H5E_CANTINIT, "Can't initialize interface"},
+ {H5E_ALREADYINIT, "Object already initialized"},
+ {H5E_BADATOM, "Can't find atom information"},
+ {H5E_CANTREGISTER, "Can't register new atom"},
+ {H5E_CANTFLUSH, "Can't flush object from cache"},
+ {H5E_CANTLOAD, "Can't load object into cache"},
+ {H5E_PROTECT, "Protected object error"},
+ {H5E_NOTCACHED, "Object not currently cached"},
+ {H5E_NOTFOUND, "Object not found"},
+ {H5E_EXISTS, "Object already exists"},
+ {H5E_CANTENCODE, "Can't encode value"},
+ {H5E_CANTDECODE, "Can't decode value"},
+ {H5E_CANTSPLIT, "Can't split node"},
+ {H5E_CANTINSERT, "Can't insert object"},
+ {H5E_CANTLIST, "Can't list node"},
+ {H5E_LINKCOUNT, "Bad object header link count"},
+ {H5E_VERSION, "Wrong version number"},
+ {H5E_ALIGNMENT, "Alignment error"},
+ {H5E_BADMESG, "Unrecognized message"},
+ {H5E_COMPLEN, "Name component is too long"},
+ {H5E_CWG, "Problem with current working group"},
+ {H5E_LINK, "Link count failure"},
};
/* Interface initialization? */
-static intn interface_initialize_g = FALSE;
+static intn interface_initialize_g = FALSE;
#define INTERFACE_INIT H5E_init_interface
-static herr_t H5E_init_interface(void);
-static void H5E_term_interface (void);
-
-hid_t H5E_thrdid_g = FAIL; /* Thread-specific "global" error-handler ID */
+static herr_t H5E_init_interface(void);
+static void H5E_term_interface(void);
+hid_t H5E_thrdid_g = FAIL; /* Thread-specific "global" error-handler ID */
/*--------------------------------------------------------------------------
NAME
@@ -126,19 +126,18 @@ Modifications:
--------------------------------------------------------------------------*/
static herr_t
-H5E_init_interface (void)
+H5E_init_interface(void)
{
- herr_t ret_value = SUCCEED;
-
- FUNC_ENTER (H5E_init_interface, FAIL);
+ herr_t ret_value = SUCCEED;
- /* Initialize the atom group for the error stacks */
- if ((ret_value=H5Ainit_group (H5_ERR, H5A_ERRSTACK_HASHSIZE, 0,
- (herr_t (*)(void*))H5E_close))!=FAIL) {
- ret_value = H5_add_exit (H5E_term_interface);
- }
+ FUNC_ENTER(H5E_init_interface, FAIL);
- FUNC_LEAVE (ret_value);
+ /* Initialize the atom group for the error stacks */
+ if ((ret_value = H5Ainit_group(H5_ERR, H5A_ERRSTACK_HASHSIZE, 0,
+ (herr_t (*)(void *)) H5E_close)) != FAIL) {
+ ret_value = H5_add_exit(H5E_term_interface);
+ }
+ FUNC_LEAVE(ret_value);
}
/*--------------------------------------------------------------------------
@@ -159,9 +158,9 @@ H5E_init_interface (void)
REVISION LOG
--------------------------------------------------------------------------*/
static void
-H5E_term_interface (void)
+H5E_term_interface(void)
{
- H5Adestroy_group(H5_ERR);
+ H5Adestroy_group(H5_ERR);
}
/*--------------------------------------------------------------------------
@@ -169,7 +168,7 @@ NAME
H5Ecreate -- Create a new error stack
USAGE
hid_t H5Ecreate (initial_stack_size);
- uintn initial_stack_size; IN: Starting size of the error stack
+ uintn initial_stack_size; IN: Starting size of the error stack
RETURNS
The ID of the error stack created on success, FAIL on failure.
@@ -179,33 +178,32 @@ DESCRIPTION
--------------------------------------------------------------------------*/
hid_t
-H5Ecreate (uintn initial_stack_nelmts)
+H5Ecreate(uintn initial_stack_nelmts)
{
- H5E_t *new_stack=NULL; /* Pointer to the new error stack */
- hid_t ret_value = FAIL;
-
- FUNC_ENTER (H5Ecreate, FAIL);
- H5ECLEAR;
-
- /* check args */
- initial_stack_nelmts = MAX (10, MIN (initial_stack_nelmts, 1000));
-
- /* Allocate the stack header */
- new_stack = H5MM_xmalloc (sizeof(H5E_t));
-
- /* Initialize the stack header */
- new_stack->nelmts = initial_stack_nelmts;
- new_stack->top = 0;
- new_stack->stack = H5MM_xcalloc (initial_stack_nelmts, sizeof(H5E_error_t));
- new_stack->push = H5E_push; /* Set the default error handler */
-
- /* Get an atom for the error stack */
- if ((ret_value = H5Aregister_atom (H5_ERR, new_stack))<0) {
- HRETURN_ERROR (H5E_ATOM, H5E_CANTREGISTER, FAIL,
- "unable to register error stack");
- }
-
- FUNC_LEAVE (ret_value);
+ H5E_t *new_stack = NULL; /* Pointer to the new error stack */
+ hid_t ret_value = FAIL;
+
+ FUNC_ENTER(H5Ecreate, FAIL);
+ H5ECLEAR;
+
+ /* check args */
+ initial_stack_nelmts = MAX(10, MIN(initial_stack_nelmts, 1000));
+
+ /* Allocate the stack header */
+ new_stack = H5MM_xmalloc(sizeof(H5E_t));
+
+ /* Initialize the stack header */
+ new_stack->nelmts = initial_stack_nelmts;
+ new_stack->top = 0;
+ new_stack->stack = H5MM_xcalloc(initial_stack_nelmts, sizeof(H5E_error_t));
+ new_stack->push = H5E_push; /* Set the default error handler */
+
+ /* Get an atom for the error stack */
+ if ((ret_value = H5Aregister_atom(H5_ERR, new_stack)) < 0) {
+ HRETURN_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL,
+ "unable to register error stack");
+ }
+ FUNC_LEAVE(ret_value);
}
/*--------------------------------------------------------------------------
@@ -213,7 +211,7 @@ NAME
H5Eclose -- Destroy an error stack
USAGE
herr_t H5Eclose (err_stack);
- hid_t err_stack; IN: Error stack to delete
+ hid_t err_stack; IN: Error stack to delete
RETURNS
SUCCEED/FAIL
@@ -223,49 +221,47 @@ DESCRIPTION
--------------------------------------------------------------------------*/
herr_t
-H5Eclose (hid_t estack_id)
+H5Eclose(hid_t estack_id)
{
- FUNC_ENTER (H5Eclose, FAIL);
- H5ECLEAR;
-
- /* check args */
- if (H5_ERR!=H5Aatom_group (estack_id)) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not an error stack");
- }
-
- /*
- * Decrement the reference count. When it reaches zero the error stack
- * will be freed.
- */
- H5A_dec_ref (estack_id);
-
- FUNC_LEAVE (SUCCEED);
+ FUNC_ENTER(H5Eclose, FAIL);
+ H5ECLEAR;
+
+ /* check args */
+ if (H5_ERR != H5Aatom_group(estack_id)) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an error stack");
+ }
+ /*
+ * Decrement the reference count. When it reaches zero the error stack
+ * will be freed.
+ */
+ H5A_dec_ref(estack_id);
+
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Epush
+ * Function: H5Epush
*
- * Purpose: Pushes a new error record onto error stack ESTACK_ID. The
- * error has major and minor numbers MAJ_NUM and MIN_NUM, the
- * name of a function where the error was detected, the name of
- * the file where the error was detected, and the line within
- * that file. An error description string is also passed to
- * this function.
+ * Purpose: Pushes a new error record onto error stack ESTACK_ID. The
+ * error has major and minor numbers MAJ_NUM and MIN_NUM, the
+ * name of a function where the error was detected, the name of
+ * the file where the error was detected, and the line within
+ * that file. An error description string is also passed to
+ * this function.
*
- * The FUNCTION_NAME is copied (and possibly truncated) into a
- * fixed length character buffer; the FILE_NAME is pointed to
- * without copying it (we assume it's statically allocated from
- * __FILE__); and the DESC argument is strdup'd.
+ * The FUNCTION_NAME is copied (and possibly truncated) into a
+ * fixed length character buffer; the FILE_NAME is pointed to
+ * without copying it (we assume it's statically allocated from
+ * __FILE__); and the DESC argument is strdup'd.
*
- * It is safe to call this function before the thread global
- * error stack is initialized.
+ * It is safe to call this function before the thread global
+ * error stack is initialized.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, December 12, 1997
*
* Modifications:
@@ -273,49 +269,48 @@ H5Eclose (hid_t estack_id)
*-------------------------------------------------------------------------
*/
herr_t
-H5Epush (hid_t estack_id, H5E_major_t maj_num, H5E_minor_t min_num,
- const char *function_name, const char *file_name, intn line,
- const char *desc)
+H5Epush(hid_t estack_id, H5E_major_t maj_num, H5E_minor_t min_num,
+ const char *function_name, const char *file_name, intn line,
+ const char *desc)
{
-
- H5E_t *estack = NULL; /* Ptr to the stack to put value on */
-
- /*
- * WARNING WARNING WARNING: We cannot call HERROR() from within this
- * function if ESTACK_ID is the thread global error stack or else we may
- * enter infinite recursion. Furthermore, we also cannot call any other
- * HDF5 macro or function which might call HERROR(). HERROR() is called
- * by HRETURN_ERROR() which could be called by FUNC_ENTER().
- */
-
- /*
- * Clear the thread global error stack only if it isn't the error stack on
- * which we're pushing the new error.
- */
- if (estack_id!=H5E_thrdid_g) H5ECLEAR;
-
- /*
- * check args, but don't call error functions if ESTACK_ID is the thread
- * global error handler.
- */
- if (H5_ERR!=H5Aatom_group (estack_id) ||
- NULL==(estack=H5Aatom_object (estack_id))) {
- HRETURN (FAIL);
- }
- if (!function_name || !file_name || !desc) {
- HRETURN (FAIL);
- }
- if (!estack->push) {
- HRETURN (FAIL);
- }
-
- /* Push the new error. It must be safe to call the push function. */
- if ((estack->push)(estack, maj_num, min_num, function_name, file_name,
- line, desc)<0) {
- HRETURN (FAIL);
- }
-
- return SUCCEED; /*don't use FUNC_LEAVE() here*/
+
+ H5E_t *estack = NULL; /* Ptr to the stack to put value on */
+
+ /*
+ * WARNING WARNING WARNING: We cannot call HERROR() from within this
+ * function if ESTACK_ID is the thread global error stack or else we may
+ * enter infinite recursion. Furthermore, we also cannot call any other
+ * HDF5 macro or function which might call HERROR(). HERROR() is called
+ * by HRETURN_ERROR() which could be called by FUNC_ENTER().
+ */
+
+ /*
+ * Clear the thread global error stack only if it isn't the error stack on
+ * which we're pushing the new error.
+ */
+ if (estack_id != H5E_thrdid_g)
+ H5ECLEAR;
+
+ /*
+ * check args, but don't call error functions if ESTACK_ID is the thread
+ * global error handler.
+ */
+ if (H5_ERR != H5Aatom_group(estack_id) ||
+ NULL == (estack = H5Aatom_object(estack_id))) {
+ HRETURN(FAIL);
+ }
+ if (!function_name || !file_name || !desc) {
+ HRETURN(FAIL);
+ }
+ if (!estack->push) {
+ HRETURN(FAIL);
+ }
+ /* Push the new error. It must be safe to call the push function. */
+ if ((estack->push) (estack, maj_num, min_num, function_name, file_name,
+ line, desc) < 0) {
+ HRETURN(FAIL);
+ }
+ return SUCCEED; /*don't use FUNC_LEAVE() here */
}
/*--------------------------------------------------------------------------
@@ -323,7 +318,7 @@ NAME
H5Eclear -- Clear an error stack for later error entries
USAGE
void H5Eclear(int32 err_hand)
- int32 err_hand; IN: The ID of the error stack to push the error onto.
+ int32 err_hand; IN: The ID of the error stack to push the error onto.
RETURNS
SUCCEED/FAIL
@@ -332,45 +327,43 @@ DESCRIPTION
--------------------------------------------------------------------------*/
herr_t
-H5Eclear (hid_t estack_id)
+H5Eclear(hid_t estack_id)
{
- H5E_t *estack = NULL;
-
- FUNC_ENTER (H5Eclear, FAIL);
-
- /*
- * Normally we would clear the thread error stack since we're entering an
- * API function, but we have to be careful here to not get into an
- * infinite recursion.
- */
- if (estack_id != H5E_thrdid_g) H5ECLEAR;
-
- /* check args */
- if (H5_ERR!=H5Aatom_group (estack_id) ||
- NULL==(estack=H5Aatom_object (estack_id))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not an error stack");
- }
-
- if (H5E_clear (estack)<0) {
- HRETURN_ERROR (H5E_INTERNAL, H5E_CANTINIT, FAIL,
- "unable to clear error stack");
- }
-
- FUNC_LEAVE (SUCCEED);
+ H5E_t *estack = NULL;
+
+ FUNC_ENTER(H5Eclear, FAIL);
+
+ /*
+ * Normally we would clear the thread error stack since we're entering an
+ * API function, but we have to be careful here to not get into an
+ * infinite recursion.
+ */
+ if (estack_id != H5E_thrdid_g)
+ H5ECLEAR;
+
+ /* check args */
+ if (H5_ERR != H5Aatom_group(estack_id) ||
+ NULL == (estack = H5Aatom_object(estack_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an error stack");
+ }
+ if (H5E_clear(estack) < 0) {
+ HRETURN_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL,
+ "unable to clear error stack");
+ }
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Eprint
+ * Function: H5Eprint
*
- * Purpose: Prints the current contents of error stack ESTACK_ID to the
- * stream FILE.
+ * Purpose: Prints the current contents of error stack ESTACK_ID to the
+ * stream FILE.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, December 12, 1997
*
* Modifications:
@@ -378,122 +371,120 @@ H5Eclear (hid_t estack_id)
*-------------------------------------------------------------------------
*/
herr_t
-H5Eprint (hid_t estack_id, FILE *file)
+H5Eprint(hid_t estack_id, FILE * file)
{
- H5E_t *estack = NULL;
-
- FUNC_ENTER (H5Eprint, FAIL);
- /*
- * Don't clear the thread error stack if it's the one we're about to
- * print.
- */
- if (estack_id!=H5E_thrdid_g) H5ECLEAR;
-
- /* check args */
- if (H5_ERR!=H5Aatom_group (estack_id) ||
- NULL==(estack=H5Aatom_object (estack_id))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not an error stack");
- }
- if (!file) file = stderr;
-
- /* print it */
- if (H5E_print (estack, file)<0) {
- HRETURN_ERROR (H5E_INTERNAL, H5E_CANTINIT, FAIL,
- "can't print error stack");
- }
-
- FUNC_LEAVE (SUCCEED);
+ H5E_t *estack = NULL;
+
+ FUNC_ENTER(H5Eprint, FAIL);
+ /*
+ * Don't clear the thread error stack if it's the one we're about to
+ * print.
+ */
+ if (estack_id != H5E_thrdid_g)
+ H5ECLEAR;
+
+ /* check args */
+ if (H5_ERR != H5Aatom_group(estack_id) ||
+ NULL == (estack = H5Aatom_object(estack_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an error stack");
+ }
+ if (!file)
+ file = stderr;
+
+ /* print it */
+ if (H5E_print(estack, file) < 0) {
+ HRETURN_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL,
+ "can't print error stack");
+ }
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5E_close
+ * Function: H5E_close
*
- * Purpose: Frees resources associated with an error stack.
+ * Purpose: Frees resources associated with an error stack.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * Friday, December 12, 1997
+ * Programmer: Robb Matzke
+ * Friday, December 12, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
-H5E_close (H5E_t *estack)
+H5E_close(H5E_t *estack)
{
- FUNC_ENTER (H5E_close, FAIL);
+ FUNC_ENTER(H5E_close, FAIL);
- /* check args */
- assert (estack);
+ /* check args */
+ assert(estack);
- /* clear error stack, then free it */
- H5E_clear (estack);
- H5MM_xfree (estack->stack);
- H5MM_xfree (estack);
+ /* clear error stack, then free it */
+ H5E_clear(estack);
+ H5MM_xfree(estack->stack);
+ H5MM_xfree(estack);
- FUNC_LEAVE (SUCCEED);
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5E_clear
+ * Function: H5E_clear
*
- * Purpose: Clears an error stack but does not release the stack.
+ * Purpose: Clears an error stack but does not release the stack.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * Friday, December 12, 1997
+ * Programmer: Robb Matzke
+ * Friday, December 12, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
-H5E_clear (H5E_t *estack)
+H5E_clear(H5E_t *estack)
{
- int i;
-
- FUNC_ENTER (H5E_clear, FAIL);
+ int i;
- /* check args */
- assert (estack);
+ FUNC_ENTER(H5E_clear, FAIL);
- /* Clear the error descriptions and reset the stack top */
- for (i=0; i<estack->top; i++) {
- H5MM_xfree (estack->stack[i].desc);
- estack->stack[i].desc = NULL;
- }
- estack->top = 0;
-
- FUNC_LEAVE (SUCCEED);
-}
+ /* check args */
+ assert(estack);
+
+ /* Clear the error descriptions and reset the stack top */
+ for (i = 0; i < estack->top; i++) {
+ H5MM_xfree(estack->stack[i].desc);
+ estack->stack[i].desc = NULL;
+ }
+ estack->top = 0;
+ FUNC_LEAVE(SUCCEED);
+}
/*-------------------------------------------------------------------------
- * Function: H5E_push
+ * Function: H5E_push
*
- * Purpose: Push an error onto an error stack. The FUNCTION_NAME is
- * copied (and possibly truncated) into the error record. The
- * FILE_NAME pointer is used directly since we assume it came
- * from the __FILE__ construct and is thus static data. The
- * description, DESC, is strdup'd into the error record.
+ * Purpose: Push an error onto an error stack. The FUNCTION_NAME is
+ * copied (and possibly truncated) into the error record. The
+ * FILE_NAME pointer is used directly since we assume it came
+ * from the __FILE__ construct and is thus static data. The
+ * description, DESC, is strdup'd into the error record.
*
- * Note: Warning: to prevent infinite recursivion this function must
- * not call any other HDF5 function and especially not
- * the HDF5 error handling macros.
+ * Note: Warning: to prevent infinite recursivion this function must
+ * not call any other HDF5 function and especially not
+ * the HDF5 error handling macros.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, December 12, 1997
*
* Modifications:
@@ -501,61 +492,59 @@ H5E_clear (H5E_t *estack)
*-------------------------------------------------------------------------
*/
herr_t
-H5E_push (H5E_t *estack, H5E_major_t maj_num, H5E_minor_t min_num,
- const char *function_name, const char *file_name, intn line,
- const char *desc)
+H5E_push(H5E_t *estack, H5E_major_t maj_num, H5E_minor_t min_num,
+ const char *function_name, const char *file_name, intn line,
+ const char *desc)
{
- /* FUNC_ENTER (H5E_push, FAIL); -- can't do this here! */
-
- /* check args */
- assert (estack);
- assert (function_name);
- assert (file_name);
-
- /* Check if we need to expand the stack */
- if (estack->top >= estack->nelmts) {
- /*
- * Ask for new stack that's twice as large. Do not use hdf5 functions
- * to allocate the memory!
- */
- estack->nelmts *= 2;
- estack->stack = realloc (estack->stack,
- estack->nelmts * sizeof(H5E_error_t));
- assert (estack->stack);
- }
-
- /* Push the error onto the error stack */
- estack->stack[estack->top].maj_num = maj_num;
- estack->stack[estack->top].min_num = min_num;
- HDstrncpy (estack->stack[estack->top].func_name, function_name,
- MAX_FUNC_NAME);
- estack->stack[estack->top].func_name[MAX_FUNC_NAME-1] = '\0';
- estack->stack[estack->top].file_name = file_name;
- estack->stack[estack->top].line = line;
-
- /* strdup the description but don't use H5MM_xstrdup() */
- estack->stack[estack->top].desc = malloc (strlen (desc) + 1);
- assert (estack->stack[estack->top].desc);
- strcpy (estack->stack[estack->top].desc, desc);
-
- /* Increment the top of the error stack */
- estack->top++;
-
- return SUCCEED; /*don't use FUNC_LEAVE() here*/
+ /* FUNC_ENTER (H5E_push, FAIL); -- can't do this here! */
+
+ /* check args */
+ assert(estack);
+ assert(function_name);
+ assert(file_name);
+
+ /* Check if we need to expand the stack */
+ if (estack->top >= estack->nelmts) {
+ /*
+ * Ask for new stack that's twice as large. Do not use hdf5 functions
+ * to allocate the memory!
+ */
+ estack->nelmts *= 2;
+ estack->stack = realloc(estack->stack,
+ estack->nelmts * sizeof(H5E_error_t));
+ assert(estack->stack);
+ }
+ /* Push the error onto the error stack */
+ estack->stack[estack->top].maj_num = maj_num;
+ estack->stack[estack->top].min_num = min_num;
+ HDstrncpy(estack->stack[estack->top].func_name, function_name,
+ MAX_FUNC_NAME);
+ estack->stack[estack->top].func_name[MAX_FUNC_NAME - 1] = '\0';
+ estack->stack[estack->top].file_name = file_name;
+ estack->stack[estack->top].line = line;
+
+ /* strdup the description but don't use H5MM_xstrdup() */
+ estack->stack[estack->top].desc = malloc(strlen(desc) + 1);
+ assert(estack->stack[estack->top].desc);
+ strcpy(estack->stack[estack->top].desc, desc);
+
+ /* Increment the top of the error stack */
+ estack->top++;
+
+ return SUCCEED; /*don't use FUNC_LEAVE() here */
}
-
/*-------------------------------------------------------------------------
- * Function: H5E_print
+ * Function: H5E_print
*
- * Purpose: Prints an error stack ESTACK to the stream FILE.
+ * Purpose: Prints an error stack ESTACK to the stream FILE.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, December 12, 1997
*
* Modifications:
@@ -563,44 +552,45 @@ H5E_push (H5E_t *estack, H5E_major_t maj_num, H5E_minor_t min_num,
*-------------------------------------------------------------------------
*/
herr_t
-H5E_print (H5E_t *estack, FILE *file)
+H5E_print(H5E_t *estack, FILE * file)
{
- intn i, j;
- const char *maj_str = NULL;
- const char *min_str = NULL;
-
- FUNC_ENTER (H5E_print, FAIL);
-
- /* check args */
- assert (estack);
- assert (file);
-
- if (0==estack->top) HRETURN (SUCCEED);
-
- fprintf (file, "HDF5-DIAG: error stack:\n");
- for (i=0; i<estack->top; i++) {
-
- /* Find major and minor error strings */
- for (j=0, maj_str="??"; j<NELMTS (H5E_major_mesg_g); j++) {
- if (H5E_major_mesg_g[j].error_code==estack->stack[i].maj_num) {
- maj_str = H5E_major_mesg_g[j].str;
- break;
- }
- }
- for (j=0, min_str="??"; j<NELMTS (H5E_minor_mesg_g); j++) {
- if (H5E_minor_mesg_g[j].error_code==estack->stack[i].min_num) {
- min_str = H5E_minor_mesg_g[j].str;
- break;
- }
- }
-
- /* Print error message */
- fprintf (file, " #%03d: %s:%d in %s() error %02d/%02d: %s\n",
- i, estack->stack[i].file_name, estack->stack[i].line,
- estack->stack[i].func_name, estack->stack[i].maj_num,
- estack->stack[i].min_num, estack->stack[i].desc);
- fprintf (file, " %s (%s)\n", maj_str, min_str);
- }
-
- FUNC_LEAVE (SUCCEED);
+ intn i, j;
+ const char *maj_str = NULL;
+ const char *min_str = NULL;
+
+ FUNC_ENTER(H5E_print, FAIL);
+
+ /* check args */
+ assert(estack);
+ assert(file);
+
+ if (0 == estack->top)
+ HRETURN(SUCCEED);
+
+ fprintf(file, "HDF5-DIAG: error stack:\n");
+ for (i = 0; i < estack->top; i++) {
+
+ /* Find major and minor error strings */
+ for (j = 0, maj_str = "??"; j < NELMTS(H5E_major_mesg_g); j++) {
+ if (H5E_major_mesg_g[j].error_code == estack->stack[i].maj_num) {
+ maj_str = H5E_major_mesg_g[j].str;
+ break;
+ }
+ }
+ for (j = 0, min_str = "??"; j < NELMTS(H5E_minor_mesg_g); j++) {
+ if (H5E_minor_mesg_g[j].error_code == estack->stack[i].min_num) {
+ min_str = H5E_minor_mesg_g[j].str;
+ break;
+ }
+ }
+
+ /* Print error message */
+ fprintf(file, " #%03d: %s:%d in %s() error %02d/%02d: %s\n",
+ i, estack->stack[i].file_name, estack->stack[i].line,
+ estack->stack[i].func_name, estack->stack[i].maj_num,
+ estack->stack[i].min_num, estack->stack[i].desc);
+ fprintf(file, " %s (%s)\n", maj_str, min_str);
+ }
+
+ FUNC_LEAVE(SUCCEED);
}
diff --git a/src/H5Eprivate.h b/src/H5Eprivate.h
index 8e809c4..2b0ce4e 100644
--- a/src/H5Eprivate.h
+++ b/src/H5Eprivate.h
@@ -36,24 +36,24 @@
Assume that func and file are both stored in static space, or at
least be not corrupted in the meanwhile. */
-#define HERROR(maj, min, str) H5Epush (H5E_thrdid_g, maj, min, \
- FUNC, __FILE__, __LINE__, str)
+#define HERROR(maj, min, str) H5Epush (H5E_thrdid_g, maj, min, \
+ FUNC, __FILE__, __LINE__, str)
/* HRETURN_ERROR macro, used to facilitate error reporting. Makes
same assumptions as HERROR. IN ADDITION, this macro causes
a return from the calling routine */
-#define HRETURN_ERROR(maj, min, ret_val, str) { \
- HERROR (maj, min, str); \
- PABLO_TRACE_OFF (PABLO_MASK, pablo_func_id); \
- return (ret_val); \
+#define HRETURN_ERROR(maj, min, ret_val, str) { \
+ HERROR (maj, min, str); \
+ PABLO_TRACE_OFF (PABLO_MASK, pablo_func_id); \
+ return (ret_val); \
}
/* HRETURN macro, similar to HRETURN_ERROR() except for success */
-#define HRETURN(ret_val) { \
- PABLO_TRACE_OFF (PABLO_MASK, pablo_func_id); \
- return (ret_val); \
+#define HRETURN(ret_val) { \
+ PABLO_TRACE_OFF (PABLO_MASK, pablo_func_id); \
+ return (ret_val); \
}
/* HGOTO_ERROR macro, used to facilitate error reporting. Makes
@@ -61,10 +61,10 @@
a jump to the label 'done' which should be in every fucntion
Also there is an assumption of a variable 'ret_value' */
-#define HGOTO_ERROR(maj, min, ret_val, str) { \
- HERROR (maj, min, str); \
- ret_value = ret_val; \
- goto done; \
+#define HGOTO_ERROR(maj, min, ret_val, str) { \
+ HERROR (maj, min, str); \
+ ret_value = ret_val; \
+ goto done; \
}
/* HGOTO_DONE macro, used to facilitate the new error reporting model.
@@ -80,28 +80,28 @@
#define H5ECLEAR H5Eclear(H5E_thrdid_g)
/* Maximum length of function name to push onto error stack */
-#define MAX_FUNC_NAME 32
+#define MAX_FUNC_NAME 32
/*
* error_messages is the list of error messages in the system, kept as
* error_code-message pairs.
*/
typedef struct H5E_major_mesg_t {
- H5E_major_t error_code;
- const char *str;
+ H5E_major_t error_code;
+ const char *str;
} H5E_major_mesg_t;
typedef struct H5E_minor_mesg_t {
- H5E_minor_t error_code;
- const char *str;
+ H5E_minor_t error_code;
+ const char *str;
} H5E_minor_mesg_t;
/* Function pointer to report errors through */
-struct H5E_t; /*forward decl*/
-typedef herr_t (*H5E_push_t)(struct H5E_t *estack, H5E_major_t maj_num,
- H5E_minor_t min_num, const char *function_name,
- const char *file_name, intn line,
- const char *desc);
+struct H5E_t; /*forward decl */
+typedef herr_t (*H5E_push_t) (struct H5E_t *estack, H5E_major_t maj_num,
+ H5E_minor_t min_num, const char *function_name,
+ const char *file_name, intn line,
+ const char *desc);
/*
* We use a stack to hold the errors plus we keep track of the function, file
@@ -110,34 +110,31 @@ typedef herr_t (*H5E_push_t)(struct H5E_t *estack, H5E_major_t maj_num,
/* the structure of the error stack element */
typedef struct H5E_error_t {
- H5E_major_t maj_num; /* Major error number */
- H5E_minor_t min_num; /* Minor error number */
- char func_name[MAX_FUNC_NAME]; /* function where error occur */
- const char *file_name; /* file where error occur */
- intn line; /* line in file where error occurs */
- char *desc; /* optional supplied description */
+ H5E_major_t maj_num; /* Major error number */
+ H5E_minor_t min_num; /* Minor error number */
+ char func_name[MAX_FUNC_NAME]; /* function where error occur */
+ const char *file_name; /* file where error occur */
+ intn line; /* line in file where error occurs */
+ char *desc; /* optional supplied description */
} H5E_error_t;
/* Structure to store error information for a thread */
typedef struct H5E_t {
- uintn nelmts; /* Num elements allocated in the stack */
- uintn top; /* Index of the next open stack element */
- H5E_error_t *stack; /* Pointer to the error stack */
- H5E_push_t push; /* Func that pushes new error on stack */
+ uintn nelmts; /* Num elements allocated in the stack */
+ uintn top; /* Index of the next open stack element */
+ H5E_error_t *stack; /* Pointer to the error stack */
+ H5E_push_t push; /* Func that pushes new error on stack */
} H5E_t;
/* Private global variables in H5E.c */
-extern hid_t H5E_thrdid_g; /* Thread-specific "global" error-handler ID */
-extern hbool_t install_atexit; /* Whether to install the atexit routine */
-
-herr_t H5E_close (H5E_t *estack);
-herr_t H5E_clear (H5E_t *estack);
-herr_t H5E_print (H5E_t *estack, FILE *file);
-herr_t H5E_push (H5E_t *estack, H5E_major_t maj_num, H5E_minor_t min_num,
- const char *function_name, const char *file_name, intn line,
- const char *desc);
-
-
-
+extern hid_t H5E_thrdid_g; /* Thread-specific "global" error-handler ID */
+extern hbool_t install_atexit; /* Whether to install the atexit routine */
+
+herr_t H5E_close(H5E_t *estack);
+herr_t H5E_clear(H5E_t *estack);
+herr_t H5E_print(H5E_t *estack, FILE * file);
+herr_t H5E_push(H5E_t *estack, H5E_major_t maj_num, H5E_minor_t min_num,
+ const char *function_name, const char *file_name, intn line,
+ const char *desc);
#endif
diff --git a/src/H5Epublic.h b/src/H5Epublic.h
index f11a900..570ac2f 100644
--- a/src/H5Epublic.h
+++ b/src/H5Epublic.h
@@ -1,13 +1,13 @@
/****************************************************************************
- * NCSA HDF *
- * Software Development Group *
- * National Center for Supercomputing Applications *
- * University of Illinois at Urbana-Champaign *
- * 605 E. Springfield, Champaign IL 61820 *
- * *
- * For conditions of distribution and use, see the accompanying *
- * hdf/COPYING file. *
- * *
+ * NCSA HDF *
+ * Software Development Group *
+ * National Center for Supercomputing Applications *
+ * University of Illinois at Urbana-Champaign *
+ * 605 E. Springfield, Champaign IL 61820 *
+ * *
+ * For conditions of distribution and use, see the accompanying *
+ * hdf/COPYING file. *
+ * *
****************************************************************************/
/* $Id$ */
@@ -19,7 +19,7 @@
#ifndef _H5Epublic_H
#define _H5Epublic_H
-#include <stdio.h> /*FILE arg of H5Eprint() */
+#include <stdio.h> /*FILE arg of H5Eprint() */
/* Public headers needed by this file */
#include <H5public.h>
@@ -29,109 +29,107 @@
* Declare an enumerated type which holds all the valid major HDF error codes.
*/
typedef enum H5E_major_t {
- H5E_NONE_MAJOR = 0, /* special zero, no error */
- H5E_ARGS, /* Invalid arguments to routine */
- H5E_RESOURCE, /* Resource unavailable */
- H5E_INTERNAL, /* Internal error (too specific to document
- * in detail)
- */
- H5E_FILE, /* File Accessability */
- H5E_IO, /* Low-level I/O */
- H5E_FUNC, /* Function Entry/Exit */
- H5E_ATOM, /* Object Atom */
- H5E_CACHE, /* Object Cache */
- H5E_BTREE, /* B-Tree Node */
- H5E_SYM, /* Symbol Table */
- H5E_HEAP, /* Heap */
- H5E_OHDR, /* Object Header */
- H5E_DATATYPE, /* Datatype */
- H5E_DATASPACE, /* Dataspace */
- H5E_DATASET, /* Dataset */
- H5E_STORAGE, /* Data storage */
- H5E_TEMPLATE /* Templates */
+ H5E_NONE_MAJOR = 0, /* special zero, no error */
+ H5E_ARGS, /* Invalid arguments to routine */
+ H5E_RESOURCE, /* Resource unavailable */
+ H5E_INTERNAL, /* Internal error (too specific to document
+ * in detail)
+ */
+ H5E_FILE, /* File Accessability */
+ H5E_IO, /* Low-level I/O */
+ H5E_FUNC, /* Function Entry/Exit */
+ H5E_ATOM, /* Object Atom */
+ H5E_CACHE, /* Object Cache */
+ H5E_BTREE, /* B-Tree Node */
+ H5E_SYM, /* Symbol Table */
+ H5E_HEAP, /* Heap */
+ H5E_OHDR, /* Object Header */
+ H5E_DATATYPE, /* Datatype */
+ H5E_DATASPACE, /* Dataspace */
+ H5E_DATASET, /* Dataset */
+ H5E_STORAGE, /* Data storage */
+ H5E_TEMPLATE /* Templates */
} H5E_major_t;
-
/* Declare an enumerated type which holds all the valid minor HDF error codes */
typedef enum H5E_minor_t {
- H5E_NONE_MINOR = 0, /* special zero, no error */
-
- /* Argument errors */
- H5E_UNINITIALIZED, /* Information is unitialized */
- H5E_UNSUPPORTED, /* Feature is unsupported */
- H5E_BADTYPE, /* Incorrect type found */
- H5E_BADRANGE, /* Argument out of range */
- H5E_BADVALUE, /* Bad value for argument */
-
- /* Resource errors */
- H5E_NOSPACE, /* No space available for allocation */
-
- /* File accessability errors */
- H5E_FILEEXISTS, /* File already exists */
- H5E_FILEOPEN, /* File already open */
- H5E_CANTCREATE, /* Can't create file */
- H5E_CANTOPENFILE, /* Can't open file */
- H5E_NOTHDF5, /* Not an HDF5 format file */
- H5E_BADFILE, /* Bad file ID accessed */
- H5E_TRUNCATED, /* File has been truncated */
-
- /* Generic low-level file I/O errors */
- H5E_SEEKERROR, /* Seek failed */
- H5E_READERROR, /* Read failed */
- H5E_WRITEERROR, /* Write failed */
- H5E_CLOSEERROR, /* Close failed */
-
- /* Function entry/exit interface errors */
- H5E_CANTINIT, /* Can't initialize interface */
- H5E_ALREADYINIT, /* Object already initialized */
-
- /* Object atom related errors */
- H5E_BADATOM, /* Can't find atom information */
- H5E_CANTREGISTER, /* Can't register new atom */
-
- /* Cache related errors */
- H5E_CANTFLUSH, /* Can't flush object from cache */
- H5E_CANTLOAD, /* Can't load object into cache */
- H5E_PROTECT, /* Protected object error */
- H5E_NOTCACHED, /* Object not currently cached */
-
- /* B-tree related errors */
- H5E_NOTFOUND, /* Object not found */
- H5E_EXISTS, /* Object already exists */
- H5E_CANTENCODE, /* Can't encode value */
- H5E_CANTDECODE, /* Can't decode value */
- H5E_CANTSPLIT, /* Can't split node */
- H5E_CANTINSERT, /* Can't insert object */
- H5E_CANTLIST, /* Can't list node */
-
- /* Object header related errors */
- H5E_LINKCOUNT, /* Bad object header link count */
- H5E_VERSION, /* Wrong version number */
- H5E_ALIGNMENT, /* Alignment error */
- H5E_BADMESG, /* Unrecognized message */
-
- /* Group related errors */
- H5E_CANTOPENOBJ, /* Can't open object */
- H5E_COMPLEN, /* Name component is too long */
- H5E_CWG, /* Problem with current working group */
- H5E_LINK /* Link count failure */
+ H5E_NONE_MINOR = 0, /* special zero, no error */
+
+ /* Argument errors */
+ H5E_UNINITIALIZED, /* Information is unitialized */
+ H5E_UNSUPPORTED, /* Feature is unsupported */
+ H5E_BADTYPE, /* Incorrect type found */
+ H5E_BADRANGE, /* Argument out of range */
+ H5E_BADVALUE, /* Bad value for argument */
+
+ /* Resource errors */
+ H5E_NOSPACE, /* No space available for allocation */
+
+ /* File accessability errors */
+ H5E_FILEEXISTS, /* File already exists */
+ H5E_FILEOPEN, /* File already open */
+ H5E_CANTCREATE, /* Can't create file */
+ H5E_CANTOPENFILE, /* Can't open file */
+ H5E_NOTHDF5, /* Not an HDF5 format file */
+ H5E_BADFILE, /* Bad file ID accessed */
+ H5E_TRUNCATED, /* File has been truncated */
+
+ /* Generic low-level file I/O errors */
+ H5E_SEEKERROR, /* Seek failed */
+ H5E_READERROR, /* Read failed */
+ H5E_WRITEERROR, /* Write failed */
+ H5E_CLOSEERROR, /* Close failed */
+
+ /* Function entry/exit interface errors */
+ H5E_CANTINIT, /* Can't initialize interface */
+ H5E_ALREADYINIT, /* Object already initialized */
+
+ /* Object atom related errors */
+ H5E_BADATOM, /* Can't find atom information */
+ H5E_CANTREGISTER, /* Can't register new atom */
+
+ /* Cache related errors */
+ H5E_CANTFLUSH, /* Can't flush object from cache */
+ H5E_CANTLOAD, /* Can't load object into cache */
+ H5E_PROTECT, /* Protected object error */
+ H5E_NOTCACHED, /* Object not currently cached */
+
+ /* B-tree related errors */
+ H5E_NOTFOUND, /* Object not found */
+ H5E_EXISTS, /* Object already exists */
+ H5E_CANTENCODE, /* Can't encode value */
+ H5E_CANTDECODE, /* Can't decode value */
+ H5E_CANTSPLIT, /* Can't split node */
+ H5E_CANTINSERT, /* Can't insert object */
+ H5E_CANTLIST, /* Can't list node */
+
+ /* Object header related errors */
+ H5E_LINKCOUNT, /* Bad object header link count */
+ H5E_VERSION, /* Wrong version number */
+ H5E_ALIGNMENT, /* Alignment error */
+ H5E_BADMESG, /* Unrecognized message */
+
+ /* Group related errors */
+ H5E_CANTOPENOBJ, /* Can't open object */
+ H5E_COMPLEN, /* Name component is too long */
+ H5E_CWG, /* Problem with current working group */
+ H5E_LINK /* Link count failure */
} H5E_minor_t;
-
#ifdef __cplusplus
-extern "C" {
+extern "C" {
#endif
-hid_t H5Ecreate (uintn initial_stack_nelmts);
-herr_t H5Eclose (hid_t estack_id);
-herr_t H5Epush (hid_t estack_id, H5E_major_t maj_num, H5E_minor_t min_num,
- const char *function_name, const char *file_name, intn line,
- const char *desc);
-herr_t H5Eclear (hid_t estack_id);
-herr_t H5Eprint (hid_t estack_id, FILE *file);
+ hid_t H5Ecreate(uintn initial_stack_nelmts);
+ herr_t H5Eclose(hid_t estack_id);
+ herr_t H5Epush(hid_t estack_id, H5E_major_t maj_num, H5E_minor_t min_num,
+ const char *function_name, const char *file_name, intn line,
+ const char *desc);
+ herr_t H5Eclear(hid_t estack_id);
+ herr_t H5Eprint(hid_t estack_id, FILE * file);
#ifdef __cplusplus
}
-#endif
#endif
+#endif
diff --git a/src/H5F.c b/src/H5F.c
index 416f3e9..985f10a 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -9,13 +9,13 @@
* hdf/COPYING file. *
*
* MODIFICATIONS
-* Robb Matzke, 30 Aug 1997
-* Added `ERRORS' fields to function prologues.
+* Robb Matzke, 30 Aug 1997
+* Added `ERRORS' fields to function prologues.
* *
****************************************************************************/
#ifdef RCSID
-static char RcsId[] = "@(#)$Revision$";
+static char RcsId[] = "@(#)$Revision$";
#endif
/* $Id$ */
@@ -23,28 +23,28 @@ static char RcsId[] = "@(#)$Revision$";
/*LINTLIBRARY */
/*
FILE
- hdf5file.c
+ hdf5file.c
HDF5 file I/O routines
EXPORTED ROUTINES
- H5Fcreate -- Create an HDF5 file
- H5Fclose -- Close an open HDF5 file
+ H5Fcreate -- Create an HDF5 file
+ H5Fclose -- Close an open HDF5 file
LIBRARY-SCOPED ROUTINES
LOCAL ROUTINES
- H5F_init_interface -- initialize the H5F interface
+ H5F_init_interface -- initialize the H5F interface
*/
/* Packages needed by this file... */
-#include <H5private.h> /*library functions */
-#include <H5Aprivate.h> /*atoms */
-#include <H5ACprivate.h> /*cache */
-#include <H5Cprivate.h> /*templates */
-#include <H5Eprivate.h> /*error handling */
-#include <H5Gprivate.h> /*symbol tables */
-#include <H5Mprivate.h> /*meta data */
-#include <H5MMprivate.h> /*core memory management */
+#include <H5private.h> /*library functions */
+#include <H5Aprivate.h> /*atoms */
+#include <H5ACprivate.h> /*cache */
+#include <H5Cprivate.h> /*templates */
+#include <H5Eprivate.h> /*error handling */
+#include <H5Gprivate.h> /*symbol tables */
+#include <H5Mprivate.h> /*meta data */
+#include <H5MMprivate.h> /*core memory management */
#include <ctype.h>
#include <sys/types.h>
@@ -57,29 +57,29 @@ static char RcsId[] = "@(#)$Revision$";
*/
/* #define H5F_OPT_SEEK */
-
-#define PABLO_MASK H5F_mask
+#define PABLO_MASK H5F_mask
/*--------------------- Locally scoped variables -----------------------------*/
/*
* Define the default file creation template.
*/
-const H5F_create_t H5F_create_dflt = {
- 0, /* Default user-block size */
- 4, /* Default 1/2 rank for symtab leaf nodes */
- { /* Default 1/2 rank for btree intern nodes*/
- 16, /* Symbol table internal nodes */
- 32, /* Indexed storage internal nodes */
- 0, /* unused */
- 0, /* unused */
- 0, /* unused */
- 0, /* unused */
- 0, /* unused */
- 0, /* unused */
+const H5F_create_t H5F_create_dflt =
+{
+ 0, /* Default user-block size */
+ 4, /* Default 1/2 rank for symtab leaf nodes */
+ { /* Default 1/2 rank for btree intern nodes */
+ 16, /* Symbol table internal nodes */
+ 32, /* Indexed storage internal nodes */
+ 0, /* unused */
+ 0, /* unused */
+ 0, /* unused */
+ 0, /* unused */
+ 0, /* unused */
+ 0, /* unused */
},
- 4, /* Default offset size */
- 4, /* Default length size */
+ 4, /* Default offset size */
+ 4, /* Default length size */
HDF5_BOOTBLOCK_VERSION, /* Current Boot-Block version # */
HDF5_SMALLOBJECT_VERSION, /* Current Small-Object heap version # */
HDF5_FREESPACE_VERSION, /* Current Free-Space info version # */
@@ -88,16 +88,16 @@ const H5F_create_t H5F_create_dflt = {
};
/* Interface initialization */
-static intn interface_initialize_g = FALSE;
+static intn interface_initialize_g = FALSE;
#define INTERFACE_INIT H5F_init_interface
-static herr_t H5F_init_interface(void);
-static void H5F_term_interface (void);
+static herr_t H5F_init_interface(void);
+static void H5F_term_interface(void);
/* PRIVATE PROTOTYPES */
-static H5F_t *H5F_new (H5F_file_t *shared);
-static H5F_t *H5F_dest (H5F_t *f);
-static herr_t H5F_flush (H5F_t *f, hbool_t invalidate);
-static herr_t H5F_locate_signature (H5F_low_t *f_handle, haddr_t *addr/*out*/);
+static H5F_t *H5F_new(H5F_file_t *shared);
+static H5F_t *H5F_dest(H5F_t *f);
+static herr_t H5F_flush(H5F_t *f, hbool_t invalidate);
+static herr_t H5F_locate_signature(H5F_low_t *f_handle, haddr_t *addr /*out */ );
/*--------------------------------------------------------------------------
NAME
@@ -118,17 +118,18 @@ Modifications:
It was already H5F_mask for the PABLO_TRACE_ON call.
--------------------------------------------------------------------------*/
-static herr_t H5F_init_interface(void)
+static herr_t
+H5F_init_interface(void)
{
- herr_t ret_value = SUCCEED;
- FUNC_ENTER (H5F_init_interface, FAIL);
+ herr_t ret_value = SUCCEED;
+ FUNC_ENTER(H5F_init_interface, FAIL);
/* Initialize the atom group for the file IDs */
- if((ret_value=H5Ainit_group(H5_FILE,H5A_FILEID_HASHSIZE,0,NULL))!=FAIL)
- ret_value=H5_add_exit(&H5F_term_interface);
+ if ((ret_value = H5Ainit_group(H5_FILE, H5A_FILEID_HASHSIZE, 0, NULL)) != FAIL)
+ ret_value = H5_add_exit(&H5F_term_interface);
FUNC_LEAVE(ret_value);
-} /* H5F_init_interface */
+} /* H5F_init_interface */
/*--------------------------------------------------------------------------
NAME
@@ -148,7 +149,7 @@ static herr_t H5F_init_interface(void)
REVISION LOG
--------------------------------------------------------------------------*/
static void
-H5F_term_interface (void)
+H5F_term_interface(void)
{
H5Adestroy_group(H5_FILE);
}
@@ -169,33 +170,33 @@ H5F_term_interface (void)
DESCRIPTION
Encode non-standard (i.e. not 2, 4 or 8-byte) lengths in file meta-data.
--------------------------------------------------------------------------*/
-void H5F_encode_length_unusual(const H5F_t *f, uint8 **p, uint8 *l)
+void
+H5F_encode_length_unusual(const H5F_t *f, uint8 **p, uint8 *l)
{
- intn i = H5F_SIZEOF_SIZE (f);
+ intn i = H5F_SIZEOF_SIZE(f);
#ifdef WORDS_BIGENDIAN
/*
* For non-little-endian platforms, encode each byte in memory backwards.
*/
- for(; i>=0; i--,(*p)++)
- *(*p)=*(l+i);
+ for (; i >= 0; i--, (*p)++)
+ *(*p) = *(l + i);
#else
/* platform has little-endian integers */
- for(; i>=0; i--,(*p)++)
- *(*p)=*l;
+ for (; i >= 0; i--, (*p)++)
+ *(*p) = *l;
#endif
#ifdef LATER
-done:
- if(ret_value == FALSE)
- { /* Error condition cleanup */
+ done:
+ if (ret_value == FALSE) { /* Error condition cleanup */
- } /* end if */
-#endif /* LATER */
+ } /* end if */
+#endif /* LATER */
/* Normal function cleanup */
-} /* H5F_encode_length_unusual */
+} /* H5F_encode_length_unusual */
/*--------------------------------------------------------------------------
NAME
@@ -221,32 +222,30 @@ done:
used to create a file.
--------------------------------------------------------------------------*/
hid_t
-H5Fget_create_template (hid_t fid)
+H5Fget_create_template(hid_t fid)
{
- H5F_t *file = NULL;
- hid_t ret_value = FAIL;
- H5F_create_t *tmpl = NULL;
+ H5F_t *file = NULL;
+ hid_t ret_value = FAIL;
+ H5F_create_t *tmpl = NULL;
- FUNC_ENTER (H5Fget_create_template, FAIL);
+ FUNC_ENTER(H5Fget_create_template, FAIL);
H5ECLEAR;
/* check args */
- if (H5_FILE!=H5Aatom_group (fid)) {
- HRETURN_ERROR (H5E_ATOM, H5E_BADATOM, FAIL, "not a file");
+ if (H5_FILE != H5Aatom_group(fid)) {
+ HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a file");
}
- if (NULL==(file=H5Aatom_object (fid))) {
- HRETURN_ERROR (H5E_ATOM, H5E_BADATOM, FAIL, "can't get file struct");
+ if (NULL == (file = H5Aatom_object(fid))) {
+ HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't get file struct");
}
-
/* Create the template object to return */
- tmpl = H5MM_xmalloc (sizeof(H5F_create_t));
+ tmpl = H5MM_xmalloc(sizeof(H5F_create_t));
*tmpl = file->shared->create_parms;
- if ((ret_value=H5C_create (H5C_FILE_CREATE, tmpl))<0) {
- HRETURN_ERROR (H5E_ATOM, H5E_CANTREGISTER, FAIL,
- "can't register template");
+ if ((ret_value = H5C_create(H5C_FILE_CREATE, tmpl)) < 0) {
+ HRETURN_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL,
+ "can't register template");
}
-
- FUNC_LEAVE (ret_value);
+ FUNC_LEAVE(ret_value);
}
/*--------------------------------------------------------------------------
@@ -266,34 +265,33 @@ H5Fget_create_template (hid_t fid)
keys.
--------------------------------------------------------------------------*/
static intn
-H5F_compare_files (const VOIDP _obj, const VOIDP _key)
+H5F_compare_files(const VOIDP _obj, const VOIDP _key)
{
- const H5F_t *obj = (const H5F_t *)_obj;
- const H5F_search_t *key = (const H5F_search_t *)_key;
- int ret_value = FALSE;
-
- FUNC_ENTER (H5F_compare_files, FALSE);
+ const H5F_t *obj = (const H5F_t *) _obj;
+ const H5F_search_t *key = (const H5F_search_t *) _key;
+ int ret_value = FALSE;
- ret_value = (obj->shared->key.dev == key->dev &&
- obj->shared->key.ino == key->ino);
+ FUNC_ENTER(H5F_compare_files, FALSE);
- FUNC_LEAVE (ret_value);
-}
+ ret_value = (obj->shared->key.dev == key->dev &&
+ obj->shared->key.ino == key->ino);
+ FUNC_LEAVE(ret_value);
+}
/*-------------------------------------------------------------------------
- * Function: H5F_locate_signature
+ * Function: H5F_locate_signature
*
- * Purpose: Finds the HDF5 boot block signature in a file. The signature
- * can appear at address 0, or any power of two beginning with
- * 512.
+ * Purpose: Finds the HDF5 boot block signature in a file. The signature
+ * can appear at address 0, or any power of two beginning with
+ * 512.
*
- * Return: Success: SUCCEED. The address of the signature is
- * returned through the ADDR argument.
+ * Return: Success: SUCCEED. The address of the signature is
+ * returned through the ADDR argument.
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, November 7, 1997
*
* Modifications:
@@ -301,25 +299,26 @@ H5F_compare_files (const VOIDP _obj, const VOIDP _key)
*-------------------------------------------------------------------------
*/
static herr_t
-H5F_locate_signature (H5F_low_t *f_handle, haddr_t *addr/*out*/)
+H5F_locate_signature(H5F_low_t *f_handle, haddr_t *addr /*out */ )
{
- haddr_t max_addr;
- uint8 buf[H5F_SIGNATURE_LEN];
- uintn n=9;
-
- FUNC_ENTER (H5F_locate_signature, FAIL);
-
- H5F_low_size (f_handle, &max_addr);
- H5F_addr_reset (addr);
- while (H5F_addr_lt (addr, &max_addr)) {
- if (H5F_low_read (f_handle, addr, H5F_SIGNATURE_LEN, buf)<0) {
- HRETURN_ERROR (H5E_IO, H5E_READERROR, FAIL, "can't read file");
- }
- if (!HDmemcmp (buf, H5F_SIGNATURE, H5F_SIGNATURE_LEN)) break;
- H5F_addr_pow2 (n++, addr);
- }
-
- FUNC_LEAVE (SUCCEED);
+ haddr_t max_addr;
+ uint8 buf[H5F_SIGNATURE_LEN];
+ uintn n = 9;
+
+ FUNC_ENTER(H5F_locate_signature, FAIL);
+
+ H5F_low_size(f_handle, &max_addr);
+ H5F_addr_reset(addr);
+ while (H5F_addr_lt(addr, &max_addr)) {
+ if (H5F_low_read(f_handle, addr, H5F_SIGNATURE_LEN, buf) < 0) {
+ HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, "can't read file");
+ }
+ if (!HDmemcmp(buf, H5F_SIGNATURE, H5F_SIGNATURE_LEN))
+ break;
+ H5F_addr_pow2(n++, addr);
+ }
+
+ FUNC_LEAVE(SUCCEED);
}
/*--------------------------------------------------------------------------
@@ -346,598 +345,577 @@ H5F_locate_signature (H5F_low_t *f_handle, haddr_t *addr/*out*/)
DESCRIPTION
This function determines if a file is an HDF5 format file.
--------------------------------------------------------------------------*/
-hbool_t H5Fis_hdf5(const char *filename)
+hbool_t
+H5Fis_hdf5(const char *filename)
{
- H5F_low_t *f_handle=NULL; /* file handle */
- haddr_t addr; /* Address of file signature & header */
- hbool_t ret_value = BFALSE;
+ H5F_low_t *f_handle = NULL; /* file handle */
+ haddr_t addr; /* Address of file signature & header */
+ hbool_t ret_value = BFALSE;
FUNC_ENTER(H5Fis_hdf5, BFAIL);
/* Clear errors and check args and all the boring stuff. */
H5ECLEAR;
- if(filename==NULL)
+ if (filename == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, BFAIL, "no filename specified");
/* Open the file */
- if (NULL==(f_handle=H5F_low_open (H5F_LOW_DFLT, filename, 0, NULL))) {
- HGOTO_ERROR(H5E_FILE, H5E_BADFILE, BFAIL,
- "low-level file open failure");
+ if (NULL == (f_handle = H5F_low_open(H5F_LOW_DFLT, filename, 0, NULL))) {
+ HGOTO_ERROR(H5E_FILE, H5E_BADFILE, BFAIL,
+ "low-level file open failure");
}
-
- if (H5F_locate_signature (f_handle, &addr)>=0) {
- ret_value = BTRUE;
+ if (H5F_locate_signature(f_handle, &addr) >= 0) {
+ ret_value = BTRUE;
}
-
- done:
- H5F_low_close(f_handle); /* close the file we opened */
+ done:
+ H5F_low_close(f_handle); /* close the file we opened */
FUNC_LEAVE(ret_value);
}
-
/*-------------------------------------------------------------------------
- * Function: H5F_new
+ * Function: H5F_new
*
- * Purpose: Creates a new file object and initializes it. The
- * H5Fopen and H5Fcreate functions then fill in various
- * fields. If SHARED is a non-null pointer then the shared info
- * to which it points has the reference count incremented.
- * Otherwise a new, empty shared info struct is created.
+ * Purpose: Creates a new file object and initializes it. The
+ * H5Fopen and H5Fcreate functions then fill in various
+ * fields. If SHARED is a non-null pointer then the shared info
+ * to which it points has the reference count incremented.
+ * Otherwise a new, empty shared info struct is created.
*
* Errors:
*
- * Return: Success: Ptr to a new file struct.
+ * Return: Success: Ptr to a new file struct.
*
- * Failure: NULL
+ * Failure: NULL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jul 18 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jul 18 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-static H5F_t *
-H5F_new (H5F_file_t *shared)
+static H5F_t *
+H5F_new(H5F_file_t *shared)
{
- H5F_t *f = NULL;
- FUNC_ENTER (H5F_new, NULL);
-
- f = H5MM_xcalloc (1, sizeof(H5F_t));
- f->shared = shared;
-
- if (!f->shared) {
- f->shared = H5MM_xcalloc (1, sizeof(H5F_file_t));
- H5F_addr_undef (&(f->shared->boot_addr));
- H5F_addr_undef (&(f->shared->base_addr));
- H5F_addr_undef (&(f->shared->smallobj_addr));
- H5F_addr_undef (&(f->shared->freespace_addr));
- H5F_addr_undef (&(f->shared->hdf5_eof));
-
- /* Create a main cache */
- H5AC_create (f, H5AC_NSLOTS);
- }
-
- f->shared->nrefs++;
+ H5F_t *f = NULL;
+ FUNC_ENTER(H5F_new, NULL);
+
+ f = H5MM_xcalloc(1, sizeof(H5F_t));
+ f->shared = shared;
+
+ if (!f->shared) {
+ f->shared = H5MM_xcalloc(1, sizeof(H5F_file_t));
+ H5F_addr_undef(&(f->shared->boot_addr));
+ H5F_addr_undef(&(f->shared->base_addr));
+ H5F_addr_undef(&(f->shared->smallobj_addr));
+ H5F_addr_undef(&(f->shared->freespace_addr));
+ H5F_addr_undef(&(f->shared->hdf5_eof));
+
+ /* Create a main cache */
+ H5AC_create(f, H5AC_NSLOTS);
+ }
+ f->shared->nrefs++;
- FUNC_LEAVE (f);
+ FUNC_LEAVE(f);
}
-
/*-------------------------------------------------------------------------
- * Function: H5F_dest
+ * Function: H5F_dest
*
- * Purpose: Destroys a file structure. This function does not flush
- * the cache or anything else; it only frees memory associated
- * with the file struct. The shared info for the file is freed
- * only when its reference count reaches zero.
+ * Purpose: Destroys a file structure. This function does not flush
+ * the cache or anything else; it only frees memory associated
+ * with the file struct. The shared info for the file is freed
+ * only when its reference count reaches zero.
*
* Errors:
*
- * Return: Success: NULL
+ * Return: Success: NULL
*
- * Failure: NULL
+ * Failure: NULL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jul 18 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jul 18 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-static H5F_t *
-H5F_dest (H5F_t *f)
+static H5F_t *
+H5F_dest(H5F_t *f)
{
- FUNC_ENTER (H5F_dest, NULL);
-
- if (f) {
- if (0 == --(f->shared->nrefs)) {
- H5AC_dest (f);
- f->shared->root_ent = H5MM_xfree (f->shared->root_ent);
- f->shared = H5MM_xfree (f->shared);
- }
- f->name = H5MM_xfree (f->name);
- H5MM_xfree (f);
- }
-
- FUNC_LEAVE (NULL);
+ FUNC_ENTER(H5F_dest, NULL);
+
+ if (f) {
+ if (0 == --(f->shared->nrefs)) {
+ H5AC_dest(f);
+ f->shared->root_ent = H5MM_xfree(f->shared->root_ent);
+ f->shared = H5MM_xfree(f->shared);
+ }
+ f->name = H5MM_xfree(f->name);
+ H5MM_xfree(f);
+ }
+ FUNC_LEAVE(NULL);
}
-
-
/*-------------------------------------------------------------------------
- * Function: H5F_open
+ * Function: H5F_open
*
- * Purpose: Opens (or creates) a file. This function understands the
- * following flags which are similar in nature to the Posix
- * open(2) flags.
+ * Purpose: Opens (or creates) a file. This function understands the
+ * following flags which are similar in nature to the Posix
+ * open(2) flags.
*
- * H5F_ACC_WRITE: Open with read/write access. If the file is
- * currently open for read-only access then it
- * will be reopened. Absence of this flag
- * implies read-only access.
+ * H5F_ACC_WRITE: Open with read/write access. If the file is
+ * currently open for read-only access then it
+ * will be reopened. Absence of this flag
+ * implies read-only access.
*
- * H5F_ACC_CREAT: Create a new file if it doesn't exist yet.
- * The permissions are 0666 bit-wise AND with
- * the current umask. H5F_ACC_WRITE must also
- * be specified.
+ * H5F_ACC_CREAT: Create a new file if it doesn't exist yet.
+ * The permissions are 0666 bit-wise AND with
+ * the current umask. H5F_ACC_WRITE must also
+ * be specified.
*
- * H5F_ACC_EXCL: This flag causes H5F_open() to fail if the
- * file already exists.
+ * H5F_ACC_EXCL: This flag causes H5F_open() to fail if the
+ * file already exists.
*
- * H5F_ACC_TRUNC: The file is truncated and a new HDF5 boot
- * block is written. This operation will fail
- * if the file is already open.
+ * H5F_ACC_TRUNC: The file is truncated and a new HDF5 boot
+ * block is written. This operation will fail
+ * if the file is already open.
*
- * Unlinking the file name from the group directed graph while
- * the file is opened causes the file to continue to exist but
- * one will not be able to upgrade the file from read-only
- * access to read-write access by reopening it. Disk resources
- * for the file are released when all handles to the file are
- * closed. NOTE: This paragraph probably only applies to Unix;
- * deleting the file name in other OS's has undefined results.
+ * Unlinking the file name from the group directed graph while
+ * the file is opened causes the file to continue to exist but
+ * one will not be able to upgrade the file from read-only
+ * access to read-write access by reopening it. Disk resources
+ * for the file are released when all handles to the file are
+ * closed. NOTE: This paragraph probably only applies to Unix;
+ * deleting the file name in other OS's has undefined results.
*
- * The CREATE_PARMS argument is optional. A null pointer will
- * cause the default file creation parameters to be used.
+ * The CREATE_PARMS argument is optional. A null pointer will
+ * cause the default file creation parameters to be used.
*
- * The TYPE argument determins the low-level type of file that
- * is opened. The special value H5F_LOW_DFLT uses the default
- * method which is defined at compile time.
+ * The TYPE argument determins the low-level type of file that
+ * is opened. The special value H5F_LOW_DFLT uses the default
+ * method which is defined at compile time.
*
* Errors:
- * ATOM BADATOM Can't unatomize default template
- * id.
- * FILE BADVALUE Can't create file without write
- * intent.
- * FILE BADVALUE Can't truncate without write intent.
- * FILE CANTCREATE Can't create file.
- * FILE CANTCREATE Can't truncate file.
- * FILE CANTINIT Can't get default file create template
- * id.
- * FILE CANTINIT Can't write file boot block.
- * FILE CANTOPENFILE Bad address size.
- * FILE CANTOPENFILE Bad boot block version number.
- * FILE CANTOPENFILE Bad free space version number.
- * FILE CANTOPENFILE Bad length size.
- * FILE CANTOPENFILE Bad object dir version number.
- * FILE CANTOPENFILE Bad shared header version number.
- * FILE CANTOPENFILE Bad small object heap version number.
- * FILE CANTOPENFILE Bad symbol table internal node 1/2
- * rank.
- * FILE CANTOPENFILE Bad symbol table leaf node 1/2 rank.
- * FILE CANTOPENFILE Can't read root symbol entry.
- * FILE CANTOPENFILE Cannot open existing file.
- * FILE CANTOPENFILE File cannot be reopened with write
- * access.
- * FILE CANTOPENFILE File does not exist.
- * FILE CANTOPENFILE Invalid file family name.
- * FILE FILEEXISTS File already exists - CREAT EXCL
- * failed.
- * FILE FILEOPEN File already open - TRUNC failed.
- * FILE NOTHDF5 Can't find signature.
- * FILE NOTHDF5 Can't read boot block.
- * FILE READERROR File is not readable.
- * FILE TRUNCATED Truncated file?
- * FILE WRITEERROR File is not writable.
- * IO READERROR Can't read boot block.
- *
- * Return: Success: Ptr to the file pointer.
- *
- * Failure: NULL
- *
- * Programmer: Robb Matzke
+ * ATOM BADATOM Can't unatomize default template
+ * id.
+ * FILE BADVALUE Can't create file without write
+ * intent.
+ * FILE BADVALUE Can't truncate without write intent.
+ * FILE CANTCREATE Can't create file.
+ * FILE CANTCREATE Can't truncate file.
+ * FILE CANTINIT Can't get default file create template
+ * id.
+ * FILE CANTINIT Can't write file boot block.
+ * FILE CANTOPENFILE Bad address size.
+ * FILE CANTOPENFILE Bad boot block version number.
+ * FILE CANTOPENFILE Bad free space version number.
+ * FILE CANTOPENFILE Bad length size.
+ * FILE CANTOPENFILE Bad object dir version number.
+ * FILE CANTOPENFILE Bad shared header version number.
+ * FILE CANTOPENFILE Bad small object heap version number.
+ * FILE CANTOPENFILE Bad symbol table internal node 1/2
+ * rank.
+ * FILE CANTOPENFILE Bad symbol table leaf node 1/2 rank.
+ * FILE CANTOPENFILE Can't read root symbol entry.
+ * FILE CANTOPENFILE Cannot open existing file.
+ * FILE CANTOPENFILE File cannot be reopened with write
+ * access.
+ * FILE CANTOPENFILE File does not exist.
+ * FILE CANTOPENFILE Invalid file family name.
+ * FILE FILEEXISTS File already exists - CREAT EXCL
+ * failed.
+ * FILE FILEOPEN File already open - TRUNC failed.
+ * FILE NOTHDF5 Can't find signature.
+ * FILE NOTHDF5 Can't read boot block.
+ * FILE READERROR File is not readable.
+ * FILE TRUNCATED Truncated file?
+ * FILE WRITEERROR File is not writable.
+ * IO READERROR Can't read boot block.
+ *
+ * Return: Success: Ptr to the file pointer.
+ *
+ * Failure: NULL
+ *
+ * Programmer: Robb Matzke
* Tuesday, September 23, 1997
*
* Modifications:
*
- * Robb Matzke, 11 Nov 1997
- * If the name contains the pattern /[^%]%\d*[duxX]/ then the file is
- * assumed to be a family of files. The TYPE argument is ignored and
- * H5F_LOW_FAM is used instead.
+ * Robb Matzke, 11 Nov 1997
+ * If the name contains the pattern /[^%]%\d*[duxX]/ then the file is
+ * assumed to be a family of files. The TYPE argument is ignored and
+ * H5F_LOW_FAM is used instead.
*
*-------------------------------------------------------------------------
*/
-H5F_t *
-H5F_open (const H5F_low_class_t *type, const char *name, uintn flags,
- const H5F_create_t *create_parms)
+H5F_t *
+H5F_open(const H5F_low_class_t *type, const char *name, uintn flags,
+ const H5F_create_t *create_parms)
{
- H5F_t *f = NULL; /*return value */
- H5F_t *ret_value = NULL; /*a copy of `f' */
- H5F_t *old = NULL; /*a file already opened */
- H5F_search_t search; /*file search key */
- H5F_low_t *fd = NULL; /*low level file desc */
- hbool_t empty_file = FALSE; /*is file empty? */
- hbool_t file_exists = FALSE; /*file already exists */
- uint8 buf[256]; /*I/O buffer.. */
- const uint8 *p=NULL; /* ..and pointer into it*/
- size_t fixed_size = 24; /*size of fixed part of boot blk*/
- size_t variable_size; /*variable part of boot block */
- H5F_create_t *cp=NULL; /*file creation parameters */
- haddr_t addr1, addr2; /*temporary address */
- H5G_entry_t root_ent; /*root symbol table entry */
- const char *s = name;
-
- FUNC_ENTER (H5F_open, NULL);
-
- assert (name && *name);
-
- /*
- * Does the name look like a family name? A family name always has a
- * percent (not preceded by a percent) followed by an optional plus and/or
- * minus, followed by optional digits, followed by the letter `d', `u',
- * `x', or `X'. This is a printf() format for an integer.
- */
- while (*s) {
- if ('%'!=*s++) continue;
- if ('%'==*s) {
- s++;
- continue;
- }
- while (*s && isdigit (*s)) s++;
- if ('d'!=*s && 'u'!=*s && 'x'!=*s && 'X'!=*s) continue;
- break;
- }
- if (*s) {
+ H5F_t *f = NULL; /*return value */
+ H5F_t *ret_value = NULL; /*a copy of `f' */
+ H5F_t *old = NULL; /*a file already opened */
+ H5F_search_t search; /*file search key */
+ H5F_low_t *fd = NULL; /*low level file desc */
+ hbool_t empty_file = FALSE; /*is file empty? */
+ hbool_t file_exists = FALSE; /*file already exists */
+ uint8 buf[256]; /*I/O buffer.. */
+ const uint8 *p = NULL; /* ..and pointer into it */
+ size_t fixed_size = 24; /*size of fixed part of boot blk */
+ size_t variable_size; /*variable part of boot block */
+ H5F_create_t *cp = NULL; /*file creation parameters */
+ haddr_t addr1, addr2; /*temporary address */
+ H5G_entry_t root_ent; /*root symbol table entry */
+ const char *s = name;
+
+ FUNC_ENTER(H5F_open, NULL);
+
+ assert(name && *name);
+
+ /*
+ * Does the name look like a family name? A family name always has a
+ * percent (not preceded by a percent) followed by an optional plus and/or
+ * minus, followed by optional digits, followed by the letter `d', `u',
+ * `x', or `X'. This is a printf() format for an integer.
+ */
+ while (*s) {
+ if ('%' != *s++)
+ continue;
+ if ('%' == *s) {
+ s++;
+ continue;
+ }
+ while (*s && isdigit(*s))
+ s++;
+ if ('d' != *s && 'u' != *s && 'x' != *s && 'X' != *s)
+ continue;
+ break;
+ }
+ if (*s) {
#ifdef H5F_DEBUG
- if (type!=H5F_LOW_FAM) {
- fprintf (stderr, "HDF5-DIAG: opening a file family\n");
- }
+ if (type != H5F_LOW_FAM) {
+ fprintf(stderr, "HDF5-DIAG: opening a file family\n");
+ }
#endif
- type = H5F_LOW_FAM;
- } else if (type==H5F_LOW_FAM) {
- HRETURN_ERROR (H5E_FILE, H5E_CANTOPENFILE, NULL,
- "invalid file family name");
- }
-
- /*
- * If the name ends with `.h5' and there's another file that ends with
- * `.raw' then open the file as a split file.
- */
- {
- if (H5F_LOW_SPLIT!=type && (s=strstr (name, ".h5")) && !s[3]) {
- char fullname[4096];
- strncpy (fullname, name, s-name);
- strcpy (fullname+(s-name), ".raw");
- if (H5F_low_access (H5F_LOW_DFLT, fullname, F_OK, NULL)) {
+ type = H5F_LOW_FAM;
+ } else if (type == H5F_LOW_FAM) {
+ HRETURN_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL,
+ "invalid file family name");
+ }
+ /*
+ * If the name ends with `.h5' and there's another file that ends with
+ * `.raw' then open the file as a split file.
+ */
+ {
+ if (H5F_LOW_SPLIT != type && (s = strstr(name, ".h5")) && !s[3]) {
+ char fullname[4096];
+ strncpy(fullname, name, s - name);
+ strcpy(fullname + (s - name), ".raw");
+ if (H5F_low_access(H5F_LOW_DFLT, fullname, F_OK, NULL)) {
#ifdef H5F_DEBUG
- fprintf (stderr, "HDF5-DIAG: opening a split file\n");
+ fprintf(stderr, "HDF5-DIAG: opening a split file\n");
#endif
- fullname[s-name] = '\0';
- f = H5F_open (H5F_LOW_SPLIT, fullname, flags, create_parms);
- HRETURN (f);
- }
- }
- }
-
- /*
- * If no file creation parameters are supplied then use defaults.
- */
- if (!create_parms) create_parms = &H5F_create_dflt;
-
- /*
- * Does the file exist? If so, get the device and i-node values so we can
- * compare them with other files already open. On Unix (and other systems
- * with hard or soft links) it doesn't work to compare files based only on
- * their full path name.
- */
- file_exists = H5F_low_access (type, name, F_OK, &search);
-
- /*
- * Open the low-level file (if necessary) and create an H5F_t struct that
- * points to an H5F_file_t struct.
- */
- if (file_exists) {
- if (flags & H5F_ACC_EXCL) {
- HRETURN_ERROR (H5E_FILE, H5E_FILEEXISTS, NULL,
- "file already exists - CREAT EXCL failed");
- }
- if (!H5F_low_access (type, name, R_OK, NULL)) {
- HRETURN_ERROR (H5E_FILE, H5E_READERROR, NULL,
- "file is not readable");
- }
- if ((flags & H5F_ACC_WRITE) &&
- !H5F_low_access (type, name, W_OK, NULL)) {
- HRETURN_ERROR (H5E_FILE, H5E_WRITEERROR, NULL,
- "file is not writable");
- }
-
- if ((old=H5Asearch_atom (H5_FILE, H5F_compare_files, &search))) {
- if (flags & H5F_ACC_TRUNC) {
- HRETURN_ERROR (H5E_FILE, H5E_FILEOPEN, NULL,
- "file already open - TRUNC failed");
- }
- if ((flags & H5F_ACC_WRITE) &&
- 0==(old->shared->flags & H5F_ACC_WRITE)) {
- if (NULL==(fd=H5F_low_open (type, name, H5F_ACC_WRITE, NULL))) {
- HRETURN_ERROR (H5E_FILE, H5E_CANTOPENFILE, NULL,
- "file cannot be reopened with write access");
- }
- H5F_low_close (old->shared->lf);
- old->shared->lf = fd;
- old->shared->flags |= H5F_ACC_WRITE;
- fd = NULL; /*so we don't close it during error*/
- }
- f = H5F_new (old->shared);
-
- } else if (flags & H5F_ACC_TRUNC) {
- /* Truncate existing file */
- if (0==(flags & H5F_ACC_WRITE)) {
- HRETURN_ERROR (H5E_FILE, H5E_BADVALUE, NULL,
- "can't truncate without write intent");
- }
- fd = H5F_low_open (type, name, H5F_ACC_WRITE|H5F_ACC_TRUNC, NULL);
- if (!fd) {
- HRETURN_ERROR (H5E_FILE, H5E_CANTCREATE, NULL,
- "can't truncate file");
- }
- f = H5F_new (NULL);
- f->shared->key = search;
- f->shared->flags = flags;
- f->shared->lf = fd;
- empty_file = TRUE;
-
- } else {
- fd = H5F_low_open (type, name, (flags & H5F_ACC_WRITE), NULL);
- if (!fd) {
- HRETURN_ERROR (H5E_FILE, H5E_CANTOPENFILE, NULL,
- "cannot open existing file");
- }
- f = H5F_new (NULL);
- f->shared->key = search;
- f->shared->flags = flags;
- f->shared->lf = fd;
- }
-
- } else if (flags & H5F_ACC_CREAT) {
- if (0==(flags & H5F_ACC_WRITE)) {
- HRETURN_ERROR (H5E_FILE, H5E_BADVALUE, NULL,
- "can't create file without write intent");
- }
- fd = H5F_low_open (type, name,
- H5F_ACC_WRITE|H5F_ACC_CREAT|H5F_ACC_EXCL,
- &search);
- if (!fd) {
- HRETURN_ERROR (H5E_FILE, H5E_CANTCREATE, NULL,
- "can't create file");
- }
- f = H5F_new (NULL);
- f->shared->key = search;
- f->shared->flags = flags;
- f->shared->lf = fd;
- empty_file = TRUE;
-
- } else {
- HRETURN_ERROR (H5E_FILE, H5E_CANTOPENFILE, NULL,
- "file does not exist");
- }
- assert (f);
-
- /*
- * The intent at the top level file struct are not necessarily the same as
- * the flags at the bottom. The top level describes how the file can be
- * accessed through the HDF5 library. The bottom level describes how the
- * file can be accessed through the C library.
- */
- f->intent = flags;
- f->name = H5MM_xstrdup (name);
-
- /*
- * Update the file creation parameters with default values if this is the
- * first time this file is opened.
- */
- if (1==f->shared->nrefs) {
- f->shared->create_parms = *create_parms;
- }
- cp = &(f->shared->create_parms);
-
- /*
- * Read or write the file boot block.
- */
- if (empty_file) {
- /*
- * For new files we must write the boot block. The boot block starts
- * immediately after the user-defined header, which we have already
- * insured is a proper size. The base address is set to the same thing
- * as the boot block.
- */
- H5F_addr_reset (&(f->shared->boot_addr));
- H5F_addr_inc (&(f->shared->boot_addr),
- f->shared->create_parms.userblock_size);
- f->shared->base_addr = f->shared->boot_addr;
-
- f->shared->consist_flags = 0x03;
- if (H5F_flush (f, FALSE)<0) {
- HGOTO_ERROR (H5E_FILE, H5E_CANTINIT, NULL,
- "can't write file boot block");
- }
- } else if (1==f->shared->nrefs) {
- /* For existing files we must read the boot block. */
- if (H5F_locate_signature (f->shared->lf, &(f->shared->boot_addr))<0) {
- HGOTO_ERROR (H5E_FILE, H5E_NOTHDF5, NULL, "can't find signature");
- }
- if (H5F_low_read (f->shared->lf, &(f->shared->boot_addr),
- fixed_size, buf)<0) {
- HGOTO_ERROR (H5E_IO, H5E_READERROR, NULL, "can't read boot block");
- }
-
- /*
- * Decode the fixed size part of the boot block. For each of the
- * version parameters, check that the library is able to handle that
- * version.
- */
- p = buf + H5F_SIGNATURE_LEN; /*already checked*/
-
- cp->bootblock_ver = *p++;
- if (cp->bootblock_ver != HDF5_BOOTBLOCK_VERSION) {
- HGOTO_ERROR (H5E_FILE, H5E_CANTOPENFILE, NULL,
- "bad boot block version number");
- }
-
- cp->smallobject_ver = *p++;
- if (cp->smallobject_ver != HDF5_SMALLOBJECT_VERSION) {
- HGOTO_ERROR (H5E_FILE, H5E_CANTOPENFILE, NULL,
- "bad small object heap version number");
- }
-
- cp->freespace_ver = *p++;
- if (cp->freespace_ver != HDF5_FREESPACE_VERSION) {
- HGOTO_ERROR (H5E_FILE, H5E_CANTOPENFILE, NULL,
- "bad free space version number");
- }
-
- cp->objectdir_ver = *p++;
- if (cp->objectdir_ver != HDF5_OBJECTDIR_VERSION) {
- HGOTO_ERROR (H5E_FILE, H5E_CANTOPENFILE, NULL,
- "bad object dir version number");
- }
-
- cp->sharedheader_ver = *p++;
- if (cp->sharedheader_ver != HDF5_SHAREDHEADER_VERSION) {
- HGOTO_ERROR (H5E_FILE, H5E_CANTOPENFILE, NULL,
- "bad shared header version number");
- }
-
- cp->sizeof_addr = *p++;
- if (cp->sizeof_addr!=2 &&
- cp->sizeof_addr!=4 &&
- cp->sizeof_addr!=8 &&
- cp->sizeof_addr!=16 &&
- cp->sizeof_addr!=32) {
- HGOTO_ERROR (H5E_FILE, H5E_CANTOPENFILE, NULL,
- "bad address size");
- }
-
- cp->sizeof_size = *p++;
- if (cp->sizeof_size!=2 &&
- cp->sizeof_size!=4 &&
- cp->sizeof_size!=8 &&
- cp->sizeof_size!=16 &&
- cp->sizeof_size!=32) {
- HGOTO_ERROR (H5E_FILE, H5E_CANTOPENFILE, NULL,
- "bad length size");
- }
-
- /* Reserved byte */
- p++;
-
- UINT16DECODE (p, cp->sym_leaf_k);
- if (cp->sym_leaf_k<1) {
- HGOTO_ERROR (H5E_FILE, H5E_CANTOPENFILE, NULL,
- "bad symbol table leaf node 1/2 rank");
- }
-
- UINT16DECODE (p, cp->btree_k[H5B_SNODE_ID]);
- if (cp->btree_k[H5B_SNODE_ID]<1) {
- HGOTO_ERROR (H5E_FILE, H5E_CANTOPENFILE, NULL,
- "bad symbol table internal node 1/2 rank");
- }
-
- UINT32DECODE (p, f->shared->consist_flags);
- /* nothing to check for consistency flags */
-
- assert (p-buf == fixed_size);
-
- /* Read the variable length part of the boot block... */
- variable_size = H5F_SIZEOF_ADDR (f) + /*base address*/
- H5F_SIZEOF_ADDR (f) + /*global small obj heap*/
- H5F_SIZEOF_ADDR (f) + /*global free list addr*/
- H5F_SIZEOF_ADDR (f) + /*logical file size*/
- H5G_SIZEOF_ENTRY (f);
- assert (variable_size <= sizeof buf);
- addr1 = f->shared->boot_addr;
- H5F_addr_inc (&addr1, fixed_size);
- if (H5F_low_read (f->shared->lf, &addr1, variable_size, buf)<0) {
- HGOTO_ERROR (H5E_FILE, H5E_NOTHDF5, NULL,
- "can't read boot block");
- }
-
- p = buf;
- H5F_addr_decode (f, &p, &(f->shared->base_addr));
- H5F_addr_decode (f, &p, &(f->shared->smallobj_addr));
- H5F_addr_decode (f, &p, &(f->shared->freespace_addr));
- H5F_addr_decode (f, &p, &(f->shared->hdf5_eof));
- if (H5G_ent_decode (f, &p, &root_ent)<0) {
- HGOTO_ERROR (H5E_FILE, H5E_CANTOPENFILE, NULL,
- "can't read root symbol entry");
- }
- if (H5F_addr_defined (&(root_ent.header))) {
- f->shared->root_ent = H5MM_xmalloc (sizeof(H5G_entry_t));
- *(f->shared->root_ent) = root_ent;
- }
-
-
- /*
- * The userdefined data is the area of the file before the base
- * address.
- */
- f->shared->create_parms.userblock_size=f->shared->base_addr.offset;
- }
-
- /*
- * What is the current size of the file? The max_addr field is a relative
- * address while H5F_low_size() returns an absolute address.
- */
- H5F_low_size (f->shared->lf, &addr1);
- addr2 = f->shared->hdf5_eof;
- H5F_addr_add (&addr2, &(f->shared->base_addr));
- if (H5F_addr_lt (&addr1, &addr2)) {
- /*
- * Truncated file? This might happen if one tries to open the first
- * member of a file family.
- */
- HGOTO_ERROR (H5E_FILE, H5E_TRUNCATED, NULL, "truncated file");
- } else if (H5F_addr_gt (&addr1, &addr2)) {
- /*
- * The file is larger than the hdf5 data. It either has extra junk at
- * the end, or a wrapper. In either case, make the file think it's
- * shorter so when we allocate memory from the file for hdf5 it's
- * allocated immediately after the end of the previous hdf5 data. This
- * will cause internal wrappers to be overwritten if they follow the
- * hdf5 data.
- */
+ fullname[s - name] = '\0';
+ f = H5F_open(H5F_LOW_SPLIT, fullname, flags, create_parms);
+ HRETURN(f);
+ }
+ }
+ }
+
+ /*
+ * If no file creation parameters are supplied then use defaults.
+ */
+ if (!create_parms)
+ create_parms = &H5F_create_dflt;
+
+ /*
+ * Does the file exist? If so, get the device and i-node values so we can
+ * compare them with other files already open. On Unix (and other systems
+ * with hard or soft links) it doesn't work to compare files based only on
+ * their full path name.
+ */
+ file_exists = H5F_low_access(type, name, F_OK, &search);
+
+ /*
+ * Open the low-level file (if necessary) and create an H5F_t struct that
+ * points to an H5F_file_t struct.
+ */
+ if (file_exists) {
+ if (flags & H5F_ACC_EXCL) {
+ HRETURN_ERROR(H5E_FILE, H5E_FILEEXISTS, NULL,
+ "file already exists - CREAT EXCL failed");
+ }
+ if (!H5F_low_access(type, name, R_OK, NULL)) {
+ HRETURN_ERROR(H5E_FILE, H5E_READERROR, NULL,
+ "file is not readable");
+ }
+ if ((flags & H5F_ACC_WRITE) &&
+ !H5F_low_access(type, name, W_OK, NULL)) {
+ HRETURN_ERROR(H5E_FILE, H5E_WRITEERROR, NULL,
+ "file is not writable");
+ }
+ if ((old = H5Asearch_atom(H5_FILE, H5F_compare_files, &search))) {
+ if (flags & H5F_ACC_TRUNC) {
+ HRETURN_ERROR(H5E_FILE, H5E_FILEOPEN, NULL,
+ "file already open - TRUNC failed");
+ }
+ if ((flags & H5F_ACC_WRITE) &&
+ 0 == (old->shared->flags & H5F_ACC_WRITE)) {
+ if (NULL == (fd = H5F_low_open(type, name, H5F_ACC_WRITE, NULL))) {
+ HRETURN_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL,
+ "file cannot be reopened with write access");
+ }
+ H5F_low_close(old->shared->lf);
+ old->shared->lf = fd;
+ old->shared->flags |= H5F_ACC_WRITE;
+ fd = NULL; /*so we don't close it during error */
+ }
+ f = H5F_new(old->shared);
+
+ } else if (flags & H5F_ACC_TRUNC) {
+ /* Truncate existing file */
+ if (0 == (flags & H5F_ACC_WRITE)) {
+ HRETURN_ERROR(H5E_FILE, H5E_BADVALUE, NULL,
+ "can't truncate without write intent");
+ }
+ fd = H5F_low_open(type, name, H5F_ACC_WRITE | H5F_ACC_TRUNC, NULL);
+ if (!fd) {
+ HRETURN_ERROR(H5E_FILE, H5E_CANTCREATE, NULL,
+ "can't truncate file");
+ }
+ f = H5F_new(NULL);
+ f->shared->key = search;
+ f->shared->flags = flags;
+ f->shared->lf = fd;
+ empty_file = TRUE;
+
+ } else {
+ fd = H5F_low_open(type, name, (flags & H5F_ACC_WRITE), NULL);
+ if (!fd) {
+ HRETURN_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL,
+ "cannot open existing file");
+ }
+ f = H5F_new(NULL);
+ f->shared->key = search;
+ f->shared->flags = flags;
+ f->shared->lf = fd;
+ }
+
+ } else if (flags & H5F_ACC_CREAT) {
+ if (0 == (flags & H5F_ACC_WRITE)) {
+ HRETURN_ERROR(H5E_FILE, H5E_BADVALUE, NULL,
+ "can't create file without write intent");
+ }
+ fd = H5F_low_open(type, name,
+ H5F_ACC_WRITE | H5F_ACC_CREAT | H5F_ACC_EXCL,
+ &search);
+ if (!fd) {
+ HRETURN_ERROR(H5E_FILE, H5E_CANTCREATE, NULL,
+ "can't create file");
+ }
+ f = H5F_new(NULL);
+ f->shared->key = search;
+ f->shared->flags = flags;
+ f->shared->lf = fd;
+ empty_file = TRUE;
+
+ } else {
+ HRETURN_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL,
+ "file does not exist");
+ }
+ assert(f);
+
+ /*
+ * The intent at the top level file struct are not necessarily the same as
+ * the flags at the bottom. The top level describes how the file can be
+ * accessed through the HDF5 library. The bottom level describes how the
+ * file can be accessed through the C library.
+ */
+ f->intent = flags;
+ f->name = H5MM_xstrdup(name);
+
+ /*
+ * Update the file creation parameters with default values if this is the
+ * first time this file is opened.
+ */
+ if (1 == f->shared->nrefs) {
+ f->shared->create_parms = *create_parms;
+ }
+ cp = &(f->shared->create_parms);
+
+ /*
+ * Read or write the file boot block.
+ */
+ if (empty_file) {
+ /*
+ * For new files we must write the boot block. The boot block starts
+ * immediately after the user-defined header, which we have already
+ * insured is a proper size. The base address is set to the same thing
+ * as the boot block.
+ */
+ H5F_addr_reset(&(f->shared->boot_addr));
+ H5F_addr_inc(&(f->shared->boot_addr),
+ f->shared->create_parms.userblock_size);
+ f->shared->base_addr = f->shared->boot_addr;
+
+ f->shared->consist_flags = 0x03;
+ if (H5F_flush(f, FALSE) < 0) {
+ HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL,
+ "can't write file boot block");
+ }
+ } else if (1 == f->shared->nrefs) {
+ /* For existing files we must read the boot block. */
+ if (H5F_locate_signature(f->shared->lf, &(f->shared->boot_addr)) < 0) {
+ HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, NULL, "can't find signature");
+ }
+ if (H5F_low_read(f->shared->lf, &(f->shared->boot_addr),
+ fixed_size, buf) < 0) {
+ HGOTO_ERROR(H5E_IO, H5E_READERROR, NULL, "can't read boot block");
+ }
+ /*
+ * Decode the fixed size part of the boot block. For each of the
+ * version parameters, check that the library is able to handle that
+ * version.
+ */
+ p = buf + H5F_SIGNATURE_LEN; /*already checked */
+
+ cp->bootblock_ver = *p++;
+ if (cp->bootblock_ver != HDF5_BOOTBLOCK_VERSION) {
+ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL,
+ "bad boot block version number");
+ }
+ cp->smallobject_ver = *p++;
+ if (cp->smallobject_ver != HDF5_SMALLOBJECT_VERSION) {
+ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL,
+ "bad small object heap version number");
+ }
+ cp->freespace_ver = *p++;
+ if (cp->freespace_ver != HDF5_FREESPACE_VERSION) {
+ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL,
+ "bad free space version number");
+ }
+ cp->objectdir_ver = *p++;
+ if (cp->objectdir_ver != HDF5_OBJECTDIR_VERSION) {
+ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL,
+ "bad object dir version number");
+ }
+ cp->sharedheader_ver = *p++;
+ if (cp->sharedheader_ver != HDF5_SHAREDHEADER_VERSION) {
+ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL,
+ "bad shared header version number");
+ }
+ cp->sizeof_addr = *p++;
+ if (cp->sizeof_addr != 2 &&
+ cp->sizeof_addr != 4 &&
+ cp->sizeof_addr != 8 &&
+ cp->sizeof_addr != 16 &&
+ cp->sizeof_addr != 32) {
+ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL,
+ "bad address size");
+ }
+ cp->sizeof_size = *p++;
+ if (cp->sizeof_size != 2 &&
+ cp->sizeof_size != 4 &&
+ cp->sizeof_size != 8 &&
+ cp->sizeof_size != 16 &&
+ cp->sizeof_size != 32) {
+ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL,
+ "bad length size");
+ }
+ /* Reserved byte */
+ p++;
+
+ UINT16DECODE(p, cp->sym_leaf_k);
+ if (cp->sym_leaf_k < 1) {
+ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL,
+ "bad symbol table leaf node 1/2 rank");
+ }
+ UINT16DECODE(p, cp->btree_k[H5B_SNODE_ID]);
+ if (cp->btree_k[H5B_SNODE_ID] < 1) {
+ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL,
+ "bad symbol table internal node 1/2 rank");
+ }
+ UINT32DECODE(p, f->shared->consist_flags);
+ /* nothing to check for consistency flags */
+
+ assert(p - buf == fixed_size);
+
+ /* Read the variable length part of the boot block... */
+ variable_size = H5F_SIZEOF_ADDR(f) + /*base address */
+ H5F_SIZEOF_ADDR(f) + /*global small obj heap */
+ H5F_SIZEOF_ADDR(f) + /*global free list addr */
+ H5F_SIZEOF_ADDR(f) + /*logical file size */
+ H5G_SIZEOF_ENTRY(f);
+ assert(variable_size <= sizeof buf);
+ addr1 = f->shared->boot_addr;
+ H5F_addr_inc(&addr1, fixed_size);
+ if (H5F_low_read(f->shared->lf, &addr1, variable_size, buf) < 0) {
+ HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, NULL,
+ "can't read boot block");
+ }
+ p = buf;
+ H5F_addr_decode(f, &p, &(f->shared->base_addr));
+ H5F_addr_decode(f, &p, &(f->shared->smallobj_addr));
+ H5F_addr_decode(f, &p, &(f->shared->freespace_addr));
+ H5F_addr_decode(f, &p, &(f->shared->hdf5_eof));
+ if (H5G_ent_decode(f, &p, &root_ent) < 0) {
+ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL,
+ "can't read root symbol entry");
+ }
+ if (H5F_addr_defined(&(root_ent.header))) {
+ f->shared->root_ent = H5MM_xmalloc(sizeof(H5G_entry_t));
+ *(f->shared->root_ent) = root_ent;
+ }
+ /*
+ * The userdefined data is the area of the file before the base
+ * address.
+ */
+ f->shared->create_parms.userblock_size = f->shared->base_addr.offset;
+ }
+ /*
+ * What is the current size of the file? The max_addr field is a relative
+ * address while H5F_low_size() returns an absolute address.
+ */
+ H5F_low_size(f->shared->lf, &addr1);
+ addr2 = f->shared->hdf5_eof;
+ H5F_addr_add(&addr2, &(f->shared->base_addr));
+ if (H5F_addr_lt(&addr1, &addr2)) {
+ /*
+ * Truncated file? This might happen if one tries to open the first
+ * member of a file family.
+ */
+ HGOTO_ERROR(H5E_FILE, H5E_TRUNCATED, NULL, "truncated file");
+ } else if (H5F_addr_gt(&addr1, &addr2)) {
+ /*
+ * The file is larger than the hdf5 data. It either has extra junk at
+ * the end, or a wrapper. In either case, make the file think it's
+ * shorter so when we allocate memory from the file for hdf5 it's
+ * allocated immediately after the end of the previous hdf5 data. This
+ * will cause internal wrappers to be overwritten if they follow the
+ * hdf5 data.
+ */
#ifdef H5F_DEBUG
- fprintf (stderr, "HDF5-DIAG: resetting EOF from ");
- H5F_addr_print (stderr, &addr1);
- fprintf (stderr, " to ");
- H5F_addr_print (stderr, &addr2);
- fprintf (stderr, " (abs)\n");
+ fprintf(stderr, "HDF5-DIAG: resetting EOF from ");
+ H5F_addr_print(stderr, &addr1);
+ fprintf(stderr, " to ");
+ H5F_addr_print(stderr, &addr2);
+ fprintf(stderr, " (abs)\n");
#endif
- H5F_low_seteof (f->shared->lf, &addr2);
- }
-
-
- /* Success! */
- ret_value = f;
-
- done:
- if (!ret_value) {
- if (f) H5F_dest (f);
- H5F_low_close (fd);
- }
-
- FUNC_LEAVE (ret_value);
+ H5F_low_seteof(f->shared->lf, &addr2);
+ }
+ /* Success! */
+ ret_value = f;
+
+ done:
+ if (!ret_value) {
+ if (f)
+ H5F_dest(f);
+ H5F_low_close(fd);
+ }
+ FUNC_LEAVE(ret_value);
}
/*--------------------------------------------------------------------------
@@ -972,8 +950,8 @@ H5F_open (const H5F_low_class_t *type, const char *name, uintn flags,
of the file open call.
The flags currently defined:
H5ACC_OVERWRITE - Truncate file, if it already exists. The file
- will be truncated, erasing all data previously stored in the
- file.
+ will be truncated, erasing all data previously stored in the
+ file.
The more complex behaviors of a file's creation and access are
controlled through the file-creation and file-access templates. The value
of 0 for a template value indicates that the library should use the default
@@ -993,64 +971,61 @@ H5F_open (const H5F_low_class_t *type, const char *name, uintn flags,
Most of the work is now done by H5F_open() since H5Fcreate() and H5Fopen()
originally contained almost identical code.
--------------------------------------------------------------------------*/
-hid_t H5Fcreate(const char *filename, uintn flags, hid_t create_temp,
- hid_t access_temp)
+hid_t
+H5Fcreate(const char *filename, uintn flags, hid_t create_temp,
+ hid_t access_temp)
{
- H5F_t *new_file=NULL; /* file struct for new file */
- const H5F_create_t *create_parms; /* pointer to the parameters to
- * use when creating the file
- */
- hid_t ret_value = FAIL;
+ H5F_t *new_file = NULL; /* file struct for new file */
+ const H5F_create_t *create_parms; /* pointer to the parameters to
+ * use when creating the file
+ */
+ hid_t ret_value = FAIL;
FUNC_ENTER(H5Fcreate, FAIL);
H5ECLEAR;
/* Check/fix arguments */
if (!filename || !*filename)
- HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file name");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file name");
if (flags & ~H5ACC_OVERWRITE)
- HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid flags");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid flags");
flags = (H5F_ACC_WRITE | H5F_ACC_CREAT) |
- (H5ACC_OVERWRITE==flags ? H5F_ACC_TRUNC : H5F_ACC_EXCL);
-
- if (create_temp<=0) {
- create_parms = &H5F_create_dflt;
- } else if (NULL==(create_parms=H5Aatom_object (create_temp))) {
- HGOTO_ERROR (H5E_ATOM, H5E_BADATOM, FAIL, "can't unatomize template");
+ (H5ACC_OVERWRITE == flags ? H5F_ACC_TRUNC : H5F_ACC_EXCL);
+
+ if (create_temp <= 0) {
+ create_parms = &H5F_create_dflt;
+ } else if (NULL == (create_parms = H5Aatom_object(create_temp))) {
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't unatomize template");
}
-
#ifdef LATER
- if (access_temp<=0) {
- access_parms = &H5F_access_dflt;
- } else if (NULL==(access_parms=H5Aatom_object (access_temp))) {
- HGOTO_ERROR (H5E_ATOM, H5E_BADATOM, FAIL); /*can't unatomize template*/
+ if (access_temp <= 0) {
+ access_parms = &H5F_access_dflt;
+ } else if (NULL == (access_parms = H5Aatom_object(access_temp))) {
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL); /*can't unatomize template */
}
#endif
-
+
/*
* Create a new file or truncate an existing file.
*/
- if (NULL==(new_file = H5F_open (H5F_LOW_DFLT, filename, flags,
- create_parms))) {
- HGOTO_ERROR (H5E_FILE, H5E_CANTOPENFILE, FAIL, "can't create file");
+ if (NULL == (new_file = H5F_open(H5F_LOW_DFLT, filename, flags,
+ create_parms))) {
+ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "can't create file");
}
-
/* Get an atom for the file */
- if ((ret_value=H5Aregister_atom (H5_FILE, new_file))<0)
+ if ((ret_value = H5Aregister_atom(H5_FILE, new_file)) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "can't atomize file");
- done:
- if (ret_value<0 && new_file) {
- /* Error condition cleanup */
- H5F_close (new_file);
+ done:
+ if (ret_value < 0 && new_file) {
+ /* Error condition cleanup */
+ H5F_close(new_file);
}
-
/* Normal function cleanup */
FUNC_LEAVE(ret_value);
}
-
/*--------------------------------------------------------------------------
NAME
H5Fopen
@@ -1092,141 +1067,135 @@ hid_t H5Fcreate(const char *filename, uintn flags, hid_t create_temp,
Most of the work is now done by H5F_open() since H5Fcreate() and H5Fopen()
originally contained almost identical code.
--------------------------------------------------------------------------*/
-hid_t H5Fopen(const char *filename, uintn flags, hid_t access_temp)
+hid_t
+H5Fopen(const char *filename, uintn flags, hid_t access_temp)
{
- H5F_t *new_file=NULL; /* file struct for new file */
- hid_t ret_value = FAIL;
+ H5F_t *new_file = NULL; /* file struct for new file */
+ hid_t ret_value = FAIL;
FUNC_ENTER(H5Fopen, FAIL);
H5ECLEAR;
/* Check/fix arguments. */
if (!filename || !*filename)
- HGOTO_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL, "invalid file name");
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid file name");
flags = flags & H5ACC_WRITE ? H5F_ACC_WRITE : 0;
#ifdef LATER
- if (access_temp<=0)
- access_temp = H5CPget_default_atom (H5_TEMPLATE);
- if (NULL==(f_access_parms=H5Aatom_object (access_temp)))
- HGOTO_ERROR (H5E_ATOM, H5E_BADATOM, FAIL);/*can't unatomize template*/
+ if (access_temp <= 0)
+ access_temp = H5CPget_default_atom(H5_TEMPLATE);
+ if (NULL == (f_access_parms = H5Aatom_object(access_temp)))
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL); /*can't unatomize template */
#endif
/* Open the file */
- if (NULL==(new_file=H5F_open (H5F_LOW_DFLT, filename, flags, NULL))) {
- HGOTO_ERROR (H5E_FILE, H5E_CANTOPENFILE, FAIL, "cant open file");
+ if (NULL == (new_file = H5F_open(H5F_LOW_DFLT, filename, flags, NULL))) {
+ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "cant open file");
}
-
/* Get an atom for the file */
- if ((ret_value = H5Aregister_atom (H5_FILE, new_file))<0)
+ if ((ret_value = H5Aregister_atom(H5_FILE, new_file)) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "can't atomize file");
- done:
- if (ret_value<0 && new_file) {
- H5F_close (new_file);
+ done:
+ if (ret_value < 0 && new_file) {
+ H5F_close(new_file);
}
-
/* Normal function cleanup */
FUNC_LEAVE(ret_value);
}
-
/*-------------------------------------------------------------------------
- * Function: H5F_flush
+ * Function: H5F_flush
*
- * Purpose: Flushes (and optionally invalidates) cached data plus the
- * file boot block. If the logical file size field is zero
- * then it is updated to be the length of the boot block.
+ * Purpose: Flushes (and optionally invalidates) cached data plus the
+ * file boot block. If the logical file size field is zero
+ * then it is updated to be the length of the boot block.
*
* Errors:
- * CACHE CANTFLUSH Can't flush cache.
- * IO WRITEERROR Can't write header.
+ * CACHE CANTFLUSH Can't flush cache.
+ * IO WRITEERROR Can't write header.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Aug 29 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Aug 29 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static herr_t
-H5F_flush (H5F_t *f, hbool_t invalidate)
+H5F_flush(H5F_t *f, hbool_t invalidate)
{
- uint8 buf[2048], *p=buf;
-
- FUNC_ENTER (H5F_flush, FAIL);
-
- /*
- * Nothing to do if the file is read only. This determination is made at
- * the shared open(2) flags level, implying that opening a file twice,
- * once for read-only and once for read-write, and then calling
- * H5F_flush() with the read-only handle, still causes data to be flushed.
- */
- if (0==(H5F_ACC_WRITE & f->shared->flags)) HRETURN (SUCCEED);
-
- /* flush (and invalidate) the entire cache */
- if (H5AC_flush (f, NULL, 0, invalidate)<0) {
- HRETURN_ERROR (H5E_CACHE, H5E_CANTFLUSH, FAIL, "can't flush cache");
- }
-
- /* encode the file boot block */
- HDmemcpy (p, H5F_SIGNATURE, H5F_SIGNATURE_LEN);
- p += H5F_SIGNATURE_LEN;
-
- *p++ = f->shared->create_parms.bootblock_ver;
- *p++ = f->shared->create_parms.smallobject_ver;
- *p++ = f->shared->create_parms.freespace_ver;
- *p++ = f->shared->create_parms.objectdir_ver;
- *p++ = f->shared->create_parms.sharedheader_ver;
- *p++ = H5F_SIZEOF_ADDR (f);
- *p++ = H5F_SIZEOF_SIZE (f);
- *p++ = 0; /*reserved*/
- UINT16ENCODE (p, f->shared->create_parms.sym_leaf_k);
- UINT16ENCODE (p, f->shared->create_parms.btree_k[H5B_SNODE_ID]);
- UINT32ENCODE (p, f->shared->consist_flags);
- H5F_addr_encode (f, &p, &(f->shared->base_addr));
- H5F_addr_encode (f, &p, &(f->shared->smallobj_addr));
- H5F_addr_encode (f, &p, &(f->shared->freespace_addr));
- H5F_addr_encode (f, &p, &(f->shared->hdf5_eof));
- H5G_ent_encode (f, &p, f->shared->root_ent);
-
- /* update file length if necessary */
- if (!H5F_addr_defined (&(f->shared->hdf5_eof))) {
- H5F_addr_reset (&(f->shared->hdf5_eof));
- H5F_addr_inc (&(f->shared->hdf5_eof), p-buf);
- H5F_low_seteof (f->shared->lf, &(f->shared->hdf5_eof));
- }
-
- /* write the boot block to disk */
- if (H5F_low_write (f->shared->lf, &(f->shared->boot_addr), p-buf, buf)<0) {
- HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "can't write header");
- }
-
- /* Flush file buffers to disk */
- if (H5F_low_flush (f->shared->lf)<0) {
- HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "low level flush failed");
- }
-
- FUNC_LEAVE (SUCCEED);
-}
+ uint8 buf[2048], *p = buf;
+
+ FUNC_ENTER(H5F_flush, FAIL);
+ /*
+ * Nothing to do if the file is read only. This determination is made at
+ * the shared open(2) flags level, implying that opening a file twice,
+ * once for read-only and once for read-write, and then calling
+ * H5F_flush() with the read-only handle, still causes data to be flushed.
+ */
+ if (0 == (H5F_ACC_WRITE & f->shared->flags))
+ HRETURN(SUCCEED);
+
+ /* flush (and invalidate) the entire cache */
+ if (H5AC_flush(f, NULL, 0, invalidate) < 0) {
+ HRETURN_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "can't flush cache");
+ }
+ /* encode the file boot block */
+ HDmemcpy(p, H5F_SIGNATURE, H5F_SIGNATURE_LEN);
+ p += H5F_SIGNATURE_LEN;
+
+ *p++ = f->shared->create_parms.bootblock_ver;
+ *p++ = f->shared->create_parms.smallobject_ver;
+ *p++ = f->shared->create_parms.freespace_ver;
+ *p++ = f->shared->create_parms.objectdir_ver;
+ *p++ = f->shared->create_parms.sharedheader_ver;
+ *p++ = H5F_SIZEOF_ADDR(f);
+ *p++ = H5F_SIZEOF_SIZE(f);
+ *p++ = 0; /*reserved */
+ UINT16ENCODE(p, f->shared->create_parms.sym_leaf_k);
+ UINT16ENCODE(p, f->shared->create_parms.btree_k[H5B_SNODE_ID]);
+ UINT32ENCODE(p, f->shared->consist_flags);
+ H5F_addr_encode(f, &p, &(f->shared->base_addr));
+ H5F_addr_encode(f, &p, &(f->shared->smallobj_addr));
+ H5F_addr_encode(f, &p, &(f->shared->freespace_addr));
+ H5F_addr_encode(f, &p, &(f->shared->hdf5_eof));
+ H5G_ent_encode(f, &p, f->shared->root_ent);
+
+ /* update file length if necessary */
+ if (!H5F_addr_defined(&(f->shared->hdf5_eof))) {
+ H5F_addr_reset(&(f->shared->hdf5_eof));
+ H5F_addr_inc(&(f->shared->hdf5_eof), p - buf);
+ H5F_low_seteof(f->shared->lf, &(f->shared->hdf5_eof));
+ }
+ /* write the boot block to disk */
+ if (H5F_low_write(f->shared->lf, &(f->shared->boot_addr), p - buf, buf) < 0) {
+ HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "can't write header");
+ }
+ /* Flush file buffers to disk */
+ if (H5F_low_flush(f->shared->lf) < 0) {
+ HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "low level flush failed");
+ }
+ FUNC_LEAVE(SUCCEED);
+}
/*-------------------------------------------------------------------------
- * Function: H5F_close
+ * Function: H5F_close
*
- * Purpose: Closes an open HDF5 file.
+ * Purpose: Closes an open HDF5 file.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Tuesday, September 23, 1997
*
* Modifications:
@@ -1234,48 +1203,47 @@ H5F_flush (H5F_t *f, hbool_t invalidate)
*-------------------------------------------------------------------------
*/
herr_t
-H5F_close (H5F_t *f)
+H5F_close(H5F_t *f)
{
- FUNC_ENTER (H5F_close, FAIL);
-
- /* Close all current working groups */
- while (H5G_pop (f)>=0) /*void*/;
-
- /* Flush the boot block and caches */
- if (H5F_flush (f, TRUE)<0) {
- HRETURN_ERROR (H5E_CACHE, H5E_CANTFLUSH, FAIL, "can't flush cache");
- }
-
- /*
- * If object headers are still open then delay deletion of resources until
- * they have all been closed. The file is in a consistent state now, so
- * forgetting to close everything is not a major problem.
- */
- if (f->nopen>0) {
+ FUNC_ENTER(H5F_close, FAIL);
+
+ /* Close all current working groups */
+ while (H5G_pop(f) >= 0) /*void */
+ ;
+
+ /* Flush the boot block and caches */
+ if (H5F_flush(f, TRUE) < 0) {
+ HRETURN_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "can't flush cache");
+ }
+ /*
+ * If object headers are still open then delay deletion of resources until
+ * they have all been closed. The file is in a consistent state now, so
+ * forgetting to close everything is not a major problem.
+ */
+ if (f->nopen > 0) {
#ifndef NDEBUG
- fprintf (stderr, "HDF5-DIAG: H5F_close: %d object header%s still "
- "open (file close will complete when %s closed)\n",
- f->nopen,
- 1==f->nopen?" is":"s are",
- 1==f->nopen?"that header is":"those headers are");
+ fprintf(stderr, "HDF5-DIAG: H5F_close: %d object header%s still "
+ "open (file close will complete when %s closed)\n",
+ f->nopen,
+ 1 == f->nopen ? " is" : "s are",
+ 1 == f->nopen ? "that header is" : "those headers are");
#endif
- f->close_pending = TRUE;
- HRETURN (SUCCEED);
- } else if (f->close_pending) {
+ f->close_pending = TRUE;
+ HRETURN(SUCCEED);
+ } else if (f->close_pending) {
#ifndef NDEBUG
- fprintf (stderr, "HDF5-DIAG: H5F_close: operation completed\n");
+ fprintf(stderr, "HDF5-DIAG: H5F_close: operation completed\n");
#endif
- }
-
-
- /* Dump debugging info */
- if (f->intent & H5F_ACC_DEBUG) H5AC_debug (f);
+ }
+ /* Dump debugging info */
+ if (f->intent & H5F_ACC_DEBUG)
+ H5AC_debug(f);
- /* Close files and release resources */
- H5F_low_close (f->shared->lf);
- f = H5F_dest (f);
+ /* Close files and release resources */
+ H5F_low_close(f->shared->lf);
+ f = H5F_dest(f);
- FUNC_LEAVE (SUCCEED);
+ FUNC_LEAVE(SUCCEED);
}
/*--------------------------------------------------------------------------
@@ -1311,240 +1279,234 @@ H5F_close (H5F_t *f)
The file boot block is flushed to disk since it's contents may have
changed.
--------------------------------------------------------------------------*/
-herr_t H5Fclose(hid_t fid)
+herr_t
+H5Fclose(hid_t fid)
{
- H5F_t *file=NULL; /* file struct for file to close */
- herr_t ret_value = SUCCEED;
+ H5F_t *file = NULL; /* file struct for file to close */
+ herr_t ret_value = SUCCEED;
FUNC_ENTER(H5Fclose, FAIL);
H5ECLEAR;
/* Check/fix arguments. */
- if (H5_FILE!=H5Aatom_group (fid))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file atom");
- if (NULL==(file=H5Aatom_object (fid)))
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't unatomize file");
+ if (H5_FILE != H5Aatom_group(fid))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file atom");
+ if (NULL == (file = H5Aatom_object(fid)))
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't unatomize file");
/* Close the file */
- ret_value = H5F_close (file);
-
+ ret_value = H5F_close(file);
+
/* Remove the file atom */
- if (NULL==H5Aremove_atom(fid)) {
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't remove atom");
+ if (NULL == H5Aremove_atom(fid)) {
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't remove atom");
}
-
-done:
- FUNC_LEAVE (ret_value<0?FAIL:SUCCEED);
+ done:
+ FUNC_LEAVE(ret_value < 0 ? FAIL : SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5F_block_read
+ * Function: H5F_block_read
*
- * Purpose: Reads some data from a file/server/etc into a buffer.
- * The data is contiguous. The address is relative to the base
- * address for the file.
+ * Purpose: Reads some data from a file/server/etc into a buffer.
+ * The data is contiguous. The address is relative to the base
+ * address for the file.
*
* Errors:
- * IO READERROR Low-level read failed.
+ * IO READERROR Low-level read failed.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jul 10 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jul 10 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
-H5F_block_read (H5F_t *f, const haddr_t *addr, size_t size, void *buf)
+H5F_block_read(H5F_t *f, const haddr_t *addr, size_t size, void *buf)
{
- haddr_t abs_addr;
-
- FUNC_ENTER (H5F_block_read, FAIL);
+ haddr_t abs_addr;
- if (0==size) return 0;
+ FUNC_ENTER(H5F_block_read, FAIL);
- /* convert the relative address to an absolute address */
- abs_addr = f->shared->base_addr;
- H5F_addr_add (&abs_addr, addr);
+ if (0 == size)
+ return 0;
- /* Read the data */
- if (H5F_low_read (f->shared->lf, &abs_addr, size, buf)<0) {
- HRETURN_ERROR (H5E_IO, H5E_READERROR, FAIL, "low-level read failed");
- }
+ /* convert the relative address to an absolute address */
+ abs_addr = f->shared->base_addr;
+ H5F_addr_add(&abs_addr, addr);
- FUNC_LEAVE (SUCCEED);
+ /* Read the data */
+ if (H5F_low_read(f->shared->lf, &abs_addr, size, buf) < 0) {
+ HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, "low-level read failed");
+ }
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5F_block_write
+ * Function: H5F_block_write
*
- * Purpose: Writes some data from memory to a file/server/etc. The
- * data is contiguous. The address is relative to the base
- * address.
+ * Purpose: Writes some data from memory to a file/server/etc. The
+ * data is contiguous. The address is relative to the base
+ * address.
*
* Errors:
- * IO WRITEERROR Low-level write failed.
- * IO WRITEERROR No write intent.
+ * IO WRITEERROR Low-level write failed.
+ * IO WRITEERROR No write intent.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jul 10 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jul 10 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
-H5F_block_write (H5F_t *f, const haddr_t *addr, size_t size, const void *buf)
+H5F_block_write(H5F_t *f, const haddr_t *addr, size_t size, const void *buf)
{
- haddr_t abs_addr;
-
- FUNC_ENTER (H5F_block_write, FAIL);
+ haddr_t abs_addr;
- if (0==size) return 0;
+ FUNC_ENTER(H5F_block_write, FAIL);
- if (0==(f->intent & H5F_ACC_WRITE)) {
- HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "no write intent");
- }
+ if (0 == size)
+ return 0;
- /* Convert the relative address to an absolute address */
- abs_addr = f->shared->base_addr;
- H5F_addr_add (&abs_addr, addr);
-
- /* Write the data */
- if (H5F_low_write (f->shared->lf, &abs_addr, size, buf)) {
- HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "low-level write failed");
- }
+ if (0 == (f->intent & H5F_ACC_WRITE)) {
+ HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "no write intent");
+ }
+ /* Convert the relative address to an absolute address */
+ abs_addr = f->shared->base_addr;
+ H5F_addr_add(&abs_addr, addr);
- FUNC_LEAVE (SUCCEED);
+ /* Write the data */
+ if (H5F_low_write(f->shared->lf, &abs_addr, size, buf)) {
+ HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "low-level write failed");
+ }
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5F_debug
+ * Function: H5F_debug
*
- * Purpose: Prints a file header to the specified stream. Each line
- * is indented and the field name occupies the specified width
- * number of characters.
+ * Purpose: Prints a file header to the specified stream. Each line
+ * is indented and the field name occupies the specified width
+ * number of characters.
*
* Errors:
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Aug 1 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Aug 1 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
-H5F_debug (H5F_t *f, const haddr_t *addr, FILE *stream, intn indent,
- intn fwidth)
+H5F_debug(H5F_t *f, const haddr_t *addr, FILE * stream, intn indent,
+ intn fwidth)
{
- FUNC_ENTER (H5F_debug, FAIL);
-
- /* check args */
- assert (f);
- assert (addr && H5F_addr_defined (addr));
- assert (stream);
- assert (indent>=0);
- assert (fwidth>=0);
+ FUNC_ENTER(H5F_debug, FAIL);
- /* debug */
- fprintf (stream, "%*sFile Boot Block...\n", indent, "");
-
- fprintf (stream, "%*s%-*s %s\n", indent, "", fwidth,
- "File name:",
- f->name);
- fprintf (stream, "%*s%-*s 0x%08x\n", indent, "", fwidth,
- "Flags",
- (unsigned)(f->shared->flags));
- fprintf (stream, "%*s%-*s %u\n", indent, "", fwidth,
- "Reference count:",
- (unsigned)(f->shared->nrefs));
- fprintf (stream, "%*s%-*s 0x%08lx\n", indent, "", fwidth,
- "Consistency flags:",
- (unsigned long)(f->shared->consist_flags));
-
- fprintf (stream, "%*s%-*s ", indent, "", fwidth,
- "Address of boot block:");
- H5F_addr_print (stream, &(f->shared->boot_addr));
- fprintf (stream, " (abs)\n");
-
- fprintf (stream, "%*s%-*s ", indent, "", fwidth,
- "Base address:");
- H5F_addr_print (stream, &(f->shared->base_addr));
- fprintf (stream, " (abs)\n");
-
- fprintf (stream, "%*s%-*s ", indent, "", fwidth,
- "Small object heap address:");
- H5F_addr_print (stream, &(f->shared->smallobj_addr));
- fprintf (stream, " (rel)\n");
-
- fprintf (stream, "%*s%-*s ", indent, "", fwidth,
- "Free list address:");
- H5F_addr_print (stream, &(f->shared->freespace_addr));
- fprintf (stream, " (rel)\n");
-
- fprintf (stream, "%*s%-*s ", indent, "", fwidth,
- "Total size of hdf5 data:");
- H5F_addr_print (stream, &(f->shared->hdf5_eof));
- fprintf (stream, " bytes\n");
-
- fprintf (stream, "%*s%-*s %lu bytes\n", indent, "", fwidth,
- "Size of user block:",
- (unsigned long)(f->shared->create_parms.userblock_size));
- fprintf (stream, "%*s%-*s %u bytes\n", indent, "", fwidth,
- "Size of file size_t type:",
- (unsigned)(f->shared->create_parms.sizeof_size));
- fprintf (stream, "%*s%-*s %u bytes\n", indent, "", fwidth,
- "Size of file haddr_t type:",
- (unsigned)(f->shared->create_parms.sizeof_addr));
- fprintf (stream, "%*s%-*s %u\n", indent, "", fwidth,
- "Symbol table leaf node 1/2 rank:",
- (unsigned)(f->shared->create_parms.sym_leaf_k));
- fprintf (stream, "%*s%-*s %u\n", indent, "", fwidth,
- "Symbol table internal node 1/2 rank:",
- (unsigned)(f->shared->create_parms.btree_k[H5B_SNODE_ID]));
- fprintf (stream, "%*s%-*s %u\n", indent, "", fwidth,
- "Boot block version number:",
- (unsigned)(f->shared->create_parms.bootblock_ver));
- fprintf (stream, "%*s%-*s %u\n", indent, "", fwidth,
- "Small object heap version number:",
- (unsigned)(f->shared->create_parms.smallobject_ver));
- fprintf (stream, "%*s%-*s %u\n", indent, "", fwidth,
- "Free list version number:",
- (unsigned)(f->shared->create_parms.freespace_ver));
- fprintf (stream, "%*s%-*s %u\n", indent, "", fwidth,
- "Object directory version number:",
- (unsigned)(f->shared->create_parms.objectdir_ver));
- fprintf (stream, "%*s%-*s %u\n", indent, "", fwidth,
- "Shared header version number:",
- (unsigned)(f->shared->create_parms.sharedheader_ver));
-
- fprintf (stream, "%*s%-*s %s\n", indent, "", fwidth,
- "Root symbol table entry:",
- f->shared->root_ent ? "" : "(none)");
- if (f->shared->root_ent) {
- H5G_ent_debug (f, f->shared->root_ent, stream,
- indent+3, MAX(0, fwidth-3));
- }
-
-
- FUNC_LEAVE (SUCCEED);
+ /* check args */
+ assert(f);
+ assert(addr && H5F_addr_defined(addr));
+ assert(stream);
+ assert(indent >= 0);
+ assert(fwidth >= 0);
+
+ /* debug */
+ fprintf(stream, "%*sFile Boot Block...\n", indent, "");
+
+ fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
+ "File name:",
+ f->name);
+ fprintf(stream, "%*s%-*s 0x%08x\n", indent, "", fwidth,
+ "Flags",
+ (unsigned) (f->shared->flags));
+ fprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
+ "Reference count:",
+ (unsigned) (f->shared->nrefs));
+ fprintf(stream, "%*s%-*s 0x%08lx\n", indent, "", fwidth,
+ "Consistency flags:",
+ (unsigned long) (f->shared->consist_flags));
+
+ fprintf(stream, "%*s%-*s ", indent, "", fwidth,
+ "Address of boot block:");
+ H5F_addr_print(stream, &(f->shared->boot_addr));
+ fprintf(stream, " (abs)\n");
+
+ fprintf(stream, "%*s%-*s ", indent, "", fwidth,
+ "Base address:");
+ H5F_addr_print(stream, &(f->shared->base_addr));
+ fprintf(stream, " (abs)\n");
+
+ fprintf(stream, "%*s%-*s ", indent, "", fwidth,
+ "Small object heap address:");
+ H5F_addr_print(stream, &(f->shared->smallobj_addr));
+ fprintf(stream, " (rel)\n");
+
+ fprintf(stream, "%*s%-*s ", indent, "", fwidth,
+ "Free list address:");
+ H5F_addr_print(stream, &(f->shared->freespace_addr));
+ fprintf(stream, " (rel)\n");
+
+ fprintf(stream, "%*s%-*s ", indent, "", fwidth,
+ "Total size of hdf5 data:");
+ H5F_addr_print(stream, &(f->shared->hdf5_eof));
+ fprintf(stream, " bytes\n");
+
+ fprintf(stream, "%*s%-*s %lu bytes\n", indent, "", fwidth,
+ "Size of user block:",
+ (unsigned long) (f->shared->create_parms.userblock_size));
+ fprintf(stream, "%*s%-*s %u bytes\n", indent, "", fwidth,
+ "Size of file size_t type:",
+ (unsigned) (f->shared->create_parms.sizeof_size));
+ fprintf(stream, "%*s%-*s %u bytes\n", indent, "", fwidth,
+ "Size of file haddr_t type:",
+ (unsigned) (f->shared->create_parms.sizeof_addr));
+ fprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
+ "Symbol table leaf node 1/2 rank:",
+ (unsigned) (f->shared->create_parms.sym_leaf_k));
+ fprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
+ "Symbol table internal node 1/2 rank:",
+ (unsigned) (f->shared->create_parms.btree_k[H5B_SNODE_ID]));
+ fprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
+ "Boot block version number:",
+ (unsigned) (f->shared->create_parms.bootblock_ver));
+ fprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
+ "Small object heap version number:",
+ (unsigned) (f->shared->create_parms.smallobject_ver));
+ fprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
+ "Free list version number:",
+ (unsigned) (f->shared->create_parms.freespace_ver));
+ fprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
+ "Object directory version number:",
+ (unsigned) (f->shared->create_parms.objectdir_ver));
+ fprintf(stream, "%*s%-*s %u\n", indent, "", fwidth,
+ "Shared header version number:",
+ (unsigned) (f->shared->create_parms.sharedheader_ver));
+
+ fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
+ "Root symbol table entry:",
+ f->shared->root_ent ? "" : "(none)");
+ if (f->shared->root_ent) {
+ H5G_ent_debug(f, f->shared->root_ent, stream,
+ indent + 3, MAX(0, fwidth - 3));
+ }
+ FUNC_LEAVE(SUCCEED);
}
diff --git a/src/H5Farray.c b/src/H5Farray.c
index 88dae0b..9b2d194 100644
--- a/src/H5Farray.c
+++ b/src/H5Farray.c
@@ -5,8 +5,8 @@
* Programmer: Robb Matzke <robb@arborea.spizella.com>
* Thursday, January 15, 1998
*
- * Purpose: Provides I/O facilities for multi-dimensional arrays of bytes
- * stored with various layout policies.
+ * Purpose: Provides I/O facilities for multi-dimensional arrays of bytes
+ * stored with various layout policies.
*/
#include <H5private.h>
#include <H5Dprivate.h>
@@ -16,25 +16,23 @@
#include <H5Oprivate.h>
/* Interface initialization */
-#define PABLO_MASK H5F_arr_mask
-#define INTERFACE_INIT NULL
-static intn interface_initialize_g = FALSE;
-
-
+#define PABLO_MASK H5F_arr_mask
+#define INTERFACE_INIT NULL
+static intn interface_initialize_g = FALSE;
/*-------------------------------------------------------------------------
- * Function: H5F_arr_create
+ * Function: H5F_arr_create
*
- * Purpose: Creates an array of bytes. When called to create an array of
- * some type, the fastest varying dimension corresponds to an
- * instance of that type. That is, a 10x20 array of int32 is
- * really a 10x20x4 array of bytes.
+ * Purpose: Creates an array of bytes. When called to create an array of
+ * some type, the fastest varying dimension corresponds to an
+ * instance of that type. That is, a 10x20 array of int32 is
+ * really a 10x20x4 array of bytes.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, January 16, 1998
*
* Modifications:
@@ -42,178 +40,180 @@ static intn interface_initialize_g = FALSE;
*-------------------------------------------------------------------------
*/
herr_t
-H5F_arr_create (H5F_t *f, struct H5O_layout_t *layout/*in,out*/)
+H5F_arr_create(H5F_t *f, struct H5O_layout_t *layout /*in,out */ )
{
- intn i;
- size_t nbytes;
-
- FUNC_ENTER (H5F_arr_create, FAIL);
-
- /* check args */
- assert (f);
- assert (layout);
- H5F_addr_undef (&(layout->addr)); /*just in case we fail*/
-
- switch (layout->type) {
- case H5D_CONTIGUOUS:
- /* Reserve space in the file for the entire array */
- for (i=0, nbytes=1; i<layout->ndims; i++) nbytes *= layout->dim[i];
- assert (nbytes>0);
- if (H5MF_alloc (f, H5MF_RAW, nbytes, &(layout->addr)/*out*/)<0) {
- HRETURN_ERROR (H5E_IO, H5E_NOSPACE, FAIL,
- "unable to reserve file space");
- }
- break;
-
- case H5D_CHUNKED:
- /* Create the root of the B-tree that describes chunked storage */
- if (H5F_istore_create (f, layout/*out*/)<0) {
- HRETURN_ERROR (H5E_IO, H5E_CANTINIT, FAIL,
- "unable to initialize chunked storage");
- }
- break;
-
- default:
- assert ("not implemented yet" && 0);
- HRETURN_ERROR (H5E_IO, H5E_UNSUPPORTED, FAIL,
- "unsupported storage layout");
- break;
- }
-
- FUNC_LEAVE (SUCCEED);
+ intn i;
+ size_t nbytes;
+
+ FUNC_ENTER(H5F_arr_create, FAIL);
+
+ /* check args */
+ assert(f);
+ assert(layout);
+ H5F_addr_undef(&(layout->addr)); /*just in case we fail */
+
+ switch (layout->type) {
+ case H5D_CONTIGUOUS:
+ /* Reserve space in the file for the entire array */
+ for (i = 0, nbytes = 1; i < layout->ndims; i++)
+ nbytes *= layout->dim[i];
+ assert(nbytes > 0);
+ if (H5MF_alloc(f, H5MF_RAW, nbytes, &(layout->addr) /*out */ ) < 0) {
+ HRETURN_ERROR(H5E_IO, H5E_NOSPACE, FAIL,
+ "unable to reserve file space");
+ }
+ break;
+
+ case H5D_CHUNKED:
+ /* Create the root of the B-tree that describes chunked storage */
+ if (H5F_istore_create(f, layout /*out */ ) < 0) {
+ HRETURN_ERROR(H5E_IO, H5E_CANTINIT, FAIL,
+ "unable to initialize chunked storage");
+ }
+ break;
+
+ default:
+ assert("not implemented yet" && 0);
+ HRETURN_ERROR(H5E_IO, H5E_UNSUPPORTED, FAIL,
+ "unsupported storage layout");
+ break;
+ }
+
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5F_arr_read
+ * Function: H5F_arr_read
*
- * Purpose: Reads a hyperslab of a file byte array into a byte array in
- * memory which has the same dimensions as the hyperslab.
+ * Purpose: Reads a hyperslab of a file byte array into a byte array in
+ * memory which has the same dimensions as the hyperslab.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, January 16, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-herr_t H5F_arr_read (H5F_t *f, const struct H5O_layout_t *layout,
- const size_t offset[], const size_t size[],
- void *buf/*out*/)
+herr_t
+H5F_arr_read(H5F_t *f, const struct H5O_layout_t *layout,
+ const size_t offset[], const size_t size[],
+ void *buf /*out */ )
{
- intn i;
- size_t nbytes;
- size_t zero_offset[H5O_LAYOUT_NDIMS];
-
- FUNC_ENTER (H5F_arr_read, FAIL);
-
- /* Check args */
- assert (f);
- assert (layout);
- if (!offset) {
- HDmemset (zero_offset, 0, sizeof zero_offset);
- offset = zero_offset;
- }
- assert (size);
- assert (buf);
-
- switch (layout->type) {
- case H5D_CONTIGUOUS:
- /*
- * We currently only support complete I/O.
- */
- for (i=0; i<layout->ndims; i++) {
- assert (0==offset[i]);
- assert (size[i]==layout->dim[i]);
- }
- for (i=0, nbytes=1; i<layout->ndims; i++) nbytes *= layout->dim[i];
- if (H5F_block_read (f, &(layout->addr), nbytes, buf)<0) {
- HRETURN_ERROR (H5E_IO, H5E_READERROR, FAIL, "block read failed");
- }
- break;
-
- case H5D_CHUNKED:
- if (H5F_istore_read (f, layout, offset, size, buf)<0) {
- HRETURN_ERROR (H5E_IO, H5E_READERROR, FAIL, "chunked read failed");
- }
- break;
-
- default:
- assert ("not implemented yet" && 0);
- HRETURN_ERROR (H5E_IO, H5E_UNSUPPORTED, FAIL,
- "unsupported storage layout");
- break;
- }
-
- FUNC_LEAVE (SUCCEED);
+ intn i;
+ size_t nbytes;
+ size_t zero_offset[H5O_LAYOUT_NDIMS];
+
+ FUNC_ENTER(H5F_arr_read, FAIL);
+
+ /* Check args */
+ assert(f);
+ assert(layout);
+ if (!offset) {
+ HDmemset(zero_offset, 0, sizeof zero_offset);
+ offset = zero_offset;
+ }
+ assert(size);
+ assert(buf);
+
+ switch (layout->type) {
+ case H5D_CONTIGUOUS:
+ /*
+ * We currently only support complete I/O.
+ */
+ for (i = 0; i < layout->ndims; i++) {
+ assert(0 == offset[i]);
+ assert(size[i] == layout->dim[i]);
+ }
+ for (i = 0, nbytes = 1; i < layout->ndims; i++)
+ nbytes *= layout->dim[i];
+ if (H5F_block_read(f, &(layout->addr), nbytes, buf) < 0) {
+ HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, "block read failed");
+ }
+ break;
+
+ case H5D_CHUNKED:
+ if (H5F_istore_read(f, layout, offset, size, buf) < 0) {
+ HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, "chunked read failed");
+ }
+ break;
+
+ default:
+ assert("not implemented yet" && 0);
+ HRETURN_ERROR(H5E_IO, H5E_UNSUPPORTED, FAIL,
+ "unsupported storage layout");
+ break;
+ }
+
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5F_arr_write
+ * Function: H5F_arr_write
*
- * Purpose: Writes an array to a hyperslab of a file byte array. The
- * memory array and the hyperslab are the same size.
+ * Purpose: Writes an array to a hyperslab of a file byte array. The
+ * memory array and the hyperslab are the same size.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, January 16, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-herr_t H5F_arr_write (H5F_t *f, const struct H5O_layout_t *layout,
- const size_t offset[], const size_t size[],
- const void *buf)
+herr_t
+H5F_arr_write(H5F_t *f, const struct H5O_layout_t *layout,
+ const size_t offset[], const size_t size[],
+ const void *buf)
{
- intn i;
- size_t nbytes;
-
- FUNC_ENTER (H5F_arr_write, FAIL);
-
- /* Check args */
- assert (f);
- assert (layout);
- assert (offset);
- assert (size);
- assert (buf);
-
- switch (layout->type) {
- case H5D_CONTIGUOUS:
- /*
- * We currently only support complete I/O.
- */
- for (i=0; i<layout->ndims; i++) {
- assert (0==offset[i]);
- assert (size[i]==layout->dim[i]);
- }
- for (i=0, nbytes=1; i<layout->ndims; i++) nbytes *= layout->dim[i];
- if (H5F_block_write (f, &(layout->addr), nbytes, buf)<0) {
- HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "block write failed");
- }
- break;
-
- case H5D_CHUNKED:
- if (H5F_istore_write (f, layout, offset, size, buf)<0) {
- HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "chunked write failed");
- }
- break;
-
- default:
- assert ("not implemented yet" && 0);
- HRETURN_ERROR (H5E_IO, H5E_UNSUPPORTED, FAIL,
- "unsupported storage layout");
- break;
- }
-
- FUNC_LEAVE (SUCCEED);
+ intn i;
+ size_t nbytes;
+
+ FUNC_ENTER(H5F_arr_write, FAIL);
+
+ /* Check args */
+ assert(f);
+ assert(layout);
+ assert(offset);
+ assert(size);
+ assert(buf);
+
+ switch (layout->type) {
+ case H5D_CONTIGUOUS:
+ /*
+ * We currently only support complete I/O.
+ */
+ for (i = 0; i < layout->ndims; i++) {
+ assert(0 == offset[i]);
+ assert(size[i] == layout->dim[i]);
+ }
+ for (i = 0, nbytes = 1; i < layout->ndims; i++)
+ nbytes *= layout->dim[i];
+ if (H5F_block_write(f, &(layout->addr), nbytes, buf) < 0) {
+ HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "block write failed");
+ }
+ break;
+
+ case H5D_CHUNKED:
+ if (H5F_istore_write(f, layout, offset, size, buf) < 0) {
+ HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "chunked write failed");
+ }
+ break;
+
+ default:
+ assert("not implemented yet" && 0);
+ HRETURN_ERROR(H5E_IO, H5E_UNSUPPORTED, FAIL,
+ "unsupported storage layout");
+ break;
+ }
+
+ FUNC_LEAVE(SUCCEED);
}
-
diff --git a/src/H5Fcore.c b/src/H5Fcore.c
index 0a8797f..9069df5 100644
--- a/src/H5Fcore.c
+++ b/src/H5Fcore.c
@@ -6,12 +6,12 @@
* Wednesday, October 22, 1997
*
* Purpose: This file implements an in-core temporary file. It's intended
- * for storing small temporary files such as wrappers generated
- * on the fly.
+ * for storing small temporary files such as wrappers generated
+ * on the fly.
*
* Note: This is mostly an exercise to help clean up parts of the H5F
- * package since this driver is quite different than the other
- * low level drivers we have so far.
+ * package since this driver is quite different than the other
+ * low level drivers we have so far.
*
*/
#include <H5private.h>
@@ -19,45 +19,46 @@
#include <H5Fprivate.h>
#include <H5MMprivate.h>
-#define H5F_CORE_INC 10240 /*amount by which to grow file */
-#define H5F_CORE_DEV 0xffff /*pseudo dev for core until we fix things*/
+#define H5F_CORE_INC 10240 /*amount by which to grow file */
+#define H5F_CORE_DEV 0xffff /*pseudo dev for core until we fix things */
-#define PABLO_MASK H5F_core
-static hbool_t interface_initialize_g = FALSE;
+#define PABLO_MASK H5F_core
+static hbool_t interface_initialize_g = FALSE;
#define INTERFACE_INIT NULL
-static hbool_t H5F_core_access (const char *name, int mode, H5F_search_t *key);
-static H5F_low_t *H5F_core_open (const char *name, uintn flags, H5F_search_t*);
-static herr_t H5F_core_close (H5F_low_t *lf);
-static herr_t H5F_core_read (H5F_low_t *lf, const haddr_t *addr, size_t size,
- uint8 *buf);
-static herr_t H5F_core_write (H5F_low_t *lf, const haddr_t *addr, size_t size,
- const uint8 *buf);
-
-const H5F_low_class_t H5F_LOW_CORE[1] = {{
- H5F_core_access, /* access method */
- H5F_core_open, /* open method */
- H5F_core_close, /* close method */
- H5F_core_read, /* read method */
- H5F_core_write, /* write method */
- NULL, /* flush method */
- NULL, /* extend method */
-}};
+static hbool_t H5F_core_access(const char *name, int mode, H5F_search_t *key);
+static H5F_low_t *H5F_core_open(const char *name, uintn flags, H5F_search_t *);
+static herr_t H5F_core_close(H5F_low_t *lf);
+static herr_t H5F_core_read(H5F_low_t *lf, const haddr_t *addr, size_t size,
+ uint8 *buf);
+static herr_t H5F_core_write(H5F_low_t *lf, const haddr_t *addr, size_t size,
+ const uint8 *buf);
+const H5F_low_class_t H5F_LOW_CORE[1] =
+{
+ {
+ H5F_core_access, /* access method */
+ H5F_core_open, /* open method */
+ H5F_core_close, /* close method */
+ H5F_core_read, /* read method */
+ H5F_core_write, /* write method */
+ NULL, /* flush method */
+ NULL, /* extend method */
+ }};
/*-------------------------------------------------------------------------
- * Function: H5F_core_access
+ * Function: H5F_core_access
*
- * Purpose: Determines if the specified file already exists. This driver
- * doesn't use names, so every call to H5F_core_open() would
- * create a new file. Therefore, this function always returns
- * false and KEY is never initialized.
+ * Purpose: Determines if the specified file already exists. This driver
+ * doesn't use names, so every call to H5F_core_open() would
+ * create a new file. Therefore, this function always returns
+ * false and KEY is never initialized.
*
- * Return: Success: FALSE
+ * Return: Success: FALSE
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, October 24, 1997
*
* Modifications:
@@ -65,74 +66,70 @@ const H5F_low_class_t H5F_LOW_CORE[1] = {{
*-------------------------------------------------------------------------
*/
static hbool_t
-H5F_core_access (const char *name, int mode, H5F_search_t *key/*out*/)
+H5F_core_access(const char *name, int mode, H5F_search_t *key /*out */ )
{
- FUNC_ENTER (H5F_core_access, FAIL);
- FUNC_LEAVE (FALSE);
+ FUNC_ENTER(H5F_core_access, FAIL);
+ FUNC_LEAVE(FALSE);
}
-
/*-------------------------------------------------------------------------
- * Function: H5F_core_open
+ * Function: H5F_core_open
*
- * Purpose: Opens a temporary file which will exist only in memory. The
- * NAME argument is unused. The FLAGS are a bit field with
- * the possible values defined in H5F_low_open().
+ * Purpose: Opens a temporary file which will exist only in memory. The
+ * NAME argument is unused. The FLAGS are a bit field with
+ * the possible values defined in H5F_low_open().
*
* Errors:
- * IO CANTOPENFILE Must creat file with write access.
+ * IO CANTOPENFILE Must creat file with write access.
*
- * Return: Success: Low-level file pointer
+ * Return: Success: Low-level file pointer
*
- * Failure: NULL
+ * Failure: NULL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, October 22, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-static H5F_low_t *
-H5F_core_open (const char *name, uintn flags, H5F_search_t *key)
+static H5F_low_t *
+H5F_core_open(const char *name, uintn flags, H5F_search_t *key)
{
- H5F_low_t *lf = NULL;
- static ino_t ino=0;
-
- FUNC_ENTER (H5F_core_open, NULL);
-
- if (0==(flags & H5F_ACC_WRITE) || 0==(flags & H5F_ACC_CREAT)) {
- HRETURN_ERROR (H5E_IO, H5E_CANTOPENFILE, NULL,
- "must creat file with write access");
- }
-
- lf = H5MM_xcalloc (1, sizeof(H5F_low_t));
- lf->u.core.mem = H5MM_xmalloc (H5F_CORE_INC);
- lf->u.core.alloc = H5F_CORE_INC;
- lf->u.core.size = 0;
- H5F_addr_reset (&(lf->eof));
-
- if (key) {
- key->dev = H5F_CORE_DEV;
- key->ino = ino++;
- }
-
- FUNC_LEAVE (lf);
+ H5F_low_t *lf = NULL;
+ static ino_t ino = 0;
+
+ FUNC_ENTER(H5F_core_open, NULL);
+
+ if (0 == (flags & H5F_ACC_WRITE) || 0 == (flags & H5F_ACC_CREAT)) {
+ HRETURN_ERROR(H5E_IO, H5E_CANTOPENFILE, NULL,
+ "must creat file with write access");
+ }
+ lf = H5MM_xcalloc(1, sizeof(H5F_low_t));
+ lf->u.core.mem = H5MM_xmalloc(H5F_CORE_INC);
+ lf->u.core.alloc = H5F_CORE_INC;
+ lf->u.core.size = 0;
+ H5F_addr_reset(&(lf->eof));
+
+ if (key) {
+ key->dev = H5F_CORE_DEV;
+ key->ino = ino++;
+ }
+ FUNC_LEAVE(lf);
}
-
/*-------------------------------------------------------------------------
- * Function: H5F_core_close
+ * Function: H5F_core_close
*
- * Purpose: Closes a file.
+ * Purpose: Closes a file.
*
* Errors:
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, October 22, 1997
*
* Modifications:
@@ -140,32 +137,31 @@ H5F_core_open (const char *name, uintn flags, H5F_search_t *key)
*-------------------------------------------------------------------------
*/
static herr_t
-H5F_core_close (H5F_low_t *lf)
+H5F_core_close(H5F_low_t *lf)
{
- FUNC_ENTER (H5F_core_close, FAIL);
+ FUNC_ENTER(H5F_core_close, FAIL);
- lf->u.core.mem = H5MM_xfree (lf->u.core.mem);
- lf->u.core.size = 0;
- lf->u.core.alloc = 0;
+ lf->u.core.mem = H5MM_xfree(lf->u.core.mem);
+ lf->u.core.size = 0;
+ lf->u.core.alloc = 0;
- FUNC_LEAVE (SUCCEED);
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5F_core_read
+ * Function: H5F_core_read
*
- * Purpose: Reads SIZE bytes beginning at address ADDR in file LF and
- * places them in buffer BUF. Reading past the logical or
- * physical end of the file returns zeros instead of failing.
+ * Purpose: Reads SIZE bytes beginning at address ADDR in file LF and
+ * places them in buffer BUF. Reading past the logical or
+ * physical end of the file returns zeros instead of failing.
*
* Errors:
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, October 22, 1997
*
* Modifications:
@@ -173,46 +169,44 @@ H5F_core_close (H5F_low_t *lf)
*-------------------------------------------------------------------------
*/
static herr_t
-H5F_core_read (H5F_low_t *lf, const haddr_t *addr, size_t size, uint8 *buf)
+H5F_core_read(H5F_low_t *lf, const haddr_t *addr, size_t size, uint8 *buf)
{
- size_t n;
- size_t eof;
-
- FUNC_ENTER (H5F_core_read, FAIL);
-
- assert (lf);
- assert (addr && H5F_addr_defined (addr));
- assert (buf);
-
- eof = MIN (lf->eof.offset, lf->u.core.size);
-
- if (addr->offset>=eof) {
- HDmemset (buf, 0, size);
- } else {
- n = MIN (size, eof - addr->offset);
- HDmemcpy (buf, lf->u.core.mem + addr->offset, n);
- HDmemset (buf+n, 0, size-n);
- }
-
- FUNC_LEAVE (SUCCEED);
-}
+ size_t n;
+ size_t eof;
+ FUNC_ENTER(H5F_core_read, FAIL);
+ assert(lf);
+ assert(addr && H5F_addr_defined(addr));
+ assert(buf);
+
+ eof = MIN(lf->eof.offset, lf->u.core.size);
+
+ if (addr->offset >= eof) {
+ HDmemset(buf, 0, size);
+ } else {
+ n = MIN(size, eof - addr->offset);
+ HDmemcpy(buf, lf->u.core.mem + addr->offset, n);
+ HDmemset(buf + n, 0, size - n);
+ }
+
+ FUNC_LEAVE(SUCCEED);
+}
/*-------------------------------------------------------------------------
- * Function: H5F_core_write
+ * Function: H5F_core_write
*
- * Purpose: Writes SIZE bytes from the beginning of BUF into file LF at
- * file address ADDR. The file is extended as necessary to
- * accommodate the new data.
+ * Purpose: Writes SIZE bytes from the beginning of BUF into file LF at
+ * file address ADDR. The file is extended as necessary to
+ * accommodate the new data.
*
* Errors:
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, October 22, 1997
*
* Modifications:
@@ -220,31 +214,29 @@ H5F_core_read (H5F_low_t *lf, const haddr_t *addr, size_t size, uint8 *buf)
*-------------------------------------------------------------------------
*/
static herr_t
-H5F_core_write (H5F_low_t *lf, const haddr_t *addr, size_t size,
- const uint8 *buf)
+H5F_core_write(H5F_low_t *lf, const haddr_t *addr, size_t size,
+ const uint8 *buf)
{
- size_t inc_amount;
-
- FUNC_ENTER (H5F_core_write, FAIL);
-
- assert (lf);
- assert (addr && H5F_addr_defined (addr));
- assert (buf);
-
- /* Allocate more space */
- if (addr->offset+size>lf->u.core.alloc) {
- inc_amount = MAX (addr->offset+size-lf->u.core.alloc, H5F_CORE_INC);
- lf->u.core.alloc = lf->u.core.alloc + inc_amount;
- lf->u.core.mem = H5MM_xrealloc (lf->u.core.mem, lf->u.core.alloc);
- }
-
- /* Move the physical EOF marker */
- if (addr->offset+size>lf->u.core.size) {
- lf->u.core.size = addr->offset + size;
- }
-
- /* Copy data */
- HDmemcpy (lf->u.core.mem+addr->offset, buf, size);
-
- FUNC_LEAVE (SUCCEED);
+ size_t inc_amount;
+
+ FUNC_ENTER(H5F_core_write, FAIL);
+
+ assert(lf);
+ assert(addr && H5F_addr_defined(addr));
+ assert(buf);
+
+ /* Allocate more space */
+ if (addr->offset + size > lf->u.core.alloc) {
+ inc_amount = MAX(addr->offset + size - lf->u.core.alloc, H5F_CORE_INC);
+ lf->u.core.alloc = lf->u.core.alloc + inc_amount;
+ lf->u.core.mem = H5MM_xrealloc(lf->u.core.mem, lf->u.core.alloc);
+ }
+ /* Move the physical EOF marker */
+ if (addr->offset + size > lf->u.core.size) {
+ lf->u.core.size = addr->offset + size;
+ }
+ /* Copy data */
+ HDmemcpy(lf->u.core.mem + addr->offset, buf, size);
+
+ FUNC_LEAVE(SUCCEED);
}
diff --git a/src/H5Ffamily.c b/src/H5Ffamily.c
index 3c4c35b..b85ca71 100644
--- a/src/H5Ffamily.c
+++ b/src/H5Ffamily.c
@@ -5,21 +5,21 @@
* Programmer: Robb Matzke <matzke@llnl.gov>
* Monday, November 10, 1997
*
- * Purpose: Implements a family of files that acts as a single hdf5
- * file. The purpose is to be able to split a huge file on a
- * 64-bit platform, transfer all the <2GB members to a 32-bit
- * platform, and then access the entire huge file on the 32-bit
- * platform.
- *
- * All family members are logically the same size although their
- * physical sizes may vary. The logical member size is
- * determined by looking at the physical size of the first
- * member and rounding that up to the next power of two. When
- * creating a file family, the first member is created with a
- * predefined physical size (actually, this happens when the
- * file family is flushed, and can be quite time consuming on
- * file systems that don't implement holes, like nfs).
- *
+ * Purpose: Implements a family of files that acts as a single hdf5
+ * file. The purpose is to be able to split a huge file on a
+ * 64-bit platform, transfer all the <2GB members to a 32-bit
+ * platform, and then access the entire huge file on the 32-bit
+ * platform.
+ *
+ * All family members are logically the same size although their
+ * physical sizes may vary. The logical member size is
+ * determined by looking at the physical size of the first
+ * member and rounding that up to the next power of two. When
+ * creating a file family, the first member is created with a
+ * predefined physical size (actually, this happens when the
+ * file family is flushed, and can be quite time consuming on
+ * file systems that don't implement holes, like nfs).
+ *
*/
#include <H5private.h>
#include <H5Eprivate.h>
@@ -27,7 +27,7 @@
#include <H5MMprivate.h>
#define PABLO_MASK H5F_family
-static hbool_t interface_initialize_g = FALSE;
+static hbool_t interface_initialize_g = FALSE;
#define INTERFACE_INIT NULL
/*
@@ -38,185 +38,184 @@ static hbool_t interface_initialize_g = FALSE;
* Smaller values result in files of a more manageable size (from a human
* perspective) but also limit the total logical size of the hdf5 file.
*/
-#define H5F_FAM_DFLT_NBITS 26u /*64MB*/
-
-#define H5F_FAM_MASK(N) (((uint64)1<<(N))-1)
-#define H5F_FAM_OFFSET(ADDR,N) ((ADDR)->offset & H5F_FAM_MASK(N))
-#define H5F_FAM_MEMBNO(ADDR,N) ((ADDR)->offset >> N)
-
-static hbool_t H5F_fam_access (const char *name, int mode, H5F_search_t *key);
-static H5F_low_t *H5F_fam_open (const char *name, uintn flags, H5F_search_t*);
-static herr_t H5F_fam_close (H5F_low_t *lf);
-static herr_t H5F_fam_read (H5F_low_t *lf, const haddr_t *addr, size_t size,
- uint8 *buf);
-static herr_t H5F_fam_write (H5F_low_t *lf, const haddr_t *addr, size_t size,
- const uint8 *buf);
-static herr_t H5F_fam_flush (H5F_low_t *lf);
-
-const H5F_low_class_t H5F_LOW_FAM[1] = {{
- H5F_fam_access, /* access method */
- H5F_fam_open, /* open method */
- H5F_fam_close, /* close method */
- H5F_fam_read, /* read method */
- H5F_fam_write, /* write method */
- H5F_fam_flush, /* flush method */
- NULL, /* extend method */
-}};
-
+#define H5F_FAM_DFLT_NBITS 26u /*64MB */
+
+#define H5F_FAM_MASK(N) (((uint64)1<<(N))-1)
+#define H5F_FAM_OFFSET(ADDR,N) ((ADDR)->offset & H5F_FAM_MASK(N))
+#define H5F_FAM_MEMBNO(ADDR,N) ((ADDR)->offset >> N)
+
+static hbool_t H5F_fam_access(const char *name, int mode, H5F_search_t *key);
+static H5F_low_t *H5F_fam_open(const char *name, uintn flags, H5F_search_t *);
+static herr_t H5F_fam_close(H5F_low_t *lf);
+static herr_t H5F_fam_read(H5F_low_t *lf, const haddr_t *addr, size_t size,
+ uint8 *buf);
+static herr_t H5F_fam_write(H5F_low_t *lf, const haddr_t *addr, size_t size,
+ const uint8 *buf);
+static herr_t H5F_fam_flush(H5F_low_t *lf);
+
+const H5F_low_class_t H5F_LOW_FAM[1] =
+{
+ {
+ H5F_fam_access, /* access method */
+ H5F_fam_open, /* open method */
+ H5F_fam_close, /* close method */
+ H5F_fam_read, /* read method */
+ H5F_fam_write, /* write method */
+ H5F_fam_flush, /* flush method */
+ NULL, /* extend method */
+ }};
/*-------------------------------------------------------------------------
- * Function: H5F_fam_open
+ * Function: H5F_fam_open
*
- * Purpose: Opens a file family with the specified base name. The name
- * should contain a printf-style "%d" field which will be
- * expanded with a zero-origin family member number.
+ * Purpose: Opens a file family with the specified base name. The name
+ * should contain a printf-style "%d" field which will be
+ * expanded with a zero-origin family member number.
*
- * Bugs: We don't check for overflow on the name, so keep it under
- * 4kb, please. Also, we don't actually check for the `%d'
- * field because we assume that the caller already did. Who
- * knows what happens when all the family member names are the
- * same!
+ * Bugs: We don't check for overflow on the name, so keep it under
+ * 4kb, please. Also, we don't actually check for the `%d'
+ * field because we assume that the caller already did. Who
+ * knows what happens when all the family member names are the
+ * same!
*
- * Return: Success: Low-level file pointer
+ * Return: Success: Low-level file pointer
*
- * Failure: NULL
+ * Failure: NULL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Monday, November 10, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-static H5F_low_t *
-H5F_fam_open (const char *name, uintn flags, H5F_search_t *key/*out*/)
+static H5F_low_t *
+H5F_fam_open(const char *name, uintn flags, H5F_search_t *key /*out */ )
{
- H5F_low_t *ret_value = NULL, *lf=NULL;
- H5F_low_t *member = NULL; /*a family member */
- char member_name[4096]; /*name of family member */
- intn membno; /*member number (zero-origin) */
- size_t nbits=H5F_FAM_DFLT_NBITS;/*num bits in an offset */
- haddr_t tmp_addr; /*temporary address */
-
- FUNC_ENTER (H5F_fam_open, NULL);
-
- /*
- * If we're truncating the file then delete all but the first family
- * member. Use the default number of bits for the offset.
- */
- if ((flags & H5F_ACC_WRITE) && (flags & H5F_ACC_TRUNC)) {
- for (membno=1; /*void*/; membno++) {
- sprintf (member_name, name, membno);
- if (!H5F_low_access (H5F_LOW_DFLT, member_name, F_OK, NULL)) {
- break;
- } else if (unlink (member_name)<0) {
- HGOTO_ERROR (H5E_IO, H5E_CANTINIT, NULL, "can't delete member");
- }
- }
- }
-
- /* Create the file descriptor */
- lf = H5MM_xcalloc (1, sizeof(H5F_low_t));
- lf->u.fam.name = H5MM_xstrdup (name);
- lf->u.fam.flags = (flags & ~H5F_ACC_CREAT);
-
- /* Open all existing members */
- for (membno=0; /*void*/; membno++) {
- sprintf (member_name, name, membno);
-
- /*
- * Open the family member. After the first member is opened or created,
- * turn off the creation flag so we don't create a zillion family
- * members.
- */
- member = H5F_low_open (H5F_LOW_DFLT, member_name, flags,
- 0==membno?key:NULL);
- if (!member) {
- if (0==membno) {
- HGOTO_ERROR (H5E_IO, H5E_CANTOPENFILE, NULL,
- "can't open first family member");
- }
- break;
- }
- flags &= ~H5F_ACC_CREAT;
-
- /* Add the member to the family */
- if (lf->u.fam.nmemb>=lf->u.fam.nalloc) {
- lf->u.fam.nalloc = MAX (100, 2*lf->u.fam.nalloc);
- lf->u.fam.memb = H5MM_xrealloc (lf->u.fam.memb,
- lf->u.fam.nalloc*sizeof(H5F_low_t*));
- }
- lf->u.fam.memb[lf->u.fam.nmemb++] = member;
- member = NULL;
- }
-
- /*
- * If the first and second files exists then round the first file size up
- * to the next power of two and use that as the number of bits per family
- * member.
- */
- if (lf->u.fam.nmemb>=2) {
- size_t size = H5F_low_size (lf->u.fam.memb[0], &tmp_addr);
- for (nbits=8*sizeof(size_t)-1; nbits>0; --nbits) {
- size_t mask = (size_t)1 << nbits;
- if (size & mask) {
- if (size != mask) {
- size++;
+ H5F_low_t *ret_value = NULL, *lf = NULL;
+ H5F_low_t *member = NULL; /*a family member */
+ char member_name[4096]; /*name of family member */
+ intn membno; /*member number (zero-origin) */
+ size_t nbits = H5F_FAM_DFLT_NBITS; /*num bits in an offset */
+ haddr_t tmp_addr; /*temporary address */
+
+ FUNC_ENTER(H5F_fam_open, NULL);
+
+ /*
+ * If we're truncating the file then delete all but the first family
+ * member. Use the default number of bits for the offset.
+ */
+ if ((flags & H5F_ACC_WRITE) && (flags & H5F_ACC_TRUNC)) {
+ for (membno = 1; /*void */ ; membno++) {
+ sprintf(member_name, name, membno);
+ if (!H5F_low_access(H5F_LOW_DFLT, member_name, F_OK, NULL)) {
+ break;
+ } else if (unlink(member_name) < 0) {
+ HGOTO_ERROR(H5E_IO, H5E_CANTINIT, NULL, "can't delete member");
+ }
+ }
+ }
+ /* Create the file descriptor */
+ lf = H5MM_xcalloc(1, sizeof(H5F_low_t));
+ lf->u.fam.name = H5MM_xstrdup(name);
+ lf->u.fam.flags = (flags & ~H5F_ACC_CREAT);
+
+ /* Open all existing members */
+ for (membno = 0; /*void */ ; membno++) {
+ sprintf(member_name, name, membno);
+
+ /*
+ * Open the family member. After the first member is opened or created,
+ * turn off the creation flag so we don't create a zillion family
+ * members.
+ */
+ member = H5F_low_open(H5F_LOW_DFLT, member_name, flags,
+ 0 == membno ? key : NULL);
+ if (!member) {
+ if (0 == membno) {
+ HGOTO_ERROR(H5E_IO, H5E_CANTOPENFILE, NULL,
+ "can't open first family member");
+ }
+ break;
+ }
+ flags &= ~H5F_ACC_CREAT;
+
+ /* Add the member to the family */
+ if (lf->u.fam.nmemb >= lf->u.fam.nalloc) {
+ lf->u.fam.nalloc = MAX(100, 2 * lf->u.fam.nalloc);
+ lf->u.fam.memb = H5MM_xrealloc(lf->u.fam.memb,
+ lf->u.fam.nalloc * sizeof(H5F_low_t *));
+ }
+ lf->u.fam.memb[lf->u.fam.nmemb++] = member;
+ member = NULL;
+ }
+
+ /*
+ * If the first and second files exists then round the first file size up
+ * to the next power of two and use that as the number of bits per family
+ * member.
+ */
+ if (lf->u.fam.nmemb >= 2) {
+ size_t size = H5F_low_size(lf->u.fam.memb[0], &tmp_addr);
+ for (nbits = 8 * sizeof(size_t) - 1; nbits > 0; --nbits) {
+ size_t mask = (size_t) 1 << nbits;
+ if (size & mask) {
+ if (size != mask) {
+ size++;
#ifdef H5F_DEBUG
- fprintf (stderr, "HDF5-DIAG: family member size was rounded up "
- "to a power of 2");
+ fprintf(stderr, "HDF5-DIAG: family member size was rounded up "
+ "to a power of 2");
#endif
- }
- break;
- }
- }
- }
- lf->u.fam.offset_bits = nbits;
-
+ }
+ break;
+ }
+ }
+ }
+ lf->u.fam.offset_bits = nbits;
+
#ifdef H5F_DEBUG
- if (nbits>=30) {
- fprintf (stderr, "HDF5-DIAG: family members are %dGB\n", 1<<(nbits-30));
- } else if (nbits>=20) {
- fprintf (stderr, "HDF5-DIAG: family members are %dMB\n", 1<<(nbits-20));
- } else if (nbits>=10) {
- fprintf (stderr, "HDF5-DIAG: family members are %dkB\n", 1<<(nbits-10));
- } else {
- fprintf (stderr, "HDF5-DIAG: family members are %d bytes\n", 1<<nbits);
- }
+ if (nbits >= 30) {
+ fprintf(stderr, "HDF5-DIAG: family members are %dGB\n", 1 << (nbits - 30));
+ } else if (nbits >= 20) {
+ fprintf(stderr, "HDF5-DIAG: family members are %dMB\n", 1 << (nbits - 20));
+ } else if (nbits >= 10) {
+ fprintf(stderr, "HDF5-DIAG: family members are %dkB\n", 1 << (nbits - 10));
+ } else {
+ fprintf(stderr, "HDF5-DIAG: family members are %d bytes\n", 1 << nbits);
+ }
#endif
- /*
- * Get the total family size and store it in the max_addr field.
- */
- assert (lf->u.fam.nmemb>=1);
- lf->eof.offset = (size_t)1 << lf->u.fam.offset_bits;
- lf->eof.offset *= (lf->u.fam.nmemb-1);
- lf->eof.offset += lf->u.fam.memb[lf->u.fam.nmemb-1]->eof.offset;
-
- HRETURN (lf);
-
- done:
- if (!ret_value) {
- if (lf) {
- H5F_fam_close (lf);
- H5MM_xfree (lf);
- }
- }
- FUNC_LEAVE (ret_value);
+ /*
+ * Get the total family size and store it in the max_addr field.
+ */
+ assert(lf->u.fam.nmemb >= 1);
+ lf->eof.offset = (size_t) 1 << lf->u.fam.offset_bits;
+ lf->eof.offset *= (lf->u.fam.nmemb - 1);
+ lf->eof.offset += lf->u.fam.memb[lf->u.fam.nmemb - 1]->eof.offset;
+
+ HRETURN(lf);
+
+ done:
+ if (!ret_value) {
+ if (lf) {
+ H5F_fam_close(lf);
+ H5MM_xfree(lf);
+ }
+ }
+ FUNC_LEAVE(ret_value);
}
-
/*-------------------------------------------------------------------------
- * Function: H5F_fam_close
+ * Function: H5F_fam_close
*
- * Purpose: Closes all members of a file family and releases resources
- * used by the file descriptor.
+ * Purpose: Closes all members of a file family and releases resources
+ * used by the file descriptor.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Monday, November 10, 1997
*
* Modifications:
@@ -224,41 +223,40 @@ H5F_fam_open (const char *name, uintn flags, H5F_search_t *key/*out*/)
*-------------------------------------------------------------------------
*/
static herr_t
-H5F_fam_close (H5F_low_t *lf)
+H5F_fam_close(H5F_low_t *lf)
{
- intn membno;
-
- FUNC_ENTER (H5F_fam_close, FAIL);
-
- assert (lf);
-
- for (membno=0; membno<lf->u.fam.nmemb; membno++) {
- lf->u.fam.memb[membno] = H5F_low_close (lf->u.fam.memb[membno]);
- }
- H5MM_xfree (lf->u.fam.memb);
- H5MM_xfree (lf->u.fam.name);
-
- FUNC_LEAVE (SUCCEED);
-}
+ intn membno;
+
+ FUNC_ENTER(H5F_fam_close, FAIL);
+ assert(lf);
+
+ for (membno = 0; membno < lf->u.fam.nmemb; membno++) {
+ lf->u.fam.memb[membno] = H5F_low_close(lf->u.fam.memb[membno]);
+ }
+ H5MM_xfree(lf->u.fam.memb);
+ H5MM_xfree(lf->u.fam.name);
+
+ FUNC_LEAVE(SUCCEED);
+}
/*-------------------------------------------------------------------------
- * Function: H5F_fam_read
+ * Function: H5F_fam_read
*
- * Purpose: Reads a chunk of contiguous data from the file family.
- * Reading past the physical end of a file returns zeros instead
- * of failing. We must insure that if the logical end of file is
- * before the physical end of file that we will read zeros there
- * also (the only time this can happen is if we create a family
- * and then close it before the first member is filled, since
- * flushing the file causes the first member to be physically
- * extended to it's maximum size).
+ * Purpose: Reads a chunk of contiguous data from the file family.
+ * Reading past the physical end of a file returns zeros instead
+ * of failing. We must insure that if the logical end of file is
+ * before the physical end of file that we will read zeros there
+ * also (the only time this can happen is if we create a family
+ * and then close it before the first member is filled, since
+ * flushing the file causes the first member to be physically
+ * extended to it's maximum size).
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Monday, November 10, 1997
*
* Modifications:
@@ -266,61 +264,60 @@ H5F_fam_close (H5F_low_t *lf)
*-------------------------------------------------------------------------
*/
static herr_t
-H5F_fam_read (H5F_low_t *lf, const haddr_t *addr, size_t size, uint8 *buf)
+H5F_fam_read(H5F_low_t *lf, const haddr_t *addr, size_t size, uint8 *buf)
{
- size_t nbytes;
- haddr_t cur_addr;
- uintn membno;
- off_t offset;
- size_t member_size;
-
- FUNC_ENTER (H5F_fam_read, FAIL);
-
- assert (lf);
- assert (addr && H5F_addr_defined (addr));
- assert (buf);
-
- member_size = (size_t)1 << lf->u.fam.offset_bits;
- membno = H5F_FAM_MEMBNO (addr, lf->u.fam.offset_bits);
- offset = H5F_FAM_OFFSET (addr, lf->u.fam.offset_bits);
- cur_addr = *addr;
-
- while (size>0) {
- if (membno>=lf->u.fam.nmemb) {
- HDmemset (buf, 0, size);
- break;
- } else {
- nbytes = MIN (size, member_size-offset);
- cur_addr.offset = offset;
- if (H5F_low_read (lf->u.fam.memb[membno], &cur_addr,
- nbytes, buf)<0) {
- HRETURN_ERROR (H5E_IO, H5E_READERROR, FAIL,
- "can't read from family member");
- }
- buf += nbytes;
- size -= nbytes;
- membno++;
- offset=0;
- }
- }
-
- FUNC_LEAVE (SUCCEED);
+ size_t nbytes;
+ haddr_t cur_addr;
+ uintn membno;
+ off_t offset;
+ size_t member_size;
+
+ FUNC_ENTER(H5F_fam_read, FAIL);
+
+ assert(lf);
+ assert(addr && H5F_addr_defined(addr));
+ assert(buf);
+
+ member_size = (size_t) 1 << lf->u.fam.offset_bits;
+ membno = H5F_FAM_MEMBNO(addr, lf->u.fam.offset_bits);
+ offset = H5F_FAM_OFFSET(addr, lf->u.fam.offset_bits);
+ cur_addr = *addr;
+
+ while (size > 0) {
+ if (membno >= lf->u.fam.nmemb) {
+ HDmemset(buf, 0, size);
+ break;
+ } else {
+ nbytes = MIN(size, member_size - offset);
+ cur_addr.offset = offset;
+ if (H5F_low_read(lf->u.fam.memb[membno], &cur_addr,
+ nbytes, buf) < 0) {
+ HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL,
+ "can't read from family member");
+ }
+ buf += nbytes;
+ size -= nbytes;
+ membno++;
+ offset = 0;
+ }
+ }
+
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5F_fam_write
+ * Function: H5F_fam_write
*
- * Purpose: Writes BUF to the family of files. The superclass has
- * already insured that we aren't writing past the logical end
- * of file, so this function will extend the physical file to
- * accommodate the new data if necessary.
+ * Purpose: Writes BUF to the family of files. The superclass has
+ * already insured that we aren't writing past the logical end
+ * of file, so this function will extend the physical file to
+ * accommodate the new data if necessary.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Monday, November 10, 1997
*
* Modifications:
@@ -328,105 +325,100 @@ H5F_fam_read (H5F_low_t *lf, const haddr_t *addr, size_t size, uint8 *buf)
*-------------------------------------------------------------------------
*/
static herr_t
-H5F_fam_write (H5F_low_t *lf, const haddr_t *addr, size_t size,
- const uint8 *buf)
+H5F_fam_write(H5F_low_t *lf, const haddr_t *addr, size_t size,
+ const uint8 *buf)
{
- size_t nbytes;
- haddr_t cur_addr, max_addr;
- uintn membno;
- off_t offset;
- H5F_low_t *member = NULL;
- char member_name[4096];
- intn i;
- size_t member_size;
-
- FUNC_ENTER (H5F_fam_write, FAIL);
-
- assert (lf);
- assert (addr && H5F_addr_defined (addr));
- assert (buf);
-
- member_size = (size_t)1 << lf->u.fam.offset_bits;
- membno = H5F_FAM_MEMBNO (addr, lf->u.fam.offset_bits);
- offset = H5F_FAM_OFFSET (addr, lf->u.fam.offset_bits);
- cur_addr = *addr;
-
- while (size>0) {
- nbytes = MIN (size, member_size-offset);
- cur_addr.offset = offset;
-
- if (membno>=lf->u.fam.nmemb) {
- /*
- * We're writing past the end of the last family member--create the
- * new family member(s)
- */
- for (i=lf->u.fam.nmemb; i<=membno; i++) {
- sprintf (member_name, lf->u.fam.name, i);
- member = H5F_low_open (H5F_LOW_DFLT, member_name,
- lf->u.fam.flags|H5F_ACC_CREAT,
- NULL);
- if (!member) {
- HRETURN_ERROR (H5E_IO, H5E_CANTOPENFILE, FAIL,
- "can't create a new member");
- }
-
- /*
- * For members in the middle, set their logical eof to the
- * maximum possible value.
- */
- if (i<membno) {
- H5F_addr_reset (&max_addr);
- H5F_addr_inc (&max_addr, member_size);
- H5F_low_seteof (member, &max_addr);
- }
-
- if (lf->u.fam.nmemb>=lf->u.fam.nalloc) {
- lf->u.fam.nalloc *= 2;
- lf->u.fam.memb = H5MM_xrealloc (lf->u.fam.memb,
- (lf->u.fam.nalloc *
- sizeof(H5F_low_t*)));
- }
- lf->u.fam.memb[lf->u.fam.nmemb++] = member;
- }
- }
-
- /*
- * Make sure the logical eof is large enough to handle the request.
- */
- max_addr = cur_addr;
- H5F_addr_inc (&max_addr, nbytes);
- H5F_low_seteof (lf->u.fam.memb[membno], &max_addr);
-
-
- /* Write the data to the member */
- if (H5F_low_write (lf->u.fam.memb[membno], &cur_addr,
- nbytes, buf)<0) {
- HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL,
- "can't write to family member");
- }
- buf += nbytes;
- size -= nbytes;
- membno++;
- offset=0;
- }
-
- FUNC_LEAVE (SUCCEED);
+ size_t nbytes;
+ haddr_t cur_addr, max_addr;
+ uintn membno;
+ off_t offset;
+ H5F_low_t *member = NULL;
+ char member_name[4096];
+ intn i;
+ size_t member_size;
+
+ FUNC_ENTER(H5F_fam_write, FAIL);
+
+ assert(lf);
+ assert(addr && H5F_addr_defined(addr));
+ assert(buf);
+
+ member_size = (size_t) 1 << lf->u.fam.offset_bits;
+ membno = H5F_FAM_MEMBNO(addr, lf->u.fam.offset_bits);
+ offset = H5F_FAM_OFFSET(addr, lf->u.fam.offset_bits);
+ cur_addr = *addr;
+
+ while (size > 0) {
+ nbytes = MIN(size, member_size - offset);
+ cur_addr.offset = offset;
+
+ if (membno >= lf->u.fam.nmemb) {
+ /*
+ * We're writing past the end of the last family member--create the
+ * new family member(s)
+ */
+ for (i = lf->u.fam.nmemb; i <= membno; i++) {
+ sprintf(member_name, lf->u.fam.name, i);
+ member = H5F_low_open(H5F_LOW_DFLT, member_name,
+ lf->u.fam.flags | H5F_ACC_CREAT,
+ NULL);
+ if (!member) {
+ HRETURN_ERROR(H5E_IO, H5E_CANTOPENFILE, FAIL,
+ "can't create a new member");
+ }
+ /*
+ * For members in the middle, set their logical eof to the
+ * maximum possible value.
+ */
+ if (i < membno) {
+ H5F_addr_reset(&max_addr);
+ H5F_addr_inc(&max_addr, member_size);
+ H5F_low_seteof(member, &max_addr);
+ }
+ if (lf->u.fam.nmemb >= lf->u.fam.nalloc) {
+ lf->u.fam.nalloc *= 2;
+ lf->u.fam.memb = H5MM_xrealloc(lf->u.fam.memb,
+ (lf->u.fam.nalloc *
+ sizeof(H5F_low_t *)));
+ }
+ lf->u.fam.memb[lf->u.fam.nmemb++] = member;
+ }
+ }
+ /*
+ * Make sure the logical eof is large enough to handle the request.
+ */
+ max_addr = cur_addr;
+ H5F_addr_inc(&max_addr, nbytes);
+ H5F_low_seteof(lf->u.fam.memb[membno], &max_addr);
+
+ /* Write the data to the member */
+ if (H5F_low_write(lf->u.fam.memb[membno], &cur_addr,
+ nbytes, buf) < 0) {
+ HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,
+ "can't write to family member");
+ }
+ buf += nbytes;
+ size -= nbytes;
+ membno++;
+ offset = 0;
+ }
+
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5F_fam_flush
+ * Function: H5F_fam_flush
*
- * Purpose: Flushes all data to disk and makes sure that the first member
- * is as large as a member can be so we can accurately detect
- * the member size if we open this file for read access at a
- * later date.
+ * Purpose: Flushes all data to disk and makes sure that the first member
+ * is as large as a member can be so we can accurately detect
+ * the member size if we open this file for read access at a
+ * later date.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Monday, November 10, 1997
*
* Modifications:
@@ -434,68 +426,66 @@ H5F_fam_write (H5F_low_t *lf, const haddr_t *addr, size_t size,
*-------------------------------------------------------------------------
*/
static herr_t
-H5F_fam_flush (H5F_low_t *lf)
+H5F_fam_flush(H5F_low_t *lf)
{
- int membno, nerrors=0;
- uint8 buf[1];
- haddr_t addr1, addr2, addr3;
- size_t max_offset;
-
- FUNC_ENTER (H5F_fam_flush, FAIL);
-
- /*
- * Make sure that the first family member is the maximum size because
- * H5F_fam_open() looks at the size of the first member to determine the
- * number of bits to use for each family member offset. We do this by
- * reading the last possible byte from the member (which defaults to zero
- * if we're reading past the end of the member) and then writing it back.
- */
- max_offset = H5F_FAM_MASK (lf->u.fam.offset_bits);
- H5F_addr_reset (&addr1);
- H5F_addr_inc (&addr1, max_offset);
- H5F_low_size (lf->u.fam.memb[0], &addr2); /*remember logical eof*/
- addr3 = addr1;
- H5F_addr_inc (&addr3, (size_t)1);
- H5F_low_seteof (lf->u.fam.memb[0], &addr3); /*prevent a warning*/
- if (H5F_low_read (lf->u.fam.memb[0], &addr1, 1, buf)<0) {
- HRETURN_ERROR (H5E_IO, H5E_READERROR, FAIL,
- "can't read from first family member");
- }
- if (H5F_low_write (lf->u.fam.memb[0], &addr1, 1, buf)<0) {
- HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL,
- "can't write to first family member");
- }
- H5F_low_seteof (lf->u.fam.memb[0], &addr2); /*reset old eof*/
-
- /*
- * Flush each member file. Don't return an error status until we've
- * flushed as much as possible.
- */
- for (membno=0; membno<lf->u.fam.nmemb; membno++) {
- if (H5F_low_flush (lf->u.fam.memb[membno])<0) {
- nerrors++;
- }
- }
- if (nerrors) {
- HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL,
- "can't flush family member");
- }
-
- FUNC_LEAVE (SUCCEED);
+ int membno, nerrors = 0;
+ uint8 buf[1];
+ haddr_t addr1, addr2, addr3;
+ size_t max_offset;
+
+ FUNC_ENTER(H5F_fam_flush, FAIL);
+
+ /*
+ * Make sure that the first family member is the maximum size because
+ * H5F_fam_open() looks at the size of the first member to determine the
+ * number of bits to use for each family member offset. We do this by
+ * reading the last possible byte from the member (which defaults to zero
+ * if we're reading past the end of the member) and then writing it back.
+ */
+ max_offset = H5F_FAM_MASK(lf->u.fam.offset_bits);
+ H5F_addr_reset(&addr1);
+ H5F_addr_inc(&addr1, max_offset);
+ H5F_low_size(lf->u.fam.memb[0], &addr2); /*remember logical eof */
+ addr3 = addr1;
+ H5F_addr_inc(&addr3, (size_t) 1);
+ H5F_low_seteof(lf->u.fam.memb[0], &addr3); /*prevent a warning */
+ if (H5F_low_read(lf->u.fam.memb[0], &addr1, 1, buf) < 0) {
+ HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL,
+ "can't read from first family member");
+ }
+ if (H5F_low_write(lf->u.fam.memb[0], &addr1, 1, buf) < 0) {
+ HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,
+ "can't write to first family member");
+ }
+ H5F_low_seteof(lf->u.fam.memb[0], &addr2); /*reset old eof */
+
+ /*
+ * Flush each member file. Don't return an error status until we've
+ * flushed as much as possible.
+ */
+ for (membno = 0; membno < lf->u.fam.nmemb; membno++) {
+ if (H5F_low_flush(lf->u.fam.memb[membno]) < 0) {
+ nerrors++;
+ }
+ }
+ if (nerrors) {
+ HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,
+ "can't flush family member");
+ }
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5F_fam_access
+ * Function: H5F_fam_access
*
- * Purpose: Determines if all members of the file family can be accessed
- * and returns the key for the first member of the family.
+ * Purpose: Determines if all members of the file family can be accessed
+ * and returns the key for the first member of the family.
*
- * Return: Success: TRUE or FALSE
+ * Return: Success: TRUE or FALSE
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Monday, November 10, 1997
*
* Modifications:
@@ -503,46 +493,45 @@ H5F_fam_flush (H5F_low_t *lf)
*-------------------------------------------------------------------------
*/
static hbool_t
-H5F_fam_access (const char *name, int mode, H5F_search_t *key/*out*/)
+H5F_fam_access(const char *name, int mode, H5F_search_t *key /*out */ )
{
- intn membno;
- char member_name[4096];
- hbool_t status;
-
- FUNC_ENTER (H5F_fam_access, FAIL);
-
- for (membno=0; /*void*/; membno++) {
- sprintf (member_name, name, membno);
- status = H5F_low_access (H5F_LOW_DFLT, member_name, mode,
- 0==membno?key:NULL);
-
- if (!status) {
- if (F_OK==mode) {
- /*
- * If we didn't find a member then we must have gotten to the end
- * of the family. As long as we found the first member(s) the
- * family exists.
- */
- HRETURN (membno>0);
- } else if (H5F_low_access (H5F_LOW_DFLT, member_name, F_OK, NULL)) {
- /*
- * The file exists but didn't have the write access permissions.
- */
- HRETURN (FALSE);
- } else {
- /*
- * The file doesn't exist because we got to the end of the
- * family.
- */
- HRETURN (TRUE);
- }
- }
-
- if (status<0) {
- HRETURN_ERROR (H5E_IO, H5E_CANTOPENFILE, FAIL,
- "access method failed for a member file");
- }
- }
-
- FUNC_LEAVE (TRUE);
+ intn membno;
+ char member_name[4096];
+ hbool_t status;
+
+ FUNC_ENTER(H5F_fam_access, FAIL);
+
+ for (membno = 0; /*void */ ; membno++) {
+ sprintf(member_name, name, membno);
+ status = H5F_low_access(H5F_LOW_DFLT, member_name, mode,
+ 0 == membno ? key : NULL);
+
+ if (!status) {
+ if (F_OK == mode) {
+ /*
+ * If we didn't find a member then we must have gotten to the end
+ * of the family. As long as we found the first member(s) the
+ * family exists.
+ */
+ HRETURN(membno > 0);
+ } else if (H5F_low_access(H5F_LOW_DFLT, member_name, F_OK, NULL)) {
+ /*
+ * The file exists but didn't have the write access permissions.
+ */
+ HRETURN(FALSE);
+ } else {
+ /*
+ * The file doesn't exist because we got to the end of the
+ * family.
+ */
+ HRETURN(TRUE);
+ }
+ }
+ if (status < 0) {
+ HRETURN_ERROR(H5E_IO, H5E_CANTOPENFILE, FAIL,
+ "access method failed for a member file");
+ }
+ }
+
+ FUNC_LEAVE(TRUE);
}
diff --git a/src/H5Fistore.c b/src/H5Fistore.c
index fa53b91..10f9eae 100644
--- a/src/H5Fistore.c
+++ b/src/H5Fistore.c
@@ -15,47 +15,45 @@
#include <H5Vprivate.h>
typedef enum H5F_isop_t {
- H5F_ISTORE_READ, /*read from file to memory */
- H5F_ISTORE_WRITE /*write from memory to file */
+ H5F_ISTORE_READ, /*read from file to memory */
+ H5F_ISTORE_WRITE /*write from memory to file */
} H5F_isop_t;
/* Does the array domain include negative indices? */
#undef H5F_ISTORE_NEGATIVE_DOMAIN
-
-#define PABLO_MASK H5F_istore_mask
+#define PABLO_MASK H5F_istore_mask
/* Interface initialization */
-static hbool_t interface_initialize_g = FALSE;
+static hbool_t interface_initialize_g = FALSE;
#define INTERFACE_INIT NULL
/* PRIVATE PROTOTYPES */
-static size_t H5F_istore_sizeof_rkey (H5F_t *f, const void *_udata);
-static herr_t H5F_istore_new_node (H5F_t *f, H5B_ins_t, void *_lt_key,
- void *_udata, void *_rt_key, haddr_t*);
-static intn H5F_istore_cmp2 (H5F_t *f, void *_lt_key, void *_udata,
- void *_rt_key);
-static intn H5F_istore_cmp3 (H5F_t *f, void *_lt_key, void *_udata,
- void *_rt_key);
-static herr_t H5F_istore_found (H5F_t *f, const haddr_t *addr,
- const void *_lt_key, void *_udata,
- const void *_rt_key);
-static H5B_ins_t H5F_istore_insert (H5F_t *f, const haddr_t *addr,
- void *_lt_key, hbool_t *lt_key_changed,
- void *_md_key, void *_udata,
- void *_rt_key, hbool_t *rt_key_changed,
- haddr_t*);
-static herr_t H5F_istore_decode_key (H5F_t *f, H5B_t *bt, uint8 *raw,
- void *_key);
-static herr_t H5F_istore_encode_key (H5F_t *f, H5B_t *bt, uint8 *raw,
- void *_key);
-static herr_t H5F_istore_copy_hyperslab (H5F_t *f, const H5O_layout_t *layout,
- H5F_isop_t op,
- const size_t offset_f[],
- const size_t size[],
- const size_t offset_m[],
- const size_t size_m[], void *buf);
-
+static size_t H5F_istore_sizeof_rkey(H5F_t *f, const void *_udata);
+static herr_t H5F_istore_new_node(H5F_t *f, H5B_ins_t, void *_lt_key,
+ void *_udata, void *_rt_key, haddr_t *);
+static intn H5F_istore_cmp2(H5F_t *f, void *_lt_key, void *_udata,
+ void *_rt_key);
+static intn H5F_istore_cmp3(H5F_t *f, void *_lt_key, void *_udata,
+ void *_rt_key);
+static herr_t H5F_istore_found(H5F_t *f, const haddr_t *addr,
+ const void *_lt_key, void *_udata,
+ const void *_rt_key);
+static H5B_ins_t H5F_istore_insert(H5F_t *f, const haddr_t *addr,
+ void *_lt_key, hbool_t *lt_key_changed,
+ void *_md_key, void *_udata,
+ void *_rt_key, hbool_t *rt_key_changed,
+ haddr_t *);
+static herr_t H5F_istore_decode_key(H5F_t *f, H5B_t *bt, uint8 *raw,
+ void *_key);
+static herr_t H5F_istore_encode_key(H5F_t *f, H5B_t *bt, uint8 *raw,
+ void *_key);
+static herr_t H5F_istore_copy_hyperslab(H5F_t *f, const H5O_layout_t *layout,
+ H5F_isop_t op,
+ const size_t offset_f[],
+ const size_t size[],
+ const size_t offset_m[],
+ const size_t size_m[], void *buf);
/*
* B-tree key. A key contains the minimum logical N-dimensional address and
@@ -72,49 +70,49 @@ static herr_t H5F_istore_copy_hyperslab (H5F_t *f, const H5O_layout_t *layout,
* The storage file address is part of the B-tree and not part of the key.
*/
typedef struct H5F_istore_key_t {
- uintn file_number; /*external file number */
- size_t offset[H5O_LAYOUT_NDIMS]; /*logical offset to start*/
- size_t size[H5O_LAYOUT_NDIMS]; /*logical chunk size */
+ uintn file_number; /*external file number */
+ size_t offset[H5O_LAYOUT_NDIMS]; /*logical offset to start */
+ size_t size[H5O_LAYOUT_NDIMS]; /*logical chunk size */
} H5F_istore_key_t;
typedef struct H5F_istore_ud1_t {
- H5F_istore_key_t key; /*key values */
- haddr_t addr; /*file address of chunk */
- H5O_layout_t mesg; /*layout message */
+ H5F_istore_key_t key; /*key values */
+ haddr_t addr; /*file address of chunk */
+ H5O_layout_t mesg; /*layout message */
} H5F_istore_ud1_t;
-
-/* inherits B-tree like properties from H5B */
-H5B_class_t H5B_ISTORE[1] = {{
- H5B_ISTORE_ID, /*id */
- sizeof (H5F_istore_key_t), /*sizeof_nkey */
- H5F_istore_sizeof_rkey, /*get_sizeof_rkey */
- H5F_istore_new_node, /*new */
- H5F_istore_cmp2, /*cmp2 */
- H5F_istore_cmp3, /*cmp3 */
- H5F_istore_found, /*found */
- H5F_istore_insert, /*insert */
- FALSE, /*follow min branch? */
- FALSE, /*follow max branch? */
- NULL, /*list */
- H5F_istore_decode_key, /*decode */
- H5F_istore_encode_key, /*encode */
-}};
-
+/* inherits B-tree like properties from H5B */
+H5B_class_t H5B_ISTORE[1] =
+{
+ {
+ H5B_ISTORE_ID, /*id */
+ sizeof(H5F_istore_key_t), /*sizeof_nkey */
+ H5F_istore_sizeof_rkey, /*get_sizeof_rkey */
+ H5F_istore_new_node, /*new */
+ H5F_istore_cmp2, /*cmp2 */
+ H5F_istore_cmp3, /*cmp3 */
+ H5F_istore_found, /*found */
+ H5F_istore_insert, /*insert */
+ FALSE, /*follow min branch? */
+ FALSE, /*follow max branch? */
+ NULL, /*list */
+ H5F_istore_decode_key, /*decode */
+ H5F_istore_encode_key, /*encode */
+ }};
/*-------------------------------------------------------------------------
- * Function: H5F_istore_sizeof_rkey
+ * Function: H5F_istore_sizeof_rkey
*
- * Purpose: Returns the size of a raw key for the specified UDATA. The
- * size of the key is dependent on the number of dimensions for
- * the object to which this B-tree points. The dimensionality
- * of the UDATA is the only portion that's referenced here.
+ * Purpose: Returns the size of a raw key for the specified UDATA. The
+ * size of the key is dependent on the number of dimensions for
+ * the object to which this B-tree points. The dimensionality
+ * of the UDATA is the only portion that's referenced here.
*
- * Return: Success: Size of raw key in bytes.
+ * Return: Success: Size of raw key in bytes.
*
- * Failure: abort()
+ * Failure: abort()
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, October 8, 1997
*
* Modifications:
@@ -122,33 +120,31 @@ H5B_class_t H5B_ISTORE[1] = {{
*-------------------------------------------------------------------------
*/
static size_t
-H5F_istore_sizeof_rkey (H5F_t *f, const void *_udata)
+H5F_istore_sizeof_rkey(H5F_t *f, const void *_udata)
{
- const H5F_istore_ud1_t *udata = (const H5F_istore_ud1_t *)_udata;
- size_t nbytes;
+ const H5F_istore_ud1_t *udata = (const H5F_istore_ud1_t *) _udata;
+ size_t nbytes;
- assert (udata);
- assert (udata->mesg.ndims>0 && udata->mesg.ndims<=H5O_LAYOUT_NDIMS);
-
- nbytes = 4 + /*external file number */
- udata->mesg.ndims * 4 + /*dimension indices */
- udata->mesg.ndims * 4; /*dimension sizes */
-
- return nbytes;
-}
+ assert(udata);
+ assert(udata->mesg.ndims > 0 && udata->mesg.ndims <= H5O_LAYOUT_NDIMS);
+ nbytes = 4 + /*external file number */
+ udata->mesg.ndims * 4 + /*dimension indices */
+ udata->mesg.ndims * 4; /*dimension sizes */
+ return nbytes;
+}
/*-------------------------------------------------------------------------
- * Function: H5F_istore_decode_key
+ * Function: H5F_istore_decode_key
*
- * Purpose: Decodes a raw key into a native key for the B-tree
+ * Purpose: Decodes a raw key into a native key for the B-tree
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, October 10, 1997
*
* Modifications:
@@ -156,44 +152,43 @@ H5F_istore_sizeof_rkey (H5F_t *f, const void *_udata)
*-------------------------------------------------------------------------
*/
static herr_t
-H5F_istore_decode_key (H5F_t *f, H5B_t *bt, uint8 *raw, void *_key)
+H5F_istore_decode_key(H5F_t *f, H5B_t *bt, uint8 *raw, void *_key)
{
- H5F_istore_key_t *key = (H5F_istore_key_t *)_key;
- int i;
- int ndims = bt->sizeof_rkey / 8;
+ H5F_istore_key_t *key = (H5F_istore_key_t *) _key;
+ int i;
+ int ndims = bt->sizeof_rkey / 8;
- FUNC_ENTER (H5F_istore_decode_key, FAIL);
+ FUNC_ENTER(H5F_istore_decode_key, FAIL);
- /* check args */
- assert (f);
- assert (bt);
- assert (raw);
- assert (key);
- assert (ndims>0 && ndims<=H5O_LAYOUT_NDIMS);
+ /* check args */
+ assert(f);
+ assert(bt);
+ assert(raw);
+ assert(key);
+ assert(ndims > 0 && ndims <= H5O_LAYOUT_NDIMS);
- /* decode */
- UINT32DECODE (raw, key->file_number);
- assert (0==key->file_number);
- for (i=0; i<ndims; i++) {
- UINT32DECODE (raw, key->offset[i]);
- UINT32DECODE (raw, key->size[i]);
- }
+ /* decode */
+ UINT32DECODE(raw, key->file_number);
+ assert(0 == key->file_number);
+ for (i = 0; i < ndims; i++) {
+ UINT32DECODE(raw, key->offset[i]);
+ UINT32DECODE(raw, key->size[i]);
+ }
- FUNC_LEAVE (SUCCEED);
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5F_istore_encode_key
+ * Function: H5F_istore_encode_key
*
- * Purpose: Encode a key from native format to raw format.
+ * Purpose: Encode a key from native format to raw format.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, October 10, 1997
*
* Modifications:
@@ -201,48 +196,47 @@ H5F_istore_decode_key (H5F_t *f, H5B_t *bt, uint8 *raw, void *_key)
*-------------------------------------------------------------------------
*/
static herr_t
-H5F_istore_encode_key (H5F_t *f, H5B_t *bt, uint8 *raw, void *_key)
+H5F_istore_encode_key(H5F_t *f, H5B_t *bt, uint8 *raw, void *_key)
{
- H5F_istore_key_t *key = (H5F_istore_key_t *)_key;
- intn ndims = bt->sizeof_rkey / 8;
- intn i;
-
- FUNC_ENTER (H5F_istore_encode_key, FAIL);
-
- /* check args */
- assert (f);
- assert (bt);
- assert (raw);
- assert (key);
- assert (ndims>0 && ndims<=H5O_LAYOUT_NDIMS);
-
- /* encode */
- UINT32ENCODE (raw, key->file_number);
- assert (0==key->file_number);
- for (i=0; i<ndims; i++) {
- UINT32ENCODE (raw, key->offset[i]);
- UINT32ENCODE (raw, key->size[i]);
- }
-
- FUNC_LEAVE (SUCCEED);
+ H5F_istore_key_t *key = (H5F_istore_key_t *) _key;
+ intn ndims = bt->sizeof_rkey / 8;
+ intn i;
+
+ FUNC_ENTER(H5F_istore_encode_key, FAIL);
+
+ /* check args */
+ assert(f);
+ assert(bt);
+ assert(raw);
+ assert(key);
+ assert(ndims > 0 && ndims <= H5O_LAYOUT_NDIMS);
+
+ /* encode */
+ UINT32ENCODE(raw, key->file_number);
+ assert(0 == key->file_number);
+ for (i = 0; i < ndims; i++) {
+ UINT32ENCODE(raw, key->offset[i]);
+ UINT32ENCODE(raw, key->size[i]);
+ }
+
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5F_istore_cmp2
+ * Function: H5F_istore_cmp2
*
- * Purpose: Compares two keys sort of like strcmp(). The UDATA pointer
- * is only to supply extra information not carried in the keys
- * (in this case, the dimensionality) and is not compared
- * against the keys.
+ * Purpose: Compares two keys sort of like strcmp(). The UDATA pointer
+ * is only to supply extra information not carried in the keys
+ * (in this case, the dimensionality) and is not compared
+ * against the keys.
*
- * Return: Success: -1 if LT_KEY is less than RT_KEY;
- * 1 if LT_KEY is greater than RT_KEY;
- * 0 if LT_KEY and RT_KEY are equal.
+ * Return: Success: -1 if LT_KEY is less than RT_KEY;
+ * 1 if LT_KEY is greater than RT_KEY;
+ * 0 if LT_KEY and RT_KEY are equal.
*
- * Failure: FAIL (same as LT_KEY<RT_KEY)
+ * Failure: FAIL (same as LT_KEY<RT_KEY)
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Thursday, November 6, 1997
*
* Modifications:
@@ -250,50 +244,49 @@ H5F_istore_encode_key (H5F_t *f, H5B_t *bt, uint8 *raw, void *_key)
*-------------------------------------------------------------------------
*/
static intn
-H5F_istore_cmp2 (H5F_t *f, void *_lt_key, void *_udata, void *_rt_key)
+H5F_istore_cmp2(H5F_t *f, void *_lt_key, void *_udata, void *_rt_key)
{
- H5F_istore_key_t *lt_key = (H5F_istore_key_t *)_lt_key;
- H5F_istore_key_t *rt_key = (H5F_istore_key_t *)_rt_key;
- H5F_istore_ud1_t *udata = (H5F_istore_ud1_t *)_udata;
- intn cmp;
+ H5F_istore_key_t *lt_key = (H5F_istore_key_t *) _lt_key;
+ H5F_istore_key_t *rt_key = (H5F_istore_key_t *) _rt_key;
+ H5F_istore_ud1_t *udata = (H5F_istore_ud1_t *) _udata;
+ intn cmp;
- FUNC_ENTER (H5F_istore_cmp2, FAIL);
+ FUNC_ENTER(H5F_istore_cmp2, FAIL);
- assert (lt_key);
- assert (rt_key);
- assert (udata);
- assert (udata->mesg.ndims>0 && udata->mesg.ndims<=H5O_LAYOUT_NDIMS);
+ assert(lt_key);
+ assert(rt_key);
+ assert(udata);
+ assert(udata->mesg.ndims > 0 && udata->mesg.ndims <= H5O_LAYOUT_NDIMS);
- /* Compare the offsets but ignore the other fields */
- cmp = H5V_vector_cmp (udata->mesg.ndims, lt_key->offset, rt_key->offset);
+ /* Compare the offsets but ignore the other fields */
+ cmp = H5V_vector_cmp(udata->mesg.ndims, lt_key->offset, rt_key->offset);
- FUNC_LEAVE (cmp);
+ FUNC_LEAVE(cmp);
}
-
/*-------------------------------------------------------------------------
- * Function: H5F_istore_cmp3
+ * Function: H5F_istore_cmp3
*
- * Purpose: Compare the requested datum UDATA with the left and right
- * keys of the B-tree.
+ * Purpose: Compare the requested datum UDATA with the left and right
+ * keys of the B-tree.
*
- * Return: Success: negative if the min_corner of UDATA is less
- * than the min_corner of LT_KEY.
+ * Return: Success: negative if the min_corner of UDATA is less
+ * than the min_corner of LT_KEY.
*
- * positive if the min_corner of UDATA is
- * greater than or equal the min_corner of
- * RT_KEY.
+ * positive if the min_corner of UDATA is
+ * greater than or equal the min_corner of
+ * RT_KEY.
*
- * zero otherwise. The min_corner of UDATA is
- * not necessarily contained within the address
- * space represented by LT_KEY, but a key that
- * would describe the UDATA min_corner address
- * would fall lexicographically between LT_KEY
- * and RT_KEY.
- *
- * Failure: FAIL (same as UDATA < LT_KEY)
+ * zero otherwise. The min_corner of UDATA is
+ * not necessarily contained within the address
+ * space represented by LT_KEY, but a key that
+ * would describe the UDATA min_corner address
+ * would fall lexicographically between LT_KEY
+ * and RT_KEY.
+ *
+ * Failure: FAIL (same as UDATA < LT_KEY)
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, October 8, 1997
*
* Modifications:
@@ -301,45 +294,43 @@ H5F_istore_cmp2 (H5F_t *f, void *_lt_key, void *_udata, void *_rt_key)
*-------------------------------------------------------------------------
*/
static intn
-H5F_istore_cmp3 (H5F_t *f, void *_lt_key, void *_udata, void *_rt_key)
+H5F_istore_cmp3(H5F_t *f, void *_lt_key, void *_udata, void *_rt_key)
{
- H5F_istore_key_t *lt_key = (H5F_istore_key_t *)_lt_key;
- H5F_istore_key_t *rt_key = (H5F_istore_key_t *)_rt_key;
- H5F_istore_ud1_t *udata = (H5F_istore_ud1_t *)_udata;
- intn cmp = 0;
-
- FUNC_ENTER (H5F_istore_cmp3, FAIL);
-
- assert (lt_key);
- assert (rt_key);
- assert (udata);
- assert (udata->mesg.ndims>0 && udata->mesg.ndims<=H5O_LAYOUT_NDIMS);
-
- if (H5V_vector_lt (udata->mesg.ndims, udata->key.offset, lt_key->offset)) {
- cmp = -1;
- } else if (H5V_vector_ge (udata->mesg.ndims, udata->key.offset,
- rt_key->offset)) {
- cmp = 1;
- }
-
- FUNC_LEAVE (cmp);
+ H5F_istore_key_t *lt_key = (H5F_istore_key_t *) _lt_key;
+ H5F_istore_key_t *rt_key = (H5F_istore_key_t *) _rt_key;
+ H5F_istore_ud1_t *udata = (H5F_istore_ud1_t *) _udata;
+ intn cmp = 0;
+
+ FUNC_ENTER(H5F_istore_cmp3, FAIL);
+
+ assert(lt_key);
+ assert(rt_key);
+ assert(udata);
+ assert(udata->mesg.ndims > 0 && udata->mesg.ndims <= H5O_LAYOUT_NDIMS);
+
+ if (H5V_vector_lt(udata->mesg.ndims, udata->key.offset, lt_key->offset)) {
+ cmp = -1;
+ } else if (H5V_vector_ge(udata->mesg.ndims, udata->key.offset,
+ rt_key->offset)) {
+ cmp = 1;
+ }
+ FUNC_LEAVE(cmp);
}
-
/*-------------------------------------------------------------------------
- * Function: H5F_istore_new_node
+ * Function: H5F_istore_new_node
*
- * Purpose: Adds a new entry to an i-storage B-tree. We can assume that
- * the domain represented by UDATA doesn't intersect the domain
- * already represented by the B-tree.
+ * Purpose: Adds a new entry to an i-storage B-tree. We can assume that
+ * the domain represented by UDATA doesn't intersect the domain
+ * already represented by the B-tree.
*
- * Return: Success: SUCCEED. The address of leaf is returned
- * through the ADDR argument. It is also added
- * to the UDATA.
+ * Return: Success: SUCCEED. The address of leaf is returned
+ * through the ADDR argument. It is also added
+ * to the UDATA.
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Tuesday, October 14, 1997
*
* Modifications:
@@ -347,78 +338,78 @@ H5F_istore_cmp3 (H5F_t *f, void *_lt_key, void *_udata, void *_rt_key)
*-------------------------------------------------------------------------
*/
static herr_t
-H5F_istore_new_node (H5F_t *f, H5B_ins_t op,
- void *_lt_key, void *_udata, void *_rt_key,
- haddr_t *addr/*out*/)
+H5F_istore_new_node(H5F_t *f, H5B_ins_t op,
+ void *_lt_key, void *_udata, void *_rt_key,
+ haddr_t *addr /*out */ )
{
- H5F_istore_key_t *lt_key = (H5F_istore_key_t *)_lt_key;
- H5F_istore_key_t *rt_key = (H5F_istore_key_t *)_rt_key;
- H5F_istore_ud1_t *udata = (H5F_istore_ud1_t *)_udata;
- size_t nbytes;
- intn i;
-
- FUNC_ENTER (H5F_istore_new_node, FAIL);
-
- /* check args */
- assert (f);
- assert (lt_key);
- assert (rt_key);
- assert (udata);
- assert (udata->mesg.ndims>=0 && udata->mesg.ndims<H5O_LAYOUT_NDIMS);
- assert (addr);
-
- /* Allocate new storage */
- nbytes = H5V_vector_reduce_product (udata->mesg.ndims, udata->key.size);
- assert (nbytes>0);
- if (H5MF_alloc (f, H5MF_RAW, nbytes, addr/*out*/)<0) {
- HRETURN_ERROR (H5E_IO, H5E_CANTINIT, FAIL,
- "couldn't allocate new file storage");
- }
- udata->addr = *addr;
- udata->key.file_number = 0;
- lt_key->file_number = udata->key.file_number;
- if (H5B_INS_LEFT!=op) rt_key->file_number = 0;
-
- /* Initialize the key(s) */
- for (i=0; i<udata->mesg.ndims; i++) {
- /*
- * The left key describes the storage of the UDATA chunk being inserted
- * into the tree.
- */
- assert (udata->key.size[i]>0);
- lt_key->offset[i] = udata->key.offset[i];
- lt_key->size[i] = udata->key.size[i];
-
- /*
- * The right key might already be present. If not, then add
- * a zero-width chunk.
- */
- if (H5B_INS_LEFT!=op) {
- rt_key->offset[i] = udata->key.offset[i] + udata->key.size[i];
- rt_key->size[i] = 0;
- }
- }
-
- FUNC_LEAVE (SUCCEED);
+ H5F_istore_key_t *lt_key = (H5F_istore_key_t *) _lt_key;
+ H5F_istore_key_t *rt_key = (H5F_istore_key_t *) _rt_key;
+ H5F_istore_ud1_t *udata = (H5F_istore_ud1_t *) _udata;
+ size_t nbytes;
+ intn i;
+
+ FUNC_ENTER(H5F_istore_new_node, FAIL);
+
+ /* check args */
+ assert(f);
+ assert(lt_key);
+ assert(rt_key);
+ assert(udata);
+ assert(udata->mesg.ndims >= 0 && udata->mesg.ndims < H5O_LAYOUT_NDIMS);
+ assert(addr);
+
+ /* Allocate new storage */
+ nbytes = H5V_vector_reduce_product(udata->mesg.ndims, udata->key.size);
+ assert(nbytes > 0);
+ if (H5MF_alloc(f, H5MF_RAW, nbytes, addr /*out */ ) < 0) {
+ HRETURN_ERROR(H5E_IO, H5E_CANTINIT, FAIL,
+ "couldn't allocate new file storage");
+ }
+ udata->addr = *addr;
+ udata->key.file_number = 0;
+ lt_key->file_number = udata->key.file_number;
+ if (H5B_INS_LEFT != op)
+ rt_key->file_number = 0;
+
+ /* Initialize the key(s) */
+ for (i = 0; i < udata->mesg.ndims; i++) {
+ /*
+ * The left key describes the storage of the UDATA chunk being inserted
+ * into the tree.
+ */
+ assert(udata->key.size[i] > 0);
+ lt_key->offset[i] = udata->key.offset[i];
+ lt_key->size[i] = udata->key.size[i];
+
+ /*
+ * The right key might already be present. If not, then add
+ * a zero-width chunk.
+ */
+ if (H5B_INS_LEFT != op) {
+ rt_key->offset[i] = udata->key.offset[i] + udata->key.size[i];
+ rt_key->size[i] = 0;
+ }
+ }
+
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5F_istore_found
+ * Function: H5F_istore_found
*
- * Purpose: This function is called when the B-tree search engine has
- * found the leaf entry that points to a chunk of storage that
- * contains the beginning of the logical address space
- * represented by UDATA. The LT_KEY is the left key (the one
- * that describes the chunk) and RT_KEY is the right key (the
- * one that describes the next or last chunk).
+ * Purpose: This function is called when the B-tree search engine has
+ * found the leaf entry that points to a chunk of storage that
+ * contains the beginning of the logical address space
+ * represented by UDATA. The LT_KEY is the left key (the one
+ * that describes the chunk) and RT_KEY is the right key (the
+ * one that describes the next or last chunk).
*
- * Return: Success: SUCCEED with information about the chunk
- * returned through the UDATA argument.
+ * Return: Success: SUCCEED with information about the chunk
+ * returned through the UDATA argument.
*
- * Failure: FAIL if not found.
+ * Failure: FAIL if not found.
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Thursday, October 9, 1997
*
* Modifications:
@@ -426,59 +417,58 @@ H5F_istore_new_node (H5F_t *f, H5B_ins_t op,
*-------------------------------------------------------------------------
*/
static herr_t
-H5F_istore_found (H5F_t *f, const haddr_t *addr, const void *_lt_key,
- void *_udata, const void *_rt_key)
+H5F_istore_found(H5F_t *f, const haddr_t *addr, const void *_lt_key,
+ void *_udata, const void *_rt_key)
{
- H5F_istore_ud1_t *udata = (H5F_istore_ud1_t *)_udata;
- const H5F_istore_key_t *lt_key = (const H5F_istore_key_t *)_lt_key;
- int i;
-
- FUNC_ENTER (H5F_istore_found, FAIL);
-
- /* Check arguments */
- assert (f);
- assert (addr && H5F_addr_defined (addr));
- assert (udata);
- assert (lt_key);
-
- /* Initialize return values */
- udata->addr = *addr;
- udata->key.file_number = lt_key->file_number;
- assert (0==lt_key->file_number);
- for (i=0; i<udata->mesg.ndims; i++) {
- udata->key.offset[i] = lt_key->offset[i];
- udata->key.size[i] = lt_key->size[i];
- assert (lt_key->size[i]>0);
- }
-
- FUNC_LEAVE (SUCCEED);
+ H5F_istore_ud1_t *udata = (H5F_istore_ud1_t *) _udata;
+ const H5F_istore_key_t *lt_key = (const H5F_istore_key_t *) _lt_key;
+ int i;
+
+ FUNC_ENTER(H5F_istore_found, FAIL);
+
+ /* Check arguments */
+ assert(f);
+ assert(addr && H5F_addr_defined(addr));
+ assert(udata);
+ assert(lt_key);
+
+ /* Initialize return values */
+ udata->addr = *addr;
+ udata->key.file_number = lt_key->file_number;
+ assert(0 == lt_key->file_number);
+ for (i = 0; i < udata->mesg.ndims; i++) {
+ udata->key.offset[i] = lt_key->offset[i];
+ udata->key.size[i] = lt_key->size[i];
+ assert(lt_key->size[i] > 0);
+ }
+
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5F_istore_insert
+ * Function: H5F_istore_insert
*
- * Purpose: This function is called when the B-tree insert engine finds
- * the node to use to insert new data. The UDATA argument
- * points to a struct that describes the logical addresses being
- * added to the file. This function allocates space for the
- * data and returns information through UDATA describing a
- * file chunk to receive (part of) the data.
+ * Purpose: This function is called when the B-tree insert engine finds
+ * the node to use to insert new data. The UDATA argument
+ * points to a struct that describes the logical addresses being
+ * added to the file. This function allocates space for the
+ * data and returns information through UDATA describing a
+ * file chunk to receive (part of) the data.
*
- * The LT_KEY is always the key describing the chunk of file
- * memory at address ADDR. On entry, UDATA describes the logical
- * addresses for which storage is being requested (through the
- * `offset' and `size' fields). On return, UDATA describes the
- * logical addresses contained in a chunk on disk.
+ * The LT_KEY is always the key describing the chunk of file
+ * memory at address ADDR. On entry, UDATA describes the logical
+ * addresses for which storage is being requested (through the
+ * `offset' and `size' fields). On return, UDATA describes the
+ * logical addresses contained in a chunk on disk.
*
- * Return: Success: An insertion command for the caller, one of
- * the H5B_INS_* constants. The address of the
- * new chunk is returned through the NEW_NODE
- * argument.
+ * Return: Success: An insertion command for the caller, one of
+ * the H5B_INS_* constants. The address of the
+ * new chunk is returned through the NEW_NODE
+ * argument.
*
- * Failure: H5B_INS_ERROR
+ * Failure: H5B_INS_ERROR
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Thursday, October 9, 1997
*
* Modifications:
@@ -486,117 +476,116 @@ H5F_istore_found (H5F_t *f, const haddr_t *addr, const void *_lt_key,
*-------------------------------------------------------------------------
*/
static H5B_ins_t
-H5F_istore_insert (H5F_t *f, const haddr_t *addr,
- void *_lt_key, hbool_t *lt_key_changed,
- void *_md_key, void *_udata,
- void *_rt_key, hbool_t *rt_key_changed,
- haddr_t *new_node/*out*/)
+H5F_istore_insert(H5F_t *f, const haddr_t *addr,
+ void *_lt_key, hbool_t *lt_key_changed,
+ void *_md_key, void *_udata,
+ void *_rt_key, hbool_t *rt_key_changed,
+ haddr_t *new_node /*out */ )
{
- H5F_istore_key_t *lt_key = (H5F_istore_key_t *)_lt_key;
- H5F_istore_key_t *md_key = (H5F_istore_key_t *)_md_key;
- H5F_istore_key_t *rt_key = (H5F_istore_key_t *)_rt_key;
- H5F_istore_ud1_t *udata = (H5F_istore_ud1_t *)_udata;
- intn i, cmp;
- H5B_ins_t ret_value = H5B_INS_ERROR;
- size_t nbytes;
-
- FUNC_ENTER (H5F_istore_insert, FAIL);
-
- /* check args */
- assert (f);
- assert (addr && H5F_addr_defined (addr));
- assert (lt_key);
- assert (lt_key_changed);
- assert (md_key);
- assert (udata);
- assert (rt_key);
- assert (rt_key_changed);
- assert (new_node);
-
- cmp = H5F_istore_cmp3 (f, lt_key, udata, rt_key);
- assert (cmp<=0);
-
- if (cmp<0) {
- /* Negative indices not supported yet */
- assert ("HDF5 INTERNAL ERROR -- see rpm" && 0);
- HRETURN_ERROR (H5E_STORAGE, H5E_UNSUPPORTED, FAIL, "internal error");
-
- } else if (H5V_hyper_eq (udata->mesg.ndims,
- udata->key.offset, udata->key.size,
- lt_key->offset, lt_key->size)) {
- /*
- * Already exists. Just return the info.
- */
- udata->addr = *addr;
- udata->key.file_number = lt_key->file_number;
- ret_value = H5B_INS_NOOP;
-
- } else if (H5V_hyper_disjointp (udata->mesg.ndims,
- lt_key->offset, lt_key->size,
- udata->key.offset, udata->key.size)) {
- assert (H5V_hyper_disjointp (udata->mesg.ndims,
- rt_key->offset, rt_key->size,
- udata->key.offset, udata->key.size));
-
- /*
- * Split this node, inserting the new new node to the right of the
- * current node. The MD_KEY is where the split occurs.
- */
- md_key->file_number = udata->key.file_number;
- for (i=0, nbytes=1; i<udata->mesg.ndims; i++) {
- assert (0==udata->key.offset[i] % udata->mesg.dim[i]);
- assert (udata->key.size[i] == udata->mesg.dim[i]);
- md_key->offset[i] = udata->key.offset[i];
- md_key->size[i] = udata->key.size[i];
- nbytes *= udata->key.size[i];
- }
-
- /*
- * Allocate storage for the new chunk
- */
- if (H5MF_alloc (f, H5MF_RAW, nbytes, new_node/*out*/)<0) {
- HRETURN_ERROR (H5E_IO, H5E_CANTINIT, FAIL,
- "file allocation failed");
- }
- udata->addr = *new_node;
- udata->key.file_number = 0;
- ret_value = H5B_INS_RIGHT;
-
- } else {
- assert ("HDF5 INTERNAL ERROR -- see rpm" && 0);
- HRETURN_ERROR (H5E_IO, H5E_UNSUPPORTED, FAIL, "internal error");
- }
-
- FUNC_LEAVE (ret_value);
+ H5F_istore_key_t *lt_key = (H5F_istore_key_t *) _lt_key;
+ H5F_istore_key_t *md_key = (H5F_istore_key_t *) _md_key;
+ H5F_istore_key_t *rt_key = (H5F_istore_key_t *) _rt_key;
+ H5F_istore_ud1_t *udata = (H5F_istore_ud1_t *) _udata;
+ intn i, cmp;
+ H5B_ins_t ret_value = H5B_INS_ERROR;
+ size_t nbytes;
+
+ FUNC_ENTER(H5F_istore_insert, FAIL);
+
+ /* check args */
+ assert(f);
+ assert(addr && H5F_addr_defined(addr));
+ assert(lt_key);
+ assert(lt_key_changed);
+ assert(md_key);
+ assert(udata);
+ assert(rt_key);
+ assert(rt_key_changed);
+ assert(new_node);
+
+ cmp = H5F_istore_cmp3(f, lt_key, udata, rt_key);
+ assert(cmp <= 0);
+
+ if (cmp < 0) {
+ /* Negative indices not supported yet */
+ assert("HDF5 INTERNAL ERROR -- see rpm" && 0);
+ HRETURN_ERROR(H5E_STORAGE, H5E_UNSUPPORTED, FAIL, "internal error");
+
+ } else if (H5V_hyper_eq(udata->mesg.ndims,
+ udata->key.offset, udata->key.size,
+ lt_key->offset, lt_key->size)) {
+ /*
+ * Already exists. Just return the info.
+ */
+ udata->addr = *addr;
+ udata->key.file_number = lt_key->file_number;
+ ret_value = H5B_INS_NOOP;
+
+ } else if (H5V_hyper_disjointp(udata->mesg.ndims,
+ lt_key->offset, lt_key->size,
+ udata->key.offset, udata->key.size)) {
+ assert(H5V_hyper_disjointp(udata->mesg.ndims,
+ rt_key->offset, rt_key->size,
+ udata->key.offset, udata->key.size));
+
+ /*
+ * Split this node, inserting the new new node to the right of the
+ * current node. The MD_KEY is where the split occurs.
+ */
+ md_key->file_number = udata->key.file_number;
+ for (i = 0, nbytes = 1; i < udata->mesg.ndims; i++) {
+ assert(0 == udata->key.offset[i] % udata->mesg.dim[i]);
+ assert(udata->key.size[i] == udata->mesg.dim[i]);
+ md_key->offset[i] = udata->key.offset[i];
+ md_key->size[i] = udata->key.size[i];
+ nbytes *= udata->key.size[i];
+ }
+
+ /*
+ * Allocate storage for the new chunk
+ */
+ if (H5MF_alloc(f, H5MF_RAW, nbytes, new_node /*out */ ) < 0) {
+ HRETURN_ERROR(H5E_IO, H5E_CANTINIT, FAIL,
+ "file allocation failed");
+ }
+ udata->addr = *new_node;
+ udata->key.file_number = 0;
+ ret_value = H5B_INS_RIGHT;
+
+ } else {
+ assert("HDF5 INTERNAL ERROR -- see rpm" && 0);
+ HRETURN_ERROR(H5E_IO, H5E_UNSUPPORTED, FAIL, "internal error");
+ }
+
+ FUNC_LEAVE(ret_value);
}
-
/*-------------------------------------------------------------------------
- * Function: H5F_istore_copy_hyperslab
+ * Function: H5F_istore_copy_hyperslab
*
- * Purpose: Reads or writes a hyperslab to disk depending on whether OP
- * is H5F_ISTORE_READ or H5F_ISTORE_WRITE. The hyperslab
- * storage is described with ISTORE and exists in file F. The
- * file hyperslab begins at location OFFSET_F[] (an N-dimensional
- * point in the domain in terms of elements) in the file and
- * OFFSET_M[] in memory pointed to by BUF. Its size is SIZE[]
- * elements. The dimensionality of memory is assumed to be the
- * same as the file and the total size of the multi-dimensional
- * memory buffer is SIZE_M[].
+ * Purpose: Reads or writes a hyperslab to disk depending on whether OP
+ * is H5F_ISTORE_READ or H5F_ISTORE_WRITE. The hyperslab
+ * storage is described with ISTORE and exists in file F. The
+ * file hyperslab begins at location OFFSET_F[] (an N-dimensional
+ * point in the domain in terms of elements) in the file and
+ * OFFSET_M[] in memory pointed to by BUF. Its size is SIZE[]
+ * elements. The dimensionality of memory is assumed to be the
+ * same as the file and the total size of the multi-dimensional
+ * memory buffer is SIZE_M[].
*
- * The slowest varying dimension is always listed first in the
- * various offset and size arrays.
+ * The slowest varying dimension is always listed first in the
+ * various offset and size arrays.
*
- * A `chunk' is a hyperslab of the disk array which is stored
- * contiguously. I/O occurs in units of chunks where the size of
- * a chunk is determined by the alignment constraints specified
- * in ISTORE.
+ * A `chunk' is a hyperslab of the disk array which is stored
+ * contiguously. I/O occurs in units of chunks where the size of
+ * a chunk is determined by the alignment constraints specified
+ * in ISTORE.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, October 17, 1997
*
* Modifications:
@@ -604,159 +593,159 @@ H5F_istore_insert (H5F_t *f, const haddr_t *addr,
*-------------------------------------------------------------------------
*/
static herr_t
-H5F_istore_copy_hyperslab (H5F_t *f, const H5O_layout_t *layout, H5F_isop_t op,
- const size_t offset_f[], const size_t size[],
- const size_t offset_m[], const size_t size_m[],
- void *buf)
+H5F_istore_copy_hyperslab(H5F_t *f, const H5O_layout_t *layout, H5F_isop_t op,
+ const size_t offset_f[], const size_t size[],
+ const size_t offset_m[], const size_t size_m[],
+ void *buf)
{
- intn i, carry;
- size_t idx_cur[H5O_LAYOUT_NDIMS];
- size_t idx_min[H5O_LAYOUT_NDIMS];
- size_t idx_max[H5O_LAYOUT_NDIMS];
- size_t sub_size[H5O_LAYOUT_NDIMS];
- size_t offset_wrt_chunk[H5O_LAYOUT_NDIMS];
- size_t sub_offset_m[H5O_LAYOUT_NDIMS];
- size_t chunk_size;
- uint8 *chunk=NULL;
- H5F_istore_ud1_t udata;
- herr_t status;
- herr_t ret_value = FAIL;
-
- FUNC_ENTER (H5F_istore_copy_hyperslab, FAIL);
-
- /* check args */
- assert (f);
- assert (layout && H5D_CHUNKED==layout->type);
- assert (H5F_addr_defined (&(layout->addr)));
- assert (layout->ndims>0 && layout->ndims<=H5O_LAYOUT_NDIMS);
- assert (H5F_ISTORE_READ==op || H5F_ISTORE_WRITE==op);
- assert (size);
- assert (size_m);
- assert (buf);
+ intn i, carry;
+ size_t idx_cur[H5O_LAYOUT_NDIMS];
+ size_t idx_min[H5O_LAYOUT_NDIMS];
+ size_t idx_max[H5O_LAYOUT_NDIMS];
+ size_t sub_size[H5O_LAYOUT_NDIMS];
+ size_t offset_wrt_chunk[H5O_LAYOUT_NDIMS];
+ size_t sub_offset_m[H5O_LAYOUT_NDIMS];
+ size_t chunk_size;
+ uint8 *chunk = NULL;
+ H5F_istore_ud1_t udata;
+ herr_t status;
+ herr_t ret_value = FAIL;
+
+ FUNC_ENTER(H5F_istore_copy_hyperslab, FAIL);
+
+ /* check args */
+ assert(f);
+ assert(layout && H5D_CHUNKED == layout->type);
+ assert(H5F_addr_defined(&(layout->addr)));
+ assert(layout->ndims > 0 && layout->ndims <= H5O_LAYOUT_NDIMS);
+ assert(H5F_ISTORE_READ == op || H5F_ISTORE_WRITE == op);
+ assert(size);
+ assert(size_m);
+ assert(buf);
#ifndef NDEBUG
- for (i=0; i<layout->ndims; i++) {
- assert (!offset_f || offset_f[i]>=0);/*neg domains unsupported */
- assert (!offset_m || offset_m[i]>=0);/*mem array offset never neg */
- assert (size[i]>=0); /*size may be zero, implies no-op */
- assert (size_m[i]>0); /*destination must exist */
- /*hyperslab must fit in BUF*/
- assert ((offset_m?offset_m[i]:0)+size[i]<=size_m[i]);
- assert (layout->dim[i]>0);
- }
+ for (i = 0; i < layout->ndims; i++) {
+ assert(!offset_f || offset_f[i] >= 0); /*neg domains unsupported */
+ assert(!offset_m || offset_m[i] >= 0); /*mem array offset never neg */
+ assert(size[i] >= 0); /*size may be zero, implies no-op */
+ assert(size_m[i] > 0); /*destination must exist */
+ /*hyperslab must fit in BUF */
+ assert((offset_m ? offset_m[i] : 0) + size[i] <= size_m[i]);
+ assert(layout->dim[i] > 0);
+ }
#endif
- /* Initialize indices */
- for (i=0; i<layout->ndims; i++) {
- idx_min[i] = (offset_f?offset_f[i]:0) / layout->dim[i];
- idx_max[i] = ((offset_f?offset_f[i]:0)+size[i]-1)/layout->dim[i]+1;
- idx_cur[i] = idx_min[i];
- }
-
- /* Allocate buffers */
- for (i=0, chunk_size=1; i<layout->ndims; i++) {
- chunk_size *= layout->dim[i];
- }
- chunk = H5MM_xmalloc (chunk_size);
-
- /* Initialize non-changing part of udata */
- udata.mesg = *layout;
-
- /* Loop over all chunks */
- while (1) {
-
- /* Read/Write chunk or create it if it doesn't exist */
- udata.mesg.ndims = layout->ndims;
- H5F_addr_undef (&(udata.addr));
- udata.key.file_number = 0;
-
- for (i=0; i<layout->ndims; i++) {
-
- /* The location and size of the chunk being accessed */
- udata.key.offset[i] = idx_cur[i] * layout->dim[i];
- udata.key.size[i] = layout->dim[i];
-
- /* The offset and size wrt the chunk */
- offset_wrt_chunk[i] = MAX ((offset_f?offset_f[i]:0),
- udata.key.offset[i]) -
- udata.key.offset[i];
- sub_size[i] = MIN ((idx_cur[i]+1)*layout->dim[i],
- (offset_f?offset_f[i]:0)+size[i]) -
- (udata.key.offset[i]+offset_wrt_chunk[i]);
-
- /* Offset into mem buffer */
- sub_offset_m[i] = udata.key.offset[i] + offset_wrt_chunk[i] +
- (offset_m?offset_m[i]:0) -
- (offset_f?offset_f[i]:0);
- }
-
- if (H5F_ISTORE_WRITE==op) {
- status = H5B_insert (f, H5B_ISTORE, &(layout->addr), &udata);
- assert (status>=0);
- } else {
- status = H5B_find (f, H5B_ISTORE, &(layout->addr), &udata);
- }
-
- /*
- * If the operation is reading from the disk or if we are writing a
- * partial chunk then load the chunk from disk.
- */
- if (H5F_ISTORE_READ==op ||
- !H5V_vector_zerop (layout->ndims, offset_wrt_chunk) ||
- !H5V_vector_eq (layout->ndims, sub_size, udata.key.size)) {
- if (status>=0 && H5F_addr_defined (&(udata.addr))) {
- assert (0==udata.key.file_number);
- if (H5F_block_read (f, &(udata.addr), chunk_size, chunk)<0) {
- HGOTO_ERROR (H5E_IO, H5E_READERROR, FAIL,
- "unable to read raw storage chunk");
- }
- } else {
- HDmemset (chunk, 0, chunk_size);
- }
- }
-
- /* Transfer data to/from the chunk */
- if (H5F_ISTORE_WRITE==op) {
- H5V_hyper_copy (layout->ndims, sub_size,
- udata.key.size, offset_wrt_chunk, chunk,
- size_m, sub_offset_m, buf);
- assert (0==udata.key.file_number);
- if (H5F_block_write (f, &(udata.addr), chunk_size, chunk)<0) {
- HGOTO_ERROR (H5E_IO, H5E_WRITEERROR, FAIL,
- "unable to write raw storage chunk");
- }
- } else {
- H5V_hyper_copy (layout->ndims, sub_size,
- size_m, sub_offset_m, buf,
- udata.key.size, offset_wrt_chunk, chunk);
- }
-
- /* Increment indices */
- for (i=layout->ndims-1, carry=1; i>=0 && carry; --i) {
- if (++idx_cur[i]>=idx_max[i]) idx_cur[i] = idx_min[i];
- else carry = 0;
- }
- if (carry) break;
- }
- ret_value = SUCCEED;
-
-
- done:
- chunk = H5MM_xfree (chunk);
- FUNC_LEAVE (ret_value);
+ /* Initialize indices */
+ for (i = 0; i < layout->ndims; i++) {
+ idx_min[i] = (offset_f ? offset_f[i] : 0) / layout->dim[i];
+ idx_max[i] = ((offset_f ? offset_f[i] : 0) + size[i] - 1) / layout->dim[i] + 1;
+ idx_cur[i] = idx_min[i];
+ }
+
+ /* Allocate buffers */
+ for (i = 0, chunk_size = 1; i < layout->ndims; i++) {
+ chunk_size *= layout->dim[i];
+ }
+ chunk = H5MM_xmalloc(chunk_size);
+
+ /* Initialize non-changing part of udata */
+ udata.mesg = *layout;
+
+ /* Loop over all chunks */
+ while (1) {
+
+ /* Read/Write chunk or create it if it doesn't exist */
+ udata.mesg.ndims = layout->ndims;
+ H5F_addr_undef(&(udata.addr));
+ udata.key.file_number = 0;
+
+ for (i = 0; i < layout->ndims; i++) {
+
+ /* The location and size of the chunk being accessed */
+ udata.key.offset[i] = idx_cur[i] * layout->dim[i];
+ udata.key.size[i] = layout->dim[i];
+
+ /* The offset and size wrt the chunk */
+ offset_wrt_chunk[i] = MAX((offset_f ? offset_f[i] : 0),
+ udata.key.offset[i]) -
+ udata.key.offset[i];
+ sub_size[i] = MIN((idx_cur[i] + 1) * layout->dim[i],
+ (offset_f ? offset_f[i] : 0) + size[i]) -
+ (udata.key.offset[i] + offset_wrt_chunk[i]);
+
+ /* Offset into mem buffer */
+ sub_offset_m[i] = udata.key.offset[i] + offset_wrt_chunk[i] +
+ (offset_m ? offset_m[i] : 0) -
+ (offset_f ? offset_f[i] : 0);
+ }
+
+ if (H5F_ISTORE_WRITE == op) {
+ status = H5B_insert(f, H5B_ISTORE, &(layout->addr), &udata);
+ assert(status >= 0);
+ } else {
+ status = H5B_find(f, H5B_ISTORE, &(layout->addr), &udata);
+ }
+
+ /*
+ * If the operation is reading from the disk or if we are writing a
+ * partial chunk then load the chunk from disk.
+ */
+ if (H5F_ISTORE_READ == op ||
+ !H5V_vector_zerop(layout->ndims, offset_wrt_chunk) ||
+ !H5V_vector_eq(layout->ndims, sub_size, udata.key.size)) {
+ if (status >= 0 && H5F_addr_defined(&(udata.addr))) {
+ assert(0 == udata.key.file_number);
+ if (H5F_block_read(f, &(udata.addr), chunk_size, chunk) < 0) {
+ HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL,
+ "unable to read raw storage chunk");
+ }
+ } else {
+ HDmemset(chunk, 0, chunk_size);
+ }
+ }
+ /* Transfer data to/from the chunk */
+ if (H5F_ISTORE_WRITE == op) {
+ H5V_hyper_copy(layout->ndims, sub_size,
+ udata.key.size, offset_wrt_chunk, chunk,
+ size_m, sub_offset_m, buf);
+ assert(0 == udata.key.file_number);
+ if (H5F_block_write(f, &(udata.addr), chunk_size, chunk) < 0) {
+ HGOTO_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,
+ "unable to write raw storage chunk");
+ }
+ } else {
+ H5V_hyper_copy(layout->ndims, sub_size,
+ size_m, sub_offset_m, buf,
+ udata.key.size, offset_wrt_chunk, chunk);
+ }
+
+ /* Increment indices */
+ for (i = layout->ndims - 1, carry = 1; i >= 0 && carry; --i) {
+ if (++idx_cur[i] >= idx_max[i])
+ idx_cur[i] = idx_min[i];
+ else
+ carry = 0;
+ }
+ if (carry)
+ break;
+ }
+ ret_value = SUCCEED;
+
+ done:
+ chunk = H5MM_xfree(chunk);
+ FUNC_LEAVE(ret_value);
}
-
/*-------------------------------------------------------------------------
- * Function: H5F_istore_read
+ * Function: H5F_istore_read
*
- * Purpose: Reads a multi-dimensional buffer from (part of) an indexed raw
- * storage array.
+ * Purpose: Reads a multi-dimensional buffer from (part of) an indexed raw
+ * storage array.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, October 15, 1997
*
* Modifications:
@@ -764,39 +753,37 @@ H5F_istore_copy_hyperslab (H5F_t *f, const H5O_layout_t *layout, H5F_isop_t op,
*-------------------------------------------------------------------------
*/
herr_t
-H5F_istore_read (H5F_t *f, const H5O_layout_t *layout,
- const size_t offset[], const size_t size[], void *buf)
+H5F_istore_read(H5F_t *f, const H5O_layout_t *layout,
+ const size_t offset[], const size_t size[], void *buf)
{
- FUNC_ENTER (H5F_istore_read, FAIL);
-
- /* Check args */
- assert (f);
- assert (layout && H5D_CHUNKED==layout->type);
- assert (layout->ndims>0 && layout->ndims<=H5O_LAYOUT_NDIMS);
- assert (size);
- assert (buf);
-
- if (H5F_istore_copy_hyperslab (f, layout, H5F_ISTORE_READ,
- offset, size, H5V_ZERO, size, buf)<0) {
- HRETURN_ERROR (H5E_IO, H5E_READERROR, FAIL,
- "hyperslab output failure");
- }
-
- FUNC_LEAVE (SUCCEED);
+ FUNC_ENTER(H5F_istore_read, FAIL);
+
+ /* Check args */
+ assert(f);
+ assert(layout && H5D_CHUNKED == layout->type);
+ assert(layout->ndims > 0 && layout->ndims <= H5O_LAYOUT_NDIMS);
+ assert(size);
+ assert(buf);
+
+ if (H5F_istore_copy_hyperslab(f, layout, H5F_ISTORE_READ,
+ offset, size, H5V_ZERO, size, buf) < 0) {
+ HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL,
+ "hyperslab output failure");
+ }
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5F_istore_write
+ * Function: H5F_istore_write
*
- * Purpose: Writes a multi-dimensional buffer to (part of) an indexed raw
- * storage array.
+ * Purpose: Writes a multi-dimensional buffer to (part of) an indexed raw
+ * storage array.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, October 15, 1997
*
* Modifications:
@@ -804,46 +791,43 @@ H5F_istore_read (H5F_t *f, const H5O_layout_t *layout,
*-------------------------------------------------------------------------
*/
herr_t
-H5F_istore_write (H5F_t *f, const H5O_layout_t *layout,
- const size_t offset[], const size_t size[],
- const void *buf)
+H5F_istore_write(H5F_t *f, const H5O_layout_t *layout,
+ const size_t offset[], const size_t size[],
+ const void *buf)
{
- FUNC_ENTER (H5F_istore_write, FAIL);
-
- /* Check args */
- assert (f);
- assert (layout && H5D_CHUNKED==layout->type);
- assert (layout->ndims>0 && layout->ndims<=H5O_LAYOUT_NDIMS);
- assert (size);
- assert (buf);
-
- if (H5F_istore_copy_hyperslab (f, layout, H5F_ISTORE_WRITE,
- offset, size, H5V_ZERO, size, buf)<0) {
- HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL,
- "hyperslab output failure");
- }
-
- FUNC_LEAVE (SUCCEED);
+ FUNC_ENTER(H5F_istore_write, FAIL);
+
+ /* Check args */
+ assert(f);
+ assert(layout && H5D_CHUNKED == layout->type);
+ assert(layout->ndims > 0 && layout->ndims <= H5O_LAYOUT_NDIMS);
+ assert(size);
+ assert(buf);
+
+ if (H5F_istore_copy_hyperslab(f, layout, H5F_ISTORE_WRITE,
+ offset, size, H5V_ZERO, size, buf) < 0) {
+ HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,
+ "hyperslab output failure");
+ }
+ FUNC_LEAVE(SUCCEED);
}
-
-
/*-------------------------------------------------------------------------
- * Function: H5F_istore_create
+ * Function: H5F_istore_create
*
- * Purpose: Creates a new indexed-storage B-tree and initializes the
- * istore struct with information about the storage. The
- * struct should be immediately written to the object header.
+ * Purpose: Creates a new indexed-storage B-tree and initializes the
+ * istore struct with information about the storage. The
+ * struct should be immediately written to the object header.
*
- * This function must be called before passing ISTORE to any of
- * the other indexed storage functions!
+ * This function must be called before passing ISTORE to any of
+ * the other indexed storage functions!
*
- * Return: Success: SUCCEED with the ISTORE argument initialized
- * and ready to write to an object header.
+ * Return: Success: SUCCEED with the ISTORE argument initialized
+ * and ready to write to an object header.
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Tuesday, October 21, 1997
*
* Modifications:
@@ -851,27 +835,26 @@ H5F_istore_write (H5F_t *f, const H5O_layout_t *layout,
*-------------------------------------------------------------------------
*/
herr_t
-H5F_istore_create (H5F_t *f, H5O_layout_t *layout/*out*/)
+H5F_istore_create(H5F_t *f, H5O_layout_t *layout /*out */ )
{
- H5F_istore_ud1_t udata;
- int i;
-
- FUNC_ENTER (H5F_istore_create, FAIL);
-
- /* Check args */
- assert (f);
- assert (layout && H5D_CHUNKED==layout->type);
- assert (layout->ndims>0 && layout->ndims<=H5O_LAYOUT_NDIMS);
+ H5F_istore_ud1_t udata;
+ int i;
+
+ FUNC_ENTER(H5F_istore_create, FAIL);
+
+ /* Check args */
+ assert(f);
+ assert(layout && H5D_CHUNKED == layout->type);
+ assert(layout->ndims > 0 && layout->ndims <= H5O_LAYOUT_NDIMS);
#ifndef NDEBUG
- for (i=0; i<layout->ndims; i++) {
- assert (layout->dim[i]>0);
- }
+ for (i = 0; i < layout->ndims; i++) {
+ assert(layout->dim[i] > 0);
+ }
#endif
- udata.mesg.ndims = layout->ndims;
- if (H5B_create (f, H5B_ISTORE, &udata, &(layout->addr)/*out*/)<0) {
- HRETURN_ERROR (H5E_IO, H5E_CANTINIT, FAIL, "can't create B-tree");
- }
-
- FUNC_LEAVE (SUCCEED);
+ udata.mesg.ndims = layout->ndims;
+ if (H5B_create(f, H5B_ISTORE, &udata, &(layout->addr) /*out */ ) < 0) {
+ HRETURN_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "can't create B-tree");
+ }
+ FUNC_LEAVE(SUCCEED);
}
diff --git a/src/H5Flow.c b/src/H5Flow.c
index 3871aca..e61d087 100644
--- a/src/H5Flow.c
+++ b/src/H5Flow.c
@@ -5,10 +5,10 @@
* Programmer: Robb Matzke <matzke@viper.llnl.gov>
* Wednesday, October 22, 1997
*
- * Purpose: This file contains virtual functions for the H5F_low
- * class. These are functions that operate on various kinds
- * of files at a level where the file is just a one-dimensional
- * array of bytes.
+ * Purpose: This file contains virtual functions for the H5F_low
+ * class. These are functions that operate on various kinds
+ * of files at a level where the file is just a one-dimensional
+ * array of bytes.
*/
#include <H5private.h>
#include <H5Eprivate.h>
@@ -20,139 +20,135 @@
#define addr_defined(X) (-1!=(X)->offset && (X)->offset>=0)
-#define PABLO_MASK H5F_low
-static hbool_t interface_initialize_g = FALSE;
+#define PABLO_MASK H5F_low
+static hbool_t interface_initialize_g = FALSE;
#define INTERFACE_INIT NULL
-
/*-------------------------------------------------------------------------
- * Function: H5F_low_open
+ * Function: H5F_low_open
*
- * Purpose: Opens a file of type TYPE with name NAME according to the
- * field of bit flags FLAGS which are:
- *
- * H5F_ACC_WRITE: The file is open for read/write access.
- * Without this bit set, the file would be open
- * for read-only access.
+ * Purpose: Opens a file of type TYPE with name NAME according to the
+ * field of bit flags FLAGS which are:
+ *
+ * H5F_ACC_WRITE: The file is open for read/write access.
+ * Without this bit set, the file would be open
+ * for read-only access.
*
- * H5F_ACC_CREAT: The file is created if it doesn't already
- * exist. On unix, the file permissions are set
- * to 0666 modified by the umask.
+ * H5F_ACC_CREAT: The file is created if it doesn't already
+ * exist. On unix, the file permissions are set
+ * to 0666 modified by the umask.
*
- * H5F_ACC_EXCL: This function will fail if the file already
- * exists.
+ * H5F_ACC_EXCL: This function will fail if the file already
+ * exists.
*
- * H5F_ACC_TRUNC: Truncate the file to a zero-length file as it
- * is opened. This allows existing files to be
- * overwritten.
+ * H5F_ACC_TRUNC: Truncate the file to a zero-length file as it
+ * is opened. This allows existing files to be
+ * overwritten.
*
- * The KEY argument is initialized with data which is unique to
- * this file. Opening the same file (even by a different name)
- * should return the same key.
+ * The KEY argument is initialized with data which is unique to
+ * this file. Opening the same file (even by a different name)
+ * should return the same key.
*
- * This is a virtual function only; the actual open operation is
- * performed by the subclass. This function will fail if the
- * subclass hasn't defined an open method.
+ * This is a virtual function only; the actual open operation is
+ * performed by the subclass. This function will fail if the
+ * subclass hasn't defined an open method.
*
* Errors:
- * IO CANTOPENFILE Open failed.
+ * IO CANTOPENFILE Open failed.
*
- * Return: Success: Pointer to the new file descriptor.
+ * Return: Success: Pointer to the new file descriptor.
*
- * Failure: NULL
+ * Failure: NULL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, October 22, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-H5F_low_t *
-H5F_low_open (const H5F_low_class_t *type, const char *name, uintn flags,
- H5F_search_t *key/*out*/)
+H5F_low_t *
+H5F_low_open(const H5F_low_class_t *type, const char *name, uintn flags,
+ H5F_search_t *key /*out */ )
{
- H5F_low_t *lf = NULL;
-
- FUNC_ENTER (H5F_low_open, NULL);
+ H5F_low_t *lf = NULL;
- assert (type && type->open);
- assert (name && *name);
+ FUNC_ENTER(H5F_low_open, NULL);
- if (NULL==(lf=(type->open)(name, flags, key))) {
- HRETURN_ERROR (H5E_IO, H5E_CANTOPENFILE, NULL, "open failed");
- }
- lf->type = type;
+ assert(type && type->open);
+ assert(name && *name);
- FUNC_LEAVE (lf);
-}
+ if (NULL == (lf = (type->open) (name, flags, key))) {
+ HRETURN_ERROR(H5E_IO, H5E_CANTOPENFILE, NULL, "open failed");
+ }
+ lf->type = type;
+ FUNC_LEAVE(lf);
+}
/*-------------------------------------------------------------------------
- * Function: H5F_low_close
+ * Function: H5F_low_close
*
- * Purpose: Closes a low-level file. The subclass should free all
- * resources used by the file descriptor but should not free the
- * file descriptor itself. The close method in the subclass is
- * optional; lack of a close method results in only the file
- * descriptor being freed.
+ * Purpose: Closes a low-level file. The subclass should free all
+ * resources used by the file descriptor but should not free the
+ * file descriptor itself. The close method in the subclass is
+ * optional; lack of a close method results in only the file
+ * descriptor being freed.
*
- * It is safe to call this function with a null pointer for the
- * file descriptor. This function returns a null pointer that
- * the caller can assign to the file descriptor pointer as it's
- * closed like `desc=H5F_low_close(desc)'.
+ * It is safe to call this function with a null pointer for the
+ * file descriptor. This function returns a null pointer that
+ * the caller can assign to the file descriptor pointer as it's
+ * closed like `desc=H5F_low_close(desc)'.
*
* Errors:
- * IO CLOSEERROR Close failed.
+ * IO CLOSEERROR Close failed.
*
- * Return: Success: NULL
+ * Return: Success: NULL
*
- * Failure: NULL
+ * Failure: NULL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, October 22, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-H5F_low_t *
-H5F_low_close (H5F_low_t *lf)
+H5F_low_t *
+H5F_low_close(H5F_low_t *lf)
{
- FUNC_ENTER (H5F_low_close, NULL);
-
- if (lf) {
- if ((lf->type->close)(lf)<0) {
- H5MM_xfree (lf);
- HRETURN_ERROR (H5E_IO, H5E_CLOSEERROR, NULL, "close failed");
- }
- H5MM_xfree (lf);
- }
-
- FUNC_LEAVE (NULL);
+ FUNC_ENTER(H5F_low_close, NULL);
+
+ if (lf) {
+ if ((lf->type->close) (lf) < 0) {
+ H5MM_xfree(lf);
+ HRETURN_ERROR(H5E_IO, H5E_CLOSEERROR, NULL, "close failed");
+ }
+ H5MM_xfree(lf);
+ }
+ FUNC_LEAVE(NULL);
}
-
/*-------------------------------------------------------------------------
- * Function: H5F_low_read
+ * Function: H5F_low_read
*
- * Purpose: Reads SIZE bytes of data beginning at address ADDR of the
- * file LF and puts the result in BUF. Behavior when reading
- * past the logical or physical end of file is to return zeros
- * for that part of the request.
+ * Purpose: Reads SIZE bytes of data beginning at address ADDR of the
+ * file LF and puts the result in BUF. Behavior when reading
+ * past the logical or physical end of file is to return zeros
+ * for that part of the request.
*
- * This is only a virtual function; the subclass must define a
- * read method or this function will fail.
+ * This is only a virtual function; the subclass must define a
+ * read method or this function will fail.
*
* Errors:
- * IO READERROR Read failed.
- * IO UNSUPPORTED No read method.
+ * IO READERROR Read failed.
+ * IO UNSUPPORTED No read method.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, October 22, 1997
*
* Modifications:
@@ -160,48 +156,47 @@ H5F_low_close (H5F_low_t *lf)
*-------------------------------------------------------------------------
*/
herr_t
-H5F_low_read (H5F_low_t *lf, const haddr_t *addr, size_t size,
- uint8 *buf/*out*/)
+H5F_low_read(H5F_low_t *lf, const haddr_t *addr, size_t size,
+ uint8 *buf /*out */ )
{
- herr_t ret_value = FAIL;
-
- FUNC_ENTER (H5F_low_read, FAIL);
-
- assert (lf && lf->type);
- assert (addr && addr_defined (addr));
- assert (buf);
-
- if (lf->type->read) {
- if ((ret_value = (lf->type->read)(lf, addr, size, buf))<0) {
- HRETURN_ERROR (H5E_IO, H5E_READERROR, ret_value, "read failed");
- }
- } else {
- HRETURN_ERROR (H5E_IO, H5E_UNSUPPORTED, FAIL, "no read method");
- }
-
- FUNC_LEAVE (ret_value);
-}
+ herr_t ret_value = FAIL;
+
+ FUNC_ENTER(H5F_low_read, FAIL);
+
+ assert(lf && lf->type);
+ assert(addr && addr_defined(addr));
+ assert(buf);
+
+ if (lf->type->read) {
+ if ((ret_value = (lf->type->read) (lf, addr, size, buf)) < 0) {
+ HRETURN_ERROR(H5E_IO, H5E_READERROR, ret_value, "read failed");
+ }
+ } else {
+ HRETURN_ERROR(H5E_IO, H5E_UNSUPPORTED, FAIL, "no read method");
+ }
+ FUNC_LEAVE(ret_value);
+}
/*-------------------------------------------------------------------------
- * Function: H5F_low_write
+ * Function: H5F_low_write
*
- * Purpose: Writes SIZE bytes of data from BUF into the file LF beginning
- * at address ADDR of the file. Writing past the logical or
- * physical end of file causes the file to be extended.
+ * Purpose: Writes SIZE bytes of data from BUF into the file LF beginning
+ * at address ADDR of the file. Writing past the logical or
+ * physical end of file causes the file to be extended.
*
- * This is a virtual function only; if the subclass doesn't
- * define a write method then this function will fail.
+ * This is a virtual function only; if the subclass doesn't
+ * define a write method then this function will fail.
*
* Errors:
- * IO UNSUPPORTED No write method.
- * IO WRITEERROR Write failed.
+ * IO UNSUPPORTED No write method.
+ * IO WRITEERROR Write failed.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, October 22, 1997
*
* Modifications:
@@ -209,57 +204,55 @@ H5F_low_read (H5F_low_t *lf, const haddr_t *addr, size_t size,
*-------------------------------------------------------------------------
*/
herr_t
-H5F_low_write (H5F_low_t *lf, const haddr_t *addr, size_t size,
- const uint8 *buf)
+H5F_low_write(H5F_low_t *lf, const haddr_t *addr, size_t size,
+ const uint8 *buf)
{
- herr_t ret_value = FAIL;
- haddr_t tmp_addr;
-
- FUNC_ENTER (H5F_low_write, FAIL);
-
- assert (lf && lf->type);
- assert (addr && addr_defined (addr));
- assert (buf);
-
- /* Extend the file eof marker if we write past it */
- tmp_addr = *addr;
- H5F_addr_inc (&tmp_addr, size);
- if (H5F_addr_gt (&tmp_addr, &(lf->eof))) {
- fprintf (stderr, "HDF5-DIAG: extending file w/o allocation\n");
- lf->eof = tmp_addr;
- }
-
- /* Write the data */
- if (lf->type->write) {
- if ((ret_value = (lf->type->write)(lf, addr, size, buf))<0) {
- HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, ret_value, "write failed");
- }
- } else {
- HRETURN_ERROR (H5E_IO, H5E_UNSUPPORTED, FAIL, "no write method");
- }
-
- FUNC_LEAVE (ret_value);
+ herr_t ret_value = FAIL;
+ haddr_t tmp_addr;
+
+ FUNC_ENTER(H5F_low_write, FAIL);
+
+ assert(lf && lf->type);
+ assert(addr && addr_defined(addr));
+ assert(buf);
+
+ /* Extend the file eof marker if we write past it */
+ tmp_addr = *addr;
+ H5F_addr_inc(&tmp_addr, size);
+ if (H5F_addr_gt(&tmp_addr, &(lf->eof))) {
+ fprintf(stderr, "HDF5-DIAG: extending file w/o allocation\n");
+ lf->eof = tmp_addr;
+ }
+ /* Write the data */
+ if (lf->type->write) {
+ if ((ret_value = (lf->type->write) (lf, addr, size, buf)) < 0) {
+ HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, ret_value, "write failed");
+ }
+ } else {
+ HRETURN_ERROR(H5E_IO, H5E_UNSUPPORTED, FAIL, "no write method");
+ }
+
+ FUNC_LEAVE(ret_value);
}
-
/*-------------------------------------------------------------------------
- * Function: H5F_low_flush
+ * Function: H5F_low_flush
*
- * Purpose: Flushes file buffers to disk. For instance, the stdio.h
- * driver would call fflush(). Flushing also insures that the
- * file exists to the current logical EOF (the library maintains
- * a notion of EOF which is independent of the physical EOF) by
- * reading and writing the last byte. On some systems, this
- * allocates a single block at the end of the file while on
- * other systems it allocates all blocks up to the end of the
- * file. Extending the physical file is necessary because
- * H5F_open() checks for truncated files.
+ * Purpose: Flushes file buffers to disk. For instance, the stdio.h
+ * driver would call fflush(). Flushing also insures that the
+ * file exists to the current logical EOF (the library maintains
+ * a notion of EOF which is independent of the physical EOF) by
+ * reading and writing the last byte. On some systems, this
+ * allocates a single block at the end of the file while on
+ * other systems it allocates all blocks up to the end of the
+ * file. Extending the physical file is necessary because
+ * H5F_open() checks for truncated files.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Monday, November 10, 1997
*
* Modifications:
@@ -267,63 +260,60 @@ H5F_low_write (H5F_low_t *lf, const haddr_t *addr, size_t size,
*-------------------------------------------------------------------------
*/
herr_t
-H5F_low_flush (H5F_low_t *lf)
+H5F_low_flush(H5F_low_t *lf)
{
- haddr_t last_byte;
- uint8 buf[1];
-
- FUNC_ENTER (H5F_low_flush, FAIL);
-
- assert (lf && lf->type);
-
- /* Make sure the last block of the file has been allocated on disk */
- H5F_addr_reset (&last_byte);
- if (addr_defined (&(lf->eof)) && H5F_addr_gt (&(lf->eof), &last_byte)) {
- last_byte = lf->eof;
- last_byte.offset -= 1;
- if (H5F_low_read (lf, &last_byte, 1, buf)>=0) {
- H5F_low_write (lf, &last_byte, 1, buf);
- }
- }
-
- /* Invoke the subclass the flush method */
- if (lf->type->flush) {
- if ((lf->type->flush)(lf)<0) {
- HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL,
- "low level flush failed");
- }
- }
-
- FUNC_LEAVE (SUCCEED);
+ haddr_t last_byte;
+ uint8 buf[1];
+
+ FUNC_ENTER(H5F_low_flush, FAIL);
+
+ assert(lf && lf->type);
+
+ /* Make sure the last block of the file has been allocated on disk */
+ H5F_addr_reset(&last_byte);
+ if (addr_defined(&(lf->eof)) && H5F_addr_gt(&(lf->eof), &last_byte)) {
+ last_byte = lf->eof;
+ last_byte.offset -= 1;
+ if (H5F_low_read(lf, &last_byte, 1, buf) >= 0) {
+ H5F_low_write(lf, &last_byte, 1, buf);
+ }
+ }
+ /* Invoke the subclass the flush method */
+ if (lf->type->flush) {
+ if ((lf->type->flush) (lf) < 0) {
+ HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL,
+ "low level flush failed");
+ }
+ }
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5F_low_size
- *
- * Purpose: Returns the current logical size of the file in bytes. This
- * may differ from the physical size of the file (most
- * subclasses extend the physical file size during the write
- * operation instead of the alloc operation).
- *
- * The next absolute file address is returned through the
- * EOF argument. This is the address of the logical end of
- * file (that is, the address of the first byte past the last
- * byte which is logically in the file).
- *
- * Warning: The return value type (size_t) may not be large enough to
- * represent the true size of the file. In such cases, the
- * maximum possible size is returned. It is better to look at
- * the EOF output argument to determine the total size.
+ * Function: H5F_low_size
+ *
+ * Purpose: Returns the current logical size of the file in bytes. This
+ * may differ from the physical size of the file (most
+ * subclasses extend the physical file size during the write
+ * operation instead of the alloc operation).
+ *
+ * The next absolute file address is returned through the
+ * EOF argument. This is the address of the logical end of
+ * file (that is, the address of the first byte past the last
+ * byte which is logically in the file).
+ *
+ * Warning: The return value type (size_t) may not be large enough to
+ * represent the true size of the file. In such cases, the
+ * maximum possible size is returned. It is better to look at
+ * the EOF output argument to determine the total size.
*
* Errors:
- * IO UNSUPPORTED No size method.
+ * IO UNSUPPORTED No size method.
*
- * Return: Success: Current size of file
+ * Return: Success: Current size of file
*
- * Failure: 0
+ * Failure: 0
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, October 22, 1997
*
* Modifications:
@@ -331,50 +321,50 @@ H5F_low_flush (H5F_low_t *lf)
*-------------------------------------------------------------------------
*/
size_t
-H5F_low_size (H5F_low_t *lf, haddr_t *eof/*out*/)
+H5F_low_size(H5F_low_t *lf, haddr_t *eof /*out */ )
{
- size_t size = (size_t)(-1); /*max possible size*/
-
- FUNC_ENTER (H5F_low_size, 0);
+ size_t size = (size_t) (-1); /*max possible size */
- assert (lf && lf->type);
- assert (eof);
+ FUNC_ENTER(H5F_low_size, 0);
- *eof = lf->eof;
- if (eof->offset < size) size = eof->offset;
+ assert(lf && lf->type);
+ assert(eof);
- FUNC_LEAVE (size);
-}
+ *eof = lf->eof;
+ if (eof->offset < size)
+ size = eof->offset;
+ FUNC_LEAVE(size);
+}
/*-------------------------------------------------------------------------
- * Function: H5F_low_access
+ * Function: H5F_low_access
*
- * Purpose: Determines if a file can be accessed in a particular way by a
- * particular subclass. The access modes for a file are the
- * same as those of access(2), namely
+ * Purpose: Determines if a file can be accessed in a particular way by a
+ * particular subclass. The access modes for a file are the
+ * same as those of access(2), namely
*
- * F_OK: determines if the file (or all parts of a multi-part
- * file) exists.
+ * F_OK: determines if the file (or all parts of a multi-part
+ * file) exists.
*
- * R_OK: determines if the file (or all parts of a multi-part
- * file) are readable.
+ * R_OK: determines if the file (or all parts of a multi-part
+ * file) are readable.
*
- * W_OK: determines if the file (or all parts of a multi-part
- * file) are writable.
+ * W_OK: determines if the file (or all parts of a multi-part
+ * file) are writable.
*
- * If a subclass doesn't define an access method, then we treat
- * the name as if it were a local Unix file and test
- * accessibility with the access(2) function. The KEY is
- * returned as a device number and i-node pair.
+ * If a subclass doesn't define an access method, then we treat
+ * the name as if it were a local Unix file and test
+ * accessibility with the access(2) function. The KEY is
+ * returned as a device number and i-node pair.
*
- * Return: Success: TRUE or FALSE. If TRUE, then KEY is
- * initialized with data that makes this file
- * unique (same value as H5F_low_open).
+ * Return: Success: TRUE or FALSE. If TRUE, then KEY is
+ * initialized with data that makes this file
+ * unique (same value as H5F_low_open).
*
- * Failure: FAIL, KEY is undefined.
+ * Failure: FAIL, KEY is undefined.
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, October 24, 1997
*
* Modifications:
@@ -382,46 +372,45 @@ H5F_low_size (H5F_low_t *lf, haddr_t *eof/*out*/)
*-------------------------------------------------------------------------
*/
hbool_t
-H5F_low_access (const H5F_low_class_t *type, const char *name, int mode,
- H5F_search_t *key/*out*/)
+H5F_low_access(const H5F_low_class_t *type, const char *name, int mode,
+ H5F_search_t *key /*out */ )
{
- hbool_t ret_value;
- struct stat sb;
-
- FUNC_ENTER (H5F_low_size, 0);
- assert (type);
-
- if (type->access) {
- ret_value = (type->access)(name, mode, key/*out*/);
-
- } else {
- ret_value = (0==access (name, mode));
- if (key) {
- stat (name, &sb);
- key->dev = sb.st_dev;
- key->ino = sb.st_ino;
- }
- }
-
- FUNC_LEAVE (ret_value);
-}
+ hbool_t ret_value;
+ struct stat sb;
+
+ FUNC_ENTER(H5F_low_size, 0);
+ assert(type);
+
+ if (type->access) {
+ ret_value = (type->access) (name, mode, key /*out */ );
+
+ } else {
+ ret_value = (0 == access(name, mode));
+ if (key) {
+ stat(name, &sb);
+ key->dev = sb.st_dev;
+ key->ino = sb.st_ino;
+ }
+ }
+ FUNC_LEAVE(ret_value);
+}
/*-------------------------------------------------------------------------
- * Function: H5F_low_extend
+ * Function: H5F_low_extend
*
- * Purpose: Increases the logical size of a file by moving the logical
- * end of file marker. A subclass can override this function by
- * providing its own allocation method.
+ * Purpose: Increases the logical size of a file by moving the logical
+ * end of file marker. A subclass can override this function by
+ * providing its own allocation method.
*
- * Return: Success: SUCCEED, the address of the old end-of-file
- * is returned through the ADDR argument and the
- * logical size of the file has been extended by
- * SIZE bytes.
+ * Return: Success: SUCCEED, the address of the old end-of-file
+ * is returned through the ADDR argument and the
+ * logical size of the file has been extended by
+ * SIZE bytes.
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Thursday, November 13, 1997
*
* Modifications:
@@ -429,38 +418,37 @@ H5F_low_access (const H5F_low_class_t *type, const char *name, int mode,
*-------------------------------------------------------------------------
*/
herr_t
-H5F_low_extend (H5F_low_t *lf, intn op, size_t size, haddr_t *addr/*out*/)
+H5F_low_extend(H5F_low_t *lf, intn op, size_t size, haddr_t *addr /*out */ )
{
- FUNC_ENTER (H5F_low_alloc, FAIL);
-
- assert (lf);
- assert (size>0);
- assert (addr);
-
- if (lf->type->extend) {
- if ((lf->type->extend)(lf, op, size, addr/*out*/)<0) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "unable to extend file");
- }
- } else {
- *addr = lf->eof;
- H5F_addr_inc (&(lf->eof), size);
- }
-
- FUNC_LEAVE (SUCCEED);
+ FUNC_ENTER(H5F_low_alloc, FAIL);
+
+ assert(lf);
+ assert(size > 0);
+ assert(addr);
+
+ if (lf->type->extend) {
+ if ((lf->type->extend) (lf, op, size, addr /*out */ ) < 0) {
+ HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "unable to extend file");
+ }
+ } else {
+ *addr = lf->eof;
+ H5F_addr_inc(&(lf->eof), size);
+ }
+
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5F_low_seteof
+ * Function: H5F_low_seteof
*
- * Purpose: Sets the logical end-of-file to the specified address.
+ * Purpose: Sets the logical end-of-file to the specified address.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Thursday, November 13, 1997
*
* Modifications:
@@ -468,31 +456,30 @@ H5F_low_extend (H5F_low_t *lf, intn op, size_t size, haddr_t *addr/*out*/)
*-------------------------------------------------------------------------
*/
herr_t
-H5F_low_seteof (H5F_low_t *lf, const haddr_t *addr)
+H5F_low_seteof(H5F_low_t *lf, const haddr_t *addr)
{
- FUNC_ENTER (H5F_low_seteof, FAIL);
+ FUNC_ENTER(H5F_low_seteof, FAIL);
- assert (lf);
- assert (addr && addr_defined (addr));
+ assert(lf);
+ assert(addr && addr_defined(addr));
- lf->eof = *addr;
+ lf->eof = *addr;
- FUNC_LEAVE (SUCCEED);
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5F_addr_cmp
+ * Function: H5F_addr_cmp
*
- * Purpose: Compares two addresses.
+ * Purpose: Compares two addresses.
*
- * Return: Success: <0 if A1<A2
- * =0 if A1=A2
- * >0 if A1>A2
+ * Return: Success: <0 if A1<A2
+ * =0 if A1=A2
+ * >0 if A1>A2
*
- * Failure: never fails
+ * Failure: never fails
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, November 7, 1997
*
* Modifications:
@@ -500,28 +487,29 @@ H5F_low_seteof (H5F_low_t *lf, const haddr_t *addr)
*-------------------------------------------------------------------------
*/
intn
-H5F_addr_cmp (const haddr_t *a1, const haddr_t *a2)
+H5F_addr_cmp(const haddr_t *a1, const haddr_t *a2)
{
- FUNC_ENTER (H5F_addr_cmp, FAIL);
-
- assert (a1 && addr_defined (a1));
- assert (a2 && addr_defined (a2));
+ FUNC_ENTER(H5F_addr_cmp, FAIL);
- if (a1->offset<a2->offset) HRETURN (-1);
- if (a1->offset>a2->offset) HRETURN (1);
+ assert(a1 && addr_defined(a1));
+ assert(a2 && addr_defined(a2));
- FUNC_LEAVE (0);
-}
+ if (a1->offset < a2->offset)
+ HRETURN(-1);
+ if (a1->offset > a2->offset)
+ HRETURN(1);
+ FUNC_LEAVE(0);
+}
/*-------------------------------------------------------------------------
- * Function: H5F_addr_undef
+ * Function: H5F_addr_undef
*
- * Purpose: Cause an address to become undefined.
+ * Purpose: Cause an address to become undefined.
*
- * Return: void
+ * Return: void
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, November 7, 1997
*
* Modifications:
@@ -529,24 +517,23 @@ H5F_addr_cmp (const haddr_t *a1, const haddr_t *a2)
*-------------------------------------------------------------------------
*/
void
-H5F_addr_undef (haddr_t *addr/*out*/)
+H5F_addr_undef(haddr_t *addr /*out */ )
{
- assert (addr);
-
- addr->offset = -1;
-}
+ assert(addr);
+ addr->offset = -1;
+}
/*-------------------------------------------------------------------------
- * Function: H5F_addr_defined
+ * Function: H5F_addr_defined
*
- * Purpose: Determines if an address has a defined value.
+ * Purpose: Determines if an address has a defined value.
*
- * Return: Success: TRUE or FALSE
+ * Return: Success: TRUE or FALSE
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, November 7, 1997
*
* Modifications:
@@ -554,21 +541,20 @@ H5F_addr_undef (haddr_t *addr/*out*/)
*-------------------------------------------------------------------------
*/
hbool_t
-H5F_addr_defined (const haddr_t *addr)
+H5F_addr_defined(const haddr_t *addr)
{
- FUNC_ENTER (H5F_addr_defined, FAIL);
- FUNC_LEAVE (addr_defined (addr));
+ FUNC_ENTER(H5F_addr_defined, FAIL);
+ FUNC_LEAVE(addr_defined(addr));
}
-
/*-------------------------------------------------------------------------
- * Function: H5F_addr_reset
+ * Function: H5F_addr_reset
*
- * Purpose: Reset the address to zero.
+ * Purpose: Reset the address to zero.
*
- * Return: void
+ * Return: void
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, November 7, 1997
*
* Modifications:
@@ -576,23 +562,22 @@ H5F_addr_defined (const haddr_t *addr)
*-------------------------------------------------------------------------
*/
void
-H5F_addr_reset (haddr_t *addr/*out*/)
+H5F_addr_reset(haddr_t *addr /*out */ )
{
- assert (addr);
- addr->offset = 0;
+ assert(addr);
+ addr->offset = 0;
}
-
/*-------------------------------------------------------------------------
- * Function: H5F_addr_zerop
+ * Function: H5F_addr_zerop
*
- * Purpose: Determines if an address is zero.
+ * Purpose: Determines if an address is zero.
*
- * Return: Success: TRUE or FALSE
+ * Return: Success: TRUE or FALSE
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, November 7, 1997
*
* Modifications:
@@ -600,23 +585,22 @@ H5F_addr_reset (haddr_t *addr/*out*/)
*-------------------------------------------------------------------------
*/
hbool_t
-H5F_addr_zerop (const haddr_t *addr)
+H5F_addr_zerop(const haddr_t *addr)
{
- FUNC_ENTER (H5F_addr_zerop, FAIL);
- FUNC_LEAVE (0==addr->offset);
+ FUNC_ENTER(H5F_addr_zerop, FAIL);
+ FUNC_LEAVE(0 == addr->offset);
}
-
/*-------------------------------------------------------------------------
- * Function: H5F_addr_encode
+ * Function: H5F_addr_encode
*
- * Purpose: Encodes an address into the buffer pointed to by *PP and
- * then increments the pointer to the first byte after the
- * address. An undefined value is stored as all 1's.
+ * Purpose: Encodes an address into the buffer pointed to by *PP and
+ * then increments the pointer to the first byte after the
+ * address. An undefined value is stored as all 1's.
*
- * Return: void
+ * Return: void
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, November 7, 1997
*
* Modifications:
@@ -624,44 +608,43 @@ H5F_addr_zerop (const haddr_t *addr)
*-------------------------------------------------------------------------
*/
void
-H5F_addr_encode (H5F_t *f, uint8 **pp, const haddr_t *addr)
+H5F_addr_encode(H5F_t *f, uint8 **pp, const haddr_t *addr)
{
- int i;
- haddr_t tmp;
-
- assert (f);
- assert (pp && *pp);
- assert (addr);
-
- if (addr_defined (addr)) {
- tmp = *addr;
- for (i=0; i<H5F_SIZEOF_ADDR (f); i++) {
- *(*pp)++ = tmp.offset & 0xff;
- tmp.offset >>= 8;
- }
- assert ("overflow" && 0==tmp.offset);
-
- } else {
- for (i=0; i<H5F_SIZEOF_ADDR (f); i++) {
- *(*pp)++ = 0xff;
- }
- }
+ int i;
+ haddr_t tmp;
+
+ assert(f);
+ assert(pp && *pp);
+ assert(addr);
+
+ if (addr_defined(addr)) {
+ tmp = *addr;
+ for (i = 0; i < H5F_SIZEOF_ADDR(f); i++) {
+ *(*pp)++ = tmp.offset & 0xff;
+ tmp.offset >>= 8;
+ }
+ assert("overflow" && 0 == tmp.offset);
+
+ } else {
+ for (i = 0; i < H5F_SIZEOF_ADDR(f); i++) {
+ *(*pp)++ = 0xff;
+ }
+ }
}
-
/*-------------------------------------------------------------------------
- * Function: H5F_addr_decode
+ * Function: H5F_addr_decode
*
- * Purpose: Decodes an address from the buffer pointed to by *PP and
- * updates the pointer to point to the next byte after the
- * address.
+ * Purpose: Decodes an address from the buffer pointed to by *PP and
+ * updates the pointer to point to the next byte after the
+ * address.
*
- * If the value read is all 1's then the address is returned
- * with an undefined value.
+ * If the value read is all 1's then the address is returned
+ * with an undefined value.
*
- * Return: void
+ * Return: void
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, November 7, 1997
*
* Modifications:
@@ -669,43 +652,44 @@ H5F_addr_encode (H5F_t *f, uint8 **pp, const haddr_t *addr)
*-------------------------------------------------------------------------
*/
void
-H5F_addr_decode (H5F_t *f, const uint8 **pp, haddr_t *addr/*out*/)
+H5F_addr_decode(H5F_t *f, const uint8 **pp, haddr_t *addr /*out */ )
{
- int i;
- haddr_t tmp;
- uint8 c;
- hbool_t all_zero = TRUE;
-
- assert (f);
- assert (pp && *pp);
- assert (addr);
-
- addr->offset = 0;
-
- for (i=0; i<H5F_SIZEOF_ADDR (f); i++) {
- c = *(*pp)++;
- if (c!=0xff) all_zero = FALSE;
-
- if (i<sizeof(addr->offset)) {
- tmp.offset = c;
- tmp.offset <<= i*8; /*use tmp to get casting right*/
- addr->offset |= tmp.offset;
- } else if (!all_zero) {
- assert (0==**pp); /*overflow*/
- }
- }
- if (all_zero) H5F_addr_undef (addr);
+ int i;
+ haddr_t tmp;
+ uint8 c;
+ hbool_t all_zero = TRUE;
+
+ assert(f);
+ assert(pp && *pp);
+ assert(addr);
+
+ addr->offset = 0;
+
+ for (i = 0; i < H5F_SIZEOF_ADDR(f); i++) {
+ c = *(*pp)++;
+ if (c != 0xff)
+ all_zero = FALSE;
+
+ if (i < sizeof(addr->offset)) {
+ tmp.offset = c;
+ tmp.offset <<= i * 8; /*use tmp to get casting right */
+ addr->offset |= tmp.offset;
+ } else if (!all_zero) {
+ assert(0 == **pp); /*overflow */
+ }
+ }
+ if (all_zero)
+ H5F_addr_undef(addr);
}
-
/*-------------------------------------------------------------------------
- * Function: H5F_addr_print
+ * Function: H5F_addr_print
*
- * Purpose: Print an address
+ * Purpose: Print an address
*
- * Return: void
+ * Return: void
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, November 7, 1997
*
* Modifications:
@@ -713,43 +697,42 @@ H5F_addr_decode (H5F_t *f, const uint8 **pp, haddr_t *addr/*out*/)
*-------------------------------------------------------------------------
*/
void
-H5F_addr_print (FILE *stream, const haddr_t *addr)
+H5F_addr_print(FILE * stream, const haddr_t *addr)
{
- haddr_t tmp;
-
- assert (stream);
- assert (addr);
-
- if (addr_defined (addr)) {
- /*
- * It would be nice if we could use the `%Lu', `%llu', or `%qu', but
- * we don't know which is supported. So we split the address into a
- * low 4-bytes and a high 4-bytes. If the high 4-bytes are non-zero
- * then we print the address in hexadecimal, otherwise we use decimal.
- */
- tmp = *addr;
- tmp.offset >>= 32;
- if (tmp.offset) {
- fprintf (stream, "0x%08lx%08lx",
- (unsigned long)(tmp.offset),
- (unsigned long)(addr->offset & 0xffffffff));
- } else {
- fprintf (stream, "%lu", (unsigned long)(addr->offset));
- }
- } else {
- fprintf (stream, "UNDEF");
- }
+ haddr_t tmp;
+
+ assert(stream);
+ assert(addr);
+
+ if (addr_defined(addr)) {
+ /*
+ * It would be nice if we could use the `%Lu', `%llu', or `%qu', but
+ * we don't know which is supported. So we split the address into a
+ * low 4-bytes and a high 4-bytes. If the high 4-bytes are non-zero
+ * then we print the address in hexadecimal, otherwise we use decimal.
+ */
+ tmp = *addr;
+ tmp.offset >>= 32;
+ if (tmp.offset) {
+ fprintf(stream, "0x%08lx%08lx",
+ (unsigned long) (tmp.offset),
+ (unsigned long) (addr->offset & 0xffffffff));
+ } else {
+ fprintf(stream, "%lu", (unsigned long) (addr->offset));
+ }
+ } else {
+ fprintf(stream, "UNDEF");
+ }
}
-
/*-------------------------------------------------------------------------
- * Function: H5F_addr_pow2
+ * Function: H5F_addr_pow2
*
- * Purpose: Returns an address which is a power of two.
+ * Purpose: Returns an address which is a power of two.
*
- * Return: void
+ * Return: void
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, November 7, 1997
*
* Modifications:
@@ -757,25 +740,24 @@ H5F_addr_print (FILE *stream, const haddr_t *addr)
*-------------------------------------------------------------------------
*/
void
-H5F_addr_pow2 (uintn n, haddr_t *addr/*out*/)
+H5F_addr_pow2(uintn n, haddr_t *addr /*out */ )
{
- assert (n>=0);
- assert (addr);
- assert (n<8*sizeof(addr->offset));
+ assert(n >= 0);
+ assert(addr);
+ assert(n < 8 * sizeof(addr->offset));
- addr->offset = 1;
- addr->offset <<= n;
+ addr->offset = 1;
+ addr->offset <<= n;
}
-
/*-------------------------------------------------------------------------
- * Function: H5F_addr_inc
+ * Function: H5F_addr_inc
*
- * Purpose: Increments an address by some number of bytes.
+ * Purpose: Increments an address by some number of bytes.
*
- * Return: void
+ * Return: void
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, November 7, 1997
*
* Modifications:
@@ -783,22 +765,21 @@ H5F_addr_pow2 (uintn n, haddr_t *addr/*out*/)
*-------------------------------------------------------------------------
*/
void
-H5F_addr_inc (haddr_t *addr/*in,out*/, size_t inc)
+H5F_addr_inc(haddr_t *addr /*in,out */ , size_t inc)
{
- assert (addr && addr_defined (addr));
- assert (addr->offset<=addr->offset+inc);
- addr->offset += inc;
+ assert(addr && addr_defined(addr));
+ assert(addr->offset <= addr->offset + inc);
+ addr->offset += inc;
}
-
/*-------------------------------------------------------------------------
- * Function: H5F_addr_add
+ * Function: H5F_addr_add
*
- * Purpose: Adds two addresses and puts the result in the first argument.
+ * Purpose: Adds two addresses and puts the result in the first argument.
*
- * Return: void
+ * Return: void
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, November 7, 1997
*
* Modifications:
@@ -806,25 +787,24 @@ H5F_addr_inc (haddr_t *addr/*in,out*/, size_t inc)
*-------------------------------------------------------------------------
*/
void
-H5F_addr_add (haddr_t *a1/*in,out*/, const haddr_t *a2)
+H5F_addr_add(haddr_t *a1 /*in,out */ , const haddr_t *a2)
{
- assert (a1 && addr_defined (a1));
- assert (a2 && addr_defined (a2));
- a1->offset += a2->offset;
+ assert(a1 && addr_defined(a1));
+ assert(a2 && addr_defined(a2));
+ a1->offset += a2->offset;
}
-
/*-------------------------------------------------------------------------
- * Function: H5F_addr_hash
+ * Function: H5F_addr_hash
*
- * Purpose: Computes a hash value of an address between 0 and MOD-1,
- * inclusive.
+ * Purpose: Computes a hash value of an address between 0 and MOD-1,
+ * inclusive.
*
- * Return: Success: The hash value
+ * Return: Success: The hash value
*
- * Failure: never fails
+ * Failure: never fails
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, November 7, 1997
*
* Modifications:
@@ -832,10 +812,10 @@ H5F_addr_add (haddr_t *a1/*in,out*/, const haddr_t *a2)
*-------------------------------------------------------------------------
*/
uintn
-H5F_addr_hash (const haddr_t *addr, uintn mod)
+H5F_addr_hash(const haddr_t *addr, uintn mod)
{
- assert (addr && addr_defined (addr));
- assert (mod>0);
+ assert(addr && addr_defined(addr));
+ assert(mod > 0);
- return addr->offset % mod; /*ignore file number*/
+ return addr->offset % mod; /*ignore file number */
}
diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h
index acf2e80..31ea061 100644
--- a/src/H5Fprivate.h
+++ b/src/H5Fprivate.h
@@ -25,9 +25,9 @@
/*
* Feature: Define this constant to be non-zero if you want to enable code
- * that minimizes the number of calls to lseek(). This has a huge
- * performance benefit on some systems. Set this constant to zero
- * on the compiler command line to disable that optimization.
+ * that minimizes the number of calls to lseek(). This has a huge
+ * performance benefit on some systems. Set this constant to zero
+ * on the compiler command line to disable that optimization.
*/
#ifndef H5F_OPT_SEEK
# define H5F_OPT_SEEK 1
@@ -35,7 +35,7 @@
/*
* Feature: Define this constant on the compiler command-line if you want to
- * see some debugging messages on stderr.
+ * see some debugging messages on stderr.
*/
#ifdef NDEBUG
# undef H5F_DEBUG
@@ -49,18 +49,17 @@
#define H5F_SIGNATURE_LEN 8
/* size of size_t and off_t as they exist on disk */
-#define H5F_SIZEOF_ADDR(F) ((F)->shared->create_parms.sizeof_addr)
-#define H5F_SIZEOF_SIZE(F) ((F)->shared->create_parms.sizeof_size)
+#define H5F_SIZEOF_ADDR(F) ((F)->shared->create_parms.sizeof_addr)
+#define H5F_SIZEOF_SIZE(F) ((F)->shared->create_parms.sizeof_size)
/*
* File open flags.
*/
-#define H5F_ACC_WRITE 0x0001 /* Open file for read/write access */
-#define H5F_ACC_CREAT 0x0002 /* Create non-existing files */
-#define H5F_ACC_EXCL 0x0004 /* Fail if file exists */
-#define H5F_ACC_TRUNC 0x0008 /* Truncate existing file */
-#define H5F_ACC_DEBUG 0x00010 /* Print debug info */
-
+#define H5F_ACC_WRITE 0x0001 /* Open file for read/write access */
+#define H5F_ACC_CREAT 0x0002 /* Create non-existing files */
+#define H5F_ACC_EXCL 0x0004 /* Fail if file exists */
+#define H5F_ACC_TRUNC 0x0008 /* Truncate existing file */
+#define H5F_ACC_DEBUG 0x00010 /* Print debug info */
/*
* Encode and decode macros for file meta-data.
@@ -69,100 +68,100 @@
/* For non-little-endian platforms, encode each byte by itself */
#ifdef WORDS_BIGENDIAN
-# define INT16ENCODE(p, i) { \
- *(p) = (uint8)( (uintn)(i) & 0xff); (p)++; \
- *(p) = (uint8)(((uintn)(i) >> 8) & 0xff); (p)++; \
+# define INT16ENCODE(p, i) { \
+ *(p) = (uint8)( (uintn)(i) & 0xff); (p)++; \
+ *(p) = (uint8)(((uintn)(i) >> 8) & 0xff); (p)++; \
}
-# define UINT16ENCODE(p, i) { \
- *(p) = (uint8)( (i) & 0xff); (p)++; \
- *(p) = (uint8)(((uintn)(i) >> 8) & 0xff); (p)++; \
+# define UINT16ENCODE(p, i) { \
+ *(p) = (uint8)( (i) & 0xff); (p)++; \
+ *(p) = (uint8)(((uintn)(i) >> 8) & 0xff); (p)++; \
}
-# define INT32ENCODE(p, i) { \
- *(p) = (uint8)( (uint32)(i) & 0xff); (p)++; \
- *(p) = (uint8)(((uint32)(i) >> 8) & 0xff); (p)++; \
- *(p) = (uint8)(((uint32)(i) >> 16) & 0xff); (p)++; \
- *(p) = (uint8)(((uint32)(i) >> 24) & 0xff); (p)++; \
+# define INT32ENCODE(p, i) { \
+ *(p) = (uint8)( (uint32)(i) & 0xff); (p)++; \
+ *(p) = (uint8)(((uint32)(i) >> 8) & 0xff); (p)++; \
+ *(p) = (uint8)(((uint32)(i) >> 16) & 0xff); (p)++; \
+ *(p) = (uint8)(((uint32)(i) >> 24) & 0xff); (p)++; \
}
-# define UINT32ENCODE(p, i) { \
- *(p) = (uint8)( (i) & 0xff); (p)++; \
- *(p) = (uint8)(((i) >> 8) & 0xff); (p)++; \
- *(p) = (uint8)(((i) >> 16) & 0xff); (p)++; \
- *(p) = (uint8)(((i) >> 24) & 0xff); (p)++; \
+# define UINT32ENCODE(p, i) { \
+ *(p) = (uint8)( (i) & 0xff); (p)++; \
+ *(p) = (uint8)(((i) >> 8) & 0xff); (p)++; \
+ *(p) = (uint8)(((i) >> 16) & 0xff); (p)++; \
+ *(p) = (uint8)(((i) >> 24) & 0xff); (p)++; \
}
-# define INT64ENCODE(p, n) { \
- int64 _n = (n); \
- intn _i; \
- uint8 *_p = (uint8*)(p); \
- for (_i=0; _i<sizeof(int64); _i++, _n>>=8) { \
- *_p++ = _n & 0xff; \
- } \
- for (/*void*/; _i<8; _i++) { \
- *_p++ = (n)<0 ? 0xff : 0; \
- } \
- (p) = (uint8*)(p)+8; \
+# define INT64ENCODE(p, n) { \
+ int64 _n = (n); \
+ intn _i; \
+ uint8 *_p = (uint8*)(p); \
+ for (_i=0; _i<sizeof(int64); _i++, _n>>=8) { \
+ *_p++ = _n & 0xff; \
+ } \
+ for (/*void*/; _i<8; _i++) { \
+ *_p++ = (n)<0 ? 0xff : 0; \
+ } \
+ (p) = (uint8*)(p)+8; \
}
-# define UINT64ENCODE(p, n) { \
- uint64 _n = (n); \
- intn _i; \
- uint8 *_p = (uint8*)(p); \
- for (_i=0; _i<sizeof(uint64); _i++, _n>>=8) { \
- *_p++ = _n & 0xff; \
- } \
- for (/*void*/; _i<8; _i++) { \
- *_p++ = 0; \
- } \
- (p) = (uint8*)(p)+8; \
+# define UINT64ENCODE(p, n) { \
+ uint64 _n = (n); \
+ intn _i; \
+ uint8 *_p = (uint8*)(p); \
+ for (_i=0; _i<sizeof(uint64); _i++, _n>>=8) { \
+ *_p++ = _n & 0xff; \
+ } \
+ for (/*void*/; _i<8; _i++) { \
+ *_p++ = 0; \
+ } \
+ (p) = (uint8*)(p)+8; \
}
-# define INT16DECODE(p, i) { \
- (i) = (int16)((*(p) & 0xff)); (p)++; \
- (i) |= (int16)((*(p) & 0xff) << 8); (p)++; \
+# define INT16DECODE(p, i) { \
+ (i) = (int16)((*(p) & 0xff)); (p)++; \
+ (i) |= (int16)((*(p) & 0xff) << 8); (p)++; \
}
-# define UINT16DECODE(p, i) { \
- (i) = (uint16) (*(p) & 0xff); (p)++; \
- (i) |= (uint16)((*(p) & 0xff) << 8); (p)++; \
+# define UINT16DECODE(p, i) { \
+ (i) = (uint16) (*(p) & 0xff); (p)++; \
+ (i) |= (uint16)((*(p) & 0xff) << 8); (p)++; \
}
-# define INT32DECODE(p, i) { \
- (i) = ( *(p) & 0xff); (p)++; \
- (i) |= ((int32)(*(p) & 0xff) << 8); (p)++; \
- (i) |= ((int32)(*(p) & 0xff) << 16); (p)++; \
- (i) |= ((int32)(*(p) & 0xff) << 24); (p)++; \
+# define INT32DECODE(p, i) { \
+ (i) = ( *(p) & 0xff); (p)++; \
+ (i) |= ((int32)(*(p) & 0xff) << 8); (p)++; \
+ (i) |= ((int32)(*(p) & 0xff) << 16); (p)++; \
+ (i) |= ((int32)(*(p) & 0xff) << 24); (p)++; \
}
-# define UINT32DECODE(p, i) { \
- (i) = (uint32)(*(p) & 0xff); (p)++; \
- (i) |= ((uint32)(*(p) & 0xff) << 8); (p)++; \
- (i) |= ((uint32)(*(p) & 0xff) << 16); (p)++; \
- (i) |= ((uint32)(*(p) & 0xff) << 24); (p)++; \
+# define UINT32DECODE(p, i) { \
+ (i) = (uint32)(*(p) & 0xff); (p)++; \
+ (i) |= ((uint32)(*(p) & 0xff) << 8); (p)++; \
+ (i) |= ((uint32)(*(p) & 0xff) << 16); (p)++; \
+ (i) |= ((uint32)(*(p) & 0xff) << 24); (p)++; \
}
-# define INT64DECODE(p, n) { \
- /* WE DON'T CHECK FOR OVERFLOW! */ \
- int64 _n = 0; \
- intn _i; \
- (p) += 8; \
- for (_i=0; _i<sizeof(int64); _i++, _n<<=8) { \
- _n |= *(--p); \
- } \
- (p) += 8; \
+# define INT64DECODE(p, n) { \
+ /* WE DON'T CHECK FOR OVERFLOW! */ \
+ int64 _n = 0; \
+ intn _i; \
+ (p) += 8; \
+ for (_i=0; _i<sizeof(int64); _i++, _n<<=8) { \
+ _n |= *(--p); \
+ } \
+ (p) += 8; \
}
-# define UINT64DECODE(p, n) { \
- /* WE DON'T CHECK FOR OVERFLOW! */ \
- uint64 _n = 0; \
- intn _i; \
- (p) += 8; \
- for (_i=0; _i<sizeof(uint64); _i++, _n<<=8) { \
- _n |= *(--p); \
- } \
- (p) += 8; \
+# define UINT64DECODE(p, n) { \
+ /* WE DON'T CHECK FOR OVERFLOW! */ \
+ uint64 _n = 0; \
+ intn _i; \
+ (p) += 8; \
+ for (_i=0; _i<sizeof(uint64); _i++, _n<<=8) { \
+ _n |= *(--p); \
+ } \
+ (p) += 8; \
}
#else
@@ -172,26 +171,26 @@
# define INT32ENCODE(p, i) { *((int32 *)(p)) = (int32)(i); (p)+=4; }
# define UINT32ENCODE(p, i) { *((uint32 *)(p)) = (uint32)(i); (p)+=4; }
-# define INT64ENCODE(p, i) { \
- *((int64 *)(p)) = (int64)(i); \
- (p) += sizeof(int64); \
- if (4==sizeof(int64)) { \
- *(p)++ = (i)<0?0xff:0x00; \
- *(p)++ = (i)<0?0xff:0x00; \
- *(p)++ = (i)<0?0xff:0x00; \
- *(p)++ = (i)<0?0xff:0x00; \
- } \
+# define INT64ENCODE(p, i) { \
+ *((int64 *)(p)) = (int64)(i); \
+ (p) += sizeof(int64); \
+ if (4==sizeof(int64)) { \
+ *(p)++ = (i)<0?0xff:0x00; \
+ *(p)++ = (i)<0?0xff:0x00; \
+ *(p)++ = (i)<0?0xff:0x00; \
+ *(p)++ = (i)<0?0xff:0x00; \
+ } \
}
-# define UINT64ENCODE(p, i) { \
- *((uint64 *)(p)) = (uint64)(i); \
- (p) += sizeof(uint64); \
- if (4==sizeof(uint64)) { \
- *(p)++ = 0x00; \
- *(p)++ = 0x00; \
- *(p)++ = 0x00; \
- *(p)++ = 0x00; \
- } \
+# define UINT64ENCODE(p, i) { \
+ *((uint64 *)(p)) = (uint64)(i); \
+ (p) += sizeof(uint64); \
+ if (4==sizeof(uint64)) { \
+ *(p)++ = 0x00; \
+ *(p)++ = 0x00; \
+ *(p)++ = 0x00; \
+ *(p)++ = 0x00; \
+ } \
}
# define INT16DECODE(p, i) { (i) = (int16)(*(const int16 *)(p)); (p)+=2; }
@@ -213,125 +212,125 @@
* File-creation template.
*/
typedef struct H5F_create_t {
- size_t userblock_size; /* Size of the file user block in bytes */
- intn sym_leaf_k; /* 1/2 rank for symbol table leaf nodes */
- intn btree_k[8]; /* 1/2 rank for btree internal nodes */
- size_t sizeof_addr; /* Number of bytes in an address */
- size_t sizeof_size; /* Number of bytes for obj sizes */
- intn bootblock_ver; /* Version # of the bootblock */
- intn smallobject_ver; /* Version # of the small-object heap */
- intn freespace_ver; /* Version # of the free-space information */
- intn objectdir_ver; /* Version # of the object directory format */
- intn sharedheader_ver; /* Version # of the shared header format */
+ size_t userblock_size; /* Size of the file user block in bytes */
+ intn sym_leaf_k; /* 1/2 rank for symbol table leaf nodes */
+ intn btree_k[8]; /* 1/2 rank for btree internal nodes */
+ size_t sizeof_addr; /* Number of bytes in an address */
+ size_t sizeof_size; /* Number of bytes for obj sizes */
+ intn bootblock_ver; /* Version # of the bootblock */
+ intn smallobject_ver; /* Version # of the small-object heap */
+ intn freespace_ver; /* Version # of the free-space information */
+ intn objectdir_ver; /* Version # of the object directory format */
+ intn sharedheader_ver; /* Version # of the shared header format */
} H5F_create_t;
/*
* These things make a file unique.
*/
typedef struct H5F_search_t {
- dev_t dev; /* Device number containing file */
- ino_t ino; /* Unique file number on device */
+ dev_t dev; /* Device number containing file */
+ ino_t ino; /* Unique file number on device */
} H5F_search_t;
/* For determining what the last file operation was */
typedef enum {
- H5F_OP_UNKNOWN, /* Don't know what the last operation was */
- H5F_OP_SEEK, /* Last operation was a seek */
- H5F_OP_WRITE, /* Last operation was a write */
- H5F_OP_READ /* Last operation was a read */
+ H5F_OP_UNKNOWN, /* Don't know what the last operation was */
+ H5F_OP_SEEK, /* Last operation was a seek */
+ H5F_OP_WRITE, /* Last operation was a write */
+ H5F_OP_READ /* Last operation was a read */
} H5F_fileop_t;
/*
* Define the low-level file interface.
*/
typedef struct H5F_low_class_t {
- hbool_t (*access)(const char*, int, H5F_search_t*);
- struct H5F_low_t *(*open)(const char*, uintn, H5F_search_t*);
- herr_t (*close)(struct H5F_low_t*);
- herr_t (*read)(struct H5F_low_t*, const haddr_t*, size_t, uint8*);
- herr_t (*write)(struct H5F_low_t*, const haddr_t*, size_t, const uint8*);
- herr_t (*flush)(struct H5F_low_t*);
- herr_t (*extend)(struct H5F_low_t*, intn, size_t, haddr_t*);
+ hbool_t (*access) (const char *, int, H5F_search_t *);
+ struct H5F_low_t *(*open) (const char *, uintn, H5F_search_t *);
+ herr_t (*close) (struct H5F_low_t *);
+ herr_t (*read) (struct H5F_low_t *, const haddr_t *, size_t, uint8 *);
+ herr_t (*write) (struct H5F_low_t *, const haddr_t *, size_t, const uint8 *);
+ herr_t (*flush) (struct H5F_low_t *);
+ herr_t (*extend) (struct H5F_low_t *, intn, size_t, haddr_t *);
} H5F_low_class_t;
typedef struct H5F_low_t {
- const H5F_low_class_t *type; /* What type of file is this? */
- haddr_t eof; /* Address of logical end-of-file */
- union {
-
- /* File families */
- struct {
- char *name; /* Family name */
- uintn flags; /* Flags for opening member files */
- intn nmemb; /* Number of family members */
- intn nalloc; /* Size of member table in elements */
- struct H5F_low_t **memb;/* An array of family members */
- size_t offset_bits;/* Number of bits in a member offset*/
- } fam;
-
- /* Split meta/raw data */
- struct {
- char *name; /* Base name w/o extension */
- uint64 mask; /* Bit that determines which file to use*/
- struct H5F_low_t *meta;/* Meta data file */
- struct H5F_low_t *raw; /* Raw data file */
- } split;
-
- /* Posix section 2 I/O */
- struct {
- int fd; /* The unix file descriptor */
- H5F_fileop_t op; /* Previous file operation */
- off_t cur; /* Current file position */
- } sec2;
-
- /* Posix stdio */
- struct {
- FILE *f; /* Posix stdio file */
- H5F_fileop_t op; /* Previous file operation */
- off_t cur; /* Current file position */
- } stdio;
-
- /* In-core temp file */
- struct {
- uint8 *mem; /* Mem image of the file */
- size_t size; /* Current file size */
- size_t alloc; /* Current size of MEM buffer */
- } core;
-
- } u;
+ const H5F_low_class_t *type; /* What type of file is this? */
+ haddr_t eof; /* Address of logical end-of-file */
+ union {
+
+ /* File families */
+ struct {
+ char *name; /* Family name */
+ uintn flags; /* Flags for opening member files */
+ intn nmemb; /* Number of family members */
+ intn nalloc; /* Size of member table in elements */
+ struct H5F_low_t **memb; /* An array of family members */
+ size_t offset_bits; /* Number of bits in a member offset */
+ } fam;
+
+ /* Split meta/raw data */
+ struct {
+ char *name; /* Base name w/o extension */
+ uint64 mask; /* Bit that determines which file to use */
+ struct H5F_low_t *meta; /* Meta data file */
+ struct H5F_low_t *raw; /* Raw data file */
+ } split;
+
+ /* Posix section 2 I/O */
+ struct {
+ int fd; /* The unix file descriptor */
+ H5F_fileop_t op; /* Previous file operation */
+ off_t cur; /* Current file position */
+ } sec2;
+
+ /* Posix stdio */
+ struct {
+ FILE *f; /* Posix stdio file */
+ H5F_fileop_t op; /* Previous file operation */
+ off_t cur; /* Current file position */
+ } stdio;
+
+ /* In-core temp file */
+ struct {
+ uint8 *mem; /* Mem image of the file */
+ size_t size; /* Current file size */
+ size_t alloc; /* Current size of MEM buffer */
+ } core;
+
+ } u;
} H5F_low_t;
/* What types of low-level files are there? */
#ifndef H5F_LOW_DFLT
-# define H5F_LOW_DFLT H5F_LOW_STDIO /* The default type */
+# define H5F_LOW_DFLT H5F_LOW_STDIO /* The default type */
#endif
-extern const H5F_low_class_t H5F_LOW_SEC2[]; /* Posix section 2 */
-extern const H5F_low_class_t H5F_LOW_STDIO[]; /* Posix stdio */
-extern const H5F_low_class_t H5F_LOW_CORE[]; /* In-core temp file */
-extern const H5F_low_class_t H5F_LOW_FAM[]; /* File family */
-extern const H5F_low_class_t H5F_LOW_SPLIT[]; /* Split meta/raw data */
+extern const H5F_low_class_t H5F_LOW_SEC2[]; /* Posix section 2 */
+extern const H5F_low_class_t H5F_LOW_STDIO[]; /* Posix stdio */
+extern const H5F_low_class_t H5F_LOW_CORE[]; /* In-core temp file */
+extern const H5F_low_class_t H5F_LOW_FAM[]; /* File family */
+extern const H5F_low_class_t H5F_LOW_SPLIT[]; /* Split meta/raw data */
/*
* Define the structure to store the file information for HDF5 files. One of
* these structures is allocated per file, not per H5Fopen().
*/
typedef struct H5F_file_t {
- H5F_search_t key; /* The key for looking up files */
- uintn flags; /* Access Permissions for file */
- H5F_low_t *lf; /* Lower level file handle for I/O */
- uintn nrefs; /* Ref count for times file is opened */
- uint32 consist_flags; /* File Consistency Flags */
- haddr_t boot_addr; /* Absolute address of boot block */
- haddr_t base_addr; /* Absolute base address for rel.addrs. */
- haddr_t smallobj_addr; /* Relative address of small-obj heap */
- haddr_t freespace_addr; /* Relative address of free-space info */
- haddr_t hdf5_eof; /* Relative addr of end of all hdf5 data*/
- struct H5AC_t *cache; /* The object cache */
- H5F_create_t create_parms; /* File-creation template */
+ H5F_search_t key; /* The key for looking up files */
+ uintn flags; /* Access Permissions for file */
+ H5F_low_t *lf; /* Lower level file handle for I/O */
+ uintn nrefs; /* Ref count for times file is opened */
+ uint32 consist_flags; /* File Consistency Flags */
+ haddr_t boot_addr; /* Absolute address of boot block */
+ haddr_t base_addr; /* Absolute base address for rel.addrs. */
+ haddr_t smallobj_addr; /* Relative address of small-obj heap */
+ haddr_t freespace_addr; /* Relative address of free-space info */
+ haddr_t hdf5_eof; /* Relative addr of end of all hdf5 data */
+ struct H5AC_t *cache; /* The object cache */
+ H5F_create_t create_parms; /* File-creation template */
#ifdef LATER
- file_access_temp_t file_access_parms; /* File-access template */
+ file_access_temp_t file_access_parms; /* File-access template */
#endif
- struct H5G_entry_t *root_ent;/* Root symbol table entry */
+ struct H5G_entry_t *root_ent; /* Root symbol table entry */
} H5F_file_t;
/*
@@ -340,17 +339,14 @@ typedef struct H5F_file_t {
* pointers to shared H5F_file_t structs.
*/
typedef struct H5F_t {
- uintn intent; /* The flags passed to H5F_open() */
- char *name; /* Name used to open file */
- H5F_file_t *shared; /* The shared file info */
- struct H5G_cwgstk_t *cwg_stack; /* CWG stack for push/pop functions */
- uintn nopen; /* Number of open object headers */
- hbool_t close_pending; /* File close is pending */
+ uintn intent; /* The flags passed to H5F_open() */
+ char *name; /* Name used to open file */
+ H5F_file_t *shared; /* The shared file info */
+ struct H5G_cwgstk_t *cwg_stack; /* CWG stack for push/pop functions */
+ uintn nopen; /* Number of open object headers */
+ hbool_t close_pending; /* File close is pending */
} H5F_t;
-
-
-
#ifdef NOT_YET
#define H5F_ENCODE_OFFSET(f,p,o) (H5F_SIZEOF_ADDR(f)==4 ? UINT32ENCODE(p,o) \
: H5F_SIZEOF_ADDR(f)==8 ? UINT64ENCODE(p,o) \
@@ -362,17 +358,17 @@ typedef struct H5F_t {
case 2: UINT16ENCODE(p,o); break;}
#endif /* NOT_YET */
-#define H5F_DECODE_OFFSET(f,p,o) \
- switch (H5F_SIZEOF_ADDR (f)) { \
- case 4: \
- UINT32DECODE (p, o); \
- break; \
- case 8: \
- UINT64DECODE (p, o); \
- break; \
- case 2: \
- UINT16DECODE (p, o); \
- break; \
+#define H5F_DECODE_OFFSET(f,p,o) \
+ switch (H5F_SIZEOF_ADDR (f)) { \
+ case 4: \
+ UINT32DECODE (p, o); \
+ break; \
+ case 8: \
+ UINT64DECODE (p, o); \
+ break; \
+ case 2: \
+ UINT16DECODE (p, o); \
+ break; \
}
#ifdef NOT_YET
@@ -380,72 +376,71 @@ typedef struct H5F_t {
: H5F_SIZEOF_SIZE(f)==8 ? UINT64ENCODE(p,l) \
: H5F_SIZEOF_SIZE(f)==2 ? UINT16ENCODE(p,l) : H5FPencode_unusual_length(f,&(p),(uint8 *)&(l)))
#else
-#define H5F_encode_length(f,p,l) \
- switch(H5F_SIZEOF_SIZE(f)) { \
- case 4: UINT32ENCODE(p,l); break; \
- case 8: UINT64ENCODE(p,l); break; \
- case 2: UINT16ENCODE(p,l); break; \
+#define H5F_encode_length(f,p,l) \
+ switch(H5F_SIZEOF_SIZE(f)) { \
+ case 4: UINT32ENCODE(p,l); break; \
+ case 8: UINT64ENCODE(p,l); break; \
+ case 2: UINT16ENCODE(p,l); break; \
}
#endif
-#define H5F_decode_length(f,p,l) \
- switch(H5F_SIZEOF_SIZE(f)) { \
- case 4: UINT32DECODE(p,l); break; \
- case 8: UINT64DECODE(p,l); break; \
- case 2: UINT16DECODE(p,l); break; \
+#define H5F_decode_length(f,p,l) \
+ switch(H5F_SIZEOF_SIZE(f)) { \
+ case 4: UINT32DECODE(p,l); break; \
+ case 8: UINT64DECODE(p,l); break; \
+ case 2: UINT16DECODE(p,l); break; \
}
-struct H5O_layout_t; /*forward decl for prototype arguments*/
+struct H5O_layout_t; /*forward decl for prototype arguments */
/* library variables */
extern const H5F_create_t H5F_create_dflt;
/* Private functions, not part of the publicly documented API */
-void H5F_encode_length_unusual(const H5F_t *f, uint8 **p, uint8 *l);
-H5F_t *H5F_open (const H5F_low_class_t *type, const char *name, uintn flags,
- const H5F_create_t *create_parms);
-herr_t H5F_close (H5F_t *f);
-herr_t H5F_debug (H5F_t *f, const haddr_t *addr, FILE *stream, intn indent,
- intn fwidth);
+void H5F_encode_length_unusual(const H5F_t *f, uint8 **p, uint8 *l);
+H5F_t *H5F_open(const H5F_low_class_t *type, const char *name, uintn flags,
+ const H5F_create_t *create_parms);
+herr_t H5F_close(H5F_t *f);
+herr_t H5F_debug(H5F_t *f, const haddr_t *addr, FILE * stream, intn indent,
+ intn fwidth);
/* Functions that operate on array storage */
-herr_t H5F_arr_create (H5F_t *f, struct H5O_layout_t *layout/*in,out*/);
-herr_t H5F_arr_read (H5F_t *f, const struct H5O_layout_t *layout,
- const size_t offset[], const size_t size[],
- void *buf/*out*/);
-herr_t H5F_arr_write (H5F_t *f, const struct H5O_layout_t *layout,
- const size_t offset[], const size_t size[],
- const void *buf);
+herr_t H5F_arr_create(H5F_t *f, struct H5O_layout_t *layout /*in,out */ );
+herr_t H5F_arr_read(H5F_t *f, const struct H5O_layout_t *layout,
+ const size_t offset[], const size_t size[],
+ void *buf /*out */ );
+herr_t H5F_arr_write(H5F_t *f, const struct H5O_layout_t *layout,
+ const size_t offset[], const size_t size[],
+ const void *buf);
/* Functions that operate on indexed storage */
-herr_t H5F_istore_create (H5F_t *f, struct H5O_layout_t *layout/*in,out*/);
-herr_t H5F_istore_read (H5F_t *f, const struct H5O_layout_t *layout,
- const size_t offset[], const size_t size[],
- void *buf/*out*/);
-herr_t H5F_istore_write (H5F_t *f, const struct H5O_layout_t *layout,
- const size_t offset[], const size_t size[],
- const void *buf);
+herr_t H5F_istore_create(H5F_t *f, struct H5O_layout_t *layout /*in,out */ );
+herr_t H5F_istore_read(H5F_t *f, const struct H5O_layout_t *layout,
+ const size_t offset[], const size_t size[],
+ void *buf /*out */ );
+herr_t H5F_istore_write(H5F_t *f, const struct H5O_layout_t *layout,
+ const size_t offset[], const size_t size[],
+ const void *buf);
/* Functions that operate on contiguous storage wrt boot block */
-herr_t H5F_block_read (H5F_t *f, const haddr_t *addr, size_t size, void *buf);
-herr_t H5F_block_write (H5F_t *f, const haddr_t *addr, size_t size,
- const void *buf);
+herr_t H5F_block_read(H5F_t *f, const haddr_t *addr, size_t size, void *buf);
+herr_t H5F_block_write(H5F_t *f, const haddr_t *addr, size_t size,
+ const void *buf);
/* Functions that operate directly on low-level files */
-herr_t H5F_low_extend (H5F_low_t *lf, intn op, size_t size, haddr_t *addr);
-herr_t H5F_low_seteof (H5F_low_t *lf, const haddr_t *addr);
-hbool_t H5F_low_access (const H5F_low_class_t *type, const char *name,
- int mode, H5F_search_t *key);
-H5F_low_t *H5F_low_open (const H5F_low_class_t *type, const char *name,
- uintn flags, H5F_search_t *key);
-H5F_low_t *H5F_low_close (H5F_low_t *lf);
-size_t H5F_low_size (H5F_low_t *lf, haddr_t *addr);
-herr_t H5F_low_read (H5F_low_t *lf, const haddr_t *addr, size_t size,
- uint8 *buf);
-herr_t H5F_low_write (H5F_low_t *lf, const haddr_t *addr, size_t size,
- const uint8 *buf);
-herr_t H5F_low_flush (H5F_low_t *lf);
-
+herr_t H5F_low_extend(H5F_low_t *lf, intn op, size_t size, haddr_t *addr);
+herr_t H5F_low_seteof(H5F_low_t *lf, const haddr_t *addr);
+hbool_t H5F_low_access(const H5F_low_class_t *type, const char *name,
+ int mode, H5F_search_t *key);
+H5F_low_t *H5F_low_open(const H5F_low_class_t *type, const char *name,
+ uintn flags, H5F_search_t *key);
+H5F_low_t *H5F_low_close(H5F_low_t *lf);
+size_t H5F_low_size(H5F_low_t *lf, haddr_t *addr);
+herr_t H5F_low_read(H5F_low_t *lf, const haddr_t *addr, size_t size,
+ uint8 *buf);
+herr_t H5F_low_write(H5F_low_t *lf, const haddr_t *addr, size_t size,
+ const uint8 *buf);
+herr_t H5F_low_flush(H5F_low_t *lf);
/* Functions that operate on addresses */
#define H5F_addr_eq(A1,A2) (H5F_addr_cmp(A1,A2)==0)
@@ -454,17 +449,17 @@ herr_t H5F_low_flush (H5F_low_t *lf);
#define H5F_addr_le(A1,A2) (H5F_addr_cmp(A1,A2)<=0)
#define H5F_addr_gt(A1,A2) (H5F_addr_cmp(A1,A2)>0)
#define H5F_addr_ge(A1,A2) (H5F_addr_cmp(A1,A2)>=0)
-intn H5F_addr_cmp (const haddr_t*, const haddr_t*);
-hbool_t H5F_addr_defined (const haddr_t*);
-void H5F_addr_undef (haddr_t*);
-void H5F_addr_reset (haddr_t*);
-hbool_t H5F_addr_zerop (const haddr_t*);
-void H5F_addr_encode (H5F_t*, uint8**, const haddr_t*);
-void H5F_addr_decode (H5F_t*, const uint8**, haddr_t*);
-void H5F_addr_print (FILE*, const haddr_t*);
-void H5F_addr_pow2 (uintn, haddr_t*);
-void H5F_addr_inc (haddr_t*, size_t);
-void H5F_addr_add (haddr_t*, const haddr_t *);
-uintn H5F_addr_hash (const haddr_t*, uintn mod);
+intn H5F_addr_cmp(const haddr_t *, const haddr_t *);
+hbool_t H5F_addr_defined(const haddr_t *);
+void H5F_addr_undef(haddr_t *);
+void H5F_addr_reset(haddr_t *);
+hbool_t H5F_addr_zerop(const haddr_t *);
+void H5F_addr_encode(H5F_t *, uint8 **, const haddr_t *);
+void H5F_addr_decode(H5F_t *, const uint8 **, haddr_t *);
+void H5F_addr_print(FILE *, const haddr_t *);
+void H5F_addr_pow2(uintn, haddr_t *);
+void H5F_addr_inc(haddr_t *, size_t);
+void H5F_addr_add(haddr_t *, const haddr_t *);
+uintn H5F_addr_hash(const haddr_t *, uintn mod);
#endif
diff --git a/src/H5Fpublic.h b/src/H5Fpublic.h
index 818047c..1ed15a7 100644
--- a/src/H5Fpublic.h
+++ b/src/H5Fpublic.h
@@ -24,23 +24,23 @@
#include <H5Apublic.h>
/* file access codes */
-#define H5ACC_DEFAULT 0x0000 /* Use in H5Fopen & H5Fcreate to open a file with default access */
-#define H5ACC_WRITE 0x0001 /* Use in H5Fopen to open a file with write access */
-#define H5ACC_OVERWRITE 0x0002 /* Use in H5Fcreate truncate an existing file */
+#define H5ACC_DEFAULT 0x0000 /* Use in H5Fopen & H5Fcreate to open a file with default access */
+#define H5ACC_WRITE 0x0001 /* Use in H5Fopen to open a file with write access */
+#define H5ACC_OVERWRITE 0x0002 /* Use in H5Fcreate truncate an existing file */
#ifdef __cplusplus
-extern "C" {
+extern "C" {
#endif
/* Functions in H5F.c */
-hbool_t H5Fis_hdf5(const char *filename);
-hid_t H5Fcreate(const char *filename, uintn flags, hid_t create_template, hid_t access_template);
-hid_t H5Fopen(const char *filename, uintn flags, hid_t access_template);
-herr_t H5Fclose(hid_t fid);
-hid_t H5Fget_create_template (hid_t fid);
+ hbool_t H5Fis_hdf5(const char *filename);
+ hid_t H5Fcreate(const char *filename, uintn flags, hid_t create_template, hid_t access_template);
+ hid_t H5Fopen(const char *filename, uintn flags, hid_t access_template);
+ herr_t H5Fclose(hid_t fid);
+ hid_t H5Fget_create_template(hid_t fid);
#ifdef __cplusplus
}
-#endif
#endif
+#endif
diff --git a/src/H5Fsec2.c b/src/H5Fsec2.c
index 03cd240..f97372b 100644
--- a/src/H5Fsec2.c
+++ b/src/H5Fsec2.c
@@ -8,11 +8,11 @@
* Purpose: This is the Posix section-2 I/O subclass of H5Flow.
*
* Notes: This driver keeps track of its own file position in order to
- * minimize the number of calls to lseek(). We assume that
- * opening a file sets the current file position to the beginning
- * and that read() and write() modify the file position as
- * expected when they return successfully (unsuccessful return
- * leaves the file position undefined).
+ * minimize the number of calls to lseek(). We assume that
+ * opening a file sets the current file position to the beginning
+ * and that read() and write() modify the file position as
+ * expected when they return successfully (unsuccessful return
+ * leaves the file position undefined).
*/
#include <H5private.h>
#include <H5Eprivate.h>
@@ -22,98 +22,94 @@
#include <sys/types.h>
#include <sys/stat.h>
+#define PABLO_MASK H5F_sec2
+static hbool_t interface_initialize_g = FALSE;
+#define INTERFACE_INIT NULL
-#define PABLO_MASK H5F_sec2
-static hbool_t interface_initialize_g = FALSE;
-#define INTERFACE_INIT NULL
-
-static H5F_low_t *H5F_sec2_open (const char *name, uintn flags, H5F_search_t*);
-static herr_t H5F_sec2_close (H5F_low_t *lf);
-static herr_t H5F_sec2_read (H5F_low_t *lf, const haddr_t *addr, size_t size,
- uint8 *buf);
-static herr_t H5F_sec2_write (H5F_low_t *lf, const haddr_t *addr, size_t size,
- const uint8 *buf);
-
-const H5F_low_class_t H5F_LOW_SEC2[1] = {{
- NULL, /* access method */
- H5F_sec2_open, /* open method */
- H5F_sec2_close, /* close method */
- H5F_sec2_read, /* read method */
- H5F_sec2_write, /* write method */
- NULL, /* flush method */
- NULL, /* extend method */
-}};
-
+static H5F_low_t *H5F_sec2_open(const char *name, uintn flags, H5F_search_t *);
+static herr_t H5F_sec2_close(H5F_low_t *lf);
+static herr_t H5F_sec2_read(H5F_low_t *lf, const haddr_t *addr, size_t size,
+ uint8 *buf);
+static herr_t H5F_sec2_write(H5F_low_t *lf, const haddr_t *addr, size_t size,
+ const uint8 *buf);
+const H5F_low_class_t H5F_LOW_SEC2[1] =
+{
+ {
+ NULL, /* access method */
+ H5F_sec2_open, /* open method */
+ H5F_sec2_close, /* close method */
+ H5F_sec2_read, /* read method */
+ H5F_sec2_write, /* write method */
+ NULL, /* flush method */
+ NULL, /* extend method */
+ }};
/*-------------------------------------------------------------------------
- * Function: H5F_sec2_open
+ * Function: H5F_sec2_open
*
- * Purpose: Opens a file with name NAME. The FLAGS are a bit field with
- * the possible values defined in H5F_low_open().
+ * Purpose: Opens a file with name NAME. The FLAGS are a bit field with
+ * the possible values defined in H5F_low_open().
*
* Errors:
- * IO CANTOPENFILE Open failed.
+ * IO CANTOPENFILE Open failed.
*
- * Return: Success: Low-level file pointer
+ * Return: Success: Low-level file pointer
*
- * Failure: NULL
+ * Failure: NULL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, October 22, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-static H5F_low_t *
-H5F_sec2_open (const char *name, uintn flags, H5F_search_t *key/*out*/)
+static H5F_low_t *
+H5F_sec2_open(const char *name, uintn flags, H5F_search_t *key /*out */ )
{
- uintn oflags;
- H5F_low_t *lf = NULL;
- int fd;
- struct stat sb;
-
- FUNC_ENTER (H5F_sec2_open, NULL);
+ uintn oflags;
+ H5F_low_t *lf = NULL;
+ int fd;
+ struct stat sb;
- oflags = (flags & H5F_ACC_WRITE) ? O_RDWR : O_RDONLY;
- oflags |= (flags & H5F_ACC_CREAT) ? O_CREAT : 0;
- oflags |= (flags & H5F_ACC_EXCL) ? O_EXCL : 0;
- oflags |= (flags & H5F_ACC_TRUNC) ? O_TRUNC : 0;
+ FUNC_ENTER(H5F_sec2_open, NULL);
- if ((fd=open (name, oflags, 0666))<0) {
- HRETURN_ERROR (H5E_IO, H5E_CANTOPENFILE, NULL, "open failed");
- }
-
- lf = H5MM_xcalloc (1, sizeof(H5F_low_t));
- lf->u.sec2.fd = fd;
- lf->u.sec2.op = H5F_OP_SEEK;
- lf->u.sec2.cur = 0;
- fstat (fd, &sb);
- lf->eof.offset = sb.st_size;
+ oflags = (flags & H5F_ACC_WRITE) ? O_RDWR : O_RDONLY;
+ oflags |= (flags & H5F_ACC_CREAT) ? O_CREAT : 0;
+ oflags |= (flags & H5F_ACC_EXCL) ? O_EXCL : 0;
+ oflags |= (flags & H5F_ACC_TRUNC) ? O_TRUNC : 0;
- if (key) {
- key->dev = sb.st_dev;
- key->ino = sb.st_ino;
- }
+ if ((fd = open(name, oflags, 0666)) < 0) {
+ HRETURN_ERROR(H5E_IO, H5E_CANTOPENFILE, NULL, "open failed");
+ }
+ lf = H5MM_xcalloc(1, sizeof(H5F_low_t));
+ lf->u.sec2.fd = fd;
+ lf->u.sec2.op = H5F_OP_SEEK;
+ lf->u.sec2.cur = 0;
+ fstat(fd, &sb);
+ lf->eof.offset = sb.st_size;
- FUNC_LEAVE (lf);
+ if (key) {
+ key->dev = sb.st_dev;
+ key->ino = sb.st_ino;
+ }
+ FUNC_LEAVE(lf);
}
-
/*-------------------------------------------------------------------------
- * Function: H5F_sec2_close
+ * Function: H5F_sec2_close
*
- * Purpose: Closes a file.
+ * Purpose: Closes a file.
*
* Errors:
- * IO CLOSEERROR Close failed.
+ * IO CLOSEERROR Close failed.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, October 22, 1997
*
* Modifications:
@@ -121,35 +117,34 @@ H5F_sec2_open (const char *name, uintn flags, H5F_search_t *key/*out*/)
*-------------------------------------------------------------------------
*/
static herr_t
-H5F_sec2_close (H5F_low_t *lf)
+H5F_sec2_close(H5F_low_t *lf)
{
- FUNC_ENTER (H5F_sec2_close, FAIL);
+ FUNC_ENTER(H5F_sec2_close, FAIL);
- if (close (lf->u.sec2.fd)<0) {
- HRETURN_ERROR (H5E_IO, H5E_CLOSEERROR, FAIL, "close failed");
- }
- lf->u.sec2.fd = -1;
+ if (close(lf->u.sec2.fd) < 0) {
+ HRETURN_ERROR(H5E_IO, H5E_CLOSEERROR, FAIL, "close failed");
+ }
+ lf->u.sec2.fd = -1;
- FUNC_LEAVE (SUCCEED);
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5F_sec2_read
+ * Function: H5F_sec2_read
*
- * Purpose: Reads SIZE bytes beginning at address ADDR in file LF and
- * places them in buffer BUF. Reading past the logical or
- * physical end of file returns zeros instead of failing.
+ * Purpose: Reads SIZE bytes beginning at address ADDR in file LF and
+ * places them in buffer BUF. Reading past the logical or
+ * physical end of file returns zeros instead of failing.
*
* Errors:
- * IO READERROR Read failed.
- * IO SEEKERROR Lseek failed.
+ * IO READERROR Read failed.
+ * IO SEEKERROR Lseek failed.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, October 22, 1997
*
* Modifications:
@@ -157,86 +152,81 @@ H5F_sec2_close (H5F_low_t *lf)
*-------------------------------------------------------------------------
*/
static herr_t
-H5F_sec2_read (H5F_low_t *lf, const haddr_t *addr, size_t size, uint8 *buf)
+H5F_sec2_read(H5F_low_t *lf, const haddr_t *addr, size_t size, uint8 *buf)
{
- ssize_t n;
- off_t offset;
-
- FUNC_ENTER (H5F_sec2_read, FAIL);
-
-
- /* Check for overflow */
- offset = addr->offset;
- assert ("address overflowed" && offset==addr->offset);
- assert ("overflow" && offset+size>=offset);
+ ssize_t n;
+ off_t offset;
- /* Check easy cases */
- if (0==size) HRETURN (SUCCEED);
- if (offset>=lf->eof.offset) {
- HDmemset (buf, 0, size);
- HRETURN (SUCCEED);
- }
+ FUNC_ENTER(H5F_sec2_read, FAIL);
- /*
- * Optimize seeking. If that optimization is disabled then always call
- * lseek().
- */
- if (!H5F_OPT_SEEK ||
- lf->u.sec2.op==H5F_OP_UNKNOWN ||
- lf->u.sec2.cur!=offset) {
- if (lseek (lf->u.sec2.fd, offset, SEEK_SET)<0) {
- HRETURN_ERROR (H5E_IO, H5E_SEEKERROR, FAIL, "lseek failed");
- }
- lf->u.sec2.cur = offset;
- }
+ /* Check for overflow */
+ offset = addr->offset;
+ assert("address overflowed" && offset == addr->offset);
+ assert("overflow" && offset + size >= offset);
- /*
- * Read zeros past the logical end of file (physical is handled below)
- */
- if ((size_t)offset+size>lf->eof.offset) {
- size_t nbytes = (size_t)offset+size - lf->eof.offset;
- HDmemset (buf+size-nbytes, 0, nbytes);
- size -= nbytes;
- }
+ /* Check easy cases */
+ if (0 == size)
+ HRETURN(SUCCEED);
+ if (offset >= lf->eof.offset) {
+ HDmemset(buf, 0, size);
+ HRETURN(SUCCEED);
+ }
+ /*
+ * Optimize seeking. If that optimization is disabled then always call
+ * lseek().
+ */
+ if (!H5F_OPT_SEEK ||
+ lf->u.sec2.op == H5F_OP_UNKNOWN ||
+ lf->u.sec2.cur != offset) {
+ if (lseek(lf->u.sec2.fd, offset, SEEK_SET) < 0) {
+ HRETURN_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "lseek failed");
+ }
+ lf->u.sec2.cur = offset;
+ }
+ /*
+ * Read zeros past the logical end of file (physical is handled below)
+ */
+ if ((size_t) offset + size > lf->eof.offset) {
+ size_t nbytes = (size_t) offset + size - lf->eof.offset;
+ HDmemset(buf + size - nbytes, 0, nbytes);
+ size -= nbytes;
+ }
+ /*
+ * Read the data. If a read error occurs then set the last file operation
+ * to UNKNOWN because the file position isn't guaranteed by Posix.
+ */
+ if ((n = read(lf->u.sec2.fd, buf, size)) < 0) {
+ lf->u.sec2.op = H5F_OP_UNKNOWN;
+ HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, "read failed");
+ } else if (n < size) {
+ HDmemset(buf + n, 0, size - n);
+ }
+ /*
+ * Update the file position with the number of bytes actually read. This
+ * might be different than the number requested.
+ */
+ lf->u.sec2.op = H5F_OP_READ;
+ lf->u.sec2.cur = offset + n;
+ assert("address overflowed" && lf->u.sec2.cur >= offset);
- /*
- * Read the data. If a read error occurs then set the last file operation
- * to UNKNOWN because the file position isn't guaranteed by Posix.
- */
- if ((n=read (lf->u.sec2.fd, buf, size))<0) {
- lf->u.sec2.op = H5F_OP_UNKNOWN;
- HRETURN_ERROR (H5E_IO, H5E_READERROR, FAIL, "read failed");
- } else if (n<size) {
- HDmemset (buf+n, 0, size-n);
- }
-
- /*
- * Update the file position with the number of bytes actually read. This
- * might be different than the number requested.
- */
- lf->u.sec2.op = H5F_OP_READ;
- lf->u.sec2.cur = offset + n;
- assert ("address overflowed" && lf->u.sec2.cur>=offset);
-
- FUNC_LEAVE (SUCCEED);
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5F_sec2_write
+ * Function: H5F_sec2_write
*
- * Purpose: Writes SIZE bytes from the beginning of BUF into file LF at
- * file address ADDR.
+ * Purpose: Writes SIZE bytes from the beginning of BUF into file LF at
+ * file address ADDR.
*
* Errors:
- * IO SEEKERROR Lseek failed.
- * IO WRITEERROR Write failed.
+ * IO SEEKERROR Lseek failed.
+ * IO WRITEERROR Write failed.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, October 22, 1997
*
* Modifications:
@@ -244,46 +234,44 @@ H5F_sec2_read (H5F_low_t *lf, const haddr_t *addr, size_t size, uint8 *buf)
*-------------------------------------------------------------------------
*/
static herr_t
-H5F_sec2_write (H5F_low_t *lf, const haddr_t *addr, size_t size,
- const uint8 *buf)
+H5F_sec2_write(H5F_low_t *lf, const haddr_t *addr, size_t size,
+ const uint8 *buf)
{
- off_t offset;
-
- FUNC_ENTER (H5F_sec2_write, FAIL);
-
- /* Check for overflow */
- offset = addr->offset;
- assert ("address overflowed" && offset==addr->offset);
- assert ("overflow" && offset+size>=offset);
+ off_t offset;
- /*
- * Optimize seeking. If that optimization is disabled then always call
- * lseek().
- */
- if (!H5F_OPT_SEEK ||
- lf->u.sec2.op==H5F_OP_UNKNOWN ||
- lf->u.sec2.cur!=offset) {
- if (lseek (lf->u.sec2.fd, offset, SEEK_SET)<0) {
- HRETURN_ERROR (H5E_IO, H5E_SEEKERROR, FAIL, "lseek failed");
- }
- lf->u.sec2.cur = offset;
- }
+ FUNC_ENTER(H5F_sec2_write, FAIL);
- /*
- * Write the data to the file. If the write failed then set the
- * operation back to UNKNOWN since Posix doesn't gurantee its value.
- */
- if (size != write (lf->u.sec2.fd, buf, size)) {
- lf->u.sec2.op = H5F_OP_UNKNOWN;
- HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "write failed");
- }
+ /* Check for overflow */
+ offset = addr->offset;
+ assert("address overflowed" && offset == addr->offset);
+ assert("overflow" && offset + size >= offset);
- /*
- * Update the file position.
- */
- lf->u.sec2.op = H5F_OP_WRITE;
- lf->u.sec2.cur = offset + size;
- assert ("address overflowed" && lf->u.sec2.cur>=offset);
+ /*
+ * Optimize seeking. If that optimization is disabled then always call
+ * lseek().
+ */
+ if (!H5F_OPT_SEEK ||
+ lf->u.sec2.op == H5F_OP_UNKNOWN ||
+ lf->u.sec2.cur != offset) {
+ if (lseek(lf->u.sec2.fd, offset, SEEK_SET) < 0) {
+ HRETURN_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "lseek failed");
+ }
+ lf->u.sec2.cur = offset;
+ }
+ /*
+ * Write the data to the file. If the write failed then set the
+ * operation back to UNKNOWN since Posix doesn't gurantee its value.
+ */
+ if (size != write(lf->u.sec2.fd, buf, size)) {
+ lf->u.sec2.op = H5F_OP_UNKNOWN;
+ HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "write failed");
+ }
+ /*
+ * Update the file position.
+ */
+ lf->u.sec2.op = H5F_OP_WRITE;
+ lf->u.sec2.cur = offset + size;
+ assert("address overflowed" && lf->u.sec2.cur >= offset);
- FUNC_LEAVE (SUCCEED);
+ FUNC_LEAVE(SUCCEED);
}
diff --git a/src/H5Fstdio.c b/src/H5Fstdio.c
index 169e3e2..09f61bc 100644
--- a/src/H5Fstdio.c
+++ b/src/H5Fstdio.c
@@ -16,123 +16,124 @@
#include <sys/types.h>
#include <sys/stat.h>
+#define PABLO_MASK H5F_sec2
+static hbool_t interface_initialize_g = FALSE;
+#define INTERFACE_INIT NULL
-#define PABLO_MASK H5F_sec2
-static hbool_t interface_initialize_g = FALSE;
-#define INTERFACE_INIT NULL
-
-static H5F_low_t *H5F_stdio_open (const char *name, uintn flags,
- H5F_search_t *key);
-static herr_t H5F_stdio_close (H5F_low_t *lf);
-static herr_t H5F_stdio_read (H5F_low_t *lf, const haddr_t *addr, size_t size,
- uint8 *buf);
-static herr_t H5F_stdio_write (H5F_low_t *lf, const haddr_t *addr, size_t size,
- const uint8 *buf);
-static herr_t H5F_stdio_flush (H5F_low_t *lf);
-
-const H5F_low_class_t H5F_LOW_STDIO[1] = {{
- NULL, /* use default access(2) func */
- H5F_stdio_open, /* open method */
- H5F_stdio_close, /* close method */
- H5F_stdio_read, /* read method */
- H5F_stdio_write, /* write method */
- H5F_stdio_flush, /* flush method */
- NULL, /* extend method */
-}};
+static H5F_low_t *H5F_stdio_open(const char *name, uintn flags,
+ H5F_search_t *key);
+static herr_t H5F_stdio_close(H5F_low_t *lf);
+static herr_t H5F_stdio_read(H5F_low_t *lf, const haddr_t *addr, size_t size,
+ uint8 *buf);
+static herr_t H5F_stdio_write(H5F_low_t *lf, const haddr_t *addr, size_t size,
+ const uint8 *buf);
+static herr_t H5F_stdio_flush(H5F_low_t *lf);
+const H5F_low_class_t H5F_LOW_STDIO[1] =
+{
+ {
+ NULL, /* use default access(2) func */
+ H5F_stdio_open, /* open method */
+ H5F_stdio_close, /* close method */
+ H5F_stdio_read, /* read method */
+ H5F_stdio_write, /* write method */
+ H5F_stdio_flush, /* flush method */
+ NULL, /* extend method */
+ }};
/*-------------------------------------------------------------------------
- * Function: H5F_stdio_open
+ * Function: H5F_stdio_open
*
- * Purpose: Opens a file with name NAME. The FLAGS are a bit field with
- * the possible values defined in H5F_low_open().
+ * Purpose: Opens a file with name NAME. The FLAGS are a bit field with
+ * the possible values defined in H5F_low_open().
*
- * Bugs: H5F_ACC_EXCL has a race condition.
+ * Bugs: H5F_ACC_EXCL has a race condition.
*
* Errors:
- * IO CANTOPENFILE File doesn't exist and CREAT wasn't
- * specified.
- * IO CANTOPENFILE Fopen failed.
- * IO FILEEXISTS File exists but CREAT and EXCL were
- * specified.
+ * IO CANTOPENFILE File doesn't exist and CREAT wasn't
+ * specified.
+ * IO CANTOPENFILE Fopen failed.
+ * IO FILEEXISTS File exists but CREAT and EXCL were
+ * specified.
*
- * Return: Success: Low-level file pointer
+ * Return: Success: Low-level file pointer
*
- * Failure: NULL
+ * Failure: NULL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, October 22, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-static H5F_low_t *
-H5F_stdio_open (const char *name, uintn flags, H5F_search_t *key/*out*/)
+static H5F_low_t *
+H5F_stdio_open(const char *name, uintn flags, H5F_search_t *key /*out */ )
{
- H5F_low_t *lf=NULL;
- FILE *f=NULL;
- struct stat sb;
+ H5F_low_t *lf = NULL;
+ FILE *f = NULL;
+ struct stat sb;
- FUNC_ENTER (H5F_stdio_open, NULL);
+ FUNC_ENTER(H5F_stdio_open, NULL);
- if (access (name, F_OK)<0) {
- if ((flags & H5F_ACC_CREAT) && (flags & H5F_ACC_WRITE)) {
- f = fopen (name, "wb+");
- } else {
- HRETURN_ERROR (H5E_IO, H5E_CANTOPENFILE, NULL,
- "file doesn't exist and CREAT wasn't specified");
- }
-
- } else if ((flags & H5F_ACC_CREAT) && (flags & H5F_ACC_EXCL)) {
- HRETURN_ERROR (H5E_IO, H5E_FILEEXISTS, NULL,
- "file exists but CREAT and EXCL were specified");
-
- } else if (flags & H5F_ACC_WRITE) {
- if (flags & H5F_ACC_TRUNC) f = fopen (name, "wb+");
- else f = fopen (name, "rb+");
-
- } else {
- f = fopen (name, "rb");
- }
- if (!f) HRETURN_ERROR (H5E_IO, H5E_CANTOPENFILE, NULL, "fopen failed");
+ if (access(name, F_OK) < 0) {
+ if ((flags & H5F_ACC_CREAT) && (flags & H5F_ACC_WRITE)) {
+ f = fopen(name, "wb+");
+ } else {
+ HRETURN_ERROR(H5E_IO, H5E_CANTOPENFILE, NULL,
+ "file doesn't exist and CREAT wasn't specified");
+ }
- /* Build the return value */
- lf = H5MM_xcalloc (1, sizeof(H5F_low_t));
- lf->u.stdio.f = f;
- lf->u.stdio.op = H5F_OP_SEEK;
- lf->u.stdio.cur = 0;
- H5F_addr_reset (&(lf->eof));
- if (fseek (lf->u.stdio.f, 0, SEEK_END)<0) {
- lf->u.stdio.op = H5F_OP_UNKNOWN;
- } else {
- H5F_addr_inc (&(lf->eof), ftell (lf->u.stdio.f));
- }
+ } else if ((flags & H5F_ACC_CREAT) && (flags & H5F_ACC_EXCL)) {
+ HRETURN_ERROR(H5E_IO, H5E_FILEEXISTS, NULL,
+ "file exists but CREAT and EXCL were specified");
- /* The unique key */
- if (key) {
- fstat (fileno (f), &sb);
- key->dev = sb.st_dev;
- key->ino = sb.st_ino;
- }
+ } else if (flags & H5F_ACC_WRITE) {
+ if (flags & H5F_ACC_TRUNC)
+ f = fopen(name, "wb+");
+ else
+ f = fopen(name, "rb+");
- FUNC_LEAVE (lf);
-}
+ } else {
+ f = fopen(name, "rb");
+ }
+ if (!f)
+ HRETURN_ERROR(H5E_IO, H5E_CANTOPENFILE, NULL, "fopen failed");
+ /* Build the return value */
+ lf = H5MM_xcalloc(1, sizeof(H5F_low_t));
+ lf->u.stdio.f = f;
+ lf->u.stdio.op = H5F_OP_SEEK;
+ lf->u.stdio.cur = 0;
+ H5F_addr_reset(&(lf->eof));
+ if (fseek(lf->u.stdio.f, 0, SEEK_END) < 0) {
+ lf->u.stdio.op = H5F_OP_UNKNOWN;
+ } else {
+ H5F_addr_inc(&(lf->eof), ftell(lf->u.stdio.f));
+ }
+
+ /* The unique key */
+ if (key) {
+ fstat(fileno(f), &sb);
+ key->dev = sb.st_dev;
+ key->ino = sb.st_ino;
+ }
+ FUNC_LEAVE(lf);
+}
/*-------------------------------------------------------------------------
- * Function: H5F_stdio_close
+ * Function: H5F_stdio_close
*
- * Purpose: Closes a file.
+ * Purpose: Closes a file.
*
* Errors:
- * IO CLOSEERROR Fclose failed.
+ * IO CLOSEERROR Fclose failed.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, October 22, 1997
*
* Modifications:
@@ -140,35 +141,34 @@ H5F_stdio_open (const char *name, uintn flags, H5F_search_t *key/*out*/)
*-------------------------------------------------------------------------
*/
static herr_t
-H5F_stdio_close (H5F_low_t *lf)
+H5F_stdio_close(H5F_low_t *lf)
{
- FUNC_ENTER (H5F_stdio_close, FAIL);
+ FUNC_ENTER(H5F_stdio_close, FAIL);
- if (fclose (lf->u.stdio.f)<0) {
- HRETURN_ERROR (H5E_IO, H5E_CLOSEERROR, FAIL, "fclose failed");
- }
- lf->u.stdio.f = NULL;
+ if (fclose(lf->u.stdio.f) < 0) {
+ HRETURN_ERROR(H5E_IO, H5E_CLOSEERROR, FAIL, "fclose failed");
+ }
+ lf->u.stdio.f = NULL;
- FUNC_LEAVE (SUCCEED);
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5F_stdio_read
+ * Function: H5F_stdio_read
*
- * Purpose: Reads SIZE bytes beginning at address ADDR in file LF and
- * places them in buffer BUF. Reading past the logical or
- * physical end of file returns zeros instead of failing.
+ * Purpose: Reads SIZE bytes beginning at address ADDR in file LF and
+ * places them in buffer BUF. Reading past the logical or
+ * physical end of file returns zeros instead of failing.
*
* Errors:
- * IO READERROR Fread failed.
- * IO SEEKERROR Fseek failed.
+ * IO READERROR Fread failed.
+ * IO SEEKERROR Fseek failed.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, October 22, 1997
*
* Modifications:
@@ -176,83 +176,79 @@ H5F_stdio_close (H5F_low_t *lf)
*-------------------------------------------------------------------------
*/
static herr_t
-H5F_stdio_read (H5F_low_t *lf, const haddr_t *addr, size_t size, uint8 *buf)
+H5F_stdio_read(H5F_low_t *lf, const haddr_t *addr, size_t size, uint8 *buf)
{
- size_t n;
- off_t offset;
-
- FUNC_ENTER (H5F_stdio_read, FAIL);
+ size_t n;
+ off_t offset;
- /* Check for overflow */
- offset = addr->offset;
- assert ("address overflowed" && offset==addr->offset);
- assert ("overflow" && offset+size>=offset);
+ FUNC_ENTER(H5F_stdio_read, FAIL);
- /* Check easy cases */
- if (0==size) HRETURN (SUCCEED);
- if (offset>=lf->eof.offset) {
- HDmemset (buf, 0, size);
- HRETURN (SUCCEED);
- }
-
- /*
- * Seek to the correct file position.
- */
- if (!H5F_OPT_SEEK ||
- lf->u.stdio.op!=H5F_OP_READ ||
- lf->u.stdio.cur!=offset) {
- if (fseek (lf->u.stdio.f, offset, SEEK_SET)<0) {
- HRETURN_ERROR (H5E_IO, H5E_SEEKERROR, FAIL, "fseek failed");
- }
- lf->u.stdio.cur = offset;
- }
+ /* Check for overflow */
+ offset = addr->offset;
+ assert("address overflowed" && offset == addr->offset);
+ assert("overflow" && offset + size >= offset);
- /*
- * Read zeros past the logical end of file (physical is handled below)
- */
- if ((size_t)offset+size>lf->eof.offset) {
- size_t nbytes = (size_t)offset+size - lf->eof.offset;
- HDmemset (buf+size-nbytes, 0, nbytes);
- size -= nbytes;
- }
-
- /*
- * Read the data. Since we're reading single-byte values, a partial read
- * will advance the file position by N. If N is negative or an error
- * occurs then the file position is undefined.
- */
- n = fread (buf, 1, size, lf->u.stdio.f);
- if (n<=0 && ferror (lf->u.stdio.f)) {
- lf->u.stdio.op = H5F_OP_UNKNOWN;
- HRETURN_ERROR (H5E_IO, H5E_READERROR, FAIL, "fread failed");
- } else if (n<size) {
- HDmemset (buf+n, 0, size-n);
- }
-
- /*
- * Update the file position data.
- */
- lf->u.stdio.op = H5F_OP_READ;
- lf->u.stdio.cur = offset + n;
- FUNC_LEAVE (SUCCEED);
+ /* Check easy cases */
+ if (0 == size)
+ HRETURN(SUCCEED);
+ if (offset >= lf->eof.offset) {
+ HDmemset(buf, 0, size);
+ HRETURN(SUCCEED);
+ }
+ /*
+ * Seek to the correct file position.
+ */
+ if (!H5F_OPT_SEEK ||
+ lf->u.stdio.op != H5F_OP_READ ||
+ lf->u.stdio.cur != offset) {
+ if (fseek(lf->u.stdio.f, offset, SEEK_SET) < 0) {
+ HRETURN_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "fseek failed");
+ }
+ lf->u.stdio.cur = offset;
+ }
+ /*
+ * Read zeros past the logical end of file (physical is handled below)
+ */
+ if ((size_t) offset + size > lf->eof.offset) {
+ size_t nbytes = (size_t) offset + size - lf->eof.offset;
+ HDmemset(buf + size - nbytes, 0, nbytes);
+ size -= nbytes;
+ }
+ /*
+ * Read the data. Since we're reading single-byte values, a partial read
+ * will advance the file position by N. If N is negative or an error
+ * occurs then the file position is undefined.
+ */
+ n = fread(buf, 1, size, lf->u.stdio.f);
+ if (n <= 0 && ferror(lf->u.stdio.f)) {
+ lf->u.stdio.op = H5F_OP_UNKNOWN;
+ HRETURN_ERROR(H5E_IO, H5E_READERROR, FAIL, "fread failed");
+ } else if (n < size) {
+ HDmemset(buf + n, 0, size - n);
+ }
+ /*
+ * Update the file position data.
+ */
+ lf->u.stdio.op = H5F_OP_READ;
+ lf->u.stdio.cur = offset + n;
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5F_stdio_write
+ * Function: H5F_stdio_write
*
- * Purpose: Writes SIZE bytes from the beginning of BUF into file LF at
- * file address ADDR.
+ * Purpose: Writes SIZE bytes from the beginning of BUF into file LF at
+ * file address ADDR.
*
* Errors:
- * IO SEEKERROR Fseek failed.
- * IO WRITEERROR Fwrite failed.
+ * IO SEEKERROR Fseek failed.
+ * IO WRITEERROR Fwrite failed.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, October 22, 1997
*
* Modifications:
@@ -260,62 +256,59 @@ H5F_stdio_read (H5F_low_t *lf, const haddr_t *addr, size_t size, uint8 *buf)
*-------------------------------------------------------------------------
*/
static herr_t
-H5F_stdio_write (H5F_low_t *lf, const haddr_t *addr, size_t size,
- const uint8 *buf)
+H5F_stdio_write(H5F_low_t *lf, const haddr_t *addr, size_t size,
+ const uint8 *buf)
{
- off_t offset;
+ off_t offset;
- FUNC_ENTER (H5F_stdio_write, FAIL);
+ FUNC_ENTER(H5F_stdio_write, FAIL);
- /* Check for overflow */
- offset = addr->offset;
- assert ("address overflowed" && offset==addr->offset);
- assert ("overflow" && offset+size>=offset);
+ /* Check for overflow */
+ offset = addr->offset;
+ assert("address overflowed" && offset == addr->offset);
+ assert("overflow" && offset + size >= offset);
- /*
- * Seek to the correct file position.
- */
- if (!H5F_OPT_SEEK ||
- lf->u.stdio.op!=H5F_OP_WRITE ||
- lf->u.stdio.cur!=offset) {
- if (fseek (lf->u.stdio.f, offset, SEEK_SET)<0) {
- HRETURN_ERROR (H5E_IO, H5E_SEEKERROR, FAIL, "fseek failed");
- }
- lf->u.stdio.cur = offset;
- }
-
- /*
- * Write the buffer. On successful return, the file position will be
- * advanced by the number of bytes read. Otherwise nobody knows where it
- * is.
- */
- if (size != fwrite (buf, 1, size, lf->u.stdio.f)) {
- lf->u.stdio.op = H5F_OP_UNKNOWN;
- HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "fwrite failed");
- }
-
- /*
- * Update seek optimizing data.
- */
- lf->u.stdio.op = H5F_OP_WRITE;
- lf->u.stdio.cur = offset + size;
- FUNC_LEAVE (SUCCEED);
+ /*
+ * Seek to the correct file position.
+ */
+ if (!H5F_OPT_SEEK ||
+ lf->u.stdio.op != H5F_OP_WRITE ||
+ lf->u.stdio.cur != offset) {
+ if (fseek(lf->u.stdio.f, offset, SEEK_SET) < 0) {
+ HRETURN_ERROR(H5E_IO, H5E_SEEKERROR, FAIL, "fseek failed");
+ }
+ lf->u.stdio.cur = offset;
+ }
+ /*
+ * Write the buffer. On successful return, the file position will be
+ * advanced by the number of bytes read. Otherwise nobody knows where it
+ * is.
+ */
+ if (size != fwrite(buf, 1, size, lf->u.stdio.f)) {
+ lf->u.stdio.op = H5F_OP_UNKNOWN;
+ HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "fwrite failed");
+ }
+ /*
+ * Update seek optimizing data.
+ */
+ lf->u.stdio.op = H5F_OP_WRITE;
+ lf->u.stdio.cur = offset + size;
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5F_stdio_flush
+ * Function: H5F_stdio_flush
*
- * Purpose: Makes sure that all data is on disk.
+ * Purpose: Makes sure that all data is on disk.
*
* Errors:
- * IO WRITEERROR Fflush failed.
+ * IO WRITEERROR Fflush failed.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, October 22, 1997
*
* Modifications:
@@ -323,22 +316,21 @@ H5F_stdio_write (H5F_low_t *lf, const haddr_t *addr, size_t size,
*-------------------------------------------------------------------------
*/
static herr_t
-H5F_stdio_flush (H5F_low_t *lf)
+H5F_stdio_flush(H5F_low_t *lf)
{
- FUNC_ENTER (H5F_stdio_flush, FAIL);
+ FUNC_ENTER(H5F_stdio_flush, FAIL);
- /*
- * What happens to the file position? Is it guaranteed to be the same
- * after the fflush() as it was before?
- */
- lf->u.stdio.op = H5F_OP_UNKNOWN;
+ /*
+ * What happens to the file position? Is it guaranteed to be the same
+ * after the fflush() as it was before?
+ */
+ lf->u.stdio.op = H5F_OP_UNKNOWN;
- /*
- * Flush
- */
- if (fflush (lf->u.stdio.f)<0) {
- HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL, "fflush failed");
- }
-
- FUNC_LEAVE (SUCCEED);
+ /*
+ * Flush
+ */
+ if (fflush(lf->u.stdio.f) < 0) {
+ HRETURN_ERROR(H5E_IO, H5E_WRITEERROR, FAIL, "fflush failed");
+ }
+ FUNC_LEAVE(SUCCEED);
}
diff --git a/src/H5G.c b/src/H5G.c
index 7975c56..e5acde2 100644
--- a/src/H5G.c
+++ b/src/H5G.c
@@ -1,36 +1,36 @@
/*-------------------------------------------------------------------------
- * Copyright (C) 1997 National Center for Supercomputing Applications.
+ * Copyright (C) 1997 National Center for Supercomputing Applications.
* All rights reserved.
*
*-------------------------------------------------------------------------
*
- * Created: H5G.c
- * Jul 18 1997
- * Robb Matzke <matzke@llnl.gov>
+ * Created: H5G.c
+ * Jul 18 1997
+ * Robb Matzke <matzke@llnl.gov>
*
- * Purpose: Symbol table functions. The functions that
- * begin with `H5G_stab_' don't understand the
- * naming system; they operate on a single
- * symbol table at a time.
+ * Purpose: Symbol table functions. The functions that
+ * begin with `H5G_stab_' don't understand the
+ * naming system; they operate on a single
+ * symbol table at a time.
*
- * The functions that begin with `H5G_node_' operate
- * on the leaf nodes of a symbol table B-tree. They
- * should be defined in the H5Gnode.c file.
+ * The functions that begin with `H5G_node_' operate
+ * on the leaf nodes of a symbol table B-tree. They
+ * should be defined in the H5Gnode.c file.
*
- * The remaining functions know how to traverse the
- * group directed graph
+ * The remaining functions know how to traverse the
+ * group directed graph
*
* Modifications:
*
- * Robb Matzke, 5 Aug 1997
- * Added calls to H5E.
+ * Robb Matzke, 5 Aug 1997
+ * Added calls to H5E.
*
- * Robb Matzke, 30 Aug 1997
- * Added `Errors:' field to function prologues.
+ * Robb Matzke, 30 Aug 1997
+ * Added `Errors:' field to function prologues.
*
*-------------------------------------------------------------------------
*/
-#define H5G_PACKAGE /*suppress error message about including H5Gpkg.h*/
+#define H5G_PACKAGE /*suppress error message about including H5Gpkg.h */
/* Packages needed by this file... */
#include <H5private.h>
@@ -42,43 +42,42 @@
#include <H5MMprivate.h>
#include <H5Oprivate.h>
-#define H5G_INIT_HEAP 8192
-#define H5G_RESERVED_ATOMS 0
-#define PABLO_MASK H5G_mask
+#define H5G_INIT_HEAP 8192
+#define H5G_RESERVED_ATOMS 0
+#define PABLO_MASK H5G_mask
/* Interface initialization */
-static hbool_t interface_initialize_g = FALSE;
-#define INTERFACE_INIT H5G_init_interface
-static herr_t H5G_init_interface (void);
-static void H5G_term_interface (void);
-
-static H5G_entry_t *H5G_getcwg (H5F_t *f);
+static hbool_t interface_initialize_g = FALSE;
+#define INTERFACE_INIT H5G_init_interface
+static herr_t H5G_init_interface(void);
+static void H5G_term_interface(void);
+static H5G_entry_t *H5G_getcwg(H5F_t *f);
/*-------------------------------------------------------------------------
- * Function: H5Gcreate
+ * Function: H5Gcreate
*
- * Purpose: Creates a new group in FILE and gives it the specified
- * NAME. Unless NAME begins with `/' it is relative to the
- * current working group. The group is opened for write access
- * and it's object ID is returned.
+ * Purpose: Creates a new group in FILE and gives it the specified
+ * NAME. Unless NAME begins with `/' it is relative to the
+ * current working group. The group is opened for write access
+ * and it's object ID is returned.
*
- * The optional SIZE_HINT specifies how much file space to
- * reserve to store the names that will appear in this
- * group. If a non-positive value is supplied for the SIZE_HINT
- * then a default size is chosen.
+ * The optional SIZE_HINT specifies how much file space to
+ * reserve to store the names that will appear in this
+ * group. If a non-positive value is supplied for the SIZE_HINT
+ * then a default size is chosen.
*
- * See also: H5Gset(), H5Gpush(), H5Gpop()
+ * See also: H5Gset(), H5Gpush(), H5Gpop()
*
* Errors:
*
- * Return: Success: The object ID of a new, empty group open for
- * writing. Call H5Gclose() when finished with
- * the group.
+ * Return: Success: The object ID of a new, empty group open for
+ * writing. Call H5Gclose() when finished with
+ * the group.
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, September 24, 1997
*
* Modifications:
@@ -86,52 +85,48 @@ static H5G_entry_t *H5G_getcwg (H5F_t *f);
*-------------------------------------------------------------------------
*/
hid_t
-H5Gcreate (hid_t file_id, const char *name, size_t size_hint)
+H5Gcreate(hid_t file_id, const char *name, size_t size_hint)
{
- H5F_t *f = NULL;
- H5G_t *grp;
- hid_t ret_value = FAIL;
-
- FUNC_ENTER (H5Gcreate, FAIL);
- H5ECLEAR;
-
- /* Check arguments */
- if (H5_FILE!=H5Aatom_group (file_id) ||
- NULL==(f=H5Aatom_object (file_id))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a file");
- }
- if (!name || !*name) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no name given");
- }
-
- /* Create the group */
- if (NULL==(grp=H5G_create (f, name, size_hint))) {
- HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group");
- }
-
- if ((ret_value = H5Aregister_atom (H5_GROUP, grp))<0) {
- H5G_close (grp);
- HRETURN_ERROR (H5E_ATOM, H5E_CANTREGISTER, FAIL,
- "unable to register group");
- }
-
- FUNC_LEAVE (ret_value);
+ H5F_t *f = NULL;
+ H5G_t *grp;
+ hid_t ret_value = FAIL;
+
+ FUNC_ENTER(H5Gcreate, FAIL);
+ H5ECLEAR;
+
+ /* Check arguments */
+ if (H5_FILE != H5Aatom_group(file_id) ||
+ NULL == (f = H5Aatom_object(file_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file");
+ }
+ if (!name || !*name) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name given");
+ }
+ /* Create the group */
+ if (NULL == (grp = H5G_create(f, name, size_hint))) {
+ HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group");
+ }
+ if ((ret_value = H5Aregister_atom(H5_GROUP, grp)) < 0) {
+ H5G_close(grp);
+ HRETURN_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL,
+ "unable to register group");
+ }
+ FUNC_LEAVE(ret_value);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Gopen
+ * Function: H5Gopen
*
- * Purpose: Opens an existing group for modification. When finished,
- * call H5Gclose() to close it and release resources.
+ * Purpose: Opens an existing group for modification. When finished,
+ * call H5Gclose() to close it and release resources.
*
* Errors:
*
- * Return: Success: Object ID of the group.
+ * Return: Success: Object ID of the group.
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, December 31, 1997
*
* Modifications:
@@ -139,51 +134,47 @@ H5Gcreate (hid_t file_id, const char *name, size_t size_hint)
*-------------------------------------------------------------------------
*/
hid_t
-H5Gopen (hid_t file_id, const char *name)
+H5Gopen(hid_t file_id, const char *name)
{
- hid_t ret_value = FAIL;
- H5F_t *f = NULL;
- H5G_t *grp = NULL;
-
- FUNC_ENTER (H5Gopen, FAIL);
- H5ECLEAR;
-
- /* Check args */
- if (H5_FILE!=H5Aatom_group (file_id) ||
- NULL==(f=H5Aatom_object (file_id))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a file");
- }
- if (!name || !*name) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no name");
- }
-
- /* Open the group */
- if (NULL==(grp=H5G_open (f, name))) {
- HRETURN_ERROR (H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group");
- }
-
- /* Register an atom for the group */
- if ((ret_value=H5Aregister_atom (H5_GROUP, grp))<0) {
- H5G_close (grp);
- HRETURN_ERROR (H5E_ATOM, H5E_CANTREGISTER, FAIL,
- "unable to register group");
- }
-
- FUNC_LEAVE (ret_value);
+ hid_t ret_value = FAIL;
+ H5F_t *f = NULL;
+ H5G_t *grp = NULL;
+
+ FUNC_ENTER(H5Gopen, FAIL);
+ H5ECLEAR;
+
+ /* Check args */
+ if (H5_FILE != H5Aatom_group(file_id) ||
+ NULL == (f = H5Aatom_object(file_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file");
+ }
+ if (!name || !*name) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name");
+ }
+ /* Open the group */
+ if (NULL == (grp = H5G_open(f, name))) {
+ HRETURN_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group");
+ }
+ /* Register an atom for the group */
+ if ((ret_value = H5Aregister_atom(H5_GROUP, grp)) < 0) {
+ H5G_close(grp);
+ HRETURN_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL,
+ "unable to register group");
+ }
+ FUNC_LEAVE(ret_value);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Gclose
+ * Function: H5Gclose
*
- * Purpose: Closes the specified group. The group ID will no longer be
- * valid for accessing the group.
+ * Purpose: Closes the specified group. The group ID will no longer be
+ * valid for accessing the group.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, December 31, 1997
*
* Modifications:
@@ -191,52 +182,49 @@ H5Gopen (hid_t file_id, const char *name)
*-------------------------------------------------------------------------
*/
herr_t
-H5Gclose (hid_t grp_id)
+H5Gclose(hid_t grp_id)
{
- H5G_t *grp = NULL;
-
- FUNC_ENTER (H5Gclose, FAIL);
- H5ECLEAR;
-
- /* Check args */
- if (H5_GROUP!=H5Aatom_group (grp_id) ||
- NULL==(grp=H5Aatom_object (grp_id))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a group");
- }
-
- /*
- * Decrement the counter on the group atom. It will be freed if the count
- * reaches zero.
- */
- if (H5A_dec_ref (grp_id)<0) {
- HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, FAIL, "unable to close group");
- }
-
- FUNC_LEAVE (SUCCEED);
+ H5G_t *grp = NULL;
+
+ FUNC_ENTER(H5Gclose, FAIL);
+ H5ECLEAR;
+
+ /* Check args */
+ if (H5_GROUP != H5Aatom_group(grp_id) ||
+ NULL == (grp = H5Aatom_object(grp_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group");
+ }
+ /*
+ * Decrement the counter on the group atom. It will be freed if the count
+ * reaches zero.
+ */
+ if (H5A_dec_ref(grp_id) < 0) {
+ HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to close group");
+ }
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Gset
+ * Function: H5Gset
*
- * Purpose: Sets the working group for file handle FILE to the
- * specified group.
+ * Purpose: Sets the working group for file handle FILE to the
+ * specified group.
*
- * Each file handle maintains its own notion of the current
- * working group. That is, if a single file is opened with
- * multiple calls to H5Fopen(), which returns multiple file
- * handles, then each handle's current working group can be
- * set independently of the other file handles for that file.
+ * Each file handle maintains its own notion of the current
+ * working group. That is, if a single file is opened with
+ * multiple calls to H5Fopen(), which returns multiple file
+ * handles, then each handle's current working group can be
+ * set independently of the other file handles for that file.
*
- * See also: H5Gpush(), H5Gpop()
+ * See also: H5Gpush(), H5Gpop()
*
* Errors:
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, September 24, 1997
*
* Modifications:
@@ -244,62 +232,58 @@ H5Gclose (hid_t grp_id)
*-------------------------------------------------------------------------
*/
herr_t
-H5Gset (hid_t file_id, const char *name)
+H5Gset(hid_t file_id, const char *name)
{
- H5F_t *f=NULL;
- H5G_t *grp;
-
- FUNC_ENTER (H5Gset, FAIL);
- H5ECLEAR;
-
- /* Check/fix arguments */
- if (H5_FILE!=H5Aatom_group (file_id) ||
- NULL==(f=H5Aatom_object (file_id))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a file");
- }
- if (!name || !*name) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no name");
- }
- if (NULL==(grp=H5G_open (f, name))) {
- HRETURN_ERROR (H5E_ARGS, H5E_NOTFOUND, FAIL, "no such group");
- }
-
- /* Set the current working group */
- if (H5G_set (f, grp)<0) {
- HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, FAIL,
- "unable to change current working group");
- }
-
- /* Close the handle */
- if (H5G_close (grp)<0) {
- HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, FAIL, "unable to close group");
- }
-
- FUNC_LEAVE (SUCCEED);
+ H5F_t *f = NULL;
+ H5G_t *grp;
+
+ FUNC_ENTER(H5Gset, FAIL);
+ H5ECLEAR;
+
+ /* Check/fix arguments */
+ if (H5_FILE != H5Aatom_group(file_id) ||
+ NULL == (f = H5Aatom_object(file_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file");
+ }
+ if (!name || !*name) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name");
+ }
+ if (NULL == (grp = H5G_open(f, name))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_NOTFOUND, FAIL, "no such group");
+ }
+ /* Set the current working group */
+ if (H5G_set(f, grp) < 0) {
+ HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL,
+ "unable to change current working group");
+ }
+ /* Close the handle */
+ if (H5G_close(grp) < 0) {
+ HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to close group");
+ }
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Gpush
+ * Function: H5Gpush
*
- * Purpose: Similar to H5Gset() except the new working group is pushed
- * on a stack.
+ * Purpose: Similar to H5Gset() except the new working group is pushed
+ * on a stack.
*
- * Each file handle maintains its own notion of the current
- * working group. That is, if a single file is opened with
- * multiple calls to H5Fopen(), which returns multiple file
- * handles, then each handle's current working group can be
- * set independently of the other file handles for that file.
+ * Each file handle maintains its own notion of the current
+ * working group. That is, if a single file is opened with
+ * multiple calls to H5Fopen(), which returns multiple file
+ * handles, then each handle's current working group can be
+ * set independently of the other file handles for that file.
*
- * See also: H5Gset(), H5Gpop()
+ * See also: H5Gset(), H5Gpop()
*
* Errors:
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, September 24, 1997
*
* Modifications:
@@ -307,64 +291,60 @@ H5Gset (hid_t file_id, const char *name)
*-------------------------------------------------------------------------
*/
herr_t
-H5Gpush (hid_t file_id, const char *name)
+H5Gpush(hid_t file_id, const char *name)
{
- H5F_t *f=NULL;
- H5G_t *grp;
-
- FUNC_ENTER (H5Gpush, FAIL);
- H5ECLEAR;
-
- /* Check arguments */
- if (H5_FILE!=H5Aatom_group (file_id) ||
- NULL==(f=H5Aatom_object (file_id))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a file");
- }
- if (!name || !*name) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no name");
- }
- if (NULL==(grp=H5G_open (f, name))) {
- HRETURN_ERROR (H5E_ARGS, H5E_NOTFOUND, FAIL, "no such group");
- }
-
- /* Push group onto stack */
- if (H5G_push (f, grp)<0) {
- HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, FAIL,
- "can't change current working group");
- }
-
- /* Close the handle */
- if (H5G_close (grp)<0) {
- HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, FAIL, "unable to close group");
- }
-
- FUNC_LEAVE (SUCCEED);
+ H5F_t *f = NULL;
+ H5G_t *grp;
+
+ FUNC_ENTER(H5Gpush, FAIL);
+ H5ECLEAR;
+
+ /* Check arguments */
+ if (H5_FILE != H5Aatom_group(file_id) ||
+ NULL == (f = H5Aatom_object(file_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file");
+ }
+ if (!name || !*name) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name");
+ }
+ if (NULL == (grp = H5G_open(f, name))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_NOTFOUND, FAIL, "no such group");
+ }
+ /* Push group onto stack */
+ if (H5G_push(f, grp) < 0) {
+ HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL,
+ "can't change current working group");
+ }
+ /* Close the handle */
+ if (H5G_close(grp) < 0) {
+ HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to close group");
+ }
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Gpop
+ * Function: H5Gpop
*
- * Purpose: Removes the top (latest) entry from the working group stack
- * and sets the current working group to the previous value.
+ * Purpose: Removes the top (latest) entry from the working group stack
+ * and sets the current working group to the previous value.
*
- * Each file handle maintains its own notion of the current
- * working group. That is, if a single file is opened with
- * multiple calls to H5Fopen(), which returns multiple file
- * handles, then each handle's current working group can be
- * set independently of the other file handles for that file.
+ * Each file handle maintains its own notion of the current
+ * working group. That is, if a single file is opened with
+ * multiple calls to H5Fopen(), which returns multiple file
+ * handles, then each handle's current working group can be
+ * set independently of the other file handles for that file.
*
- * See also: H5Gset(), H5Gpush()
+ * See also: H5Gset(), H5Gpush()
*
* Errors:
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL. The final entry cannot be popped from
- * the group stack (but it can be changed
- * with H5Gset()).
+ * Failure: FAIL. The final entry cannot be popped from
+ * the group stack (but it can be changed
+ * with H5Gset()).
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, September 24, 1997
*
* Modifications:
@@ -372,30 +352,25 @@ H5Gpush (hid_t file_id, const char *name)
*-------------------------------------------------------------------------
*/
herr_t
-H5Gpop (hid_t file_id)
+H5Gpop(hid_t file_id)
{
- H5F_t *f=NULL;
-
- FUNC_ENTER (H5Gpop, FAIL);
- H5ECLEAR;
-
- /* Check arguments */
- if (H5_FILE!=H5Aatom_group (file_id) ||
- NULL==(f=H5Aatom_object (file_id))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a file");
- }
-
- /* pop */
- if (H5G_pop (f)<0) {
- HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, FAIL,
- "stack is empty");
- }
-
- FUNC_LEAVE (SUCCEED);
+ H5F_t *f = NULL;
+
+ FUNC_ENTER(H5Gpop, FAIL);
+ H5ECLEAR;
+
+ /* Check arguments */
+ if (H5_FILE != H5Aatom_group(file_id) ||
+ NULL == (f = H5Aatom_object(file_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file");
+ }
+ /* pop */
+ if (H5G_pop(f) < 0) {
+ HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL,
+ "stack is empty");
+ }
+ FUNC_LEAVE(SUCCEED);
}
-
-
-
/*
*-------------------------------------------------------------------------
@@ -404,19 +379,17 @@ H5Gpop (hid_t file_id)
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
-
-
/*-------------------------------------------------------------------------
- * Function: H5G_init_interface
+ * Function: H5G_init_interface
*
- * Purpose: Initializes the H5G interface.
+ * Purpose: Initializes the H5G interface.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Monday, January 5, 1998
*
* Modifications:
@@ -424,30 +397,28 @@ H5Gpop (hid_t file_id)
*-------------------------------------------------------------------------
*/
static herr_t
-H5G_init_interface (void)
+H5G_init_interface(void)
{
- FUNC_ENTER (H5G_init_interface, FAIL);
-
- /* Initialize the atom group for the group IDs */
- if (H5Ainit_group (H5_GROUP, H5A_GROUPID_HASHSIZE, H5G_RESERVED_ATOMS,
- (herr_t (*)(void*))H5G_close)<0 ||
- H5_add_exit (H5G_term_interface)<0) {
- HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, FAIL,
- "unable to initialize interface");
- }
-
- FUNC_LEAVE (SUCCEED);
+ FUNC_ENTER(H5G_init_interface, FAIL);
+
+ /* Initialize the atom group for the group IDs */
+ if (H5Ainit_group(H5_GROUP, H5A_GROUPID_HASHSIZE, H5G_RESERVED_ATOMS,
+ (herr_t (*)(void *)) H5G_close) < 0 ||
+ H5_add_exit(H5G_term_interface) < 0) {
+ HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL,
+ "unable to initialize interface");
+ }
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5G_term_interface
+ * Function: H5G_term_interface
*
- * Purpose: Terminates the H5G interface
+ * Purpose: Terminates the H5G interface
*
- * Return: void
+ * Return: void
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Monday, January 5, 1998
*
* Modifications:
@@ -455,497 +426,491 @@ H5G_init_interface (void)
*-------------------------------------------------------------------------
*/
static void
-H5G_term_interface (void)
+H5G_term_interface(void)
{
- H5Adestroy_group (H5_GROUP);
+ H5Adestroy_group(H5_GROUP);
}
-
/*-------------------------------------------------------------------------
- * Function: H5G_component
+ * Function: H5G_component
*
- * Purpose: Returns the pointer to the first component of the
- * specified name by skipping leading slashes. Returns
- * the size in characters of the component through SIZE_P not
- * counting leading slashes or the null terminator.
+ * Purpose: Returns the pointer to the first component of the
+ * specified name by skipping leading slashes. Returns
+ * the size in characters of the component through SIZE_P not
+ * counting leading slashes or the null terminator.
*
* Errors:
*
- * Return: Success: Ptr into NAME.
+ * Return: Success: Ptr into NAME.
*
- * Failure: Ptr to the null terminator of NAME.
+ * Failure: Ptr to the null terminator of NAME.
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Aug 11 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Aug 11 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-static const char *
-H5G_component (const char *name, size_t *size_p)
+static const char *
+H5G_component(const char *name, size_t *size_p)
{
- assert (name);
-
- while ('/'==*name) name++;
- if (size_p) *size_p = HDstrcspn (name, "/");
- return name;
-}
+ assert(name);
+ while ('/' == *name)
+ name++;
+ if (size_p)
+ *size_p = HDstrcspn(name, "/");
+ return name;
+}
/*-------------------------------------------------------------------------
- * Function: H5G_namei
- *
- * Purpose: Translates a name to a symbol table entry.
- *
- * If the specified name can be fully resolved, then this
- * function returns the symbol table entry for the named object
- * through the OBJ_ENT argument. The symbol table entry for the
- * group containing the named object is returned through the
- * GRP_ENT argument if it is non-null. However, if the name
- * refers to the root object then the GRP_ENT will be
- * initialized with an undefined object header address. The
- * REST argument, if present, will point to the null terminator
- * of NAME.
- *
- * If the specified name cannot be fully resolved, then OBJ_ENT
- * is initialized with the undefined object header address. The
- * REST argument will point into the NAME argument to the start
- * of the component that could not be located. The GRP_ENT will
- * contain the entry for the symbol table that was being
- * searched at the time of the failure and will have an
- * undefined object header address if the search failed at the
- * root object. For instance, if NAME is `/foo/bar/baz' and the
- * root directory exists and contains an entry for `foo', and
- * foo is a group that contains an entry for baz, but baz is not
- * a group, then the results will be that REST points to `baz',
- * GRP_ENT has an undefined object header address, and GRP_ENT
- * is the symbol table entry for `bar' in `/foo'.
- *
- * If a file contains more than one object, then `/' is the name
- * of the root object which is a group. Otherwise, a file can
- * consist of a single object, not necessarily a group, whose
- * name is `/foo' where `foo' is the value of the name messsage
- * in the object header. A file can also contain no objects in
- * which case the function returns so REST points to the
- * beginning of NAME and OBJ_ENT and GRP_ENT contain undefined
- * header addresses.
- *
- * Components of a name are separated from one another by one or
- * more slashes (/). Slashes at the end of a name are ignored.
- * If the name begins with a slash then the search begins at the
- * root object, otherwise it begins at the group CWG, otherwise
- * it begins at the current working group of file F. The
- * component `.' is a no-op, but `..' is not understood by this
- * function (unless it appears as an entry in the symbol table).
- *
+ * Function: H5G_namei
+ *
+ * Purpose: Translates a name to a symbol table entry.
+ *
+ * If the specified name can be fully resolved, then this
+ * function returns the symbol table entry for the named object
+ * through the OBJ_ENT argument. The symbol table entry for the
+ * group containing the named object is returned through the
+ * GRP_ENT argument if it is non-null. However, if the name
+ * refers to the root object then the GRP_ENT will be
+ * initialized with an undefined object header address. The
+ * REST argument, if present, will point to the null terminator
+ * of NAME.
+ *
+ * If the specified name cannot be fully resolved, then OBJ_ENT
+ * is initialized with the undefined object header address. The
+ * REST argument will point into the NAME argument to the start
+ * of the component that could not be located. The GRP_ENT will
+ * contain the entry for the symbol table that was being
+ * searched at the time of the failure and will have an
+ * undefined object header address if the search failed at the
+ * root object. For instance, if NAME is `/foo/bar/baz' and the
+ * root directory exists and contains an entry for `foo', and
+ * foo is a group that contains an entry for baz, but baz is not
+ * a group, then the results will be that REST points to `baz',
+ * GRP_ENT has an undefined object header address, and GRP_ENT
+ * is the symbol table entry for `bar' in `/foo'.
+ *
+ * If a file contains more than one object, then `/' is the name
+ * of the root object which is a group. Otherwise, a file can
+ * consist of a single object, not necessarily a group, whose
+ * name is `/foo' where `foo' is the value of the name messsage
+ * in the object header. A file can also contain no objects in
+ * which case the function returns so REST points to the
+ * beginning of NAME and OBJ_ENT and GRP_ENT contain undefined
+ * header addresses.
+ *
+ * Components of a name are separated from one another by one or
+ * more slashes (/). Slashes at the end of a name are ignored.
+ * If the name begins with a slash then the search begins at the
+ * root object, otherwise it begins at the group CWG, otherwise
+ * it begins at the current working group of file F. The
+ * component `.' is a no-op, but `..' is not understood by this
+ * function (unless it appears as an entry in the symbol table).
+ *
* Errors:
*
- * Return: Success: SUCCEED if name can be fully resolved. See
- * above for values of REST, GRP_ENT, and
- * OBJ_ENT.
+ * Return: Success: SUCCEED if name can be fully resolved. See
+ * above for values of REST, GRP_ENT, and
+ * OBJ_ENT.
*
- * Failure: FAIL if the name could not be fully resolved.
- * See above for values of REST, GRP_ENT, and
- * OBJ_ENT.
+ * Failure: FAIL if the name could not be fully resolved.
+ * See above for values of REST, GRP_ENT, and
+ * OBJ_ENT.
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Aug 11 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Aug 11 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static herr_t
-H5G_namei (H5F_t *f, H5G_entry_t *cwg, const char *name,
- const char **rest/*out*/, H5G_entry_t *grp_ent/*out*/,
- H5G_entry_t *obj_ent/*out*/)
+H5G_namei(H5F_t *f, H5G_entry_t *cwg, const char *name,
+ const char **rest /*out */ , H5G_entry_t *grp_ent /*out */ ,
+ H5G_entry_t *obj_ent /*out */ )
{
- H5G_entry_t _grp_ent; /*entry for current group */
- H5G_entry_t _obj_ent; /*entry found */
- size_t nchars; /*component name length */
- char comp[1024]; /*component name buffer */
- hbool_t aside = FALSE; /*did we look at a name message?*/
-
- /* clear output args before FUNC_ENTER() in case it fails */
- if (rest) *rest = name;
- if (!grp_ent) grp_ent = &_grp_ent;
- if (!obj_ent) obj_ent = &_obj_ent;
- memset (grp_ent, 0, sizeof(H5G_entry_t));
- H5F_addr_undef (&(grp_ent->header));
- memset (obj_ent, 0, sizeof(H5G_entry_t));
- H5F_addr_undef (&(obj_ent->header));
-
- FUNC_ENTER (H5G_namei, FAIL);
-
- /* check args */
- assert (f);
- assert (name && *name);
-
- /* If the file contains no objects then return failure */
- if (!f->shared->root_ent) {
- HRETURN_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "no root group");
- }
-
- /* starting point */
- if ('/'==*name) {
- *obj_ent = *(f->shared->root_ent);
- } else if (cwg) {
- *obj_ent = *cwg;
- } else if ((cwg=H5G_getcwg (f))) {
- *obj_ent = *cwg;
- } else {
- HRETURN_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "no current working group");
- }
- assert (H5F_addr_defined (&(obj_ent->header)));
-
- /* traverse the name */
- while ((name=H5G_component (name, &nchars)) && *name) {
- if (rest) *rest = name;
-
- /*
- * The special name `.' is a no-op.
- */
- if ('.'==name[0] && !name[1]) continue;
-
- /*
- * Advance to the next component of the name.
- */
- *grp_ent = *obj_ent;
- HDmemset (obj_ent, 0, sizeof(H5G_entry_t));
- H5F_addr_undef (&(obj_ent->header));
-
- /*
- * Copy the component name into a null-terminated buffer so
- * we can pass it down to the other symbol table functions.
- */
- if (nchars+1 > sizeof(comp)) {
- HRETURN_ERROR (H5E_SYM, H5E_COMPLEN, FAIL, "component is too long");
- }
- HDmemcpy (comp, name, nchars);
- comp[nchars] = '\0';
-
- if (H5G_stab_find (grp_ent, comp, obj_ent/*out*/)<0) {
- /*
- * Component was not found in the current symbol table, possibly
- * because GRP_ENT isn't a symbol table. If it is the root symbol
- * then see if it has the appropriate name field. The ASIDE
- * variable prevents us from saying `/foo/foo' where the root object
- * has the name `foo'.
- */
- H5O_name_t mesg={0};
- if (!aside &&
- H5F_addr_eq (&(grp_ent->header),
- &(f->shared->root_ent->header)) &&
- H5O_read (grp_ent, H5O_NAME, 0, &mesg) &&
- !HDstrcmp (mesg.s, comp)) {
- H5O_reset (H5O_NAME, &mesg);
- *obj_ent = *grp_ent;
- HDmemset (grp_ent, 0, sizeof(H5G_entry_t));
- H5F_addr_undef (&(grp_ent->header));
- aside = TRUE;
- } else {
- H5O_reset (H5O_NAME, &mesg);
- HRETURN_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "component not found");
- }
- }
-
- /* next component */
- name += nchars;
- }
- if (rest) *rest = name; /*final null*/
-
- FUNC_LEAVE (SUCCEED);
+ H5G_entry_t _grp_ent; /*entry for current group */
+ H5G_entry_t _obj_ent; /*entry found */
+ size_t nchars; /*component name length */
+ char comp[1024]; /*component name buffer */
+ hbool_t aside = FALSE; /*did we look at a name message? */
+
+ /* clear output args before FUNC_ENTER() in case it fails */
+ if (rest)
+ *rest = name;
+ if (!grp_ent)
+ grp_ent = &_grp_ent;
+ if (!obj_ent)
+ obj_ent = &_obj_ent;
+ memset(grp_ent, 0, sizeof(H5G_entry_t));
+ H5F_addr_undef(&(grp_ent->header));
+ memset(obj_ent, 0, sizeof(H5G_entry_t));
+ H5F_addr_undef(&(obj_ent->header));
+
+ FUNC_ENTER(H5G_namei, FAIL);
+
+ /* check args */
+ assert(f);
+ assert(name && *name);
+
+ /* If the file contains no objects then return failure */
+ if (!f->shared->root_ent) {
+ HRETURN_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "no root group");
+ }
+ /* starting point */
+ if ('/' == *name) {
+ *obj_ent = *(f->shared->root_ent);
+ } else if (cwg) {
+ *obj_ent = *cwg;
+ } else if ((cwg = H5G_getcwg(f))) {
+ *obj_ent = *cwg;
+ } else {
+ HRETURN_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "no current working group");
+ }
+ assert(H5F_addr_defined(&(obj_ent->header)));
+
+ /* traverse the name */
+ while ((name = H5G_component(name, &nchars)) && *name) {
+ if (rest)
+ *rest = name;
+
+ /*
+ * The special name `.' is a no-op.
+ */
+ if ('.' == name[0] && !name[1])
+ continue;
+
+ /*
+ * Advance to the next component of the name.
+ */
+ *grp_ent = *obj_ent;
+ HDmemset(obj_ent, 0, sizeof(H5G_entry_t));
+ H5F_addr_undef(&(obj_ent->header));
+
+ /*
+ * Copy the component name into a null-terminated buffer so
+ * we can pass it down to the other symbol table functions.
+ */
+ if (nchars + 1 > sizeof(comp)) {
+ HRETURN_ERROR(H5E_SYM, H5E_COMPLEN, FAIL, "component is too long");
+ }
+ HDmemcpy(comp, name, nchars);
+ comp[nchars] = '\0';
+
+ if (H5G_stab_find(grp_ent, comp, obj_ent /*out */ ) < 0) {
+ /*
+ * Component was not found in the current symbol table, possibly
+ * because GRP_ENT isn't a symbol table. If it is the root symbol
+ * then see if it has the appropriate name field. The ASIDE
+ * variable prevents us from saying `/foo/foo' where the root object
+ * has the name `foo'.
+ */
+ H5O_name_t mesg =
+ {0};
+ if (!aside &&
+ H5F_addr_eq(&(grp_ent->header),
+ &(f->shared->root_ent->header)) &&
+ H5O_read(grp_ent, H5O_NAME, 0, &mesg) &&
+ !HDstrcmp(mesg.s, comp)) {
+ H5O_reset(H5O_NAME, &mesg);
+ *obj_ent = *grp_ent;
+ HDmemset(grp_ent, 0, sizeof(H5G_entry_t));
+ H5F_addr_undef(&(grp_ent->header));
+ aside = TRUE;
+ } else {
+ H5O_reset(H5O_NAME, &mesg);
+ HRETURN_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "component not found");
+ }
+ }
+ /* next component */
+ name += nchars;
+ }
+ if (rest)
+ *rest = name; /*final null */
+
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5G_mkroot
+ * Function: H5G_mkroot
*
- * Purpose: Creates the root group if it doesn't exist; otherwise
- * nothing happens. If the root symbol table entry previously
- * pointed to something other than a group, then that object
- * is made a member of the root group and is given a name
- * corresponding to the object's name message (the name message
- * is removed). If the root object doesn't have a name message
- * then the name `Root Object' is used.
+ * Purpose: Creates the root group if it doesn't exist; otherwise
+ * nothing happens. If the root symbol table entry previously
+ * pointed to something other than a group, then that object
+ * is made a member of the root group and is given a name
+ * corresponding to the object's name message (the name message
+ * is removed). If the root object doesn't have a name message
+ * then the name `Root Object' is used.
*
* Errors:
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL. This function returns -2 if the
- * failure is because a root group already
- * exists.
+ * Failure: FAIL. This function returns -2 if the
+ * failure is because a root group already
+ * exists.
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Aug 11 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Aug 11 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static herr_t
-H5G_mkroot (H5F_t *f, size_t size_hint)
+H5G_mkroot(H5F_t *f, size_t size_hint)
{
- herr_t ret_value=FAIL; /*return value */
- H5O_name_t name={NULL}; /*object name */
- H5O_stab_t stab; /*symbol table message */
- H5G_entry_t new_root; /*new root object */
- const char *obj_name=NULL; /*name of old root object */
-
- FUNC_ENTER (H5G_mkroot, FAIL);
-
- /* check args */
- assert (f);
-
- /*
- * If we already have a root object, then get it's name.
- */
- if (f->shared->root_ent) {
- if (H5O_read (f->shared->root_ent, H5O_STAB, 0, &stab)) {
- HGOTO_ERROR (H5E_SYM, H5E_EXISTS, -2, "root group already exists");
- } else if (NULL==H5O_read (f->shared->root_ent, H5O_NAME, 0, &name)) {
- obj_name = "Root Object";
- } else {
- obj_name = name.s; /*don't reset message until the end!*/
- }
- }
-
- /*
- * Create the new root group. Set the link count to 1.
- */
- if (H5G_stab_create (f, size_hint, &new_root/*out*/)<0) {
- HGOTO_ERROR (H5E_SYM, H5E_CANTINIT, FAIL, "cant create root");
- }
- if (1!=H5O_link (&new_root, 1)) {
- HGOTO_ERROR (H5E_SYM, H5E_LINK, FAIL,
- "internal error (wrong link count)");
- }
-
- /*
- * If there was a previous root object then insert it into the new root
- * symbol table with the specified name. Then make the root object the
- * new symbol table.
- */
- if (f->shared->root_ent) {
- assert (1==H5O_link (f->shared->root_ent, 0));
-
- if (H5G_stab_insert (&new_root, obj_name, f->shared->root_ent)<0) {
- HGOTO_ERROR (H5E_SYM, H5E_CANTINIT, FAIL,
- "can't reinsert old root object");
- }
-
- /*
- * Remove all `name' messages from the old root object. The only time
- * a name message should ever appear is to give the root object a name,
- * but the old root object is no longer the root object.
- */
- H5O_remove (f->shared->root_ent, H5O_NAME, H5O_ALL);
- H5ECLEAR; /*who really cares?*/
-
- *(f->shared->root_ent) = new_root;
-
- } else {
- f->shared->root_ent = H5G_ent_calloc (&new_root);
- }
-
- H5O_close (&new_root);
- ret_value = SUCCEED;
-
- done:
- H5O_reset (H5O_NAME, &name);
- FUNC_LEAVE (ret_value);
+ herr_t ret_value = FAIL; /*return value */
+ H5O_name_t name =
+ {NULL}; /*object name */
+ H5O_stab_t stab; /*symbol table message */
+ H5G_entry_t new_root; /*new root object */
+ const char *obj_name = NULL; /*name of old root object */
+
+ FUNC_ENTER(H5G_mkroot, FAIL);
+
+ /* check args */
+ assert(f);
+
+ /*
+ * If we already have a root object, then get it's name.
+ */
+ if (f->shared->root_ent) {
+ if (H5O_read(f->shared->root_ent, H5O_STAB, 0, &stab)) {
+ HGOTO_ERROR(H5E_SYM, H5E_EXISTS, -2, "root group already exists");
+ } else if (NULL == H5O_read(f->shared->root_ent, H5O_NAME, 0, &name)) {
+ obj_name = "Root Object";
+ } else {
+ obj_name = name.s; /*don't reset message until the end! */
+ }
+ }
+ /*
+ * Create the new root group. Set the link count to 1.
+ */
+ if (H5G_stab_create(f, size_hint, &new_root /*out */ ) < 0) {
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "cant create root");
+ }
+ if (1 != H5O_link(&new_root, 1)) {
+ HGOTO_ERROR(H5E_SYM, H5E_LINK, FAIL,
+ "internal error (wrong link count)");
+ }
+ /*
+ * If there was a previous root object then insert it into the new root
+ * symbol table with the specified name. Then make the root object the
+ * new symbol table.
+ */
+ if (f->shared->root_ent) {
+ assert(1 == H5O_link(f->shared->root_ent, 0));
+
+ if (H5G_stab_insert(&new_root, obj_name, f->shared->root_ent) < 0) {
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL,
+ "can't reinsert old root object");
+ }
+ /*
+ * Remove all `name' messages from the old root object. The only time
+ * a name message should ever appear is to give the root object a name,
+ * but the old root object is no longer the root object.
+ */
+ H5O_remove(f->shared->root_ent, H5O_NAME, H5O_ALL);
+ H5ECLEAR; /*who really cares? */
+
+ *(f->shared->root_ent) = new_root;
+
+ } else {
+ f->shared->root_ent = H5G_ent_calloc(&new_root);
+ }
+
+ H5O_close(&new_root);
+ ret_value = SUCCEED;
+
+ done:
+ H5O_reset(H5O_NAME, &name);
+ FUNC_LEAVE(ret_value);
}
-
/*-------------------------------------------------------------------------
- * Function: H5G_create
+ * Function: H5G_create
*
- * Purpose: Creates a new empty group with the specified name. The name
- * is either an absolute name or is relative to the current
- * working group.
+ * Purpose: Creates a new empty group with the specified name. The name
+ * is either an absolute name or is relative to the current
+ * working group.
*
- * A root group is created implicitly by this function
- * when necessary. Calling this function with the name "/"
- * (or any equivalent name) will result in an H5E_EXISTS
- * failure.
+ * A root group is created implicitly by this function
+ * when necessary. Calling this function with the name "/"
+ * (or any equivalent name) will result in an H5E_EXISTS
+ * failure.
*
* Errors:
*
- * Return: Success: A handle for the group. The group is opened
- * and should eventually be close by calling
- * H5G_close().
+ * Return: Success: A handle for the group. The group is opened
+ * and should eventually be close by calling
+ * H5G_close().
*
- * Failure: NULL
+ * Failure: NULL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Aug 11 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Aug 11 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-H5G_t *
-H5G_create (H5F_t *f, const char *name, size_t size_hint)
+H5G_t *
+H5G_create(H5F_t *f, const char *name, size_t size_hint)
{
- const char *rest=NULL; /*the base name */
- H5G_entry_t grp_ent; /*group containing new group */
- char _comp[1024]; /*name component */
- size_t nchars; /*number of characters in compon*/
- herr_t status; /*function return status */
- H5G_t *grp = NULL; /*new group */
-
- FUNC_ENTER (H5G_create, NULL);
-
- /* check args */
- assert (f);
- assert (name && *name);
-
- /*
- * Try to create the root group. Ignore the error if this function
- * fails because the root group already exists.
- */
- if ((status=H5G_mkroot (f, H5G_SIZE_HINT))<0 && -2!=status) {
- HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, NULL, "can't create root group");
- }
- H5ECLEAR;
-
- /* lookup name */
- if (0==H5G_namei (f, NULL, name, &rest, &grp_ent, NULL)) {
- HRETURN_ERROR (H5E_SYM, H5E_EXISTS, NULL, "already exists");
- }
- H5ECLEAR; /*it's OK that we didn't find it*/
- assert (H5F_addr_defined (&(grp_ent.header)));
-
- /* should be one null-terminated component left */
- rest = H5G_component (rest, &nchars);
- assert (rest && *rest);
- if (rest[nchars]) {
- if (H5G_component (rest+nchars, NULL)) {
- HRETURN_ERROR (H5E_SYM, H5E_NOTFOUND, NULL, "missing component");
- } else if (nchars+1 > sizeof _comp) {
- HRETURN_ERROR (H5E_SYM, H5E_COMPLEN, NULL, "component is too long");
- } else {
- /* null terminate */
- HDmemcpy (_comp, rest, nchars);
- _comp[nchars] = '\0';
- rest = _comp;
- }
- }
-
- /* create an open group */
- grp = H5MM_xcalloc (1, sizeof(H5G_t));
- if (H5G_stab_create (f, size_hint, &(grp->ent)/*out*/)<0) {
- grp = H5MM_xfree (grp);
- HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, NULL, "can't create grp");
- }
-
- /* insert child name into parent */
- if (H5G_stab_insert (&grp_ent, rest, &(grp->ent))<0) {
- H5O_close (&(grp->ent));
- grp = H5MM_xfree (grp);
- HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, NULL, "can't insert");
- }
-
- grp->nref = 1;
- FUNC_LEAVE (grp);
+ const char *rest = NULL; /*the base name */
+ H5G_entry_t grp_ent; /*group containing new group */
+ char _comp[1024]; /*name component */
+ size_t nchars; /*number of characters in compon */
+ herr_t status; /*function return status */
+ H5G_t *grp = NULL; /*new group */
+
+ FUNC_ENTER(H5G_create, NULL);
+
+ /* check args */
+ assert(f);
+ assert(name && *name);
+
+ /*
+ * Try to create the root group. Ignore the error if this function
+ * fails because the root group already exists.
+ */
+ if ((status = H5G_mkroot(f, H5G_SIZE_HINT)) < 0 && -2 != status) {
+ HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "can't create root group");
+ }
+ H5ECLEAR;
+
+ /* lookup name */
+ if (0 == H5G_namei(f, NULL, name, &rest, &grp_ent, NULL)) {
+ HRETURN_ERROR(H5E_SYM, H5E_EXISTS, NULL, "already exists");
+ }
+ H5ECLEAR; /*it's OK that we didn't find it */
+ assert(H5F_addr_defined(&(grp_ent.header)));
+
+ /* should be one null-terminated component left */
+ rest = H5G_component(rest, &nchars);
+ assert(rest && *rest);
+ if (rest[nchars]) {
+ if (H5G_component(rest + nchars, NULL)) {
+ HRETURN_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "missing component");
+ } else if (nchars + 1 > sizeof _comp) {
+ HRETURN_ERROR(H5E_SYM, H5E_COMPLEN, NULL, "component is too long");
+ } else {
+ /* null terminate */
+ HDmemcpy(_comp, rest, nchars);
+ _comp[nchars] = '\0';
+ rest = _comp;
+ }
+ }
+ /* create an open group */
+ grp = H5MM_xcalloc(1, sizeof(H5G_t));
+ if (H5G_stab_create(f, size_hint, &(grp->ent) /*out */ ) < 0) {
+ grp = H5MM_xfree(grp);
+ HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "can't create grp");
+ }
+ /* insert child name into parent */
+ if (H5G_stab_insert(&grp_ent, rest, &(grp->ent)) < 0) {
+ H5O_close(&(grp->ent));
+ grp = H5MM_xfree(grp);
+ HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "can't insert");
+ }
+ grp->nref = 1;
+ FUNC_LEAVE(grp);
}
-
/*-------------------------------------------------------------------------
- * Function: H5G_open
+ * Function: H5G_open
*
- * Purpose: Opens an existing group. The group should eventually be
- * closed by calling H5G_close().
+ * Purpose: Opens an existing group. The group should eventually be
+ * closed by calling H5G_close().
*
- * Return: Success: Ptr to a new group.
+ * Return: Success: Ptr to a new group.
*
- * Failure: NULL
+ * Failure: NULL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Monday, January 5, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-H5G_t *
-H5G_open (H5F_t *f, const char *name)
+H5G_t *
+H5G_open(H5F_t *f, const char *name)
{
- H5G_t *grp = NULL;
- H5G_t *ret_value = NULL;
-
- FUNC_ENTER (H5G_open, NULL);
-
- /* Check args */
- assert (f);
- assert (name && *name);
-
- /* Open the group */
- grp = H5MM_xcalloc (1, sizeof(H5G_t));
- if (H5G_find (f, name, NULL, &(grp->ent))<0) {
- HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, NULL, "group not found");
- }
- if (H5O_open (f, &(grp->ent))<0) {
- HGOTO_ERROR (H5E_SYM, H5E_CANTOPENOBJ, NULL, "unable to open group");
- }
- grp->nref = 1;
- ret_value = grp;
-
- done:
- if (!ret_value && grp) {
- H5MM_xfree (grp);
- }
-
- FUNC_LEAVE (ret_value);
+ H5G_t *grp = NULL;
+ H5G_t *ret_value = NULL;
+
+ FUNC_ENTER(H5G_open, NULL);
+
+ /* Check args */
+ assert(f);
+ assert(name && *name);
+
+ /* Open the group */
+ grp = H5MM_xcalloc(1, sizeof(H5G_t));
+ if (H5G_find(f, name, NULL, &(grp->ent)) < 0) {
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "group not found");
+ }
+ if (H5O_open(f, &(grp->ent)) < 0) {
+ HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "unable to open group");
+ }
+ grp->nref = 1;
+ ret_value = grp;
+
+ done:
+ if (!ret_value && grp) {
+ H5MM_xfree(grp);
+ }
+ FUNC_LEAVE(ret_value);
}
-
/*-------------------------------------------------------------------------
- * Function: H5G_reopen
+ * Function: H5G_reopen
*
- * Purpose: Reopens a group by incrementing the open count.
+ * Purpose: Reopens a group by incrementing the open count.
*
- * Return: Success: The GRP argument.
+ * Return: Success: The GRP argument.
*
- * Failure: NULL
+ * Failure: NULL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Monday, January 5, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-H5G_t *
-H5G_reopen (H5G_t *grp)
+H5G_t *
+H5G_reopen(H5G_t *grp)
{
- FUNC_ENTER (H5G_reopen, NULL);
+ FUNC_ENTER(H5G_reopen, NULL);
- assert (grp);
- assert (grp->nref>0);
+ assert(grp);
+ assert(grp->nref > 0);
- grp->nref++;
+ grp->nref++;
- FUNC_LEAVE (grp);
+ FUNC_LEAVE(grp);
}
-
/*-------------------------------------------------------------------------
- * Function: H5G_close
+ * Function: H5G_close
*
- * Purpose: Closes the specified group.
+ * Purpose: Closes the specified group.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Monday, January 5, 1998
*
* Modifications:
@@ -953,47 +918,46 @@ H5G_reopen (H5G_t *grp)
*-------------------------------------------------------------------------
*/
herr_t
-H5G_close (H5G_t *grp)
+H5G_close(H5G_t *grp)
{
- FUNC_ENTER (H5G_close, FAIL);
+ FUNC_ENTER(H5G_close, FAIL);
- /* Check args */
- assert (grp);
- assert (grp->nref>0);
+ /* Check args */
+ assert(grp);
+ assert(grp->nref > 0);
- if (1==grp->nref) {
- if (H5O_close (&(grp->ent))<0) {
- HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, FAIL, "unable to close");
- }
- }
- --grp->nref;
+ if (1 == grp->nref) {
+ if (H5O_close(&(grp->ent)) < 0) {
+ HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to close");
+ }
+ }
+ --grp->nref;
- FUNC_LEAVE (SUCCEED);
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5G_set
+ * Function: H5G_set
*
- * Purpose: Sets the current working group to be the specified group.
- * This affects only the top item on the group stack for the
- * specified file as accessed through this file handle. If the
- * file is opened multiple times, then the current working group
- * for this file handle is the only one that is changed.
+ * Purpose: Sets the current working group to be the specified group.
+ * This affects only the top item on the group stack for the
+ * specified file as accessed through this file handle. If the
+ * file is opened multiple times, then the current working group
+ * for this file handle is the only one that is changed.
*
- * Note: The group is re-opened and held open until it is removed from
- * the current working group stack.
+ * Note: The group is re-opened and held open until it is removed from
+ * the current working group stack.
*
* Errors:
- * SYM CWG Can't open group.
- * SYM CWG Couldn't close previous c.w.g.
- * SYM CWG Not a group.
+ * SYM CWG Can't open group.
+ * SYM CWG Couldn't close previous c.w.g.
+ * SYM CWG Not a group.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, September 24, 1997
*
* Modifications:
@@ -1001,87 +965,85 @@ H5G_close (H5G_t *grp)
*-------------------------------------------------------------------------
*/
herr_t
-H5G_set (H5F_t *f, H5G_t *grp)
+H5G_set(H5F_t *f, H5G_t *grp)
{
- FUNC_ENTER (H5G_set, FAIL);
-
- /* check args */
- assert (f);
- assert (grp);
-
- /*
- * If there is no stack then create one, otherwise close the current
- * working group.
- */
- if (!f->cwg_stack) {
- f->cwg_stack = H5MM_xcalloc (1, sizeof(H5G_cwgstk_t));
- } else if (H5G_close (f->cwg_stack->grp)<0) {
- HRETURN_ERROR (H5E_SYM, H5E_CWG, FAIL, "couldn't close previous c.w.g.");
- }
- f->cwg_stack->grp = H5G_reopen (grp);
-
- FUNC_LEAVE (SUCCEED);
+ FUNC_ENTER(H5G_set, FAIL);
+
+ /* check args */
+ assert(f);
+ assert(grp);
+
+ /*
+ * If there is no stack then create one, otherwise close the current
+ * working group.
+ */
+ if (!f->cwg_stack) {
+ f->cwg_stack = H5MM_xcalloc(1, sizeof(H5G_cwgstk_t));
+ } else if (H5G_close(f->cwg_stack->grp) < 0) {
+ HRETURN_ERROR(H5E_SYM, H5E_CWG, FAIL, "couldn't close previous c.w.g.");
+ }
+ f->cwg_stack->grp = H5G_reopen(grp);
+
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5G_getcwg
+ * Function: H5G_getcwg
*
- * Purpose: Returns a ptr to the symbol table entry for the current
- * working group. If there is no current working group then a
- * pointer to the root symbol is returned. If there is no root
- * symbol then the null pointer is returned.
+ * Purpose: Returns a ptr to the symbol table entry for the current
+ * working group. If there is no current working group then a
+ * pointer to the root symbol is returned. If there is no root
+ * symbol then the null pointer is returned.
*
- * Return: Success: Ptr to the current working group or root
- * object. The pointer is valid only until the
- * root object changes or the current working
- * group changes.
+ * Return: Success: Ptr to the current working group or root
+ * object. The pointer is valid only until the
+ * root object changes or the current working
+ * group changes.
*
- * Failure: NULL
+ * Failure: NULL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, September 24, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-static H5G_entry_t *
-H5G_getcwg (H5F_t *f)
+static H5G_entry_t *
+H5G_getcwg(H5F_t *f)
{
- H5G_entry_t *ret_value=NULL;
-
- FUNC_ENTER (H5G_getcwg, NULL);
-
- /* check args */
- assert (f);
-
- /* return a pointer directly into the stack */
- if (f->cwg_stack && f->cwg_stack->grp) {
- ret_value = &(f->cwg_stack->grp->ent);
- } else {
- ret_value = f->shared->root_ent;
- }
-
- FUNC_LEAVE (ret_value);
-}
+ H5G_entry_t *ret_value = NULL;
+ FUNC_ENTER(H5G_getcwg, NULL);
+
+ /* check args */
+ assert(f);
+
+ /* return a pointer directly into the stack */
+ if (f->cwg_stack && f->cwg_stack->grp) {
+ ret_value = &(f->cwg_stack->grp->ent);
+ } else {
+ ret_value = f->shared->root_ent;
+ }
+
+ FUNC_LEAVE(ret_value);
+}
/*-------------------------------------------------------------------------
- * Function: H5G_push
+ * Function: H5G_push
*
- * Purpose: Pushes a new current working group onto the stack. The GRP
- * is reopened and held open until it is removed from the stack.
+ * Purpose: Pushes a new current working group onto the stack. The GRP
+ * is reopened and held open until it is removed from the stack.
*
* Errors:
- * SYM CWG Can't open group.
- * SYM CWG Not a group.
+ * SYM CWG Can't open group.
+ * SYM CWG Not a group.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, September 19, 1997
*
* Modifications:
@@ -1089,42 +1051,41 @@ H5G_getcwg (H5F_t *f)
*-------------------------------------------------------------------------
*/
herr_t
-H5G_push (H5F_t *f, H5G_t *grp)
+H5G_push(H5F_t *f, H5G_t *grp)
{
- H5G_cwgstk_t *stack=NULL;
-
- FUNC_ENTER (H5G_push, FAIL);
-
- /* check args */
- assert (f);
- assert (grp);
-
- /*
- * Push a new entry onto the stack.
- */
- stack = H5MM_xcalloc (1, sizeof(H5G_cwgstk_t));
- stack->grp = H5G_reopen (grp);
- stack->next = f->cwg_stack;
- f->cwg_stack = stack;
-
- FUNC_LEAVE (SUCCEED);
-}
+ H5G_cwgstk_t *stack = NULL;
+
+ FUNC_ENTER(H5G_push, FAIL);
+
+ /* check args */
+ assert(f);
+ assert(grp);
+
+ /*
+ * Push a new entry onto the stack.
+ */
+ stack = H5MM_xcalloc(1, sizeof(H5G_cwgstk_t));
+ stack->grp = H5G_reopen(grp);
+ stack->next = f->cwg_stack;
+ f->cwg_stack = stack;
+ FUNC_LEAVE(SUCCEED);
+}
/*-------------------------------------------------------------------------
- * Function: H5G_pop
+ * Function: H5G_pop
*
- * Purpose: Pops the top current working group off the stack.
+ * Purpose: Pops the top current working group off the stack.
*
* Errors:
- * SYM CWG Can't close current working group.
- * SYM CWG Stack is empty.
+ * SYM CWG Can't close current working group.
+ * SYM CWG Stack is empty.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL if the stack is empty.
+ * Failure: FAIL if the stack is empty.
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, September 19, 1997
*
* Modifications:
@@ -1132,44 +1093,43 @@ H5G_push (H5F_t *f, H5G_t *grp)
*-------------------------------------------------------------------------
*/
herr_t
-H5G_pop (H5F_t *f)
+H5G_pop(H5F_t *f)
{
- H5G_cwgstk_t *stack=NULL;
-
- FUNC_ENTER (H5G_pop, FAIL);
-
- /* check args */
- assert (f);
-
- if ((stack=f->cwg_stack)) {
- if (H5G_close (stack->grp)<0) {
- HRETURN_ERROR (H5E_SYM, H5E_CWG, FAIL,
- "can't close current working group");
- }
- f->cwg_stack = stack->next;
- stack->grp = NULL;
- H5MM_xfree (stack);
- } else {
- HRETURN_ERROR (H5E_SYM, H5E_CWG, FAIL, "stack is empty");
- }
-
- FUNC_LEAVE (SUCCEED);
+ H5G_cwgstk_t *stack = NULL;
+
+ FUNC_ENTER(H5G_pop, FAIL);
+
+ /* check args */
+ assert(f);
+
+ if ((stack = f->cwg_stack)) {
+ if (H5G_close(stack->grp) < 0) {
+ HRETURN_ERROR(H5E_SYM, H5E_CWG, FAIL,
+ "can't close current working group");
+ }
+ f->cwg_stack = stack->next;
+ stack->grp = NULL;
+ H5MM_xfree(stack);
+ } else {
+ HRETURN_ERROR(H5E_SYM, H5E_CWG, FAIL, "stack is empty");
+ }
+
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5G_insert
+ * Function: H5G_insert
*
- * Purpose: Inserts a symbol table entry into the group graph. The file
- * that is used is contained in the ENT argument.
+ * Purpose: Inserts a symbol table entry into the group graph. The file
+ * that is used is contained in the ENT argument.
*
* Errors:
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, September 19, 1997
*
* Modifications:
@@ -1177,156 +1137,150 @@ H5G_pop (H5F_t *f)
*-------------------------------------------------------------------------
*/
herr_t
-H5G_insert (const char *name, H5G_entry_t *ent)
+H5G_insert(const char *name, H5G_entry_t *ent)
{
- const char *rest = NULL; /*part of name not existing yet */
- H5G_entry_t grp; /*entry for group to contain obj*/
- size_t nchars; /*number of characters in name */
- char _comp[1024]; /*name component */
- hbool_t update_grp;
- herr_t status;
-
- FUNC_ENTER (H5G_insert, FAIL);
-
- /* Check args. */
- assert (name && *name);
- assert (ent);
-
- /*
- * Look up the name -- it shouldn't exist yet.
- */
- if (H5G_namei (ent->file, NULL, name, &rest, &grp, NULL)>=0) {
- HRETURN_ERROR (H5E_SYM, H5E_EXISTS, FAIL, "already exists");
- }
- H5ECLEAR; /*it's OK that we didn't find it*/
- rest = H5G_component (rest, &nchars);
-
- if (!rest || !*rest) {
- /*
- * The caller is attempting to insert a root object that either
- * doesn't have a name or we shouldn't interfere with the name
- * it already has as a message.
- */
- if (ent->file->shared->root_ent) {
- HRETURN_ERROR (H5E_SYM, H5E_EXISTS, FAIL, "root exists");
- }
- if (1!=H5O_link (ent, 1)) {
- HRETURN_ERROR (H5E_SYM, H5E_LINK, FAIL, "bad link count");
- }
- ent->name_off = 0;
- ent->file->shared->root_ent = H5G_ent_calloc (ent);
- HRETURN (SUCCEED);
- }
-
- /*
- * There should be one component left. Make sure it's null
- * terminated.
- */
- if (rest[nchars]) {
- if (H5G_component (rest+nchars, NULL)) {
- HRETURN_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "component not found");
- } else if (nchars+1 > sizeof _comp) {
- HRETURN_ERROR (H5E_SYM, H5E_COMPLEN, FAIL, "component is too long");
- } else {
- /* null terminate */
- HDmemcpy (_comp, rest, nchars);
- _comp[nchars] = '\0';
- rest = _comp;
- }
- }
-
- if (!ent->file->shared->root_ent) {
- /*
- * This will be the only object in the file. Insert it as the root
- * object and add a name messaage to the object header (or modify
- * the first one we find).
- */
- H5O_name_t name_mesg;
- name_mesg.s = rest;
- if (H5O_modify (ent, H5O_NAME, 0, 0, &name_mesg)<0) {
- HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, FAIL,
- "cannot add/change name message");
- }
- if (1!=H5O_link (ent, 1)) {
- HRETURN_ERROR (H5E_SYM, H5E_LINK, FAIL, "bad link count");
- }
- ent->file->shared->root_ent = H5G_ent_calloc (ent);
- HRETURN (SUCCEED);
- }
-
- /*
- * Make sure the root group exists. Ignore the failure if it's
- * because the group already exists.
- */
- update_grp = H5F_addr_eq (&(grp.header),
- &(ent->file->shared->root_ent->header));
- if ((status=H5G_mkroot (ent->file, H5G_SIZE_HINT))<0 && -2!=status) {
- HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, FAIL, "can't create root group");
- }
- H5ECLEAR;
- if (update_grp) grp = *(ent->file->shared->root_ent);
-
-
- /*
- * This is the normal case. The object is just being inserted as a normal
- * entry into a symbol table.
- */
- if (H5O_link (ent, 1)<0) {
- HRETURN_ERROR (H5E_SYM, H5E_LINK, FAIL, "link inc failure");
- }
- if (H5G_stab_insert (&grp, rest, ent)<0) {
- HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, FAIL, "can't insert");
- }
-
- FUNC_LEAVE (SUCCEED);
+ const char *rest = NULL; /*part of name not existing yet */
+ H5G_entry_t grp; /*entry for group to contain obj */
+ size_t nchars; /*number of characters in name */
+ char _comp[1024]; /*name component */
+ hbool_t update_grp;
+ herr_t status;
+
+ FUNC_ENTER(H5G_insert, FAIL);
+
+ /* Check args. */
+ assert(name && *name);
+ assert(ent);
+
+ /*
+ * Look up the name -- it shouldn't exist yet.
+ */
+ if (H5G_namei(ent->file, NULL, name, &rest, &grp, NULL) >= 0) {
+ HRETURN_ERROR(H5E_SYM, H5E_EXISTS, FAIL, "already exists");
+ }
+ H5ECLEAR; /*it's OK that we didn't find it */
+ rest = H5G_component(rest, &nchars);
+
+ if (!rest || !*rest) {
+ /*
+ * The caller is attempting to insert a root object that either
+ * doesn't have a name or we shouldn't interfere with the name
+ * it already has as a message.
+ */
+ if (ent->file->shared->root_ent) {
+ HRETURN_ERROR(H5E_SYM, H5E_EXISTS, FAIL, "root exists");
+ }
+ if (1 != H5O_link(ent, 1)) {
+ HRETURN_ERROR(H5E_SYM, H5E_LINK, FAIL, "bad link count");
+ }
+ ent->name_off = 0;
+ ent->file->shared->root_ent = H5G_ent_calloc(ent);
+ HRETURN(SUCCEED);
+ }
+ /*
+ * There should be one component left. Make sure it's null
+ * terminated.
+ */
+ if (rest[nchars]) {
+ if (H5G_component(rest + nchars, NULL)) {
+ HRETURN_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "component not found");
+ } else if (nchars + 1 > sizeof _comp) {
+ HRETURN_ERROR(H5E_SYM, H5E_COMPLEN, FAIL, "component is too long");
+ } else {
+ /* null terminate */
+ HDmemcpy(_comp, rest, nchars);
+ _comp[nchars] = '\0';
+ rest = _comp;
+ }
+ }
+ if (!ent->file->shared->root_ent) {
+ /*
+ * This will be the only object in the file. Insert it as the root
+ * object and add a name messaage to the object header (or modify
+ * the first one we find).
+ */
+ H5O_name_t name_mesg;
+ name_mesg.s = rest;
+ if (H5O_modify(ent, H5O_NAME, 0, 0, &name_mesg) < 0) {
+ HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL,
+ "cannot add/change name message");
+ }
+ if (1 != H5O_link(ent, 1)) {
+ HRETURN_ERROR(H5E_SYM, H5E_LINK, FAIL, "bad link count");
+ }
+ ent->file->shared->root_ent = H5G_ent_calloc(ent);
+ HRETURN(SUCCEED);
+ }
+ /*
+ * Make sure the root group exists. Ignore the failure if it's
+ * because the group already exists.
+ */
+ update_grp = H5F_addr_eq(&(grp.header),
+ &(ent->file->shared->root_ent->header));
+ if ((status = H5G_mkroot(ent->file, H5G_SIZE_HINT)) < 0 && -2 != status) {
+ HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create root group");
+ }
+ H5ECLEAR;
+ if (update_grp)
+ grp = *(ent->file->shared->root_ent);
+
+ /*
+ * This is the normal case. The object is just being inserted as a normal
+ * entry into a symbol table.
+ */
+ if (H5O_link(ent, 1) < 0) {
+ HRETURN_ERROR(H5E_SYM, H5E_LINK, FAIL, "link inc failure");
+ }
+ if (H5G_stab_insert(&grp, rest, ent) < 0) {
+ HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't insert");
+ }
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5G_find
- *
- * Purpose: Finds an object with the specified NAME in file F. If
- * the name is relative then it is interpretted relative
- * to the current working group. On successful return,
- * GRP_ENT (if non-null) will be initialized with the symbol
- * table information for the group in which the object
- * appears (it will have an undefined object header address if
- * the object is the root object) and OBJ_ENT will be
- * initialized with the symbol table entry for the object
- * (OBJ_ENT is optional when the caller is interested only in
- * the existence of the object).
- *
- * This function will fail if the root object is requested and
- * there is none.
+ * Function: H5G_find
+ *
+ * Purpose: Finds an object with the specified NAME in file F. If
+ * the name is relative then it is interpretted relative
+ * to the current working group. On successful return,
+ * GRP_ENT (if non-null) will be initialized with the symbol
+ * table information for the group in which the object
+ * appears (it will have an undefined object header address if
+ * the object is the root object) and OBJ_ENT will be
+ * initialized with the symbol table entry for the object
+ * (OBJ_ENT is optional when the caller is interested only in
+ * the existence of the object).
+ *
+ * This function will fail if the root object is requested and
+ * there is none.
*
* Errors:
*
- * Return: Success: SUCCEED, see above for values of GRP_ENT and
- * OBJ_ENT.
+ * Return: Success: SUCCEED, see above for values of GRP_ENT and
+ * OBJ_ENT.
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Aug 12 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Aug 12 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
-H5G_find (H5F_t *f, const char *name,
- H5G_entry_t *grp_ent/*out*/, H5G_entry_t *obj_ent/*out*/)
+H5G_find(H5F_t *f, const char *name,
+ H5G_entry_t *grp_ent /*out */ , H5G_entry_t *obj_ent /*out */ )
{
- FUNC_ENTER (H5G_find, FAIL);
-
- /* check args */
- assert (f);
- assert (name && *name);
+ FUNC_ENTER(H5G_find, FAIL);
- if (H5G_namei (f, NULL, name, NULL, grp_ent, obj_ent)<0) {
- HRETURN_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "object not found");
- }
+ /* check args */
+ assert(f);
+ assert(name && *name);
- FUNC_LEAVE (SUCCEED);
+ if (H5G_namei(f, NULL, name, NULL, grp_ent, obj_ent) < 0) {
+ HRETURN_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found");
+ }
+ FUNC_LEAVE(SUCCEED);
}
diff --git a/src/H5Gent.c b/src/H5Gent.c
index 8575dd8..c3afb3d 100644
--- a/src/H5Gent.c
+++ b/src/H5Gent.c
@@ -12,86 +12,85 @@
#include <H5Gpkg.h>
#include <H5MMprivate.h>
-#define PABLO_MASK H5G_ent_mask
-static hbool_t interface_initialize_g = FALSE;
-#define INTERFACE_INIT NULL
-
+#define PABLO_MASK H5G_ent_mask
+static hbool_t interface_initialize_g = FALSE;
+#define INTERFACE_INIT NULL
/*-------------------------------------------------------------------------
- * Function: H5G_ent_calloc
+ * Function: H5G_ent_calloc
*
- * Purpose: Returns a pointer to a malloc'd, zeroed symbol table entry.
+ * Purpose: Returns a pointer to a malloc'd, zeroed symbol table entry.
*
- * Return: Success: Ptr to entry
+ * Return: Success: Ptr to entry
*
- * Failure: never fails
+ * Failure: never fails
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, September 19, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-H5G_entry_t *
-H5G_ent_calloc (H5G_entry_t *init)
+H5G_entry_t *
+H5G_ent_calloc(H5G_entry_t *init)
{
- H5G_entry_t *ent;
-
- ent = H5MM_xcalloc (1, sizeof(H5G_entry_t));
- if (init) *ent = *init;
- else H5F_addr_undef (&(ent->header));
- return ent;
+ H5G_entry_t *ent;
+
+ ent = H5MM_xcalloc(1, sizeof(H5G_entry_t));
+ if (init)
+ *ent = *init;
+ else
+ H5F_addr_undef(&(ent->header));
+ return ent;
}
-
/*-------------------------------------------------------------------------
- * Function: H5G_ent_cache
+ * Function: H5G_ent_cache
*
- * Purpose: Returns a pointer to the cache associated with the symbol
- * table entry. You should modify the cache directly, then call
- * H5G_modified() with the new cache type (even if the type is
- * still the same).
+ * Purpose: Returns a pointer to the cache associated with the symbol
+ * table entry. You should modify the cache directly, then call
+ * H5G_modified() with the new cache type (even if the type is
+ * still the same).
*
- * Return: Success: Ptr to the cache in the symbol table entry.
+ * Return: Success: Ptr to the cache in the symbol table entry.
*
- * Failure: NULL
+ * Failure: NULL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, September 19, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-H5G_cache_t *
-H5G_ent_cache (H5G_entry_t *ent, H5G_type_t *cache_type)
+H5G_cache_t *
+H5G_ent_cache(H5G_entry_t *ent, H5G_type_t *cache_type)
{
- FUNC_ENTER (H5G_ent_cache, NULL);
- if (!ent) {
- HRETURN_ERROR (H5E_SYM, H5E_BADVALUE, NULL, "no entry");
- }
- if (cache_type) *cache_type = ent->type;
-
- FUNC_LEAVE (&(ent->cache));
+ FUNC_ENTER(H5G_ent_cache, NULL);
+ if (!ent) {
+ HRETURN_ERROR(H5E_SYM, H5E_BADVALUE, NULL, "no entry");
+ }
+ if (cache_type)
+ *cache_type = ent->type;
+
+ FUNC_LEAVE(&(ent->cache));
}
-
-
/*-------------------------------------------------------------------------
- * Function: H5G_ent_modified
+ * Function: H5G_ent_modified
*
- * Purpose: This function should be called after you make any
- * modifications to a symbol table entry cache. Supply the new
- * type for the cache. If CACHE_TYPE is the constant
- * H5G_NO_CHANGE then the cache type isn't changed--just the
- * dirty bit is set.
+ * Purpose: This function should be called after you make any
+ * modifications to a symbol table entry cache. Supply the new
+ * type for the cache. If CACHE_TYPE is the constant
+ * H5G_NO_CHANGE then the cache type isn't changed--just the
+ * dirty bit is set.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, September 19, 1997
*
* Modifications:
@@ -99,302 +98,298 @@ H5G_ent_cache (H5G_entry_t *ent, H5G_type_t *cache_type)
*-------------------------------------------------------------------------
*/
herr_t
-H5G_ent_modified (H5G_entry_t *ent, H5G_type_t cache_type)
+H5G_ent_modified(H5G_entry_t *ent, H5G_type_t cache_type)
{
- FUNC_ENTER (H5G_ent_modified, FAIL);
- assert (ent);
- if (H5G_NO_CHANGE!=ent->type) ent->type = cache_type;
- ent->dirty = TRUE;
- FUNC_LEAVE (SUCCEED);
+ FUNC_ENTER(H5G_ent_modified, FAIL);
+ assert(ent);
+ if (H5G_NO_CHANGE != ent->type)
+ ent->type = cache_type;
+ ent->dirty = TRUE;
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5G_ent_decode_vec
+ * Function: H5G_ent_decode_vec
*
- * Purpose: Same as H5G_ent_decode() except it does it for an array of
- * symbol table entries.
+ * Purpose: Same as H5G_ent_decode() except it does it for an array of
+ * symbol table entries.
*
* Errors:
- * SYM CANTDECODE Can't decode.
+ * SYM CANTDECODE Can't decode.
*
- * Return: Success: SUCCEED, with *pp pointing to the first byte
- * after the last symbol.
+ * Return: Success: SUCCEED, with *pp pointing to the first byte
+ * after the last symbol.
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jul 18 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jul 18 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
-H5G_ent_decode_vec (H5F_t *f, const uint8 **pp, H5G_entry_t *ent, intn n)
+H5G_ent_decode_vec(H5F_t *f, const uint8 **pp, H5G_entry_t *ent, intn n)
{
- intn i;
+ intn i;
- FUNC_ENTER (H5G_ent_decode_vec, FAIL);
+ FUNC_ENTER(H5G_ent_decode_vec, FAIL);
- /* check arguments */
- assert (f);
- assert (pp);
- assert (ent);
- assert (n>=0);
+ /* check arguments */
+ assert(f);
+ assert(pp);
+ assert(ent);
+ assert(n >= 0);
- /* decode entries */
- for (i=0; i<n; i++) {
- if (H5G_ent_decode (f, pp, ent+i)<0) {
- HRETURN_ERROR (H5E_SYM, H5E_CANTDECODE, FAIL, "can't decode");
- }
- }
+ /* decode entries */
+ for (i = 0; i < n; i++) {
+ if (H5G_ent_decode(f, pp, ent + i) < 0) {
+ HRETURN_ERROR(H5E_SYM, H5E_CANTDECODE, FAIL, "can't decode");
+ }
+ }
- FUNC_LEAVE (SUCCEED);
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5G_ent_decode
+ * Function: H5G_ent_decode
*
- * Purpose: Decodes a symbol table entry pointed to by `*pp'.
+ * Purpose: Decodes a symbol table entry pointed to by `*pp'.
*
* Errors:
*
- * Return: Success: SUCCEED with *pp pointing to the first byte
- * following the symbol table entry.
+ * Return: Success: SUCCEED with *pp pointing to the first byte
+ * following the symbol table entry.
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jul 18 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jul 18 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
-H5G_ent_decode (H5F_t *f, const uint8 **pp, H5G_entry_t *ent)
+H5G_ent_decode(H5F_t *f, const uint8 **pp, H5G_entry_t *ent)
{
- const uint8 *p_ret = *pp;
+ const uint8 *p_ret = *pp;
- FUNC_ENTER (H5G_ent_decode, FAIL);
+ FUNC_ENTER(H5G_ent_decode, FAIL);
- /* check arguments */
- assert (f);
- assert (pp);
- assert (ent);
+ /* check arguments */
+ assert(f);
+ assert(pp);
+ assert(ent);
- ent->file = f;
+ ent->file = f;
- /* decode header */
- H5F_decode_length (f, *pp, ent->name_off);
- H5F_addr_decode (f, pp, &(ent->header));
- UINT32DECODE (*pp, ent->type);
+ /* decode header */
+ H5F_decode_length(f, *pp, ent->name_off);
+ H5F_addr_decode(f, pp, &(ent->header));
+ UINT32DECODE(*pp, ent->type);
- /* decode scratch-pad */
- switch (ent->type) {
- case H5G_NOTHING_CACHED:
- break;
+ /* decode scratch-pad */
+ switch (ent->type) {
+ case H5G_NOTHING_CACHED:
+ break;
- case H5G_CACHED_STAB:
- assert (2*H5F_SIZEOF_ADDR (f) <= H5G_SIZEOF_SCRATCH);
- H5F_addr_decode (f, pp, &(ent->cache.stab.btree_addr));
- H5F_addr_decode (f, pp, &(ent->cache.stab.heap_addr));
- break;
+ case H5G_CACHED_STAB:
+ assert(2 * H5F_SIZEOF_ADDR(f) <= H5G_SIZEOF_SCRATCH);
+ H5F_addr_decode(f, pp, &(ent->cache.stab.btree_addr));
+ H5F_addr_decode(f, pp, &(ent->cache.stab.heap_addr));
+ break;
- default:
- HDabort();
- }
+ default:
+ HDabort();
+ }
- *pp = p_ret + H5G_SIZEOF_ENTRY(f);
- FUNC_LEAVE (SUCCEED);
+ *pp = p_ret + H5G_SIZEOF_ENTRY(f);
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5G_ent_encode_vec
+ * Function: H5G_ent_encode_vec
*
- * Purpose: Same as H5G_ent_encode() except it does it for an array of
- * symbol table entries.
+ * Purpose: Same as H5G_ent_encode() except it does it for an array of
+ * symbol table entries.
*
* Errors:
- * SYM CANTENCODE Can't encode.
+ * SYM CANTENCODE Can't encode.
*
- * Return: Success: SUCCEED, with *pp pointing to the first byte
- * after the last symbol.
+ * Return: Success: SUCCEED, with *pp pointing to the first byte
+ * after the last symbol.
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jul 18 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jul 18 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
-H5G_ent_encode_vec (H5F_t *f, uint8 **pp, H5G_entry_t *ent, intn n)
+H5G_ent_encode_vec(H5F_t *f, uint8 **pp, H5G_entry_t *ent, intn n)
{
- intn i;
+ intn i;
- FUNC_ENTER (H5G_ent_encode_vec, FAIL);
+ FUNC_ENTER(H5G_ent_encode_vec, FAIL);
- /* check arguments */
- assert (f);
- assert (pp);
- assert (ent);
- assert (n>=0);
+ /* check arguments */
+ assert(f);
+ assert(pp);
+ assert(ent);
+ assert(n >= 0);
- /* encode entries */
- for (i=0; i<n; i++) {
- if (H5G_ent_encode (f, pp, ent+i)<0) {
- HRETURN_ERROR (H5E_SYM, H5E_CANTENCODE, FAIL, "can't encode");
- }
- }
+ /* encode entries */
+ for (i = 0; i < n; i++) {
+ if (H5G_ent_encode(f, pp, ent + i) < 0) {
+ HRETURN_ERROR(H5E_SYM, H5E_CANTENCODE, FAIL, "can't encode");
+ }
+ }
- FUNC_LEAVE (SUCCEED);
+ FUNC_LEAVE(SUCCEED);
}
-
-
/*-------------------------------------------------------------------------
- * Function: H5G_ent_encode
+ * Function: H5G_ent_encode
*
- * Purpose: Encodes the specified symbol table entry into the buffer
- * pointed to by *pp.
+ * Purpose: Encodes the specified symbol table entry into the buffer
+ * pointed to by *pp.
*
* Errors:
*
- * Return: Success: SUCCEED, with *pp pointing to the first byte
- * after the symbol table entry.
+ * Return: Success: SUCCEED, with *pp pointing to the first byte
+ * after the symbol table entry.
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jul 18 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jul 18 1997
*
* Modifications:
*
- * Robb Matzke, 8 Aug 1997
- * Writes zeros for the bytes that aren't used so the file doesn't
- * contain junk.
+ * Robb Matzke, 8 Aug 1997
+ * Writes zeros for the bytes that aren't used so the file doesn't
+ * contain junk.
*
*-------------------------------------------------------------------------
*/
herr_t
-H5G_ent_encode (H5F_t *f, uint8 **pp, H5G_entry_t *ent)
+H5G_ent_encode(H5F_t *f, uint8 **pp, H5G_entry_t *ent)
{
- uint8 *p_ret = *pp + H5G_SIZEOF_ENTRY(f);
-
- FUNC_ENTER (H5G_ent_encode, FAIL);
-
- /* check arguments */
- assert (f);
- assert (pp);
-
- if (ent) {
- /* encode header */
- H5F_encode_length (f, *pp, ent->name_off);
- H5F_addr_encode (f, pp, &(ent->header));
- UINT32ENCODE (*pp, ent->type);
-
- /* encode scratch-pad */
- switch (ent->type) {
- case H5G_NOTHING_CACHED:
- break;
-
- case H5G_CACHED_STAB:
- assert (2*H5F_SIZEOF_ADDR (f) <= H5G_SIZEOF_SCRATCH);
- H5F_addr_encode (f, pp, &(ent->cache.stab.btree_addr));
- H5F_addr_encode (f, pp, &(ent->cache.stab.heap_addr));
- break;
-
- default:
- HDabort();
- }
- } else {
- haddr_t undef;
- H5F_encode_length (f, *pp, 0);
- H5F_addr_undef (&undef);
- H5F_addr_encode (f, pp, &undef);
- UINT32ENCODE (*pp, H5G_NOTHING_CACHED);
- }
-
- /* fill with zero */
- while (*pp<p_ret) *(*pp)++ = 0;
-
- *pp = p_ret;
- FUNC_LEAVE (SUCCEED);
+ uint8 *p_ret = *pp + H5G_SIZEOF_ENTRY(f);
+
+ FUNC_ENTER(H5G_ent_encode, FAIL);
+
+ /* check arguments */
+ assert(f);
+ assert(pp);
+
+ if (ent) {
+ /* encode header */
+ H5F_encode_length(f, *pp, ent->name_off);
+ H5F_addr_encode(f, pp, &(ent->header));
+ UINT32ENCODE(*pp, ent->type);
+
+ /* encode scratch-pad */
+ switch (ent->type) {
+ case H5G_NOTHING_CACHED:
+ break;
+
+ case H5G_CACHED_STAB:
+ assert(2 * H5F_SIZEOF_ADDR(f) <= H5G_SIZEOF_SCRATCH);
+ H5F_addr_encode(f, pp, &(ent->cache.stab.btree_addr));
+ H5F_addr_encode(f, pp, &(ent->cache.stab.heap_addr));
+ break;
+
+ default:
+ HDabort();
+ }
+ } else {
+ haddr_t undef;
+ H5F_encode_length(f, *pp, 0);
+ H5F_addr_undef(&undef);
+ H5F_addr_encode(f, pp, &undef);
+ UINT32ENCODE(*pp, H5G_NOTHING_CACHED);
+ }
+
+ /* fill with zero */
+ while (*pp < p_ret)
+ *(*pp)++ = 0;
+
+ *pp = p_ret;
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5G_ent_debug
+ * Function: H5G_ent_debug
*
- * Purpose: Prints debugging information about a symbol table entry.
+ * Purpose: Prints debugging information about a symbol table entry.
*
* Errors:
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Aug 29 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Aug 29 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
-H5G_ent_debug (H5F_t *f, H5G_entry_t *ent, FILE *stream, intn indent,
- intn fwidth)
+H5G_ent_debug(H5F_t *f, H5G_entry_t *ent, FILE * stream, intn indent,
+ intn fwidth)
{
- FUNC_ENTER (H5G_ent_debug, FAIL);
-
- fprintf (stream, "%*s%-*s %lu\n", indent, "", fwidth,
- "Name offset into private heap:",
- (unsigned long)(ent->name_off));
-
- fprintf (stream, "%*s%-*s ", indent, "", fwidth,
- "Object header address:");
- H5F_addr_print (stream, &(ent->header));
- fprintf (stream, "\n");
-
- fprintf (stream, "%*s%-*s %s\n", indent, "", fwidth,
- "Dirty:",
- ent->dirty ? "Yes" : "No");
- fprintf (stream, "%*s%-*s ", indent, "", fwidth,
- "Symbol type:");
- switch (ent->type) {
- case H5G_NOTHING_CACHED:
- fprintf (stream, "Nothing Cached\n");
- break;
-
- case H5G_CACHED_STAB:
- fprintf (stream, "Symbol Table\n");
-
- fprintf (stream, "%*s%-*s ", indent, "", fwidth,
- "B-tree address:");
- H5F_addr_print (stream, &(ent->cache.stab.btree_addr));
- fprintf (stream, "\n");
-
- fprintf (stream, "%*s%-*s ", indent, "", fwidth,
- "Heap address:");
- H5F_addr_print (stream, &(ent->cache.stab.heap_addr));
- fprintf (stream, "\n");
- break;
-
- default:
- fprintf (stream, "*** Unknown symbol type %d\n", ent->type);
- break;
- }
-
- FUNC_LEAVE (SUCCEED);
+ FUNC_ENTER(H5G_ent_debug, FAIL);
+
+ fprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth,
+ "Name offset into private heap:",
+ (unsigned long) (ent->name_off));
+
+ fprintf(stream, "%*s%-*s ", indent, "", fwidth,
+ "Object header address:");
+ H5F_addr_print(stream, &(ent->header));
+ fprintf(stream, "\n");
+
+ fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
+ "Dirty:",
+ ent->dirty ? "Yes" : "No");
+ fprintf(stream, "%*s%-*s ", indent, "", fwidth,
+ "Symbol type:");
+ switch (ent->type) {
+ case H5G_NOTHING_CACHED:
+ fprintf(stream, "Nothing Cached\n");
+ break;
+
+ case H5G_CACHED_STAB:
+ fprintf(stream, "Symbol Table\n");
+
+ fprintf(stream, "%*s%-*s ", indent, "", fwidth,
+ "B-tree address:");
+ H5F_addr_print(stream, &(ent->cache.stab.btree_addr));
+ fprintf(stream, "\n");
+
+ fprintf(stream, "%*s%-*s ", indent, "", fwidth,
+ "Heap address:");
+ H5F_addr_print(stream, &(ent->cache.stab.heap_addr));
+ fprintf(stream, "\n");
+ break;
+
+ default:
+ fprintf(stream, "*** Unknown symbol type %d\n", ent->type);
+ break;
+ }
+
+ FUNC_LEAVE(SUCCEED);
}
diff --git a/src/H5Gnode.c b/src/H5Gnode.c
index f124d3e..d1d53ea 100644
--- a/src/H5Gnode.c
+++ b/src/H5Gnode.c
@@ -1,1017 +1,994 @@
/*-------------------------------------------------------------------------
- * Copyright (C) 1997 National Center for Supercomputing Applications.
+ * Copyright (C) 1997 National Center for Supercomputing Applications.
* All rights reserved.
*
*-------------------------------------------------------------------------
*
- * Created: snode.c
- * Jun 26 1997
- * Robb Matzke <matzke@llnl.gov>
+ * Created: snode.c
+ * Jun 26 1997
+ * Robb Matzke <matzke@llnl.gov>
*
- * Purpose: Functions for handling symbol table nodes. A
- * symbol table node is a small collection of symbol
- * table entries. A B-tree usually points to the
- * symbol table nodes for any given symbol table.
+ * Purpose: Functions for handling symbol table nodes. A
+ * symbol table node is a small collection of symbol
+ * table entries. A B-tree usually points to the
+ * symbol table nodes for any given symbol table.
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-#define H5G_PACKAGE /*suppress error message about including H5Gpkg.h*/
+#define H5G_PACKAGE /*suppress error message about including H5Gpkg.h */
/* Packages needed by this file... */
-#include <H5private.h> /*library */
-#include <H5ACprivate.h> /*cache */
-#include <H5Bprivate.h> /*B-link trees */
-#include <H5Eprivate.h> /*error handling */
-#include <H5Gpkg.h> /*me */
-#include <H5Hprivate.h> /*heap */
-#include <H5MFprivate.h> /*file memory management */
-#include <H5MMprivate.h> /*core memory management */
-#include <H5Oprivate.h> /*header messages */
-
-#define PABLO_MASK H5G_node_mask
+#include <H5private.h> /*library */
+#include <H5ACprivate.h> /*cache */
+#include <H5Bprivate.h> /*B-link trees */
+#include <H5Eprivate.h> /*error handling */
+#include <H5Gpkg.h> /*me */
+#include <H5Hprivate.h> /*heap */
+#include <H5MFprivate.h> /*file memory management */
+#include <H5MMprivate.h> /*core memory management */
+#include <H5Oprivate.h> /*header messages */
+
+#define PABLO_MASK H5G_node_mask
/* PRIVATE PROTOTYPES */
-static herr_t H5G_node_decode_key (H5F_t *f, H5B_t *bt, uint8 *raw,
- void *_key);
-static herr_t H5G_node_encode_key (H5F_t *f, H5B_t *bt, uint8 *raw,
- void *_key);
-static size_t H5G_node_size (H5F_t *f);
-static herr_t H5G_node_create (H5F_t *f, H5B_ins_t op, void *_lt_key,
- void *_udata, void *_rt_key,
- haddr_t *addr/*out*/);
-static herr_t H5G_node_flush (H5F_t *f, hbool_t destroy, const haddr_t *addr,
- H5G_node_t *sym);
-static H5G_node_t *H5G_node_load (H5F_t *f, const haddr_t *addr,
- const void *_udata1, void *_udata2);
-static intn H5G_node_cmp2 (H5F_t *f, void *_lt_key, void *_udata,
- void *_rt_key);
-static intn H5G_node_cmp3 (H5F_t *f, void *_lt_key, void *_udata,
- void *_rt_key);
-static herr_t H5G_node_found (H5F_t *f, const haddr_t *addr,
- const void *_lt_key, void *_udata,
- const void *_rt_key);
-static H5B_ins_t H5G_node_insert (H5F_t *f, const haddr_t *addr,
- void *_lt_key, hbool_t *lt_key_changed,
- void *_md_key, void *_udata,
- void *_rt_key, hbool_t *rt_key_changed,
- haddr_t *new_node/*out*/);
-static herr_t H5G_node_list (H5F_t *f, const haddr_t *addr, void *_udata);
-static size_t H5G_node_sizeof_rkey (H5F_t *f, const void *_udata);
+static herr_t H5G_node_decode_key(H5F_t *f, H5B_t *bt, uint8 *raw,
+ void *_key);
+static herr_t H5G_node_encode_key(H5F_t *f, H5B_t *bt, uint8 *raw,
+ void *_key);
+static size_t H5G_node_size(H5F_t *f);
+static herr_t H5G_node_create(H5F_t *f, H5B_ins_t op, void *_lt_key,
+ void *_udata, void *_rt_key,
+ haddr_t *addr /*out */ );
+static herr_t H5G_node_flush(H5F_t *f, hbool_t destroy, const haddr_t *addr,
+ H5G_node_t *sym);
+static H5G_node_t *H5G_node_load(H5F_t *f, const haddr_t *addr,
+ const void *_udata1, void *_udata2);
+static intn H5G_node_cmp2(H5F_t *f, void *_lt_key, void *_udata,
+ void *_rt_key);
+static intn H5G_node_cmp3(H5F_t *f, void *_lt_key, void *_udata,
+ void *_rt_key);
+static herr_t H5G_node_found(H5F_t *f, const haddr_t *addr,
+ const void *_lt_key, void *_udata,
+ const void *_rt_key);
+static H5B_ins_t H5G_node_insert(H5F_t *f, const haddr_t *addr,
+ void *_lt_key, hbool_t *lt_key_changed,
+ void *_md_key, void *_udata,
+ void *_rt_key, hbool_t *rt_key_changed,
+ haddr_t *new_node /*out */ );
+static herr_t H5G_node_list(H5F_t *f, const haddr_t *addr, void *_udata);
+static size_t H5G_node_sizeof_rkey(H5F_t *f, const void *_udata);
/* H5G inherits cache-like properties from H5AC */
-const H5AC_class_t H5AC_SNODE[1] = {{
- H5AC_SNODE_ID,
- (void*(*)(H5F_t*,const haddr_t*,const void*,void*))H5G_node_load,
- (herr_t(*)(H5F_t*,hbool_t,const haddr_t*,void*))H5G_node_flush,
-}};
+const H5AC_class_t H5AC_SNODE[1] =
+{
+ {
+ H5AC_SNODE_ID,
+ (void *(*)(H5F_t *, const haddr_t *, const void *, void *)) H5G_node_load,
+ (herr_t (*)(H5F_t *, hbool_t, const haddr_t *, void *)) H5G_node_flush,
+ }};
/* H5G inherits B-tree like properties from H5B */
-H5B_class_t H5B_SNODE[1] = {{
- H5B_SNODE_ID, /*id */
- sizeof (H5G_node_key_t), /*sizeof_nkey */
- H5G_node_sizeof_rkey, /*get_sizeof_rkey */
- H5G_node_create, /*new */
- H5G_node_cmp2, /*cmp2 */
- H5G_node_cmp3, /*cmp3 */
- H5G_node_found, /*found */
- H5G_node_insert, /*insert */
- TRUE, /*follow min branch? */
- TRUE, /*follow max branch? */
- H5G_node_list, /*list */
- H5G_node_decode_key, /*decode */
- H5G_node_encode_key, /*encode */
-}};
+H5B_class_t H5B_SNODE[1] =
+{
+ {
+ H5B_SNODE_ID, /*id */
+ sizeof(H5G_node_key_t), /*sizeof_nkey */
+ H5G_node_sizeof_rkey, /*get_sizeof_rkey */
+ H5G_node_create, /*new */
+ H5G_node_cmp2, /*cmp2 */
+ H5G_node_cmp3, /*cmp3 */
+ H5G_node_found, /*found */
+ H5G_node_insert, /*insert */
+ TRUE, /*follow min branch? */
+ TRUE, /*follow max branch? */
+ H5G_node_list, /*list */
+ H5G_node_decode_key, /*decode */
+ H5G_node_encode_key, /*encode */
+ }};
/* Interface initialization */
-static intn interface_initialize_g = FALSE;
-#define INTERFACE_INIT NULL
-
+static intn interface_initialize_g = FALSE;
+#define INTERFACE_INIT NULL
/*-------------------------------------------------------------------------
- * Function: H5G_node_sizeof_rkey
+ * Function: H5G_node_sizeof_rkey
*
- * Purpose: Returns the size of a raw B-link tree key for the specified
- * file.
+ * Purpose: Returns the size of a raw B-link tree key for the specified
+ * file.
*
- * Return: Success: Size of the key.
+ * Return: Success: Size of the key.
*
- * Failure: never fails
+ * Failure: never fails
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jul 14 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jul 14 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static size_t
-H5G_node_sizeof_rkey (H5F_t *f, const void *udata __attribute__((unused)))
+H5G_node_sizeof_rkey(H5F_t *f, const void *udata __attribute__((unused)))
{
- return H5F_SIZEOF_SIZE(f); /*the name offset*/
+ return H5F_SIZEOF_SIZE(f); /*the name offset */
}
-
/*-------------------------------------------------------------------------
- * Function: H5G_node_decode_key
+ * Function: H5G_node_decode_key
*
- * Purpose: Decodes a raw key into a native key.
+ * Purpose: Decodes a raw key into a native key.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jul 8 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jul 8 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static herr_t
-H5G_node_decode_key (H5F_t *f, H5B_t *bt, uint8 *raw, void *_key)
+H5G_node_decode_key(H5F_t *f, H5B_t *bt, uint8 *raw, void *_key)
{
- H5G_node_key_t *key = (H5G_node_key_t *)_key;
+ H5G_node_key_t *key = (H5G_node_key_t *) _key;
- FUNC_ENTER (H5G_node_decode_key, FAIL);
+ FUNC_ENTER(H5G_node_decode_key, FAIL);
- assert (f);
- assert (raw);
- assert (key);
+ assert(f);
+ assert(raw);
+ assert(key);
- H5F_decode_length (f, raw, key->offset);
+ H5F_decode_length(f, raw, key->offset);
- FUNC_LEAVE (SUCCEED);
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5G_node_encode_key
+ * Function: H5G_node_encode_key
*
- * Purpose: Encodes a native key into a raw key.
+ * Purpose: Encodes a native key into a raw key.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jul 8 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jul 8 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static herr_t
-H5G_node_encode_key (H5F_t *f, H5B_t *bt, uint8 *raw, void *_key)
+H5G_node_encode_key(H5F_t *f, H5B_t *bt, uint8 *raw, void *_key)
{
- H5G_node_key_t *key = (H5G_node_key_t *)_key;
+ H5G_node_key_t *key = (H5G_node_key_t *) _key;
- FUNC_ENTER (H5G_node_encode_key, FAIL);
+ FUNC_ENTER(H5G_node_encode_key, FAIL);
- assert (f);
- assert (raw);
- assert (key);
+ assert(f);
+ assert(raw);
+ assert(key);
- H5F_encode_length (f, raw, key->offset);
+ H5F_encode_length(f, raw, key->offset);
- FUNC_LEAVE (SUCCEED);
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5G_node_size
+ * Function: H5G_node_size
*
- * Purpose: Returns the total size of a symbol table node.
+ * Purpose: Returns the total size of a symbol table node.
*
- * Return: Success: Total size of the node in bytes.
+ * Return: Success: Total size of the node in bytes.
*
- * Failure: Never fails.
+ * Failure: Never fails.
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jun 23 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jun 23 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static size_t
-H5G_node_size (H5F_t *f)
+H5G_node_size(H5F_t *f)
{
- return H5G_NODE_SIZEOF_HDR(f) +
- (2*H5G_NODE_K(f)) * H5G_SIZEOF_ENTRY(f);
+ return H5G_NODE_SIZEOF_HDR(f) +
+ (2 * H5G_NODE_K(f)) * H5G_SIZEOF_ENTRY(f);
}
-
/*-------------------------------------------------------------------------
- * Function: H5G_node_create
+ * Function: H5G_node_create
*
- * Purpose: Creates a new empty symbol table node. This function is
- * called by the B-tree insert function for an empty tree. It
- * is also called internally to split a symbol node with LT_KEY
- * and RT_KEY null pointers.
+ * Purpose: Creates a new empty symbol table node. This function is
+ * called by the B-tree insert function for an empty tree. It
+ * is also called internally to split a symbol node with LT_KEY
+ * and RT_KEY null pointers.
*
- * Return: Success: SUCCEED. The address of symbol table node is
- * returned through the ADDR argument.
+ * Return: Success: SUCCEED. The address of symbol table node is
+ * returned through the ADDR argument.
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jun 23 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jun 23 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static herr_t
-H5G_node_create (H5F_t *f, H5B_ins_t op,
- void *_lt_key, void *_udata, void *_rt_key,
- haddr_t *addr/*out*/)
+H5G_node_create(H5F_t *f, H5B_ins_t op,
+ void *_lt_key, void *_udata, void *_rt_key,
+ haddr_t *addr /*out */ )
{
- H5G_node_key_t *lt_key = (H5G_node_key_t*)_lt_key;
- H5G_node_key_t *rt_key = (H5G_node_key_t*)_rt_key;
- H5G_node_t *sym = NULL;
- size_t size = 0;
-
- FUNC_ENTER (H5G_node_create, FAIL);
-
- /*
- * Check arguments.
- */
- assert (f);
- assert (H5B_INS_FIRST==op);
-
- sym = H5MM_xcalloc (1, sizeof(H5G_node_t));
- size = H5G_node_size (f);
- if (H5MF_alloc (f, H5MF_META, size, addr/*out*/)<0) {
- H5MM_xfree (sym);
- HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, FAIL,
- "unable to allocate file space");
- }
-
- sym->dirty = TRUE;
- sym->entry = H5MM_xcalloc (2 * H5G_NODE_K(f), sizeof(H5G_entry_t));
- if (H5AC_set (f, H5AC_SNODE, addr, sym)<0) {
- H5MM_xfree (sym->entry);
- H5MM_xfree (sym);
- HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, FAIL,
- "unable to cache symbol table leaf node");
- }
-
- /*
- * The left and right symbols in an empty tree are both the
- * empty string stored at offset zero by the H5G functions. This
- * allows the comparison functions to work correctly without knowing
- * that there are no symbols.
- */
- if (lt_key) lt_key->offset = 0;
- if (rt_key) rt_key->offset = 0;
-
- FUNC_LEAVE (SUCCEED);
+ H5G_node_key_t *lt_key = (H5G_node_key_t *) _lt_key;
+ H5G_node_key_t *rt_key = (H5G_node_key_t *) _rt_key;
+ H5G_node_t *sym = NULL;
+ size_t size = 0;
+
+ FUNC_ENTER(H5G_node_create, FAIL);
+
+ /*
+ * Check arguments.
+ */
+ assert(f);
+ assert(H5B_INS_FIRST == op);
+
+ sym = H5MM_xcalloc(1, sizeof(H5G_node_t));
+ size = H5G_node_size(f);
+ if (H5MF_alloc(f, H5MF_META, size, addr /*out */ ) < 0) {
+ H5MM_xfree(sym);
+ HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL,
+ "unable to allocate file space");
+ }
+ sym->dirty = TRUE;
+ sym->entry = H5MM_xcalloc(2 * H5G_NODE_K(f), sizeof(H5G_entry_t));
+ if (H5AC_set(f, H5AC_SNODE, addr, sym) < 0) {
+ H5MM_xfree(sym->entry);
+ H5MM_xfree(sym);
+ HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL,
+ "unable to cache symbol table leaf node");
+ }
+ /*
+ * The left and right symbols in an empty tree are both the
+ * empty string stored at offset zero by the H5G functions. This
+ * allows the comparison functions to work correctly without knowing
+ * that there are no symbols.
+ */
+ if (lt_key)
+ lt_key->offset = 0;
+ if (rt_key)
+ rt_key->offset = 0;
+
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5G_node_flush
+ * Function: H5G_node_flush
*
- * Purpose: Flush a symbol table node to disk.
+ * Purpose: Flush a symbol table node to disk.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jun 23 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jun 23 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static herr_t
-H5G_node_flush (H5F_t *f, hbool_t destroy, const haddr_t *addr,
- H5G_node_t *sym)
+H5G_node_flush(H5F_t *f, hbool_t destroy, const haddr_t *addr,
+ H5G_node_t *sym)
{
- uint8 *buf=NULL, *p=NULL;
- size_t size;
- herr_t status;
- int i;
-
- FUNC_ENTER (H5G_node_flush, FAIL);
-
- /*
- * Check arguments.
- */
- assert (f);
- assert (addr && H5F_addr_defined (addr));
- assert (sym);
-
- /*
- * Look for dirty entries and set the node dirty flag.
- */
- for (i=0; i<sym->nsyms; i++) {
- if (sym->entry[i].dirty) sym->dirty = TRUE;
- }
-
- /*
- * Write the symbol node to disk.
- */
- if (sym->dirty) {
- size = H5G_node_size (f);
- buf = p = H5MM_xmalloc (size);
-
- /* magic number */
- HDmemcpy (p, H5G_NODE_MAGIC, H5G_NODE_SIZEOF_MAGIC);
- p += 4;
-
- /* version number */
- *p++ = H5G_NODE_VERS;
-
- /* reserved */
- *p++ = 0;
-
- /* number of symbols */
- UINT16ENCODE (p, sym->nsyms);
-
- /* entries */
- H5G_ent_encode_vec (f, &p, sym->entry, sym->nsyms);
- HDmemset (p, 0, size - (p-buf));
-
- status = H5F_block_write (f, addr, size, buf);
- buf = H5MM_xfree (buf);
- if (status<0) HRETURN_ERROR (H5E_SYM, H5E_WRITEERROR, FAIL,
- "unable to write symbol table node to "
- "the file");
- }
-
- /*
- * Destroy the symbol node? This might happen if the node is being
- * preempted from the cache.
- */
- if (destroy) {
- sym->entry = H5MM_xfree (sym->entry);
- H5MM_xfree (sym);
- }
-
- FUNC_LEAVE (SUCCEED);
+ uint8 *buf = NULL, *p = NULL;
+ size_t size;
+ herr_t status;
+ int i;
+
+ FUNC_ENTER(H5G_node_flush, FAIL);
+
+ /*
+ * Check arguments.
+ */
+ assert(f);
+ assert(addr && H5F_addr_defined(addr));
+ assert(sym);
+
+ /*
+ * Look for dirty entries and set the node dirty flag.
+ */
+ for (i = 0; i < sym->nsyms; i++) {
+ if (sym->entry[i].dirty)
+ sym->dirty = TRUE;
+ }
+
+ /*
+ * Write the symbol node to disk.
+ */
+ if (sym->dirty) {
+ size = H5G_node_size(f);
+ buf = p = H5MM_xmalloc(size);
+
+ /* magic number */
+ HDmemcpy(p, H5G_NODE_MAGIC, H5G_NODE_SIZEOF_MAGIC);
+ p += 4;
+
+ /* version number */
+ *p++ = H5G_NODE_VERS;
+
+ /* reserved */
+ *p++ = 0;
+
+ /* number of symbols */
+ UINT16ENCODE(p, sym->nsyms);
+
+ /* entries */
+ H5G_ent_encode_vec(f, &p, sym->entry, sym->nsyms);
+ HDmemset(p, 0, size - (p - buf));
+
+ status = H5F_block_write(f, addr, size, buf);
+ buf = H5MM_xfree(buf);
+ if (status < 0)
+ HRETURN_ERROR(H5E_SYM, H5E_WRITEERROR, FAIL,
+ "unable to write symbol table node to "
+ "the file");
+ }
+ /*
+ * Destroy the symbol node? This might happen if the node is being
+ * preempted from the cache.
+ */
+ if (destroy) {
+ sym->entry = H5MM_xfree(sym->entry);
+ H5MM_xfree(sym);
+ }
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5G_node_load
+ * Function: H5G_node_load
*
- * Purpose: Loads a symbol table node from the file.
+ * Purpose: Loads a symbol table node from the file.
*
- * Return: Success: Ptr to the new table.
+ * Return: Success: Ptr to the new table.
*
- * Failure: NULL
+ * Failure: NULL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jun 23 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jun 23 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-static H5G_node_t *
-H5G_node_load (H5F_t *f, const haddr_t *addr, const void *_udata1,
- void *_udata2)
+static H5G_node_t *
+H5G_node_load(H5F_t *f, const haddr_t *addr, const void *_udata1,
+ void *_udata2)
{
- H5G_node_t *sym = NULL;
- size_t size = 0;
- uint8 *buf = NULL;
- const uint8 *p = NULL;
- H5G_node_t *ret_value = NULL; /*for error handling*/
-
- FUNC_ENTER (H5G_node_load, NULL);
-
- /*
- * Check arguments.
- */
- assert (f);
- assert (addr && H5F_addr_defined (addr));
- assert (!_udata1);
- assert (NULL==_udata2);
-
- /*
- * Initialize variables.
- */
- size = H5G_node_size (f);
- p = buf = H5MM_xmalloc (size);
- sym = H5MM_xcalloc (1, sizeof(H5G_node_t));
- sym->entry = H5MM_xcalloc (2*H5G_NODE_K(f), sizeof(H5G_entry_t));
-
- if (H5F_block_read (f, addr, size, buf)<0) {
- HGOTO_ERROR (H5E_SYM, H5E_READERROR, NULL,
- "unabel to read symbol table node");
- }
-
- /* magic */
- if (HDmemcmp (p, H5G_NODE_MAGIC, H5G_NODE_SIZEOF_MAGIC)) {
- HGOTO_ERROR (H5E_SYM, H5E_CANTLOAD, NULL,
- "bad symbol table node signature");
- }
- p += 4;
-
- /* version */
- if (H5G_NODE_VERS!=*p++) {
- HGOTO_ERROR (H5E_SYM, H5E_CANTLOAD, NULL,
- "bad symbol table node version");
- }
-
- /* reserved */
- p++;
-
- /* number of symbols */
- UINT16DECODE (p, sym->nsyms);
-
- /* entries */
- if (H5G_ent_decode_vec (f, &p, sym->entry, sym->nsyms)<0) {
- HGOTO_ERROR (H5E_SYM, H5E_CANTLOAD, NULL,
- "unable to decode symbol table entries");
- }
- buf = H5MM_xfree (buf);
-
- ret_value = sym;
-
-
- done:
- if (!ret_value) {
- buf = H5MM_xfree (buf);
- if (sym) {
- sym->entry = H5MM_xfree (sym->entry);
- sym = H5MM_xfree (sym);
- }
- }
- FUNC_LEAVE (ret_value);
+ H5G_node_t *sym = NULL;
+ size_t size = 0;
+ uint8 *buf = NULL;
+ const uint8 *p = NULL;
+ H5G_node_t *ret_value = NULL; /*for error handling */
+
+ FUNC_ENTER(H5G_node_load, NULL);
+
+ /*
+ * Check arguments.
+ */
+ assert(f);
+ assert(addr && H5F_addr_defined(addr));
+ assert(!_udata1);
+ assert(NULL == _udata2);
+
+ /*
+ * Initialize variables.
+ */
+ size = H5G_node_size(f);
+ p = buf = H5MM_xmalloc(size);
+ sym = H5MM_xcalloc(1, sizeof(H5G_node_t));
+ sym->entry = H5MM_xcalloc(2 * H5G_NODE_K(f), sizeof(H5G_entry_t));
+
+ if (H5F_block_read(f, addr, size, buf) < 0) {
+ HGOTO_ERROR(H5E_SYM, H5E_READERROR, NULL,
+ "unabel to read symbol table node");
+ }
+ /* magic */
+ if (HDmemcmp(p, H5G_NODE_MAGIC, H5G_NODE_SIZEOF_MAGIC)) {
+ HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, NULL,
+ "bad symbol table node signature");
+ }
+ p += 4;
+
+ /* version */
+ if (H5G_NODE_VERS != *p++) {
+ HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, NULL,
+ "bad symbol table node version");
+ }
+ /* reserved */
+ p++;
+
+ /* number of symbols */
+ UINT16DECODE(p, sym->nsyms);
+
+ /* entries */
+ if (H5G_ent_decode_vec(f, &p, sym->entry, sym->nsyms) < 0) {
+ HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, NULL,
+ "unable to decode symbol table entries");
+ }
+ buf = H5MM_xfree(buf);
+
+ ret_value = sym;
+
+ done:
+ if (!ret_value) {
+ buf = H5MM_xfree(buf);
+ if (sym) {
+ sym->entry = H5MM_xfree(sym->entry);
+ sym = H5MM_xfree(sym);
+ }
+ }
+ FUNC_LEAVE(ret_value);
}
-
/*-------------------------------------------------------------------------
- * Function: H5G_node_cmp2
+ * Function: H5G_node_cmp2
*
- * Purpose: Compares two keys from a B-tree node (LT_KEY and RT_KEY).
- * The UDATA pointer supplies extra data not contained in the
- * keys (in this case, the heap address).
+ * Purpose: Compares two keys from a B-tree node (LT_KEY and RT_KEY).
+ * The UDATA pointer supplies extra data not contained in the
+ * keys (in this case, the heap address).
*
- * Return: Success: negative if LT_KEY is less than RT_KEY.
+ * Return: Success: negative if LT_KEY is less than RT_KEY.
*
- * positive if LT_KEY is greater than RT_KEY.
+ * positive if LT_KEY is greater than RT_KEY.
*
- * zero if LT_KEY and RT_KEY are equal.
+ * zero if LT_KEY and RT_KEY are equal.
*
- * Failure: FAIL (same as LT_KEY<RT_KEY)
+ * Failure: FAIL (same as LT_KEY<RT_KEY)
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jun 23 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jun 23 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static intn
-H5G_node_cmp2 (H5F_t *f, void *_lt_key, void *_udata, void *_rt_key)
+H5G_node_cmp2(H5F_t *f, void *_lt_key, void *_udata, void *_rt_key)
{
- H5G_bt_ud1_t *udata = (H5G_bt_ud1_t *)_udata;
- H5G_node_key_t *lt_key = (H5G_node_key_t *)_lt_key;
- H5G_node_key_t *rt_key = (H5G_node_key_t *)_rt_key;
- const char *s1, *s2;
- intn cmp;
-
- FUNC_ENTER (H5G_node_cmp2, FAIL);
-
- assert (udata);
- assert (lt_key);
- assert (rt_key);
-
- if (NULL==(s1=H5H_peek (f, &(udata->heap_addr), lt_key->offset))) {
- HRETURN_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL,
- "unable to read symbol name");
- }
- if (NULL==(s2=H5H_peek (f, &(udata->heap_addr), rt_key->offset))) {
- HRETURN_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL,
- "unable to read symbol name");
- }
-
- cmp = HDstrcmp (s1, s2);
-
- FUNC_LEAVE (cmp);
+ H5G_bt_ud1_t *udata = (H5G_bt_ud1_t *) _udata;
+ H5G_node_key_t *lt_key = (H5G_node_key_t *) _lt_key;
+ H5G_node_key_t *rt_key = (H5G_node_key_t *) _rt_key;
+ const char *s1, *s2;
+ intn cmp;
+
+ FUNC_ENTER(H5G_node_cmp2, FAIL);
+
+ assert(udata);
+ assert(lt_key);
+ assert(rt_key);
+
+ if (NULL == (s1 = H5H_peek(f, &(udata->heap_addr), lt_key->offset))) {
+ HRETURN_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL,
+ "unable to read symbol name");
+ }
+ if (NULL == (s2 = H5H_peek(f, &(udata->heap_addr), rt_key->offset))) {
+ HRETURN_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL,
+ "unable to read symbol name");
+ }
+ cmp = HDstrcmp(s1, s2);
+
+ FUNC_LEAVE(cmp);
}
-
/*-------------------------------------------------------------------------
- * Function: H5G_node_cmp3
+ * Function: H5G_node_cmp3
*
- * Purpose: Compares two keys from a B-tree node (LT_KEY and RT_KEY)
- * against another key (not necessarily the same type)
- * pointed to by UDATA.
+ * Purpose: Compares two keys from a B-tree node (LT_KEY and RT_KEY)
+ * against another key (not necessarily the same type)
+ * pointed to by UDATA.
*
- * Return: Success: negative if the UDATA key is less than
- * or equal to the LT_KEY
+ * Return: Success: negative if the UDATA key is less than
+ * or equal to the LT_KEY
*
- * positive if the UDATA key is greater
- * than the RT_KEY.
+ * positive if the UDATA key is greater
+ * than the RT_KEY.
*
- * zero if the UDATA key falls between
- * the LT_KEY (exclusive) and the
- * RT_KEY (inclusive).
+ * zero if the UDATA key falls between
+ * the LT_KEY (exclusive) and the
+ * RT_KEY (inclusive).
*
- * Failure: FAIL (same as UDATA < LT_KEY)
+ * Failure: FAIL (same as UDATA < LT_KEY)
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jun 23 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jun 23 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static intn
-H5G_node_cmp3 (H5F_t *f, void *_lt_key, void *_udata, void *_rt_key)
+H5G_node_cmp3(H5F_t *f, void *_lt_key, void *_udata, void *_rt_key)
{
- H5G_bt_ud1_t *udata = (H5G_bt_ud1_t *)_udata;
- H5G_node_key_t *lt_key = (H5G_node_key_t *)_lt_key;
- H5G_node_key_t *rt_key = (H5G_node_key_t *)_rt_key;
- const char *s;
-
- FUNC_ENTER (H5G_node_cmp3, FAIL);
-
- /* left side */
- if (NULL==(s=H5H_peek (f, &(udata->heap_addr), lt_key->offset))) {
- HRETURN_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL,
- "unable to read symbol name");
- }
- if (HDstrcmp (udata->name, s)<=0) HRETURN (-1);
-
- /* right side */
- if (NULL==(s=H5H_peek (f, &(udata->heap_addr), rt_key->offset))) {
- HRETURN_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL,
- "unable to read symbol name");
- }
- if (HDstrcmp (udata->name, s)>0) HRETURN(1);
-
- FUNC_LEAVE (0);
+ H5G_bt_ud1_t *udata = (H5G_bt_ud1_t *) _udata;
+ H5G_node_key_t *lt_key = (H5G_node_key_t *) _lt_key;
+ H5G_node_key_t *rt_key = (H5G_node_key_t *) _rt_key;
+ const char *s;
+
+ FUNC_ENTER(H5G_node_cmp3, FAIL);
+
+ /* left side */
+ if (NULL == (s = H5H_peek(f, &(udata->heap_addr), lt_key->offset))) {
+ HRETURN_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL,
+ "unable to read symbol name");
+ }
+ if (HDstrcmp(udata->name, s) <= 0)
+ HRETURN(-1);
+
+ /* right side */
+ if (NULL == (s = H5H_peek(f, &(udata->heap_addr), rt_key->offset))) {
+ HRETURN_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL,
+ "unable to read symbol name");
+ }
+ if (HDstrcmp(udata->name, s) > 0)
+ HRETURN(1);
+
+ FUNC_LEAVE(0);
}
-
/*-------------------------------------------------------------------------
- * Function: H5G_node_found
+ * Function: H5G_node_found
*
- * Purpose: The B-tree search engine has found the symbol table node
- * which contains the requested symbol if the symbol exists.
- * This function should examine that node for the symbol and
- * return information about the symbol through the UDATA
- * structure which contains the symbol name on function
- * entry.
+ * Purpose: The B-tree search engine has found the symbol table node
+ * which contains the requested symbol if the symbol exists.
+ * This function should examine that node for the symbol and
+ * return information about the symbol through the UDATA
+ * structure which contains the symbol name on function
+ * entry.
*
- * If the operation flag in UDATA is H5G_OPER_FIND, then
- * the entry is copied from the symbol table to the UDATA
- * entry field. Otherwise the entry is copied from the
- * UDATA entry field to the symbol table.
+ * If the operation flag in UDATA is H5G_OPER_FIND, then
+ * the entry is copied from the symbol table to the UDATA
+ * entry field. Otherwise the entry is copied from the
+ * UDATA entry field to the symbol table.
*
- * Return: Success: SUCCEED if found and data returned through
- * the UDATA pointer.
+ * Return: Success: SUCCEED if found and data returned through
+ * the UDATA pointer.
*
- * Failure: FAIL if not found.
+ * Failure: FAIL if not found.
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jun 23 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jun 23 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static herr_t
-H5G_node_found (H5F_t *f, const haddr_t *addr, const void *_lt_key,
- void *_udata, const void *_rt_key)
+H5G_node_found(H5F_t *f, const haddr_t *addr, const void *_lt_key,
+ void *_udata, const void *_rt_key)
{
- H5G_bt_ud1_t *bt_udata = (H5G_bt_ud1_t *)_udata;
- H5G_node_t *sn = NULL;
- intn lt=0, idx=0, rt, cmp=1;
- const char *s;
- herr_t ret_value = FAIL;
-
- FUNC_ENTER (H5G_node_found, FAIL);
-
- /*
- * Check arguments.
- */
- assert (f);
- assert (addr && H5F_addr_defined (addr));
- assert (bt_udata);
-
-
- /*
- * Load the symbol table node for exclusive access.
- */
- if (NULL==(sn=H5AC_protect (f, H5AC_SNODE, addr, NULL, NULL))) {
- HGOTO_ERROR (H5E_SYM, H5E_CANTLOAD, FAIL,
- "unable to protect symbol table node");
- }
-
- /*
- * Binary search.
- */
- rt = sn->nsyms;
- while (lt<rt && cmp) {
- idx = (lt + rt) / 2;
- if (NULL==(s=H5H_peek (f, &(bt_udata->heap_addr),
- sn->entry[idx].name_off))) {
- HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL,
- "unable to read symbol name");
- }
- cmp = HDstrcmp (bt_udata->name, s);
-
- if (cmp<0) {
- rt = idx;
- } else {
- lt = idx+1;
- }
- }
- if (cmp) HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "not found");
-
- switch (bt_udata->operation) {
- case H5G_OPER_FIND:
- /*
- * The caller is querying the symbol entry. Return just a pointer to
- * the entry. The pointer is valid until the next call to H5AC.
- */
- bt_udata->ent = sn->entry[idx];
- break;
-
- default:
- HRETURN_ERROR (H5E_SYM, H5E_UNSUPPORTED, FAIL,
- "internal erorr (unknown symbol find operation)");
- break;
- }
- ret_value = SUCCEED;
-
-done:
- if (sn && H5AC_unprotect (f, H5AC_SNODE, addr, sn)<0) {
- HRETURN_ERROR (H5E_SYM, H5E_PROTECT, FAIL,
- "unable to release symbol table node");
- }
-
- FUNC_LEAVE (ret_value);
+ H5G_bt_ud1_t *bt_udata = (H5G_bt_ud1_t *) _udata;
+ H5G_node_t *sn = NULL;
+ intn lt = 0, idx = 0, rt, cmp = 1;
+ const char *s;
+ herr_t ret_value = FAIL;
+
+ FUNC_ENTER(H5G_node_found, FAIL);
+
+ /*
+ * Check arguments.
+ */
+ assert(f);
+ assert(addr && H5F_addr_defined(addr));
+ assert(bt_udata);
+
+ /*
+ * Load the symbol table node for exclusive access.
+ */
+ if (NULL == (sn = H5AC_protect(f, H5AC_SNODE, addr, NULL, NULL))) {
+ HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, FAIL,
+ "unable to protect symbol table node");
+ }
+ /*
+ * Binary search.
+ */
+ rt = sn->nsyms;
+ while (lt < rt && cmp) {
+ idx = (lt + rt) / 2;
+ if (NULL == (s = H5H_peek(f, &(bt_udata->heap_addr),
+ sn->entry[idx].name_off))) {
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL,
+ "unable to read symbol name");
+ }
+ cmp = HDstrcmp(bt_udata->name, s);
+
+ if (cmp < 0) {
+ rt = idx;
+ } else {
+ lt = idx + 1;
+ }
+ }
+ if (cmp)
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "not found");
+
+ switch (bt_udata->operation) {
+ case H5G_OPER_FIND:
+ /*
+ * The caller is querying the symbol entry. Return just a pointer to
+ * the entry. The pointer is valid until the next call to H5AC.
+ */
+ bt_udata->ent = sn->entry[idx];
+ break;
+
+ default:
+ HRETURN_ERROR(H5E_SYM, H5E_UNSUPPORTED, FAIL,
+ "internal erorr (unknown symbol find operation)");
+ break;
+ }
+ ret_value = SUCCEED;
+
+ done:
+ if (sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn) < 0) {
+ HRETURN_ERROR(H5E_SYM, H5E_PROTECT, FAIL,
+ "unable to release symbol table node");
+ }
+ FUNC_LEAVE(ret_value);
}
-
/*-------------------------------------------------------------------------
- * Function: H5G_node_insert
+ * Function: H5G_node_insert
*
- * Purpose: The B-tree insertion engine has found the symbol table node
- * which should receive the new symbol/address pair. This
- * function adds it to that node unless it already existed.
+ * Purpose: The B-tree insertion engine has found the symbol table node
+ * which should receive the new symbol/address pair. This
+ * function adds it to that node unless it already existed.
*
- * If the node has no room for the symbol then the node is
- * split into two nodes. The original node contains the
- * low values and the new node contains the high values.
- * The new symbol table entry is added to either node as
- * appropriate. When a split occurs, this function will
- * write the maximum key of the low node to the MID buffer
- * and return the address of the new node.
+ * If the node has no room for the symbol then the node is
+ * split into two nodes. The original node contains the
+ * low values and the new node contains the high values.
+ * The new symbol table entry is added to either node as
+ * appropriate. When a split occurs, this function will
+ * write the maximum key of the low node to the MID buffer
+ * and return the address of the new node.
*
- * If the new key is larger than RIGHT then update RIGHT
- * with the new key.
+ * If the new key is larger than RIGHT then update RIGHT
+ * with the new key.
*
- * Return: Success: An insertion command for the caller, one of
- * the H5B_INS_* constants. The address of the
- * new node, if any, is returned through the
- * NEW_NODE argument. NEW_NODE might not be
- * initialized if the return value is
- * H5B_INS_NOOP.
+ * Return: Success: An insertion command for the caller, one of
+ * the H5B_INS_* constants. The address of the
+ * new node, if any, is returned through the
+ * NEW_NODE argument. NEW_NODE might not be
+ * initialized if the return value is
+ * H5B_INS_NOOP.
*
- * Failure: H5B_INS_ERROR, NEW_NODE might not be
- * initialized.
+ * Failure: H5B_INS_ERROR, NEW_NODE might not be
+ * initialized.
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jun 24 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jun 24 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static H5B_ins_t
-H5G_node_insert (H5F_t *f, const haddr_t *addr,
- void *_lt_key, hbool_t *lt_key_changed,
- void *_md_key, void *_udata,
- void *_rt_key, hbool_t *rt_key_changed,
- haddr_t *new_node)
+H5G_node_insert(H5F_t *f, const haddr_t *addr,
+ void *_lt_key, hbool_t *lt_key_changed,
+ void *_md_key, void *_udata,
+ void *_rt_key, hbool_t *rt_key_changed,
+ haddr_t *new_node)
{
- H5G_node_key_t *md_key = (H5G_node_key_t *)_md_key;
- H5G_node_key_t *rt_key = (H5G_node_key_t *)_rt_key;
- H5G_bt_ud1_t *bt_udata = (H5G_bt_ud1_t *)_udata;
-
- H5G_node_t *sn=NULL, *snrt=NULL;
- size_t offset; /*offset of name in heap*/
- const char *s;
- intn idx=-1, cmp=1;
- intn lt=0, rt; /*binary search cntrs */
- H5B_ins_t ret_value = H5B_INS_ERROR;
- H5G_node_t *insert_into=NULL; /*node that gets new entry*/
- haddr_t insert_addr; /*address of that node */
-
- FUNC_ENTER (H5G_node_insert, H5B_INS_ERROR);
-
- /*
- * Check arguments.
- */
- assert (f);
- assert (addr && H5F_addr_defined (addr));
- assert (md_key);
- assert (rt_key);
- assert (bt_udata);
- assert (new_node);
-
- /*
- * Load the symbol node.
- */
- if (NULL==(sn=H5AC_protect (f, H5AC_SNODE, addr, NULL, NULL))) {
- HGOTO_ERROR (H5E_SYM, H5E_CANTLOAD, H5B_INS_ERROR,
- "unable to protect symbol table node");
- }
-
- /*
- * Where does the new symbol get inserted? We use a binary search.
- */
- rt = sn->nsyms;
- while (lt<rt) {
- idx = (lt + rt) / 2;
- if (NULL==(s=H5H_peek (f, &(bt_udata->heap_addr),
- sn->entry[idx].name_off))) {
- HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, H5B_INS_ERROR,
- "unable to read symbol name");
- }
- if (0==(cmp=HDstrcmp (bt_udata->name, s))) {
- /*already present*/
- HGOTO_ERROR (H5E_SYM, H5E_CANTINSERT, H5B_INS_ERROR,
- "symbol is already present in symbol table");
- }
- if (cmp<0) {
- rt = idx;
- } else {
- lt = idx+1;
- }
- }
- idx += cmp>0 ? 1 : 0;
-
- /*
- * Add the new name to the heap. The caller will check if the
- * heap address changed and update the symbol table object header
- * with the new heap address.
- */
- offset = H5H_insert (f, &(bt_udata->heap_addr), HDstrlen(bt_udata->name)+1,
- bt_udata->name);
- bt_udata->ent.name_off = offset;
- if (offset<=0) {
- HGOTO_ERROR (H5E_SYM, H5E_CANTINSERT, H5B_INS_ERROR,
- "unable to insert symbol name into heap");
- }
-
- if (sn->nsyms>=2*H5G_NODE_K(f)) {
- /*
- * The node is full. Split it into a left and right
- * node and return the address of the new right node (the
- * left node is at the same address as the original node).
- */
- ret_value = H5B_INS_RIGHT;
-
- /* The right node */
- if (H5G_node_create (f, H5B_INS_FIRST, NULL, NULL, NULL,
- new_node/*out*/)<0) {
- HGOTO_ERROR (H5E_SYM, H5E_CANTINIT, H5B_INS_ERROR,
- "unable to split symbol table node");
- }
- if (NULL==(snrt=H5AC_find (f, H5AC_SNODE, new_node, NULL, NULL))) {
- HGOTO_ERROR (H5E_SYM, H5E_CANTLOAD, H5B_INS_ERROR,
- "unable to split symbol table node");
- }
- HDmemcpy (snrt->entry, sn->entry + H5G_NODE_K(f),
- H5G_NODE_K(f) * sizeof(H5G_entry_t));
- snrt->nsyms = H5G_NODE_K(f);
- snrt->dirty = TRUE;
-
- /* The left node */
- HDmemset (sn->entry + H5G_NODE_K(f), 0,
- H5G_NODE_K(f) * sizeof(H5G_entry_t));
- sn->nsyms = H5G_NODE_K (f);
- sn->dirty = TRUE;
-
- /* The middle key */
- md_key->offset = sn->entry[sn->nsyms-1].name_off;
-
- /* Where to insert the new entry? */
- if (idx<=H5G_NODE_K(f)) {
- insert_into = sn;
- insert_addr = *addr;
- if (idx==H5G_NODE_K(f)) md_key->offset = offset;
- } else {
- idx -= H5G_NODE_K (f);
- insert_into = snrt;
- insert_addr = *new_node;
- }
-
- } else {
- /* Where to insert the new entry? */
- ret_value = H5B_INS_NOOP;
- sn->dirty = TRUE;
- insert_into = sn;
- insert_addr = *addr;
- if (idx==sn->nsyms) {
- rt_key->offset = offset;
- *rt_key_changed = TRUE;
- }
- }
-
- /* Move entries */
- HDmemmove (insert_into->entry + idx + 1,
- insert_into->entry + idx,
- (insert_into->nsyms-idx) * sizeof(H5G_entry_t));
- insert_into->entry[idx] = bt_udata->ent;
- insert_into->entry[idx].dirty = TRUE;
- insert_into->nsyms += 1;
-
-done:
- if (sn && H5AC_unprotect (f, H5AC_SNODE, addr, sn)<0) {
- HRETURN_ERROR (H5E_SYM, H5E_PROTECT, H5B_INS_ERROR,
- "unable to release symbol table node");
- }
-
- FUNC_LEAVE (ret_value);
+ H5G_node_key_t *md_key = (H5G_node_key_t *) _md_key;
+ H5G_node_key_t *rt_key = (H5G_node_key_t *) _rt_key;
+ H5G_bt_ud1_t *bt_udata = (H5G_bt_ud1_t *) _udata;
+
+ H5G_node_t *sn = NULL, *snrt = NULL;
+ size_t offset; /*offset of name in heap */
+ const char *s;
+ intn idx = -1, cmp = 1;
+ intn lt = 0, rt; /*binary search cntrs */
+ H5B_ins_t ret_value = H5B_INS_ERROR;
+ H5G_node_t *insert_into = NULL; /*node that gets new entry */
+ haddr_t insert_addr; /*address of that node */
+
+ FUNC_ENTER(H5G_node_insert, H5B_INS_ERROR);
+
+ /*
+ * Check arguments.
+ */
+ assert(f);
+ assert(addr && H5F_addr_defined(addr));
+ assert(md_key);
+ assert(rt_key);
+ assert(bt_udata);
+ assert(new_node);
+
+ /*
+ * Load the symbol node.
+ */
+ if (NULL == (sn = H5AC_protect(f, H5AC_SNODE, addr, NULL, NULL))) {
+ HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5B_INS_ERROR,
+ "unable to protect symbol table node");
+ }
+ /*
+ * Where does the new symbol get inserted? We use a binary search.
+ */
+ rt = sn->nsyms;
+ while (lt < rt) {
+ idx = (lt + rt) / 2;
+ if (NULL == (s = H5H_peek(f, &(bt_udata->heap_addr),
+ sn->entry[idx].name_off))) {
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5B_INS_ERROR,
+ "unable to read symbol name");
+ }
+ if (0 == (cmp = HDstrcmp(bt_udata->name, s))) {
+ /*already present */
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, H5B_INS_ERROR,
+ "symbol is already present in symbol table");
+ }
+ if (cmp < 0) {
+ rt = idx;
+ } else {
+ lt = idx + 1;
+ }
+ }
+ idx += cmp > 0 ? 1 : 0;
+
+ /*
+ * Add the new name to the heap. The caller will check if the
+ * heap address changed and update the symbol table object header
+ * with the new heap address.
+ */
+ offset = H5H_insert(f, &(bt_udata->heap_addr), HDstrlen(bt_udata->name) + 1,
+ bt_udata->name);
+ bt_udata->ent.name_off = offset;
+ if (offset <= 0) {
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINSERT, H5B_INS_ERROR,
+ "unable to insert symbol name into heap");
+ }
+ if (sn->nsyms >= 2 * H5G_NODE_K(f)) {
+ /*
+ * The node is full. Split it into a left and right
+ * node and return the address of the new right node (the
+ * left node is at the same address as the original node).
+ */
+ ret_value = H5B_INS_RIGHT;
+
+ /* The right node */
+ if (H5G_node_create(f, H5B_INS_FIRST, NULL, NULL, NULL,
+ new_node /*out */ ) < 0) {
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5B_INS_ERROR,
+ "unable to split symbol table node");
+ }
+ if (NULL == (snrt = H5AC_find(f, H5AC_SNODE, new_node, NULL, NULL))) {
+ HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, H5B_INS_ERROR,
+ "unable to split symbol table node");
+ }
+ HDmemcpy(snrt->entry, sn->entry + H5G_NODE_K(f),
+ H5G_NODE_K(f) * sizeof(H5G_entry_t));
+ snrt->nsyms = H5G_NODE_K(f);
+ snrt->dirty = TRUE;
+
+ /* The left node */
+ HDmemset(sn->entry + H5G_NODE_K(f), 0,
+ H5G_NODE_K(f) * sizeof(H5G_entry_t));
+ sn->nsyms = H5G_NODE_K(f);
+ sn->dirty = TRUE;
+
+ /* The middle key */
+ md_key->offset = sn->entry[sn->nsyms - 1].name_off;
+
+ /* Where to insert the new entry? */
+ if (idx <= H5G_NODE_K(f)) {
+ insert_into = sn;
+ insert_addr = *addr;
+ if (idx == H5G_NODE_K(f))
+ md_key->offset = offset;
+ } else {
+ idx -= H5G_NODE_K(f);
+ insert_into = snrt;
+ insert_addr = *new_node;
+ }
+
+ } else {
+ /* Where to insert the new entry? */
+ ret_value = H5B_INS_NOOP;
+ sn->dirty = TRUE;
+ insert_into = sn;
+ insert_addr = *addr;
+ if (idx == sn->nsyms) {
+ rt_key->offset = offset;
+ *rt_key_changed = TRUE;
+ }
+ }
+
+ /* Move entries */
+ HDmemmove(insert_into->entry + idx + 1,
+ insert_into->entry + idx,
+ (insert_into->nsyms - idx) * sizeof(H5G_entry_t));
+ insert_into->entry[idx] = bt_udata->ent;
+ insert_into->entry[idx].dirty = TRUE;
+ insert_into->nsyms += 1;
+
+ done:
+ if (sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn) < 0) {
+ HRETURN_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR,
+ "unable to release symbol table node");
+ }
+ FUNC_LEAVE(ret_value);
}
-
/*-------------------------------------------------------------------------
- * Function: H5G_node_list
+ * Function: H5G_node_list
*
- * Purpose: This function gets called during a group list operation.
- * It should fill in data in the UDATA struct.
+ * Purpose: This function gets called during a group list operation.
+ * It should fill in data in the UDATA struct.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jun 24 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jun 24 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static herr_t
-H5G_node_list (H5F_t *f, const haddr_t *addr, void *_udata)
+H5G_node_list(H5F_t *f, const haddr_t *addr, void *_udata)
{
- H5G_bt_ud2_t *bt_udata = (H5G_bt_ud2_t *)_udata;
- H5G_node_t *sn = NULL;
- intn i;
- const char *s;
- herr_t ret_value = FAIL;
-
- FUNC_ENTER (H5G_node_list, FAIL);
-
- /*
- * Check arguments.
- */
- assert (f);
- assert (addr && H5F_addr_defined (addr));
- assert (bt_udata);
-
- if (NULL==(sn=H5AC_protect (f, H5AC_SNODE, addr, NULL, NULL))) {
- HGOTO_ERROR (H5E_SYM, H5E_CANTLOAD, FAIL,
- "unable to protect symbol table node");
- }
-
- /*
- * If we've already overflowed the user-supplied buffer, then just
- * keep track of how many names we've seen and don't bother doing
- * anything else.
- */
- if (bt_udata->nsyms >= bt_udata->maxentries) {
- bt_udata->nsyms += sn->nsyms;
- HGOTO_DONE (SUCCEED);
- }
-
- /*
- * Save the symbol table entries.
- */
- if (bt_udata->entry) {
- for (i=0; i<sn->nsyms && bt_udata->nsyms+i<bt_udata->maxentries; i++) {
- bt_udata->entry[bt_udata->nsyms+i] = sn->entry[i];
- }
- }
- if (bt_udata->name) {
- for (i=0; i<sn->nsyms && bt_udata->nsyms+i<bt_udata->maxentries; i++) {
- if (NULL==(s=H5H_peek (f, &(bt_udata->heap_addr),
- sn->entry[i].name_off))) {
- HGOTO_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL,
- "unable to read symbol name");
- }
- bt_udata->name[bt_udata->nsyms+i] = H5MM_xstrdup (s);
- }
- }
-
- /*
- * Update the number of symbols.
- */
- bt_udata->nsyms += sn->nsyms;
- ret_value = SUCCEED;
-
-done:
- if (sn && H5AC_unprotect (f, H5AC_SNODE, addr, sn)<0) {
- HRETURN_ERROR (H5E_CACHE, H5E_PROTECT, FAIL,
- "unable to release symbol table node");
- }
- FUNC_LEAVE (ret_value);
+ H5G_bt_ud2_t *bt_udata = (H5G_bt_ud2_t *) _udata;
+ H5G_node_t *sn = NULL;
+ intn i;
+ const char *s;
+ herr_t ret_value = FAIL;
+
+ FUNC_ENTER(H5G_node_list, FAIL);
+
+ /*
+ * Check arguments.
+ */
+ assert(f);
+ assert(addr && H5F_addr_defined(addr));
+ assert(bt_udata);
+
+ if (NULL == (sn = H5AC_protect(f, H5AC_SNODE, addr, NULL, NULL))) {
+ HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, FAIL,
+ "unable to protect symbol table node");
+ }
+ /*
+ * If we've already overflowed the user-supplied buffer, then just
+ * keep track of how many names we've seen and don't bother doing
+ * anything else.
+ */
+ if (bt_udata->nsyms >= bt_udata->maxentries) {
+ bt_udata->nsyms += sn->nsyms;
+ HGOTO_DONE(SUCCEED);
+ }
+ /*
+ * Save the symbol table entries.
+ */
+ if (bt_udata->entry) {
+ for (i = 0; i < sn->nsyms && bt_udata->nsyms + i < bt_udata->maxentries; i++) {
+ bt_udata->entry[bt_udata->nsyms + i] = sn->entry[i];
+ }
+ }
+ if (bt_udata->name) {
+ for (i = 0; i < sn->nsyms && bt_udata->nsyms + i < bt_udata->maxentries; i++) {
+ if (NULL == (s = H5H_peek(f, &(bt_udata->heap_addr),
+ sn->entry[i].name_off))) {
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL,
+ "unable to read symbol name");
+ }
+ bt_udata->name[bt_udata->nsyms + i] = H5MM_xstrdup(s);
+ }
+ }
+ /*
+ * Update the number of symbols.
+ */
+ bt_udata->nsyms += sn->nsyms;
+ ret_value = SUCCEED;
+
+ done:
+ if (sn && H5AC_unprotect(f, H5AC_SNODE, addr, sn) < 0) {
+ HRETURN_ERROR(H5E_CACHE, H5E_PROTECT, FAIL,
+ "unable to release symbol table node");
+ }
+ FUNC_LEAVE(ret_value);
}
-
/*-------------------------------------------------------------------------
- * Function: H5G_node_debug
+ * Function: H5G_node_debug
*
- * Purpose: Prints debugging information about a symbol table node
- * or a B-tree node for a symbol table B-tree.
+ * Purpose: Prints debugging information about a symbol table node
+ * or a B-tree node for a symbol table B-tree.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Aug 4 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Aug 4 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
-H5G_node_debug (H5F_t *f, const haddr_t *addr, FILE *stream, intn indent,
- intn fwidth, const haddr_t *heap)
+H5G_node_debug(H5F_t *f, const haddr_t *addr, FILE * stream, intn indent,
+ intn fwidth, const haddr_t *heap)
{
- int i;
- H5G_node_t *sn = NULL;
- herr_t status;
- const char *s;
-
- FUNC_ENTER (H5G_node_debug, FAIL);
-
- /*
- * Check arguments.
- */
- assert (f);
- assert (addr && H5F_addr_defined (addr));
- assert (stream);
- assert (indent>=0);
- assert (fwidth>=0);
-
-
- /*
- * If we couldn't load the symbol table node, then try loading the
- * B-tree node.
- */
- if (NULL==(sn=H5AC_protect(f, H5AC_SNODE, addr, NULL, NULL))) {
- H5ECLEAR; /*discard that error*/
- status = H5B_debug (f, addr, stream, indent, fwidth, H5B_SNODE, NULL);
- if (status<0) {
- HRETURN_ERROR (H5E_SYM, H5E_CANTLOAD, FAIL,
- "unable to debug B-tree node");
- }
- HRETURN (SUCCEED);
- }
-
-
- fprintf (stream, "%*sSymbol Table Node...\n", indent, "");
- fprintf (stream, "%*s%-*s %s\n", indent, "", fwidth,
- "Dirty:",
- sn->dirty?"Yes":"No");
- fprintf (stream, "%*s%-*s %d of %d\n", indent, "", fwidth,
- "Number of Symbols:",
- sn->nsyms, 2*H5G_NODE_K(f));
-
-
- indent += 3;
- fwidth = MAX (0, fwidth-3);
- for (i=0; i<sn->nsyms; i++) {
- fprintf (stream, "%*sSymbol %d:\n", indent-3, "", i);
- if (H5F_addr_defined (heap) &&
- (s = H5H_peek (f, heap, sn->entry[i].name_off))) {
- fprintf (stream, "%*s%-*s `%s'\n", indent, "", fwidth,
- "Name:",
- s);
- }
- H5G_ent_debug (f, sn->entry+i, stream, indent, fwidth);
- }
-
- H5AC_unprotect (f, H5AC_SNODE, addr, sn);
- FUNC_LEAVE (SUCCEED);
+ int i;
+ H5G_node_t *sn = NULL;
+ herr_t status;
+ const char *s;
+
+ FUNC_ENTER(H5G_node_debug, FAIL);
+
+ /*
+ * Check arguments.
+ */
+ assert(f);
+ assert(addr && H5F_addr_defined(addr));
+ assert(stream);
+ assert(indent >= 0);
+ assert(fwidth >= 0);
+
+ /*
+ * If we couldn't load the symbol table node, then try loading the
+ * B-tree node.
+ */
+ if (NULL == (sn = H5AC_protect(f, H5AC_SNODE, addr, NULL, NULL))) {
+ H5ECLEAR; /*discard that error */
+ status = H5B_debug(f, addr, stream, indent, fwidth, H5B_SNODE, NULL);
+ if (status < 0) {
+ HRETURN_ERROR(H5E_SYM, H5E_CANTLOAD, FAIL,
+ "unable to debug B-tree node");
+ }
+ HRETURN(SUCCEED);
+ }
+ fprintf(stream, "%*sSymbol Table Node...\n", indent, "");
+ fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
+ "Dirty:",
+ sn->dirty ? "Yes" : "No");
+ fprintf(stream, "%*s%-*s %d of %d\n", indent, "", fwidth,
+ "Number of Symbols:",
+ sn->nsyms, 2 * H5G_NODE_K(f));
+
+ indent += 3;
+ fwidth = MAX(0, fwidth - 3);
+ for (i = 0; i < sn->nsyms; i++) {
+ fprintf(stream, "%*sSymbol %d:\n", indent - 3, "", i);
+ if (H5F_addr_defined(heap) &&
+ (s = H5H_peek(f, heap, sn->entry[i].name_off))) {
+ fprintf(stream, "%*s%-*s `%s'\n", indent, "", fwidth,
+ "Name:",
+ s);
+ }
+ H5G_ent_debug(f, sn->entry + i, stream, indent, fwidth);
+ }
+
+ H5AC_unprotect(f, H5AC_SNODE, addr, sn);
+ FUNC_LEAVE(SUCCEED);
}
-
diff --git a/src/H5Gpkg.h b/src/H5Gpkg.h
index 08e8156..b1aaed1 100644
--- a/src/H5Gpkg.h
+++ b/src/H5Gpkg.h
@@ -5,9 +5,9 @@
* Programmer: Robb Matzke <matzke@llnl.gov>
* Thursday, September 18, 1997
*
- * Purpose: This file contains declarations which are visible
- * only within the H5G package. Source files outside the
- * H5G package should include H5Gprivate.h instead.
+ * Purpose: This file contains declarations which are visible
+ * only within the H5G package. Source files outside the
+ * H5G package should include H5Gprivate.h instead.
*/
#ifndef H5G_PACKAGE
#error "Do not include this file outside the H5G package!"
@@ -19,8 +19,8 @@
#include <H5ACprivate.h>
#include <H5Gprivate.h>
-#define H5G_NODE_VERS 1 /*symbol table node version number */
-#define H5G_SIZE_HINT 1024 /*default root grp size hint */
+#define H5G_NODE_VERS 1 /*symbol table node version number */
+#define H5G_SIZE_HINT 1024 /*default root grp size hint */
#define H5G_NODE_K(F) ((F)->shared->create_parms.sym_leaf_k)
#define H5G_NODE_SIZEOF_HDR(F) (H5G_NODE_SIZEOF_MAGIC + 4)
#define H5G_DEFAULT_ROOT_SIZE 32
@@ -32,9 +32,9 @@
* table or group.
*/
typedef struct H5G_node_t {
- hbool_t dirty; /*has cache been modified? */
- int nsyms; /*number of symbols */
- H5G_entry_t *entry; /*array of symbol table entries */
+ hbool_t dirty; /*has cache been modified? */
+ int nsyms; /*number of symbols */
+ H5G_entry_t *entry; /*array of symbol table entries */
} H5G_node_t;
/*
@@ -42,7 +42,7 @@ typedef struct H5G_node_t {
* nodes consists of this structure...
*/
typedef struct H5G_node_key_t {
- size_t offset; /*offset into heap for name */
+ size_t offset; /*offset into heap for name */
} H5G_node_key_t;
/*
@@ -50,8 +50,8 @@ typedef struct H5G_node_key_t {
* above the H5G layer.
*/
struct H5G_t {
- int nref; /*open reference count */
- H5G_entry_t ent; /*info about the group */
+ int nref; /*open reference count */
+ H5G_entry_t ent; /*info about the group */
};
/*
@@ -60,8 +60,8 @@ struct H5G_t {
* current working group is the root object.
*/
typedef struct H5G_cwgstk_t {
- H5G_t *grp; /*a handle to an open group */
- struct H5G_cwgstk_t *next; /*next item (earlier) on stack */
+ H5G_t *grp; /*a handle to an open group */
+ struct H5G_cwgstk_t *next; /*next item (earlier) on stack */
} H5G_cwgstk_t;
/*
@@ -69,8 +69,8 @@ typedef struct H5G_cwgstk_t {
* H5G_node layer through the B-tree layer.
*/
typedef enum H5G_oper_t {
- H5G_OPER_FIND =0, /*find a symbol */
- H5G_OPER_INSERT =1 /*insert a new symbol */
+ H5G_OPER_FIND = 0, /*find a symbol */
+ H5G_OPER_INSERT = 1 /*insert a new symbol */
} H5G_oper_t;
/*
@@ -80,13 +80,13 @@ typedef enum H5G_oper_t {
*/
typedef struct H5G_bt_ud1_t {
- /* downward */
- H5G_oper_t operation; /*what operation to perform */
- const char *name; /*points to temporary memory */
- haddr_t heap_addr; /*symbol table heap address */
+ /* downward */
+ H5G_oper_t operation; /*what operation to perform */
+ const char *name; /*points to temporary memory */
+ haddr_t heap_addr; /*symbol table heap address */
- /* downward for INSERT, upward for FIND */
- H5G_entry_t ent; /*entry to insert into table */
+ /* downward for INSERT, upward for FIND */
+ H5G_entry_t ent; /*entry to insert into table */
} H5G_bt_ud1_t;
@@ -96,21 +96,21 @@ typedef struct H5G_bt_ud1_t {
*/
typedef struct H5G_bt_ud2_t {
- /* downward */
- H5G_entry_t *entry; /*array of entries, alloc'd by caller */
- char **name; /*array of string ptrs, allocd by caller*/
- intn maxentries; /*size of the ADDR and NAME arrays */
- haddr_t heap_addr; /*heap address */
+ /* downward */
+ H5G_entry_t *entry; /*array of entries, alloc'd by caller */
+ char **name; /*array of string ptrs, allocd by caller */
+ intn maxentries; /*size of the ADDR and NAME arrays */
+ haddr_t heap_addr; /*heap address */
+
+ /* upward */
+ intn nsyms; /*num. symbols processed */
- /* upward */
- intn nsyms; /*num. symbols processed */
-
} H5G_bt_ud2_t;
/*
* This is the class identifier to give to the B-tree functions.
*/
-extern H5B_class_t H5B_SNODE[1];
+extern H5B_class_t H5B_SNODE[1];
/* The cache subclass */
extern const H5AC_class_t H5AC_SNODE[1];
@@ -120,19 +120,19 @@ extern const H5AC_class_t H5AC_SNODE[1];
* functions that understand names are exported to the rest of
* the library and appear in H5Gprivate.h.
*/
-herr_t H5G_stab_create (H5F_t *f, size_t size_hint, H5G_entry_t *ent/*out*/);
-herr_t H5G_stab_find (H5G_entry_t *grp_ent, const char *name,
- H5G_entry_t *obj_ent/*out*/);
-herr_t H5G_stab_insert (H5G_entry_t *grp_ent, const char *name,
- H5G_entry_t *obj_ent);
-intn H5G_stab_list (H5G_entry_t *self, intn maxentries,
- char *names[]/*out*/, H5G_entry_t entries[]/*out*/);
+herr_t H5G_stab_create(H5F_t *f, size_t size_hint, H5G_entry_t *ent /*out */ );
+herr_t H5G_stab_find(H5G_entry_t *grp_ent, const char *name,
+ H5G_entry_t *obj_ent /*out */ );
+herr_t H5G_stab_insert(H5G_entry_t *grp_ent, const char *name,
+ H5G_entry_t *obj_ent);
+intn H5G_stab_list(H5G_entry_t *self, intn maxentries,
+ char *names[] /*out */ , H5G_entry_t entries[] /*out */ );
/*
* Functions that understand symbol table entries.
*/
-herr_t H5G_ent_decode_vec (H5F_t *f, const uint8 **pp, H5G_entry_t *ent,
- intn n);
-herr_t H5G_ent_encode_vec (H5F_t *f, uint8 **pp, H5G_entry_t *ent, intn n);
+herr_t H5G_ent_decode_vec(H5F_t *f, const uint8 **pp, H5G_entry_t *ent,
+ intn n);
+herr_t H5G_ent_encode_vec(H5F_t *f, uint8 **pp, H5G_entry_t *ent, intn n);
#endif
diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h
index 69b2ef9..da07587 100644
--- a/src/H5Gprivate.h
+++ b/src/H5Gprivate.h
@@ -1,16 +1,16 @@
/*-------------------------------------------------------------------------
- * Copyright (C) 1997 National Center for Supercomputing Applications.
+ * Copyright (C) 1997 National Center for Supercomputing Applications.
* All rights reserved.
*
*-------------------------------------------------------------------------
*
- * Created: H5Gprivate.h
- * Jul 11 1997
- * Robb Matzke <matzke@llnl.gov>
+ * Created: H5Gprivate.h
+ * Jul 11 1997
+ * Robb Matzke <matzke@llnl.gov>
*
- * Purpose: Library-visible declarations.
+ * Purpose: Library-visible declarations.
*
- * Modifications:
+ * Modifications:
*
*-------------------------------------------------------------------------
*/
@@ -30,20 +30,20 @@
# undef H5G_DEBUG
#endif
-#define H5G_NODE_MAGIC "SNOD" /*symbol table node magic number */
-#define H5G_NODE_SIZEOF_MAGIC 4 /*sizeof symbol node magic number */
-#define H5G_NO_CHANGE (-1) /*see H5G_ent_modified() */
+#define H5G_NODE_MAGIC "SNOD" /*symbol table node magic number */
+#define H5G_NODE_SIZEOF_MAGIC 4 /*sizeof symbol node magic number */
+#define H5G_NO_CHANGE (-1) /*see H5G_ent_modified() */
/*
* The disk size for a symbol table entry...
*/
-#define H5G_SIZEOF_SCRATCH 24
-#define H5G_SIZEOF_ENTRY(F) \
- (H5F_SIZEOF_SIZE(F) + /*offset of name into heap */ \
- H5F_SIZEOF_ADDR(F) + /*address of object header */ \
- 4 + /*entry type */ \
- H5G_SIZEOF_SCRATCH) /*scratch pad space */
-
+#define H5G_SIZEOF_SCRATCH 24
+#define H5G_SIZEOF_ENTRY(F) \
+ (H5F_SIZEOF_SIZE(F) + /*offset of name into heap */ \
+ H5F_SIZEOF_ADDR(F) + /*address of object header */ \
+ 4 + /*entry type */ \
+ H5G_SIZEOF_SCRATCH) /*scratch pad space */
+
/*
* Various types of object header information can be cached in a symbol
* table entry (it's normal home is the object header to which the entry
@@ -51,10 +51,10 @@
* symbol table entry.
*/
typedef enum H5G_type_t {
- H5G_NOTHING_CACHED =0, /*nothing is cached, must be 0 */
- H5G_CACHED_STAB =1, /*symbol table, `stab' */
-
- H5G_NCACHED =2 /*THIS MUST BE LAST */
+ H5G_NOTHING_CACHED = 0, /*nothing is cached, must be 0 */
+ H5G_CACHED_STAB = 1, /*symbol table, `stab' */
+
+ H5G_NCACHED = 2 /*THIS MUST BE LAST */
} H5G_type_t;
/*
@@ -65,10 +65,10 @@ typedef enum H5G_type_t {
* H5G_ent_decode(), H5G_ent_encode(), and H5G_ent_debug() as well.
*/
typedef union H5G_cache_t {
- struct {
- haddr_t btree_addr; /*file address of symbol table B-tree */
- haddr_t heap_addr; /*file address of stab name heap */
- } stab;
+ struct {
+ haddr_t btree_addr; /*file address of symbol table B-tree */
+ haddr_t heap_addr; /*file address of stab name heap */
+ } stab;
} H5G_cache_t;
/*
@@ -78,12 +78,12 @@ typedef union H5G_cache_t {
* points.
*/
typedef struct H5G_entry_t {
- hbool_t dirty; /*entry out-of-date? */
- size_t name_off; /*offset of name within name heap */
- haddr_t header; /*file address of object header */
- H5G_type_t type; /*type of information cached */
- H5G_cache_t cache; /*cached data from object header */
- H5F_t *file; /*file to which this obj hdr belongs */
+ hbool_t dirty; /*entry out-of-date? */
+ size_t name_off; /*offset of name within name heap */
+ haddr_t header; /*file address of object header */
+ H5G_type_t type; /*type of information cached */
+ H5G_cache_t cache; /*cached data from object header */
+ H5F_t *file; /*file to which this obj hdr belongs */
} H5G_entry_t;
typedef struct H5G_t H5G_t;
@@ -92,35 +92,35 @@ typedef struct H5G_t H5G_t;
* Library prototypes... These are the ones that other packages routinely
* call.
*/
-H5G_t *H5G_create (H5F_t *f, const char *name, size_t size_hint);
-H5G_t *H5G_open (H5F_t *f, const char *name);
-H5G_t *H5G_reopen (H5G_t *grp);
-herr_t H5G_close (H5G_t *grp);
-herr_t H5G_set (H5F_t *f, H5G_t *grp);
-herr_t H5G_push (H5F_t *f, H5G_t *grp);
-herr_t H5G_pop (H5F_t *f);
-herr_t H5G_insert (const char *name, H5G_entry_t *ent);
-herr_t H5G_find (H5F_t *f, const char *name, H5G_entry_t *grp_ent/*out*/,
- H5G_entry_t *ent/*out*/);
-herr_t H5G_ent_encode (H5F_t *f, uint8 **pp, H5G_entry_t *ent);
-herr_t H5G_ent_decode (H5F_t *f, const uint8 **pp, H5G_entry_t *ent/*out*/);
+H5G_t *H5G_create(H5F_t *f, const char *name, size_t size_hint);
+H5G_t *H5G_open(H5F_t *f, const char *name);
+H5G_t *H5G_reopen(H5G_t *grp);
+herr_t H5G_close(H5G_t *grp);
+herr_t H5G_set(H5F_t *f, H5G_t *grp);
+herr_t H5G_push(H5F_t *f, H5G_t *grp);
+herr_t H5G_pop(H5F_t *f);
+herr_t H5G_insert(const char *name, H5G_entry_t *ent);
+herr_t H5G_find(H5F_t *f, const char *name, H5G_entry_t *grp_ent /*out */ ,
+ H5G_entry_t *ent /*out */ );
+herr_t H5G_ent_encode(H5F_t *f, uint8 **pp, H5G_entry_t *ent);
+herr_t H5G_ent_decode(H5F_t *f, const uint8 **pp, H5G_entry_t *ent /*out */ );
/*
* These functions operate on symbol table nodes.
*/
-herr_t H5G_node_debug (H5F_t *f, const haddr_t *addr, FILE *stream,
- intn indent, intn fwidth, const haddr_t *heap);
+herr_t H5G_node_debug(H5F_t *f, const haddr_t *addr, FILE * stream,
+ intn indent, intn fwidth, const haddr_t *heap);
/*
* These functions operate on symbol table entries. They're used primarily
* in the H5O package where header messages are cached in symbol table
* entries. The subclasses of H5O probably don't need them though.
*/
-H5G_entry_t *H5G_ent_calloc (H5G_entry_t *init);
-H5G_cache_t *H5G_ent_cache (H5G_entry_t *ent, H5G_type_t *cache_type);
-herr_t H5G_ent_modified (H5G_entry_t *ent, H5G_type_t cache_type);
-herr_t H5G_ent_debug (H5F_t *f, H5G_entry_t *ent, FILE *stream,
- intn indent, intn fwidth);
+H5G_entry_t *H5G_ent_calloc(H5G_entry_t *init);
+H5G_cache_t *H5G_ent_cache(H5G_entry_t *ent, H5G_type_t *cache_type);
+herr_t H5G_ent_modified(H5G_entry_t *ent, H5G_type_t cache_type);
+herr_t H5G_ent_debug(H5F_t *f, H5G_entry_t *ent, FILE * stream,
+ intn indent, intn fwidth);
#endif
diff --git a/src/H5Gpublic.h b/src/H5Gpublic.h
index c7de680..f10f33e 100644
--- a/src/H5Gpublic.h
+++ b/src/H5Gpublic.h
@@ -1,17 +1,17 @@
/*-------------------------------------------------------------------------
- * Copyright (C) 1997 National Center for Supercomputing Applications.
+ * Copyright (C) 1997 National Center for Supercomputing Applications.
* All rights reserved.
*
*-------------------------------------------------------------------------
*
- * Created: H5Gproto.h
- * Jul 11 1997
- * Robb Matzke <matzke@llnl.gov>
+ * Created: H5Gproto.h
+ * Jul 11 1997
+ * Robb Matzke <matzke@llnl.gov>
*
- * Purpose: Public declarations for the H5G package (symbol
- * tables).
+ * Purpose: Public declarations for the H5G package (symbol
+ * tables).
*
- * Modifications:
+ * Modifications:
*
*-------------------------------------------------------------------------
*/
@@ -24,19 +24,19 @@
#include <H5Apublic.h>
#ifdef __cplusplus
-extern "C" {
+extern "C" {
#endif
-hid_t H5Gcreate (hid_t file_id, const char *name, size_t size_hint);
-hid_t H5Gopen (hid_t file_id, const char *name);
-herr_t H5Gclose (hid_t grp_id);
+ hid_t H5Gcreate(hid_t file_id, const char *name, size_t size_hint);
+ hid_t H5Gopen(hid_t file_id, const char *name);
+ herr_t H5Gclose(hid_t grp_id);
+
+ herr_t H5Gset(hid_t file, const char *name);
+ herr_t H5Gpush(hid_t file, const char *name);
+ herr_t H5Gpop(hid_t file);
-herr_t H5Gset (hid_t file, const char *name);
-herr_t H5Gpush (hid_t file, const char *name);
-herr_t H5Gpop (hid_t file);
-
#ifdef __cplusplus
}
-#endif
#endif
+#endif
diff --git a/src/H5Gstab.c b/src/H5Gstab.c
index 40ac893..5b1ed90 100644
--- a/src/H5Gstab.c
+++ b/src/H5Gstab.c
@@ -16,268 +16,260 @@
#include <H5MMprivate.h>
#include <H5Oprivate.h>
-#define PABLO_MASK H5G_stab_mask
-static hbool_t interface_initialize_g = FALSE;
-#define INTERFACE_INIT NULL
-
+#define PABLO_MASK H5G_stab_mask
+static hbool_t interface_initialize_g = FALSE;
+#define INTERFACE_INIT NULL
/*-------------------------------------------------------------------------
- * Function: H5G_stab_create
+ * Function: H5G_stab_create
*
- * Purpose: Creates a new empty symbol table (object header, name heap,
- * and B-tree). The caller can specify an initial size for the
- * name heap. The object header of the group is opened for
- * write access.
+ * Purpose: Creates a new empty symbol table (object header, name heap,
+ * and B-tree). The caller can specify an initial size for the
+ * name heap. The object header of the group is opened for
+ * write access.
*
- * In order for the B-tree to operate correctly, the first
- * item in the heap is the empty string, and must appear at
- * heap offset zero.
+ * In order for the B-tree to operate correctly, the first
+ * item in the heap is the empty string, and must appear at
+ * heap offset zero.
*
* Errors:
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Aug 1 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Aug 1 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
-H5G_stab_create (H5F_t *f, size_t init, H5G_entry_t *self/*out*/)
+H5G_stab_create(H5F_t *f, size_t init, H5G_entry_t *self /*out */ )
{
- size_t name; /*offset of "" name */
- H5O_stab_t stab; /*symbol table message */
-
- FUNC_ENTER (H5G_stab_create, FAIL);
+ size_t name; /*offset of "" name */
+ H5O_stab_t stab; /*symbol table message */
- /*
- * Check arguments.
- */
- assert (f);
- assert (self);
- init = MAX(init, H5H_SIZEOF_FREE(f)+2);
+ FUNC_ENTER(H5G_stab_create, FAIL);
- /* Create symbol table private heap */
- if (H5H_create (f, H5H_LOCAL, init, &(stab.heap_addr)/*out*/)<0) {
- HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, FAIL, "can't create heap");
- }
- if ((name = H5H_insert (f, &(stab.heap_addr), 1, "")<0)) {
- HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, FAIL, "can't initialize heap");
- }
- /*
- * B-tree's won't work if the first name isn't at the beginning
- * of the heap.
- */
- assert (0==name);
+ /*
+ * Check arguments.
+ */
+ assert(f);
+ assert(self);
+ init = MAX(init, H5H_SIZEOF_FREE(f) + 2);
- /* Create the B-tree */
- if (H5B_create (f, H5B_SNODE, NULL, &(stab.btree_addr)/*out*/)<0) {
- HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, FAIL, "can't create B-tree");
- }
+ /* Create symbol table private heap */
+ if (H5H_create(f, H5H_LOCAL, init, &(stab.heap_addr) /*out */ ) < 0) {
+ HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create heap");
+ }
+ if ((name = H5H_insert(f, &(stab.heap_addr), 1, "") < 0)) {
+ HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't initialize heap");
+ }
+ /*
+ * B-tree's won't work if the first name isn't at the beginning
+ * of the heap.
+ */
+ assert(0 == name);
- /*
- * Create symbol table object header. It has a zero link count
- * since nothing refers to it yet. The link count will be
- * incremented if the object is added to the group directed graph.
- */
- if (H5O_create (f, 4+2*H5F_SIZEOF_ADDR(f), self/*out*/)<0) {
- HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, FAIL, "can't create header");
- }
-
- /*
- * Insert the symbol table message into the object header and the symbol
- * table entry.
- */
- if (H5O_modify (self, H5O_STAB, H5O_NEW_MESG, H5O_FLAG_CONSTANT, &stab)<0) {
- H5O_close (self);
- HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, FAIL, "can't create message");
- }
- self->cache.stab.btree_addr = stab.btree_addr;
- self->cache.stab.heap_addr = stab.heap_addr;
- self->type = H5G_CACHED_STAB;
+ /* Create the B-tree */
+ if (H5B_create(f, H5B_SNODE, NULL, &(stab.btree_addr) /*out */ ) < 0) {
+ HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create B-tree");
+ }
+ /*
+ * Create symbol table object header. It has a zero link count
+ * since nothing refers to it yet. The link count will be
+ * incremented if the object is added to the group directed graph.
+ */
+ if (H5O_create(f, 4 + 2 * H5F_SIZEOF_ADDR(f), self /*out */ ) < 0) {
+ HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create header");
+ }
+ /*
+ * Insert the symbol table message into the object header and the symbol
+ * table entry.
+ */
+ if (H5O_modify(self, H5O_STAB, H5O_NEW_MESG, H5O_FLAG_CONSTANT, &stab) < 0) {
+ H5O_close(self);
+ HRETURN_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't create message");
+ }
+ self->cache.stab.btree_addr = stab.btree_addr;
+ self->cache.stab.heap_addr = stab.heap_addr;
+ self->type = H5G_CACHED_STAB;
- FUNC_LEAVE (SUCCEED);
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5G_stab_find
+ * Function: H5G_stab_find
*
- * Purpose: Finds a symbol named NAME in the symbol table whose
- * description is stored in GRP_ENT in file F and returns its
- * symbol table entry through OBJ_ENT (which is optional).
+ * Purpose: Finds a symbol named NAME in the symbol table whose
+ * description is stored in GRP_ENT in file F and returns its
+ * symbol table entry through OBJ_ENT (which is optional).
*
* Errors:
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Aug 1 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Aug 1 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
-H5G_stab_find (H5G_entry_t *grp_ent, const char *name,
- H5G_entry_t *obj_ent/*out*/)
+H5G_stab_find(H5G_entry_t *grp_ent, const char *name,
+ H5G_entry_t *obj_ent /*out */ )
{
- H5G_bt_ud1_t udata; /*data to pass through B-tree */
- H5O_stab_t stab; /*symbol table message */
-
- FUNC_ENTER (H5G_stab_find, FAIL);
+ H5G_bt_ud1_t udata; /*data to pass through B-tree */
+ H5O_stab_t stab; /*symbol table message */
- /* Check arguments */
- assert (grp_ent);
- assert (grp_ent->file);
- assert (name && *name);
+ FUNC_ENTER(H5G_stab_find, FAIL);
- /* set up the udata */
- if (NULL==H5O_read (grp_ent, H5O_STAB, 0, &stab)) {
- HRETURN_ERROR (H5E_SYM, H5E_BADMESG, FAIL, "can't read message");
- }
- udata.operation = H5G_OPER_FIND;
- udata.name = name;
- udata.heap_addr = stab.heap_addr;
+ /* Check arguments */
+ assert(grp_ent);
+ assert(grp_ent->file);
+ assert(name && *name);
- /* search the B-tree */
- if (H5B_find (grp_ent->file, H5B_SNODE, &(stab.btree_addr), &udata)<0) {
- HRETURN_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL, "not found");
- }
+ /* set up the udata */
+ if (NULL == H5O_read(grp_ent, H5O_STAB, 0, &stab)) {
+ HRETURN_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "can't read message");
+ }
+ udata.operation = H5G_OPER_FIND;
+ udata.name = name;
+ udata.heap_addr = stab.heap_addr;
- if (obj_ent) *obj_ent = udata.ent;
- FUNC_LEAVE (SUCCEED);
+ /* search the B-tree */
+ if (H5B_find(grp_ent->file, H5B_SNODE, &(stab.btree_addr), &udata) < 0) {
+ HRETURN_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "not found");
+ }
+ if (obj_ent)
+ *obj_ent = udata.ent;
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5G_stab_insert
+ * Function: H5G_stab_insert
*
- * Purpose: Insert a new symbol into the table described by GRP_ENT in
- * file F. The name of the new symbol is NAME and its symbol
- * table entry is OBJ_ENT.
+ * Purpose: Insert a new symbol into the table described by GRP_ENT in
+ * file F. The name of the new symbol is NAME and its symbol
+ * table entry is OBJ_ENT.
*
* Errors:
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Aug 1 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Aug 1 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
-H5G_stab_insert (H5G_entry_t *grp_ent, const char *name, H5G_entry_t *obj_ent)
+H5G_stab_insert(H5G_entry_t *grp_ent, const char *name, H5G_entry_t *obj_ent)
{
- H5O_stab_t stab; /*symbol table message */
- H5G_bt_ud1_t udata; /*data to pass through B-tree */
-
- FUNC_ENTER (H5G_stab_insert, FAIL);
+ H5O_stab_t stab; /*symbol table message */
+ H5G_bt_ud1_t udata; /*data to pass through B-tree */
- /* check arguments */
- assert (grp_ent && grp_ent->file);
- assert (name && *name);
- assert (obj_ent && obj_ent->file);
- assert (grp_ent->file->shared==obj_ent->file->shared);
-
- /* initialize data to pass through B-tree */
- if (NULL==H5O_read (grp_ent, H5O_STAB, 0, &stab)) {
- HRETURN_ERROR (H5E_SYM, H5E_BADMESG, FAIL, "not a symbol table");
- }
+ FUNC_ENTER(H5G_stab_insert, FAIL);
- udata.operation = H5G_OPER_INSERT;
- udata.name = name;
- udata.heap_addr = stab.heap_addr;
- udata.ent = *obj_ent;
+ /* check arguments */
+ assert(grp_ent && grp_ent->file);
+ assert(name && *name);
+ assert(obj_ent && obj_ent->file);
+ assert(grp_ent->file->shared == obj_ent->file->shared);
- /* insert */
- if (H5B_insert (grp_ent->file, H5B_SNODE, &(stab.btree_addr), &udata)<0) {
- HRETURN_ERROR (H5E_SYM, H5E_CANTINSERT, FAIL, "can't insert entry");
- }
+ /* initialize data to pass through B-tree */
+ if (NULL == H5O_read(grp_ent, H5O_STAB, 0, &stab)) {
+ HRETURN_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "not a symbol table");
+ }
+ udata.operation = H5G_OPER_INSERT;
+ udata.name = name;
+ udata.heap_addr = stab.heap_addr;
+ udata.ent = *obj_ent;
- /* update the name offset in the entry */
- obj_ent->name_off = udata.ent.name_off;
- FUNC_LEAVE (SUCCEED);
+ /* insert */
+ if (H5B_insert(grp_ent->file, H5B_SNODE, &(stab.btree_addr), &udata) < 0) {
+ HRETURN_ERROR(H5E_SYM, H5E_CANTINSERT, FAIL, "can't insert entry");
+ }
+ /* update the name offset in the entry */
+ obj_ent->name_off = udata.ent.name_off;
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5G_stab_list
+ * Function: H5G_stab_list
*
- * Purpose: Returns a list of all the symbols in a symbol table.
- * The caller allocates an array of pointers which this
- * function will fill in with malloc'd names. The caller
- * also allocates an array of symbol table entries which will
- * be filled in with data from the symbol table. Each of these
- * arrays should have at least MAXENTRIES elements.
+ * Purpose: Returns a list of all the symbols in a symbol table.
+ * The caller allocates an array of pointers which this
+ * function will fill in with malloc'd names. The caller
+ * also allocates an array of symbol table entries which will
+ * be filled in with data from the symbol table. Each of these
+ * arrays should have at least MAXENTRIES elements.
*
* Errors:
- * SYM BADMESG Not a symbol table.
- * SYM CANTLIST B-tree list failure.
+ * SYM BADMESG Not a symbol table.
+ * SYM CANTLIST B-tree list failure.
*
- * Return: Success: The total number of symbols in the
- * symbol table. This may exceed MAXENTRIES,
- * but at most MAXENTRIES values are copied
- * into the NAMES and ENTRIES arrays.
+ * Return: Success: The total number of symbols in the
+ * symbol table. This may exceed MAXENTRIES,
+ * but at most MAXENTRIES values are copied
+ * into the NAMES and ENTRIES arrays.
*
- * Failure: FAIL, the pointers in NAMES are undefined but
- * no memory is allocated. The values in
- * ENTRIES are undefined.
+ * Failure: FAIL, the pointers in NAMES are undefined but
+ * no memory is allocated. The values in
+ * ENTRIES are undefined.
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Aug 1 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Aug 1 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
intn
-H5G_stab_list (H5G_entry_t *grp_ent, intn maxentries, char *names[]/*out*/,
- H5G_entry_t entries[]/*out*/)
+H5G_stab_list(H5G_entry_t *grp_ent, intn maxentries, char *names[] /*out */ ,
+ H5G_entry_t entries[] /*out */ )
{
- H5G_bt_ud2_t udata;
- H5O_stab_t stab;
- intn i;
-
- FUNC_ENTER (H5G_stab_list, FAIL);
+ H5G_bt_ud2_t udata;
+ H5O_stab_t stab;
+ intn i;
- /* check args */
- assert (grp_ent && grp_ent->file);
- assert (maxentries>=0);
+ FUNC_ENTER(H5G_stab_list, FAIL);
- /* initialize data to pass through B-tree */
- if (NULL==H5O_read (grp_ent, H5O_STAB, 0, &stab)) {
- HRETURN_ERROR (H5E_SYM, H5E_BADMESG, FAIL, "not a symbol table");
- }
- udata.entry = entries;
- udata.name = names;
- udata.heap_addr = stab.heap_addr;
- udata.maxentries = maxentries;
- udata.nsyms = 0;
- if (names) HDmemset (names, 0, maxentries);
+ /* check args */
+ assert(grp_ent && grp_ent->file);
+ assert(maxentries >= 0);
- /* list */
- if (H5B_list (grp_ent->file, H5B_SNODE, &(stab.btree_addr), &udata)<0) {
- if (names) {
- for (i=0; i<maxentries; i++) H5MM_xfree (names[i]);
- }
- HRETURN_ERROR (H5E_SYM, H5E_CANTLIST, FAIL, "b-tree list failure");
- }
+ /* initialize data to pass through B-tree */
+ if (NULL == H5O_read(grp_ent, H5O_STAB, 0, &stab)) {
+ HRETURN_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "not a symbol table");
+ }
+ udata.entry = entries;
+ udata.name = names;
+ udata.heap_addr = stab.heap_addr;
+ udata.maxentries = maxentries;
+ udata.nsyms = 0;
+ if (names)
+ HDmemset(names, 0, maxentries);
- FUNC_LEAVE (udata.nsyms);
+ /* list */
+ if (H5B_list(grp_ent->file, H5B_SNODE, &(stab.btree_addr), &udata) < 0) {
+ if (names) {
+ for (i = 0; i < maxentries; i++)
+ H5MM_xfree(names[i]);
+ }
+ HRETURN_ERROR(H5E_SYM, H5E_CANTLIST, FAIL, "b-tree list failure");
+ }
+ FUNC_LEAVE(udata.nsyms);
}
-
diff --git a/src/H5H.c b/src/H5H.c
index 44a3b8b..0449d02 100644
--- a/src/H5H.c
+++ b/src/H5H.c
@@ -1,1000 +1,993 @@
/*-------------------------------------------------------------------------
- * Copyright (C) 1997 National Center for Supercomputing Applications.
+ * Copyright (C) 1997 National Center for Supercomputing Applications.
* All rights reserved.
*
*-------------------------------------------------------------------------
*
- * Created: H5H.c
- * Jul 16 1997
- * Robb Matzke <matzke@llnl.gov>
+ * Created: H5H.c
+ * Jul 16 1997
+ * Robb Matzke <matzke@llnl.gov>
*
- * Purpose: Heap functions for the global small object heap
- * and for local symbol table name heaps.
+ * Purpose: Heap functions for the global small object heap
+ * and for local symbol table name heaps.
*
* Modifications:
*
- * Robb Matzke, 5 Aug 1997
- * Added calls to H5E.
+ * Robb Matzke, 5 Aug 1997
+ * Added calls to H5E.
*
*-------------------------------------------------------------------------
*/
-#include <H5private.h> /*library */
-#include <H5ACprivate.h> /*cache */
-#include <H5Eprivate.h> /*error handling */
-#include <H5Hprivate.h> /*self */
-#include <H5MFprivate.h> /*file memory management */
-#include <H5MMprivate.h> /*core memory management */
+#include <H5private.h> /*library */
+#include <H5ACprivate.h> /*cache */
+#include <H5Eprivate.h> /*error handling */
+#include <H5Hprivate.h> /*self */
+#include <H5MFprivate.h> /*file memory management */
+#include <H5MMprivate.h> /*core memory management */
-#define H5H_FREE_NULL 1 /*end of free list on disk */
-#define PABLO_MASK H5H_mask
-#define H5H_ALIGN(X) (((X)+7)&~0x03) /*align on 8-byte boundary */
+#define H5H_FREE_NULL 1 /*end of free list on disk */
+#define PABLO_MASK H5H_mask
+#define H5H_ALIGN(X) (((X)+7)&~0x03) /*align on 8-byte boundary */
typedef struct H5H_free_t {
- size_t offset; /*offset of free block */
- size_t size; /*size of free block */
- struct H5H_free_t *prev; /*previous entry in free list */
- struct H5H_free_t *next; /*next entry in free list */
+ size_t offset; /*offset of free block */
+ size_t size; /*size of free block */
+ struct H5H_free_t *prev; /*previous entry in free list */
+ struct H5H_free_t *next; /*next entry in free list */
} H5H_free_t;
typedef struct H5H_t {
- intn dirty;
- haddr_t addr; /*address of data */
- size_t disk_alloc; /*data bytes allocated on disk */
- size_t mem_alloc; /*data bytes allocated in mem */
- uint8 *chunk; /*the chunk, including header */
- H5H_free_t *freelist; /*the free list */
+ intn dirty;
+ haddr_t addr; /*address of data */
+ size_t disk_alloc; /*data bytes allocated on disk */
+ size_t mem_alloc; /*data bytes allocated in mem */
+ uint8 *chunk; /*the chunk, including header */
+ H5H_free_t *freelist; /*the free list */
} H5H_t;
/* PRIVATE PROTOTYPES */
-static H5H_t *H5H_load (H5F_t *f, const haddr_t *addr, const void *udata1,
- void *udata2);
-static herr_t H5H_flush (H5F_t *f, hbool_t dest, const haddr_t *addr,
- H5H_t *heap);
+static H5H_t *H5H_load(H5F_t *f, const haddr_t *addr, const void *udata1,
+ void *udata2);
+static herr_t H5H_flush(H5F_t *f, hbool_t dest, const haddr_t *addr,
+ H5H_t *heap);
/*
* H5H inherits cache-like properties from H5AC
*/
-static const H5AC_class_t H5AC_HEAP[1] = {{
- H5AC_HEAP_ID,
- (void*(*)(H5F_t*,const haddr_t*,const void*,void*))H5H_load,
- (herr_t(*)(H5F_t*,hbool_t,const haddr_t*,void*))H5H_flush,
-}};
+static const H5AC_class_t H5AC_HEAP[1] =
+{
+ {
+ H5AC_HEAP_ID,
+ (void *(*)(H5F_t *, const haddr_t *, const void *, void *)) H5H_load,
+ (herr_t (*)(H5F_t *, hbool_t, const haddr_t *, void *)) H5H_flush,
+ }};
/* Interface initialization */
-static intn interface_initialize_g = FALSE;
-#define INTERFACE_INIT NULL
-
+static intn interface_initialize_g = FALSE;
+#define INTERFACE_INIT NULL
/*-------------------------------------------------------------------------
- * Function: H5H_create
+ * Function: H5H_create
*
- * Purpose: Creates a new heap data structure on disk and caches it
- * in memory. SIZE_HINT is a hint for the initial size of the
- * data area of the heap. If size hint is invalid then a
- * reasonable (but probably not optimal) size will be chosen.
- * If the heap ever has to grow, then REALLOC_HINT is the
- * minimum amount by which the heap will grow.
+ * Purpose: Creates a new heap data structure on disk and caches it
+ * in memory. SIZE_HINT is a hint for the initial size of the
+ * data area of the heap. If size hint is invalid then a
+ * reasonable (but probably not optimal) size will be chosen.
+ * If the heap ever has to grow, then REALLOC_HINT is the
+ * minimum amount by which the heap will grow.
*
- * Return: Success: SUCCEED. The file address of new heap is
- * returned through the ADDR argument.
+ * Return: Success: SUCCEED. The file address of new heap is
+ * returned through the ADDR argument.
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jul 16 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jul 16 1997
*
* Modifications:
*
- * Robb Matzke, 5 Aug 1997
- * Takes a flag that determines the type of heap that is
- * created.
+ * Robb Matzke, 5 Aug 1997
+ * Takes a flag that determines the type of heap that is
+ * created.
*
*-------------------------------------------------------------------------
*/
herr_t
-H5H_create (H5F_t *f, H5H_type_t heap_type, size_t size_hint,
- haddr_t *addr/*out*/)
+H5H_create(H5F_t *f, H5H_type_t heap_type, size_t size_hint,
+ haddr_t *addr /*out */ )
{
- H5H_t *heap = NULL;
- size_t total_size; /*total heap size on disk */
+ H5H_t *heap = NULL;
+ size_t total_size; /*total heap size on disk */
- FUNC_ENTER (H5H_create, FAIL);
+ FUNC_ENTER(H5H_create, FAIL);
- /* check arguments */
- assert (f);
- assert (addr);
- if (H5H_GLOBAL==heap_type) {
+ /* check arguments */
+ assert(f);
+ assert(addr);
+ if (H5H_GLOBAL == heap_type) {
#ifndef NDEBUG
- fprintf (stderr, "H5H_create: a local heap is used as the global "
- "heap\n");
+ fprintf(stderr, "H5H_create: a local heap is used as the global "
+ "heap\n");
#endif
- }
-
- size_hint = MAX (0, size_hint);
- if (size_hint && size_hint<H5H_SIZEOF_FREE(f)) {
- size_hint = H5H_SIZEOF_FREE(f);
- }
- size_hint = H5H_ALIGN (size_hint);
-
- /* allocate file version */
- total_size = H5H_SIZEOF_HDR(f) + size_hint;
- if (H5MF_alloc (f, H5MF_META, total_size, addr/*out*/)<0) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "unable to allocate file memory");
- }
-
- /* allocate memory version */
- heap = H5MM_xcalloc (1, sizeof(H5H_t));
- heap->addr = *addr;
- H5F_addr_inc (&(heap->addr), H5H_SIZEOF_HDR (f));
- heap->disk_alloc = size_hint;
- heap->mem_alloc = size_hint;
- heap->chunk = H5MM_xcalloc (1, H5H_SIZEOF_HDR(f)+size_hint);
-
- /* free list */
- if (size_hint) {
- heap->freelist = H5MM_xmalloc (sizeof(H5H_free_t));
- heap->freelist->offset = 0;
- heap->freelist->size = size_hint;
- heap->freelist->prev = heap->freelist->next = NULL;
- } else {
- heap->freelist = NULL;
- }
-
- /* add to cache */
- heap->dirty = 1;
- if (H5AC_set (f, H5AC_HEAP, addr, heap)<0) {
- heap->chunk = H5MM_xfree (heap->chunk);
- heap->freelist = H5MM_xfree (heap->freelist);
- HRETURN_ERROR (H5E_HEAP, H5E_CANTINIT, FAIL,
- "unable to cache heap");
- }
-
- FUNC_LEAVE (SUCCEED);
+ }
+ size_hint = MAX(0, size_hint);
+ if (size_hint && size_hint < H5H_SIZEOF_FREE(f)) {
+ size_hint = H5H_SIZEOF_FREE(f);
+ }
+ size_hint = H5H_ALIGN(size_hint);
+
+ /* allocate file version */
+ total_size = H5H_SIZEOF_HDR(f) + size_hint;
+ if (H5MF_alloc(f, H5MF_META, total_size, addr /*out */ ) < 0) {
+ HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "unable to allocate file memory");
+ }
+ /* allocate memory version */
+ heap = H5MM_xcalloc(1, sizeof(H5H_t));
+ heap->addr = *addr;
+ H5F_addr_inc(&(heap->addr), H5H_SIZEOF_HDR(f));
+ heap->disk_alloc = size_hint;
+ heap->mem_alloc = size_hint;
+ heap->chunk = H5MM_xcalloc(1, H5H_SIZEOF_HDR(f) + size_hint);
+
+ /* free list */
+ if (size_hint) {
+ heap->freelist = H5MM_xmalloc(sizeof(H5H_free_t));
+ heap->freelist->offset = 0;
+ heap->freelist->size = size_hint;
+ heap->freelist->prev = heap->freelist->next = NULL;
+ } else {
+ heap->freelist = NULL;
+ }
+
+ /* add to cache */
+ heap->dirty = 1;
+ if (H5AC_set(f, H5AC_HEAP, addr, heap) < 0) {
+ heap->chunk = H5MM_xfree(heap->chunk);
+ heap->freelist = H5MM_xfree(heap->freelist);
+ HRETURN_ERROR(H5E_HEAP, H5E_CANTINIT, FAIL,
+ "unable to cache heap");
+ }
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5H_load
+ * Function: H5H_load
*
- * Purpose: Loads a heap from disk.
+ * Purpose: Loads a heap from disk.
*
- * Return: Success: Ptr to heap memory data structure.
+ * Return: Success: Ptr to heap memory data structure.
*
- * Failure: NULL
+ * Failure: NULL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jul 17 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jul 17 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-static H5H_t *
-H5H_load (H5F_t *f, const haddr_t *addr, const void *udata1, void *udata2)
+static H5H_t *
+H5H_load(H5F_t *f, const haddr_t *addr, const void *udata1, void *udata2)
{
- uint8 hdr[20];
- const uint8 *p=NULL;
- H5H_t *heap=NULL;
- H5H_free_t *fl=NULL, *tail=NULL;
- size_t free_block=H5H_FREE_NULL;
- H5H_t *ret_value=NULL;
-
- FUNC_ENTER (H5H_load, NULL);
-
- /* check arguments */
- assert (f);
- assert (addr && H5F_addr_defined (addr));
- assert (H5H_SIZEOF_HDR(f) <= sizeof hdr);
- assert (!udata1);
- assert (!udata2);
-
- if (H5F_block_read (f, addr, H5H_SIZEOF_HDR(f), hdr)<0) {
- HRETURN_ERROR (H5E_HEAP, H5E_READERROR, NULL,
- "unable to read heap header");
- }
- p = hdr;
- heap = H5MM_xcalloc (1, sizeof(H5H_t));
-
- /* magic number */
- if (HDmemcmp (hdr, H5H_MAGIC, H5H_SIZEOF_MAGIC)) {
- HGOTO_ERROR (H5E_HEAP, H5E_CANTLOAD, NULL,
- "bad heap signature");
- }
- p += H5H_SIZEOF_MAGIC;
-
- /* heap data size */
- H5F_decode_length (f, p, heap->disk_alloc);
- heap->mem_alloc = heap->disk_alloc;
-
- /* free list head */
- H5F_decode_length (f, p, free_block);
- if (free_block!=H5H_FREE_NULL && free_block>=heap->disk_alloc) {
- HGOTO_ERROR (H5E_HEAP, H5E_CANTLOAD, NULL,
- "bad heap free list");
- }
-
- /* data */
- H5F_addr_decode (f, &p, &(heap->addr));
- heap->chunk = H5MM_xcalloc (1, H5H_SIZEOF_HDR(f) + heap->mem_alloc);
- if (heap->disk_alloc &&
- H5F_block_read (f, &(heap->addr), heap->disk_alloc,
- heap->chunk + H5H_SIZEOF_HDR(f))<0) {
- HGOTO_ERROR (H5E_HEAP, H5E_CANTLOAD, NULL,
- "unable to read heap data");
- }
-
- /* free list */
- while (H5H_FREE_NULL!=free_block) {
- if (free_block>=heap->disk_alloc) {
- HGOTO_ERROR (H5E_HEAP, H5E_CANTLOAD, NULL,
- "bad heap free list");
- }
- fl = H5MM_xmalloc (sizeof (H5H_free_t));
- fl->offset = free_block;
- fl->prev = tail;
- fl->next = NULL;
- if (tail) tail->next = fl;
- tail = fl;
- if (!heap->freelist) heap->freelist = fl;
-
- p = heap->chunk + H5H_SIZEOF_HDR(f) + free_block;
- H5F_decode_length (f, p, free_block);
- H5F_decode_length (f, p, fl->size);
-
- if (fl->offset + fl->size > heap->disk_alloc) {
- HGOTO_ERROR (H5E_HEAP, H5E_CANTLOAD, NULL,
- "bad heap free list");
- }
- }
-
- ret_value = heap;
-
- done:
- if (!ret_value && heap) {
- heap->chunk = H5MM_xfree (heap->chunk);
- H5MM_xfree (heap);
- for (fl=heap->freelist; fl; fl=tail) {
- tail = fl->next;
- H5MM_xfree (fl);
- }
- }
-
- FUNC_LEAVE (ret_value);
+ uint8 hdr[20];
+ const uint8 *p = NULL;
+ H5H_t *heap = NULL;
+ H5H_free_t *fl = NULL, *tail = NULL;
+ size_t free_block = H5H_FREE_NULL;
+ H5H_t *ret_value = NULL;
+
+ FUNC_ENTER(H5H_load, NULL);
+
+ /* check arguments */
+ assert(f);
+ assert(addr && H5F_addr_defined(addr));
+ assert(H5H_SIZEOF_HDR(f) <= sizeof hdr);
+ assert(!udata1);
+ assert(!udata2);
+
+ if (H5F_block_read(f, addr, H5H_SIZEOF_HDR(f), hdr) < 0) {
+ HRETURN_ERROR(H5E_HEAP, H5E_READERROR, NULL,
+ "unable to read heap header");
+ }
+ p = hdr;
+ heap = H5MM_xcalloc(1, sizeof(H5H_t));
+
+ /* magic number */
+ if (HDmemcmp(hdr, H5H_MAGIC, H5H_SIZEOF_MAGIC)) {
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL,
+ "bad heap signature");
+ }
+ p += H5H_SIZEOF_MAGIC;
+
+ /* heap data size */
+ H5F_decode_length(f, p, heap->disk_alloc);
+ heap->mem_alloc = heap->disk_alloc;
+
+ /* free list head */
+ H5F_decode_length(f, p, free_block);
+ if (free_block != H5H_FREE_NULL && free_block >= heap->disk_alloc) {
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL,
+ "bad heap free list");
+ }
+ /* data */
+ H5F_addr_decode(f, &p, &(heap->addr));
+ heap->chunk = H5MM_xcalloc(1, H5H_SIZEOF_HDR(f) + heap->mem_alloc);
+ if (heap->disk_alloc &&
+ H5F_block_read(f, &(heap->addr), heap->disk_alloc,
+ heap->chunk + H5H_SIZEOF_HDR(f)) < 0) {
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL,
+ "unable to read heap data");
+ }
+ /* free list */
+ while (H5H_FREE_NULL != free_block) {
+ if (free_block >= heap->disk_alloc) {
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL,
+ "bad heap free list");
+ }
+ fl = H5MM_xmalloc(sizeof(H5H_free_t));
+ fl->offset = free_block;
+ fl->prev = tail;
+ fl->next = NULL;
+ if (tail)
+ tail->next = fl;
+ tail = fl;
+ if (!heap->freelist)
+ heap->freelist = fl;
+
+ p = heap->chunk + H5H_SIZEOF_HDR(f) + free_block;
+ H5F_decode_length(f, p, free_block);
+ H5F_decode_length(f, p, fl->size);
+
+ if (fl->offset + fl->size > heap->disk_alloc) {
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL,
+ "bad heap free list");
+ }
+ }
+
+ ret_value = heap;
+
+ done:
+ if (!ret_value && heap) {
+ heap->chunk = H5MM_xfree(heap->chunk);
+ H5MM_xfree(heap);
+ for (fl = heap->freelist; fl; fl = tail) {
+ tail = fl->next;
+ H5MM_xfree(fl);
+ }
+ }
+ FUNC_LEAVE(ret_value);
}
-
/*-------------------------------------------------------------------------
- * Function: H5H_flush
+ * Function: H5H_flush
*
- * Purpose: Flushes a heap from memory to disk if it's dirty. Optionally
- * deletes the heap from memory.
+ * Purpose: Flushes a heap from memory to disk if it's dirty. Optionally
+ * deletes the heap from memory.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jul 17 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jul 17 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static herr_t
-H5H_flush (H5F_t *f, hbool_t destroy, const haddr_t *addr, H5H_t *heap)
+H5H_flush(H5F_t *f, hbool_t destroy, const haddr_t *addr, H5H_t *heap)
{
- uint8 *p = heap->chunk;
- H5H_free_t *fl = heap->freelist;
- haddr_t hdr_end_addr;
-
- FUNC_ENTER (H5H_flush, FAIL);
-
- /* check arguments */
- assert (f);
- assert (addr && H5F_addr_defined (addr));
- assert (heap);
-
- if (heap->dirty) {
-
- /*
- * If the heap grew larger than disk storage then move the
- * data segment of the heap to a larger contiguous block of
- * disk storage.
- */
- if (heap->mem_alloc > heap->disk_alloc) {
- haddr_t old_addr = heap->addr, new_addr;
- if (H5MF_alloc (f, H5MF_META, heap->mem_alloc, &new_addr/*out*/)<0) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "unable to allocate file space for heap");
- }
- heap->addr = new_addr;
- H5MF_free (f, &old_addr, heap->disk_alloc);
- H5ECLEAR;/*don't really care if the free failed*/
- heap->disk_alloc = heap->mem_alloc;
- }
-
- /*
- * Write the header.
- */
- HDmemcpy (p, H5H_MAGIC, H5H_SIZEOF_MAGIC); p += H5H_SIZEOF_MAGIC;
- H5F_encode_length (f, p, heap->mem_alloc);
- H5F_encode_length (f, p, fl?fl->offset:H5H_FREE_NULL);
- H5F_addr_encode (f, &p, &(heap->addr));
-
- /*
- * Write the free list.
- */
- while (fl) {
- p = heap->chunk + H5H_SIZEOF_HDR(f) + fl->offset;
- if (fl->next) {
- H5F_encode_length (f, p, fl->next->offset);
- } else {
- H5F_encode_length (f, p, H5H_FREE_NULL);
- }
- H5F_encode_length (f, p, fl->size);
- fl = fl->next;
- }
-
- /*
- * Copy buffer to disk.
- */
- hdr_end_addr = *addr;
- H5F_addr_inc (&hdr_end_addr, H5H_SIZEOF_HDR (f));
- if (H5F_addr_eq (&(heap->addr), &hdr_end_addr)) {
- /* The header and data are contiguous */
- if (H5F_block_write (f, addr, H5H_SIZEOF_HDR(f)+heap->disk_alloc,
- heap->chunk)<0) {
- HRETURN_ERROR (H5E_HEAP, H5E_WRITEERROR, FAIL,
- "unable to write heap header and data to disk");
- }
- } else {
- if (H5F_block_write (f, addr, H5H_SIZEOF_HDR(f), heap->chunk)<0) {
- HRETURN_ERROR (H5E_HEAP, H5E_WRITEERROR, FAIL,
- "unable to write heap header to disk");
- }
- if (H5F_block_write (f, &(heap->addr), heap->disk_alloc,
- heap->chunk + H5H_SIZEOF_HDR(f))<0) {
- HRETURN_ERROR (H5E_HEAP, H5E_WRITEERROR, FAIL,
- "unable to write heap data to disk");
- }
- }
-
- heap->dirty = 0;
- }
-
- /*
- * Should we destroy the memory version?
- */
- if (destroy) {
- heap->chunk = H5MM_xfree (heap->chunk);
- while (heap->freelist) {
- fl = heap->freelist;
- heap->freelist = fl->next;
- H5MM_xfree (fl);
- }
- H5MM_xfree (heap);
- }
-
- FUNC_LEAVE (SUCCEED);
+ uint8 *p = heap->chunk;
+ H5H_free_t *fl = heap->freelist;
+ haddr_t hdr_end_addr;
+
+ FUNC_ENTER(H5H_flush, FAIL);
+
+ /* check arguments */
+ assert(f);
+ assert(addr && H5F_addr_defined(addr));
+ assert(heap);
+
+ if (heap->dirty) {
+
+ /*
+ * If the heap grew larger than disk storage then move the
+ * data segment of the heap to a larger contiguous block of
+ * disk storage.
+ */
+ if (heap->mem_alloc > heap->disk_alloc) {
+ haddr_t old_addr = heap->addr, new_addr;
+ if (H5MF_alloc(f, H5MF_META, heap->mem_alloc, &new_addr /*out */ ) < 0) {
+ HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "unable to allocate file space for heap");
+ }
+ heap->addr = new_addr;
+ H5MF_free(f, &old_addr, heap->disk_alloc);
+ H5ECLEAR; /*don't really care if the free failed */
+ heap->disk_alloc = heap->mem_alloc;
+ }
+ /*
+ * Write the header.
+ */
+ HDmemcpy(p, H5H_MAGIC, H5H_SIZEOF_MAGIC);
+ p += H5H_SIZEOF_MAGIC;
+ H5F_encode_length(f, p, heap->mem_alloc);
+ H5F_encode_length(f, p, fl ? fl->offset : H5H_FREE_NULL);
+ H5F_addr_encode(f, &p, &(heap->addr));
+
+ /*
+ * Write the free list.
+ */
+ while (fl) {
+ p = heap->chunk + H5H_SIZEOF_HDR(f) + fl->offset;
+ if (fl->next) {
+ H5F_encode_length(f, p, fl->next->offset);
+ } else {
+ H5F_encode_length(f, p, H5H_FREE_NULL);
+ }
+ H5F_encode_length(f, p, fl->size);
+ fl = fl->next;
+ }
+
+ /*
+ * Copy buffer to disk.
+ */
+ hdr_end_addr = *addr;
+ H5F_addr_inc(&hdr_end_addr, H5H_SIZEOF_HDR(f));
+ if (H5F_addr_eq(&(heap->addr), &hdr_end_addr)) {
+ /* The header and data are contiguous */
+ if (H5F_block_write(f, addr, H5H_SIZEOF_HDR(f) + heap->disk_alloc,
+ heap->chunk) < 0) {
+ HRETURN_ERROR(H5E_HEAP, H5E_WRITEERROR, FAIL,
+ "unable to write heap header and data to disk");
+ }
+ } else {
+ if (H5F_block_write(f, addr, H5H_SIZEOF_HDR(f), heap->chunk) < 0) {
+ HRETURN_ERROR(H5E_HEAP, H5E_WRITEERROR, FAIL,
+ "unable to write heap header to disk");
+ }
+ if (H5F_block_write(f, &(heap->addr), heap->disk_alloc,
+ heap->chunk + H5H_SIZEOF_HDR(f)) < 0) {
+ HRETURN_ERROR(H5E_HEAP, H5E_WRITEERROR, FAIL,
+ "unable to write heap data to disk");
+ }
+ }
+
+ heap->dirty = 0;
+ }
+ /*
+ * Should we destroy the memory version?
+ */
+ if (destroy) {
+ heap->chunk = H5MM_xfree(heap->chunk);
+ while (heap->freelist) {
+ fl = heap->freelist;
+ heap->freelist = fl->next;
+ H5MM_xfree(fl);
+ }
+ H5MM_xfree(heap);
+ }
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5H_read
+ * Function: H5H_read
*
- * Purpose: Reads some object (or part of an object) from the heap
- * whose address is ADDR in file F. OFFSET is the byte offset
- * from the beginning of the heap at which to begin reading
- * and SIZE is the number of bytes to read.
+ * Purpose: Reads some object (or part of an object) from the heap
+ * whose address is ADDR in file F. OFFSET is the byte offset
+ * from the beginning of the heap at which to begin reading
+ * and SIZE is the number of bytes to read.
*
- * If BUF is the null pointer then a buffer is allocated by
- * this function.
+ * If BUF is the null pointer then a buffer is allocated by
+ * this function.
*
- * Attempting to read past the end of an object may cause this
- * function to fail.
+ * Attempting to read past the end of an object may cause this
+ * function to fail.
*
- * If the heap address ADDR is the the null pointer then the
- * address comes from the H5F_t global heap field.
+ * If the heap address ADDR is the the null pointer then the
+ * address comes from the H5F_t global heap field.
*
- * Return: Success: BUF (or the allocated buffer)
+ * Return: Success: BUF (or the allocated buffer)
*
- * Failure: NULL
+ * Failure: NULL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jul 16 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jul 16 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-void *
-H5H_read (H5F_t *f, const haddr_t *addr, size_t offset, size_t size, void *buf)
+void *
+H5H_read(H5F_t *f, const haddr_t *addr, size_t offset, size_t size, void *buf)
{
- H5H_t *heap = NULL;
+ H5H_t *heap = NULL;
- FUNC_ENTER (H5H_read, NULL);
+ FUNC_ENTER(H5H_read, NULL);
- /* check arguments */
- assert (f);
- if (!addr) addr = &(f->shared->smallobj_addr);
- assert (H5F_addr_defined (addr));
- assert (offset>=0);
+ /* check arguments */
+ assert(f);
+ if (!addr)
+ addr = &(f->shared->smallobj_addr);
+ assert(H5F_addr_defined(addr));
+ assert(offset >= 0);
- if (NULL==(heap=H5AC_find (f, H5AC_HEAP, addr, NULL, NULL))) {
- HRETURN_ERROR (H5E_HEAP, H5E_CANTLOAD, NULL,
- "unable to load heap");
- }
- assert (offset<heap->mem_alloc);
- assert (offset+size<=heap->mem_alloc);
+ if (NULL == (heap = H5AC_find(f, H5AC_HEAP, addr, NULL, NULL))) {
+ HRETURN_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL,
+ "unable to load heap");
+ }
+ assert(offset < heap->mem_alloc);
+ assert(offset + size <= heap->mem_alloc);
- if (!buf) buf = H5MM_xmalloc (size);
- HDmemcpy (buf, heap->chunk+H5H_SIZEOF_HDR(f)+offset, size);
+ if (!buf)
+ buf = H5MM_xmalloc(size);
+ HDmemcpy(buf, heap->chunk + H5H_SIZEOF_HDR(f) + offset, size);
- FUNC_LEAVE (buf);
+ FUNC_LEAVE(buf);
}
-
/*-------------------------------------------------------------------------
- * Function: H5H_peek
+ * Function: H5H_peek
*
- * Purpose: This function is a more efficient version of H5H_read.
- * Instead of copying a heap object into a caller-supplied
- * buffer, this function returns a pointer directly into the
- * cache where the heap is being held. Thus, the return pointer
- * is valid only until the next call to the cache.
+ * Purpose: This function is a more efficient version of H5H_read.
+ * Instead of copying a heap object into a caller-supplied
+ * buffer, this function returns a pointer directly into the
+ * cache where the heap is being held. Thus, the return pointer
+ * is valid only until the next call to the cache.
*
- * The address of the heap is ADDR in file F. OFFSET is the
- * byte offset of the object from the beginning of the heap and
- * may include an offset into the interior of the object.
+ * The address of the heap is ADDR in file F. OFFSET is the
+ * byte offset of the object from the beginning of the heap and
+ * may include an offset into the interior of the object.
*
- * If the heap address ADDR is the null pointer then
- * the address comes from the H5F_t global heap field.
+ * If the heap address ADDR is the null pointer then
+ * the address comes from the H5F_t global heap field.
*
- * Return: Success: Ptr to the object. The pointer points to
- * a chunk of memory large enough to hold the
- * object from the specified offset (usually
- * the beginning of the object) to the end
- * of the object. Do not attempt to read past
- * the end of the object.
+ * Return: Success: Ptr to the object. The pointer points to
+ * a chunk of memory large enough to hold the
+ * object from the specified offset (usually
+ * the beginning of the object) to the end
+ * of the object. Do not attempt to read past
+ * the end of the object.
*
- * Failure: NULL
+ * Failure: NULL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jul 16 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jul 16 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-const void *
-H5H_peek (H5F_t *f, const haddr_t *addr, size_t offset)
+const void *
+H5H_peek(H5F_t *f, const haddr_t *addr, size_t offset)
{
- H5H_t *heap = NULL;
- const void *retval = NULL;
-
- FUNC_ENTER (H5H_peek, NULL);
-
- /* check arguments */
- assert (f);
- if (!addr) addr = &(f->shared->smallobj_addr);
- assert (H5F_addr_defined (addr));
- assert (offset>=0);
-
- if (NULL==(heap=H5AC_find (f, H5AC_HEAP, addr, NULL, NULL))) {
- HRETURN_ERROR (H5E_HEAP, H5E_CANTLOAD, NULL,
- "unable to load heap");
- }
- assert (offset<heap->mem_alloc);
-
- retval = heap->chunk+H5H_SIZEOF_HDR(f)+offset;
- FUNC_LEAVE (retval);
+ H5H_t *heap = NULL;
+ const void *retval = NULL;
+
+ FUNC_ENTER(H5H_peek, NULL);
+
+ /* check arguments */
+ assert(f);
+ if (!addr)
+ addr = &(f->shared->smallobj_addr);
+ assert(H5F_addr_defined(addr));
+ assert(offset >= 0);
+
+ if (NULL == (heap = H5AC_find(f, H5AC_HEAP, addr, NULL, NULL))) {
+ HRETURN_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL,
+ "unable to load heap");
+ }
+ assert(offset < heap->mem_alloc);
+
+ retval = heap->chunk + H5H_SIZEOF_HDR(f) + offset;
+ FUNC_LEAVE(retval);
}
-
/*-------------------------------------------------------------------------
- * Function: H5H_remove_free
+ * Function: H5H_remove_free
*
- * Purpose: Removes free list element FL from the specified heap and
- * frees it.
+ * Purpose: Removes free list element FL from the specified heap and
+ * frees it.
*
- * Return: NULL
+ * Return: NULL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jul 17 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jul 17 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-static H5H_free_t *
-H5H_remove_free (H5H_t *heap, H5H_free_t *fl)
+static H5H_free_t *
+H5H_remove_free(H5H_t *heap, H5H_free_t *fl)
{
- if (fl->prev) fl->prev->next = fl->next;
- if (fl->next) fl->next->prev = fl->prev;
-
- if (!fl->prev) heap->freelist = fl->next;
- return H5MM_xfree (fl);
+ if (fl->prev)
+ fl->prev->next = fl->next;
+ if (fl->next)
+ fl->next->prev = fl->prev;
+
+ if (!fl->prev)
+ heap->freelist = fl->next;
+ return H5MM_xfree(fl);
}
-
/*-------------------------------------------------------------------------
- * Function: H5H_insert
+ * Function: H5H_insert
*
- * Purpose: Inserts a new item into the heap.
+ * Purpose: Inserts a new item into the heap.
*
- * If the heap address ADDR is the null pointer then
- * the address comes from the H5F_t global heap field.
+ * If the heap address ADDR is the null pointer then
+ * the address comes from the H5F_t global heap field.
*
- * Return: Success: Offset of new item within heap.
+ * Return: Success: Offset of new item within heap.
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jul 17 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jul 17 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
size_t
-H5H_insert (H5F_t *f, const haddr_t *addr, size_t buf_size, const void *buf)
+H5H_insert(H5F_t *f, const haddr_t *addr, size_t buf_size, const void *buf)
{
- H5H_t *heap=NULL;
- H5H_free_t *fl=NULL, *max_fl=NULL;
- size_t offset = 0;
- size_t need_size, old_size, need_more;
- hbool_t found;
+ H5H_t *heap = NULL;
+ H5H_free_t *fl = NULL, *max_fl = NULL;
+ size_t offset = 0;
+ size_t need_size, old_size, need_more;
+ hbool_t found;
#ifndef NDEBUG
- static nmessages = 0;
+ static nmessages = 0;
#endif
- FUNC_ENTER (H5H_insert, FAIL);
-
- /* check arguments */
- assert (f);
- if (!addr) addr = &(f->shared->smallobj_addr);
- assert (H5F_addr_defined (addr));
- assert (buf_size>0);
- assert (buf);
-
- if (NULL==(heap=H5AC_find (f, H5AC_HEAP, addr, NULL, NULL))) {
- HRETURN_ERROR (H5E_HEAP, H5E_CANTLOAD, FAIL,
- "unable to load heap");
- }
- heap->dirty += 1;
-
- /*
- * In order to keep the free list descriptors aligned on word boundaries,
- * whatever that might mean, we round the size up to the next multiple of
- * a word.
- */
- need_size = H5H_ALIGN (buf_size);
-
- /*
- * Look for a free slot large enough for this object and which would
- * leave zero or at least H5G_SIZEOF_FREE bytes left over.
- */
- for (fl=heap->freelist,found=FALSE; fl; fl=fl->next) {
- if (fl->size>need_size && fl->size-need_size>=H5H_SIZEOF_FREE(f)) {
- /* a bigger free block was found */
- offset = fl->offset;
- fl->offset += need_size;
- fl->size -= need_size;
- found = TRUE;
- break;
- } else if (fl->size==need_size) {
- /* free block of exact size found */
- offset = fl->offset;
- fl = H5H_remove_free (heap, fl);
- found = TRUE;
- break;
- } else if (!max_fl || max_fl->offset < fl->offset) {
- /* use worst fit */
- max_fl = fl;
- }
- }
-
-
- /*
- * If no free chunk was large enough, then allocate more space and
- * add it to the free list. If the heap ends with a free chunk, we
- * can extend that free chunk. Otherwise we'll have to make another
- * free chunk. If the heap must expand, we double its size.
- */
- if (!found) {
-
- need_more = MAX3 (need_size, heap->mem_alloc, H5H_SIZEOF_FREE(f));
-
- if (max_fl && max_fl->offset+max_fl->size==heap->mem_alloc) {
- /*
- * Increase the size of the maximum free block.
- */
- offset = max_fl->offset;
- max_fl->offset += need_size;
- max_fl->size += need_more - need_size;
-
- if (max_fl->size < H5H_SIZEOF_FREE(f)) {
+ FUNC_ENTER(H5H_insert, FAIL);
+
+ /* check arguments */
+ assert(f);
+ if (!addr)
+ addr = &(f->shared->smallobj_addr);
+ assert(H5F_addr_defined(addr));
+ assert(buf_size > 0);
+ assert(buf);
+
+ if (NULL == (heap = H5AC_find(f, H5AC_HEAP, addr, NULL, NULL))) {
+ HRETURN_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL,
+ "unable to load heap");
+ }
+ heap->dirty += 1;
+
+ /*
+ * In order to keep the free list descriptors aligned on word boundaries,
+ * whatever that might mean, we round the size up to the next multiple of
+ * a word.
+ */
+ need_size = H5H_ALIGN(buf_size);
+
+ /*
+ * Look for a free slot large enough for this object and which would
+ * leave zero or at least H5G_SIZEOF_FREE bytes left over.
+ */
+ for (fl = heap->freelist, found = FALSE; fl; fl = fl->next) {
+ if (fl->size > need_size && fl->size - need_size >= H5H_SIZEOF_FREE(f)) {
+ /* a bigger free block was found */
+ offset = fl->offset;
+ fl->offset += need_size;
+ fl->size -= need_size;
+ found = TRUE;
+ break;
+ } else if (fl->size == need_size) {
+ /* free block of exact size found */
+ offset = fl->offset;
+ fl = H5H_remove_free(heap, fl);
+ found = TRUE;
+ break;
+ } else if (!max_fl || max_fl->offset < fl->offset) {
+ /* use worst fit */
+ max_fl = fl;
+ }
+ }
+
+ /*
+ * If no free chunk was large enough, then allocate more space and
+ * add it to the free list. If the heap ends with a free chunk, we
+ * can extend that free chunk. Otherwise we'll have to make another
+ * free chunk. If the heap must expand, we double its size.
+ */
+ if (!found) {
+
+ need_more = MAX3(need_size, heap->mem_alloc, H5H_SIZEOF_FREE(f));
+
+ if (max_fl && max_fl->offset + max_fl->size == heap->mem_alloc) {
+ /*
+ * Increase the size of the maximum free block.
+ */
+ offset = max_fl->offset;
+ max_fl->offset += need_size;
+ max_fl->size += need_more - need_size;
+
+ if (max_fl->size < H5H_SIZEOF_FREE(f)) {
#ifndef NDEBUG
- if (max_fl->size) {
- fprintf (stderr, "H5H_insert: lost %lu bytes at line %d\n",
- (unsigned long)(max_fl->size), __LINE__);
- if (0==nmessages++) {
- fprintf (stderr, "Messages from H5H_insert() will go away "
- "when assertions are turned off.\n");
- }
- }
+ if (max_fl->size) {
+ fprintf(stderr, "H5H_insert: lost %lu bytes at line %d\n",
+ (unsigned long) (max_fl->size), __LINE__);
+ if (0 == nmessages++) {
+ fprintf(stderr, "Messages from H5H_insert() will go away "
+ "when assertions are turned off.\n");
+ }
+ }
#endif
- max_fl = H5H_remove_free (heap, max_fl);
- }
-
- } else {
- /*
- * Create a new free list element large enough that we can
- * take some space out of it right away.
- */
- offset = heap->mem_alloc;
- if (need_more-need_size >= H5H_SIZEOF_FREE(f)) {
- fl = H5MM_xmalloc (sizeof(H5H_free_t));
- fl->offset = heap->mem_alloc + need_size;
- fl->size = need_more - need_size;
- fl->prev = NULL;
- fl->next = heap->freelist;
- if (heap->freelist) heap->freelist->prev = fl;
- heap->freelist = fl;
+ max_fl = H5H_remove_free(heap, max_fl);
+ }
+ } else {
+ /*
+ * Create a new free list element large enough that we can
+ * take some space out of it right away.
+ */
+ offset = heap->mem_alloc;
+ if (need_more - need_size >= H5H_SIZEOF_FREE(f)) {
+ fl = H5MM_xmalloc(sizeof(H5H_free_t));
+ fl->offset = heap->mem_alloc + need_size;
+ fl->size = need_more - need_size;
+ fl->prev = NULL;
+ fl->next = heap->freelist;
+ if (heap->freelist)
+ heap->freelist->prev = fl;
+ heap->freelist = fl;
#ifndef NDEBUG
- } else if (need_more>need_size) {
- fprintf (stderr, "H5H_insert: lost %lu bytes at line %d\n",
- (unsigned long)(need_more-need_size), __LINE__);
- if (0==nmessages++) {
- fprintf (stderr, "Messages from H5H_insert() will go away "
- "when assertions are turned off.\n");
- }
+ } else if (need_more > need_size) {
+ fprintf(stderr, "H5H_insert: lost %lu bytes at line %d\n",
+ (unsigned long) (need_more - need_size), __LINE__);
+ if (0 == nmessages++) {
+ fprintf(stderr, "Messages from H5H_insert() will go away "
+ "when assertions are turned off.\n");
+ }
#endif
- }
- }
+ }
+ }
#ifndef NDEBUG
- fprintf (stderr, "H5H_insert: resize mem buf from %lu to %lu bytes\n",
- (unsigned long)(heap->mem_alloc),
- (unsigned long)(heap->mem_alloc + need_more));
- if (0==nmessages++) {
- fprintf (stderr, "Messages from H5H_insert() will go away "
- "when assertions are turned off.\n");
- }
+ fprintf(stderr, "H5H_insert: resize mem buf from %lu to %lu bytes\n",
+ (unsigned long) (heap->mem_alloc),
+ (unsigned long) (heap->mem_alloc + need_more));
+ if (0 == nmessages++) {
+ fprintf(stderr, "Messages from H5H_insert() will go away "
+ "when assertions are turned off.\n");
+ }
#endif
- old_size = heap->mem_alloc;
- heap->mem_alloc += need_more;
- heap->chunk = H5MM_xrealloc (heap->chunk,
- H5H_SIZEOF_HDR(f)+heap->mem_alloc);
-
- /* clear new section so junk doesn't appear in the file */
- HDmemset (heap->chunk+H5H_SIZEOF_HDR(f)+old_size, 0, need_more);
- }
-
- /*
- * Copy the data into the heap
- */
- HDmemcpy (heap->chunk + H5H_SIZEOF_HDR(f) + offset, buf, buf_size);
- FUNC_LEAVE (offset);
+ old_size = heap->mem_alloc;
+ heap->mem_alloc += need_more;
+ heap->chunk = H5MM_xrealloc(heap->chunk,
+ H5H_SIZEOF_HDR(f) + heap->mem_alloc);
+
+ /* clear new section so junk doesn't appear in the file */
+ HDmemset(heap->chunk + H5H_SIZEOF_HDR(f) + old_size, 0, need_more);
+ }
+ /*
+ * Copy the data into the heap
+ */
+ HDmemcpy(heap->chunk + H5H_SIZEOF_HDR(f) + offset, buf, buf_size);
+ FUNC_LEAVE(offset);
}
-
/*-------------------------------------------------------------------------
- * Function: H5H_write
+ * Function: H5H_write
*
- * Purpose: Writes (overwrites) the object (or part of object) stored
- * in BUF to the heap at file address ADDR in file F. The
- * writing begins at byte offset OFFSET from the beginning of
- * the heap and continues for SIZE bytes.
+ * Purpose: Writes (overwrites) the object (or part of object) stored
+ * in BUF to the heap at file address ADDR in file F. The
+ * writing begins at byte offset OFFSET from the beginning of
+ * the heap and continues for SIZE bytes.
*
- * Do not partially write an object to create it; the first
- * write for an object must be for the entire object.
+ * Do not partially write an object to create it; the first
+ * write for an object must be for the entire object.
*
- * If the heap address ADDR is the null pointer then
- * the address comes from the H5F_t global heap field.
+ * If the heap address ADDR is the null pointer then
+ * the address comes from the H5F_t global heap field.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jul 16 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jul 16 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
-H5H_write (H5F_t *f, const haddr_t *addr, size_t offset, size_t size,
- const void *buf)
+H5H_write(H5F_t *f, const haddr_t *addr, size_t offset, size_t size,
+ const void *buf)
{
- H5H_t *heap = NULL;
+ H5H_t *heap = NULL;
- FUNC_ENTER (H5H_write, FAIL);
+ FUNC_ENTER(H5H_write, FAIL);
- /* check arguments */
- assert (f);
- if (!addr) addr = &(f->shared->smallobj_addr);
- assert (H5F_addr_defined (addr));
- assert (offset>=0);
- assert (buf);
+ /* check arguments */
+ assert(f);
+ if (!addr)
+ addr = &(f->shared->smallobj_addr);
+ assert(H5F_addr_defined(addr));
+ assert(offset >= 0);
+ assert(buf);
- if (NULL==(heap=H5AC_find (f, H5AC_HEAP, addr, NULL, NULL))) {
- HRETURN_ERROR (H5E_HEAP, H5E_CANTLOAD, FAIL,
- "unable to load heap");
- }
- assert (offset<heap->mem_alloc);
- assert (offset+size<=heap->mem_alloc);
+ if (NULL == (heap = H5AC_find(f, H5AC_HEAP, addr, NULL, NULL))) {
+ HRETURN_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL,
+ "unable to load heap");
+ }
+ assert(offset < heap->mem_alloc);
+ assert(offset + size <= heap->mem_alloc);
- heap->dirty += 1;
- HDmemcpy (heap->chunk+H5H_SIZEOF_HDR(f)+offset, buf, size);
+ heap->dirty += 1;
+ HDmemcpy(heap->chunk + H5H_SIZEOF_HDR(f) + offset, buf, size);
- FUNC_LEAVE (SUCCEED);
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5H_remove
+ * Function: H5H_remove
*
- * Purpose: Removes an object or part of an object from the heap at
- * address ADDR of file F. The object (or part) to remove
- * begins at byte OFFSET from the beginning of the heap and
- * continues for SIZE bytes.
+ * Purpose: Removes an object or part of an object from the heap at
+ * address ADDR of file F. The object (or part) to remove
+ * begins at byte OFFSET from the beginning of the heap and
+ * continues for SIZE bytes.
*
- * Once part of an object is removed, one must not attempt
- * to access that part. Removing the beginning of an object
- * results in the object OFFSET increasing by the amount
- * truncated. Removing the end of an object results in
- * object truncation. Removing the middle of an object results
- * in two separate objects, one at the original offset and
- * one at the first offset past the removed portion.
+ * Once part of an object is removed, one must not attempt
+ * to access that part. Removing the beginning of an object
+ * results in the object OFFSET increasing by the amount
+ * truncated. Removing the end of an object results in
+ * object truncation. Removing the middle of an object results
+ * in two separate objects, one at the original offset and
+ * one at the first offset past the removed portion.
*
- * If the heap address ADDR is the null pointer then
- * the address comes from the H5F_t global heap field.
+ * If the heap address ADDR is the null pointer then
+ * the address comes from the H5F_t global heap field.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jul 16 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jul 16 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
-H5H_remove (H5F_t *f, const haddr_t *addr, size_t offset, size_t size)
+H5H_remove(H5F_t *f, const haddr_t *addr, size_t offset, size_t size)
{
- H5H_t *heap = NULL;
- H5H_free_t *fl = heap->freelist, *fl2 = NULL;
+ H5H_t *heap = NULL;
+ H5H_free_t *fl = heap->freelist, *fl2 = NULL;
#ifndef NDEBUG
- static int nmessages = 0;
+ static int nmessages = 0;
#endif
- FUNC_ENTER (H5H_remove, FAIL);
-
- /* check arguments */
- assert (f);
- if (!addr) addr = &(f->shared->smallobj_addr);
- assert (H5F_addr_defined (addr));
- assert (offset>=0);
- assert (size>0);
-
- if (NULL==(heap=H5AC_find (f, H5AC_HEAP, addr, NULL, NULL))) {
- HRETURN_ERROR (H5E_HEAP, H5E_CANTLOAD, FAIL,
- "unable to load heap");
- }
- assert (offset<heap->mem_alloc);
- assert (offset+size<=heap->mem_alloc);
-
- heap->dirty += 1;
-
- /*
- * Check if this chunk can be prepended or appended to an already
- * free chunk. It might also fall between two chunks in such a way
- * that all three chunks can be combined into one.
- */
- while (fl) {
- if (offset + size == fl->offset) {
- fl->offset = offset;
- fl->size += size;
- fl2 = fl->next;
- while (fl2) {
- if (fl2->offset + fl2->size == fl->offset) {
- fl->offset = fl2->offset;
- fl->size += fl2->size;
- fl2 = H5H_remove_free (heap, fl2);
- HRETURN (SUCCEED);
- }
- }
- HRETURN (SUCCEED);
-
- } else if (fl->offset + fl->size == offset) {
- fl->size += size;
- fl2 = fl->next;
- while (fl2) {
- if (fl->offset + fl->size == fl2->offset) {
- fl->size += fl2->size;
- fl2 = H5H_remove_free (heap, fl2);
- HRETURN (SUCCEED);
- }
- }
- HRETURN (SUCCEED);
- }
-
- fl = fl->next;
- }
-
-
- /*
- * The amount which is being removed must be large enough to
- * hold the free list data. If not, the freed chunk is forever
- * lost.
- */
- if (size < H5H_SIZEOF_FREE(f)) {
+ FUNC_ENTER(H5H_remove, FAIL);
+
+ /* check arguments */
+ assert(f);
+ if (!addr)
+ addr = &(f->shared->smallobj_addr);
+ assert(H5F_addr_defined(addr));
+ assert(offset >= 0);
+ assert(size > 0);
+
+ if (NULL == (heap = H5AC_find(f, H5AC_HEAP, addr, NULL, NULL))) {
+ HRETURN_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL,
+ "unable to load heap");
+ }
+ assert(offset < heap->mem_alloc);
+ assert(offset + size <= heap->mem_alloc);
+
+ heap->dirty += 1;
+
+ /*
+ * Check if this chunk can be prepended or appended to an already
+ * free chunk. It might also fall between two chunks in such a way
+ * that all three chunks can be combined into one.
+ */
+ while (fl) {
+ if (offset + size == fl->offset) {
+ fl->offset = offset;
+ fl->size += size;
+ fl2 = fl->next;
+ while (fl2) {
+ if (fl2->offset + fl2->size == fl->offset) {
+ fl->offset = fl2->offset;
+ fl->size += fl2->size;
+ fl2 = H5H_remove_free(heap, fl2);
+ HRETURN(SUCCEED);
+ }
+ }
+ HRETURN(SUCCEED);
+
+ } else if (fl->offset + fl->size == offset) {
+ fl->size += size;
+ fl2 = fl->next;
+ while (fl2) {
+ if (fl->offset + fl->size == fl2->offset) {
+ fl->size += fl2->size;
+ fl2 = H5H_remove_free(heap, fl2);
+ HRETURN(SUCCEED);
+ }
+ }
+ HRETURN(SUCCEED);
+ }
+ fl = fl->next;
+ }
+
+ /*
+ * The amount which is being removed must be large enough to
+ * hold the free list data. If not, the freed chunk is forever
+ * lost.
+ */
+ if (size < H5H_SIZEOF_FREE(f)) {
#ifndef NDEBUG
- fprintf (stderr, "H5H_remove: lost %lu bytes\n", (unsigned long)size);
- if (0==nmessages++) {
- fprintf (stderr, "Messages from H5H_remove() will go away "
- "when assertions are turned off.\n");
- }
+ fprintf(stderr, "H5H_remove: lost %lu bytes\n", (unsigned long) size);
+ if (0 == nmessages++) {
+ fprintf(stderr, "Messages from H5H_remove() will go away "
+ "when assertions are turned off.\n");
+ }
#endif
- HRETURN (SUCCEED);
- }
-
- /*
- * Add an entry to the free list.
- */
- fl = H5MM_xmalloc (sizeof(H5H_free_t));
- fl->offset = offset;
- fl->size = size;
- fl->prev = NULL;
- fl->next = heap->freelist;
- if (heap->freelist) heap->freelist->prev = fl;
- heap->freelist = fl;
-
- FUNC_LEAVE (SUCCEED);
+ HRETURN(SUCCEED);
+ }
+ /*
+ * Add an entry to the free list.
+ */
+ fl = H5MM_xmalloc(sizeof(H5H_free_t));
+ fl->offset = offset;
+ fl->size = size;
+ fl->prev = NULL;
+ fl->next = heap->freelist;
+ if (heap->freelist)
+ heap->freelist->prev = fl;
+ heap->freelist = fl;
+
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5H_debug
+ * Function: H5H_debug
*
- * Purpose: Prints debugging information about a heap.
+ * Purpose: Prints debugging information about a heap.
*
- * If the heap address ADDR is the null pointer then
- * the address comes from the H5F_t global heap field.
+ * If the heap address ADDR is the null pointer then
+ * the address comes from the H5F_t global heap field.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Aug 1 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Aug 1 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
-H5H_debug (H5F_t *f, const haddr_t *addr, FILE *stream, intn indent,
- intn fwidth)
+H5H_debug(H5F_t *f, const haddr_t *addr, FILE * stream, intn indent,
+ intn fwidth)
{
- H5H_t *h = NULL;
- int i, j, overlap;
- uint8 c;
- H5H_free_t *freelist=NULL;
- uint8 *marker = NULL;
- size_t amount_free = 0;
-
- FUNC_ENTER (H5H_debug, FAIL);
-
- /* check arguments */
- assert (f);
- if (!addr) addr = &(f->shared->smallobj_addr);
- assert (H5F_addr_defined (addr));
- assert (stream);
- assert (indent>=0);
- assert (fwidth>=0);
-
- if (NULL==(h=H5AC_find (f, H5AC_HEAP, addr, NULL, NULL))) {
- HRETURN_ERROR (H5E_HEAP, H5E_CANTLOAD, FAIL,
- "unable to load heap");
- }
-
- fprintf (stream, "%*sHeap...\n", indent, "");
- fprintf (stream, "%*s%-*s %d\n", indent, "", fwidth,
- "Dirty:",
- (int)(h->dirty));
- fprintf (stream, "%*s%-*s %lu\n", indent, "", fwidth,
- "Data bytes allocated on disk:",
- (unsigned long)(h->disk_alloc));
- fprintf (stream, "%*s%-*s %lu\n", indent, "", fwidth,
- "Data bytes allocated in core:",
- (unsigned long)(h->mem_alloc));
-
-
- /*
- * Traverse the free list and check that all free blocks fall within
- * the heap and that no two free blocks point to the same region of
- * the heap.
- */
- marker = H5MM_xcalloc (h->mem_alloc, 1);
- for (freelist=h->freelist; freelist; freelist=freelist->next) {
- fprintf (stream, "%*s%-*s %8lu, %8lu\n", indent, "", fwidth,
- "Free Block (offset,size):",
- (unsigned long)(freelist->offset),
- (unsigned long)(freelist->size));
- if (freelist->offset + freelist->size > h->mem_alloc) {
- fprintf (stream, "***THAT FREE BLOCK IS OUT OF BOUNDS!\n");
- } else {
- for (i=overlap=0; i<freelist->size; i++) {
- if (marker[freelist->offset+i]) overlap++;
- marker[freelist->offset+i] = 1;
- }
- if (overlap) {
- fprintf (stream,"***THAT FREE BLOCK OVERLAPPED A PREVIOUS ONE!\n");
- } else {
- amount_free += freelist->size;
- }
- }
- }
-
- if (h->mem_alloc) {
- fprintf (stream, "%*s%-*s %lu\n", indent, "", fwidth,
- "Percent of heap used:",
- (unsigned long)(100 * (h->mem_alloc - amount_free) /
- h->mem_alloc));
- }
-
- /*
- * Print the data in a VMS-style octal dump.
- */
- fprintf (stream, "%*sData follows (`__' indicates free region)...\n",
- indent, "");
- for (i=0; i<h->disk_alloc; i+=16) {
- fprintf (stream, "%*s %8d: ", indent, "", i);
- for (j=0; j<16; j++) {
- if (i+j<h->disk_alloc) {
- if (marker[i+j]) {
- fprintf (stream, "__ ");
- } else {
- c = h->chunk[H5H_SIZEOF_HDR(f)+i+j];
- fprintf (stream, "%02x ", c);
- }
- } else {
- fprintf (stream, " ");
- }
- if (7==j) HDfputc (' ', stream);
- }
-
- for (j=0; j<16; j++) {
- if (i+j<h->disk_alloc) {
- if (marker[i+j]) {
- HDfputc (' ', stream);
- } else {
- c = h->chunk[H5H_SIZEOF_HDR(f)+i+j];
- if (c>' ' && c<'~') HDfputc (c, stream);
- else HDfputc ('.', stream);
- }
- }
- }
-
- HDfputc ('\n', stream);
- }
-
- H5MM_xfree (marker);
- FUNC_LEAVE (SUCCEED);
+ H5H_t *h = NULL;
+ int i, j, overlap;
+ uint8 c;
+ H5H_free_t *freelist = NULL;
+ uint8 *marker = NULL;
+ size_t amount_free = 0;
+
+ FUNC_ENTER(H5H_debug, FAIL);
+
+ /* check arguments */
+ assert(f);
+ if (!addr)
+ addr = &(f->shared->smallobj_addr);
+ assert(H5F_addr_defined(addr));
+ assert(stream);
+ assert(indent >= 0);
+ assert(fwidth >= 0);
+
+ if (NULL == (h = H5AC_find(f, H5AC_HEAP, addr, NULL, NULL))) {
+ HRETURN_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL,
+ "unable to load heap");
+ }
+ fprintf(stream, "%*sHeap...\n", indent, "");
+ fprintf(stream, "%*s%-*s %d\n", indent, "", fwidth,
+ "Dirty:",
+ (int) (h->dirty));
+ fprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth,
+ "Data bytes allocated on disk:",
+ (unsigned long) (h->disk_alloc));
+ fprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth,
+ "Data bytes allocated in core:",
+ (unsigned long) (h->mem_alloc));
+
+ /*
+ * Traverse the free list and check that all free blocks fall within
+ * the heap and that no two free blocks point to the same region of
+ * the heap.
+ */
+ marker = H5MM_xcalloc(h->mem_alloc, 1);
+ for (freelist = h->freelist; freelist; freelist = freelist->next) {
+ fprintf(stream, "%*s%-*s %8lu, %8lu\n", indent, "", fwidth,
+ "Free Block (offset,size):",
+ (unsigned long) (freelist->offset),
+ (unsigned long) (freelist->size));
+ if (freelist->offset + freelist->size > h->mem_alloc) {
+ fprintf(stream, "***THAT FREE BLOCK IS OUT OF BOUNDS!\n");
+ } else {
+ for (i = overlap = 0; i < freelist->size; i++) {
+ if (marker[freelist->offset + i])
+ overlap++;
+ marker[freelist->offset + i] = 1;
+ }
+ if (overlap) {
+ fprintf(stream, "***THAT FREE BLOCK OVERLAPPED A PREVIOUS ONE!\n");
+ } else {
+ amount_free += freelist->size;
+ }
+ }
+ }
+
+ if (h->mem_alloc) {
+ fprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth,
+ "Percent of heap used:",
+ (unsigned long) (100 * (h->mem_alloc - amount_free) /
+ h->mem_alloc));
+ }
+ /*
+ * Print the data in a VMS-style octal dump.
+ */
+ fprintf(stream, "%*sData follows (`__' indicates free region)...\n",
+ indent, "");
+ for (i = 0; i < h->disk_alloc; i += 16) {
+ fprintf(stream, "%*s %8d: ", indent, "", i);
+ for (j = 0; j < 16; j++) {
+ if (i + j < h->disk_alloc) {
+ if (marker[i + j]) {
+ fprintf(stream, "__ ");
+ } else {
+ c = h->chunk[H5H_SIZEOF_HDR(f) + i + j];
+ fprintf(stream, "%02x ", c);
+ }
+ } else {
+ fprintf(stream, " ");
+ }
+ if (7 == j)
+ HDfputc(' ', stream);
+ }
+
+ for (j = 0; j < 16; j++) {
+ if (i + j < h->disk_alloc) {
+ if (marker[i + j]) {
+ HDfputc(' ', stream);
+ } else {
+ c = h->chunk[H5H_SIZEOF_HDR(f) + i + j];
+ if (c > ' ' && c < '~')
+ HDfputc(c, stream);
+ else
+ HDfputc('.', stream);
+ }
+ }
+ }
+
+ HDfputc('\n', stream);
+ }
+
+ H5MM_xfree(marker);
+ FUNC_LEAVE(SUCCEED);
}
diff --git a/src/H5Hprivate.h b/src/H5Hprivate.h
index ab1c401..9a6b4d6 100644
--- a/src/H5Hprivate.h
+++ b/src/H5Hprivate.h
@@ -1,16 +1,16 @@
/*-------------------------------------------------------------------------
- * Copyright (C) 1997 National Center for Supercomputing Applications.
+ * Copyright (C) 1997 National Center for Supercomputing Applications.
* All rights reserved.
*
*-------------------------------------------------------------------------
*
- * Created: H5Hprivate.h
- * Jul 16 1997
- * Robb Matzke <matzke@llnl.gov>
+ * Created: H5Hprivate.h
+ * Jul 16 1997
+ * Robb Matzke <matzke@llnl.gov>
*
- * Purpose:
+ * Purpose:
*
- * Modifications:
+ * Modifications:
*
*-------------------------------------------------------------------------
*/
@@ -22,39 +22,38 @@
#include <H5private.h>
#include <H5Fprivate.h>
-#define H5H_MAGIC "HEAP" /*heap magic number */
+#define H5H_MAGIC "HEAP" /*heap magic number */
#define H5H_SIZEOF_MAGIC 4
-#define H5H_SIZEOF_HDR(F) \
- (H5H_SIZEOF_MAGIC + /*heap signature */ \
- H5F_SIZEOF_SIZE (F) + /*data size */ \
- H5F_SIZEOF_SIZE (F) + /*free list head */ \
- H5F_SIZEOF_ADDR (F)) /*data address */
-
-#define H5H_SIZEOF_FREE(F) \
- (H5F_SIZEOF_SIZE (F) + /*ptr to next free block */ \
- H5F_SIZEOF_SIZE (F)) /*size of this free block */
+#define H5H_SIZEOF_HDR(F) \
+ (H5H_SIZEOF_MAGIC + /*heap signature */ \
+ H5F_SIZEOF_SIZE (F) + /*data size */ \
+ H5F_SIZEOF_SIZE (F) + /*free list head */ \
+ H5F_SIZEOF_ADDR (F)) /*data address */
+#define H5H_SIZEOF_FREE(F) \
+ (H5F_SIZEOF_SIZE (F) + /*ptr to next free block */ \
+ H5F_SIZEOF_SIZE (F)) /*size of this free block */
typedef enum H5H_type_t {
- H5H_LOCAL =0, /*local symtab name heap */
- H5H_GLOBAL =1 /*global small object heap */
+ H5H_LOCAL = 0, /*local symtab name heap */
+ H5H_GLOBAL = 1 /*global small object heap */
} H5H_type_t;
/*
* Library prototypes...
*/
-herr_t H5H_create (H5F_t *f, H5H_type_t type, size_t size_hint,
- haddr_t *addr/*out*/);
-void *H5H_read (H5F_t *f, const haddr_t *addr, size_t offset, size_t size,
- void *buf);
-const void *H5H_peek (H5F_t *f, const haddr_t *addr, size_t offset);
-size_t H5H_insert (H5F_t *f, const haddr_t *addr, size_t size,
- const void *buf);
-herr_t H5H_write (H5F_t *f, const haddr_t *addr, size_t offset, size_t size,
- const void *buf);
-herr_t H5H_remove (H5F_t *f, const haddr_t *addr, size_t offset, size_t size);
-herr_t H5H_debug (H5F_t *f, const haddr_t *addr, FILE *stream, intn indent,
- intn fwidth);
+herr_t H5H_create(H5F_t *f, H5H_type_t type, size_t size_hint,
+ haddr_t *addr /*out */ );
+void *H5H_read(H5F_t *f, const haddr_t *addr, size_t offset, size_t size,
+ void *buf);
+const void *H5H_peek(H5F_t *f, const haddr_t *addr, size_t offset);
+size_t H5H_insert(H5F_t *f, const haddr_t *addr, size_t size,
+ const void *buf);
+herr_t H5H_write(H5F_t *f, const haddr_t *addr, size_t offset, size_t size,
+ const void *buf);
+herr_t H5H_remove(H5F_t *f, const haddr_t *addr, size_t offset, size_t size);
+herr_t H5H_debug(H5F_t *f, const haddr_t *addr, FILE * stream, intn indent,
+ intn fwidth);
#endif
diff --git a/src/H5Hpublic.h b/src/H5Hpublic.h
index 7ec8c7c..f5f65f2 100644
--- a/src/H5Hpublic.h
+++ b/src/H5Hpublic.h
@@ -1,16 +1,16 @@
/*-------------------------------------------------------------------------
- * Copyright (C) 1997 National Center for Supercomputing Applications.
+ * Copyright (C) 1997 National Center for Supercomputing Applications.
* All rights reserved.
*
*-------------------------------------------------------------------------
*
- * Created: H5Hproto.h
- * Jul 16 1997
- * Robb Matzke <matzke@llnl.gov>
+ * Created: H5Hproto.h
+ * Jul 16 1997
+ * Robb Matzke <matzke@llnl.gov>
*
- * Purpose: Public declarations for the H5H (heap) package.
+ * Purpose: Public declarations for the H5H (heap) package.
*
- * Modifications:
+ * Modifications:
*
*-------------------------------------------------------------------------
*/
@@ -21,11 +21,11 @@
#include <H5public.h>
#ifdef __cplusplus
-extern "C" {
+extern "C" {
#endif
#ifdef __cplusplus
}
-#endif
#endif
+#endif
diff --git a/src/H5M.c b/src/H5M.c
index 31a5bd4..c1aca8d 100644
--- a/src/H5M.c
+++ b/src/H5M.c
@@ -1,17 +1,17 @@
/****************************************************************************
-* NCSA HDF *
-* Software Development Group *
-* National Center for Supercomputing Applications *
-* University of Illinois at Urbana-Champaign *
-* 605 E. Springfield, Champaign IL 61820 *
-* *
-* For conditions of distribution and use, see the accompanying *
-* hdf/COPYING file. *
-* *
+* NCSA HDF *
+* Software Development Group *
+* National Center for Supercomputing Applications *
+* University of Illinois at Urbana-Champaign *
+* 605 E. Springfield, Champaign IL 61820 *
+* *
+* For conditions of distribution and use, see the accompanying *
+* hdf/COPYING file. *
+* *
****************************************************************************/
#ifdef RCSID
-static char RcsId[] = "@(#)$Revision$";
+static char RcsId[] = "@(#)$Revision$";
#endif
/* $Id$ */
@@ -19,118 +19,119 @@ static char RcsId[] = "@(#)$Revision$";
/*LINTLIBRARY */
/*+
FILE
- hdf5meta.c
+ hdf5meta.c
HDF5 "Meta-Object" routines
EXPORTED ROUTINES
- H5Maccess -- Start access to an existing object
- H5Mcopy -- Copy an object
- H5Mopen -- Find an object by name
- H5Mname_len -- Get the length of an object's name
- H5Mget_name -- Get an object's name
- H5Mset_name -- Set an object's name
- H5Msearch -- Wildcard search for an object by name
- H5Mindex -- Get an object by index
- H5Mflush -- Flush an object out to disk
- H5Mdelete -- Delete an object from disk
- H5Mget_file -- Get the file ID for an object
- H5Mget_file -- Get the parent ID for an object
- H5Mclose -- Release access to an object
+ H5Maccess -- Start access to an existing object
+ H5Mcopy -- Copy an object
+ H5Mopen -- Find an object by name
+ H5Mname_len -- Get the length of an object's name
+ H5Mget_name -- Get an object's name
+ H5Mset_name -- Set an object's name
+ H5Msearch -- Wildcard search for an object by name
+ H5Mindex -- Get an object by index
+ H5Mflush -- Flush an object out to disk
+ H5Mdelete -- Delete an object from disk
+ H5Mget_file -- Get the file ID for an object
+ H5Mget_file -- Get the parent ID for an object
+ H5Mclose -- Release access to an object
LIBRARY-SCOPED ROUTINES
LOCAL ROUTINES
- H5M_init_interface -- initialize the interface
+ H5M_init_interface -- initialize the interface
+ */
-#include <H5private.h> /* Generic functions */
-#include <H5Cprivate.h> /* Template interface */
-#include <H5Dprivate.h> /* Dataset interface */
-#include <H5Eprivate.h> /*error handling */
-#include <H5Pprivate.h> /* Dataspace functions */
-#include <H5Tprivate.h> /* Datatype interface */
-#include <H5Mprivate.h> /* Meta-object interface */
-#include <H5Cprivate.h> /* Template interface */
+#include <H5private.h> /* Generic functions */
+#include <H5Cprivate.h> /* Template interface */
+#include <H5Dprivate.h> /* Dataset interface */
+#include <H5Eprivate.h> /*error handling */
+#include <H5Pprivate.h> /* Dataspace functions */
+#include <H5Tprivate.h> /* Datatype interface */
+#include <H5Mprivate.h> /* Meta-object interface */
+#include <H5Cprivate.h> /* Template interface */
-#define PABLO_MASK H5M_mask
+#define PABLO_MASK H5M_mask
/*--------------------- Locally scoped variables -----------------------------*/
-static meta_func_t meta_func_arr[]={
- { /* Template object meta-functions (defined in H5C.c) */
- H5_TEMPLATE_0, /* File-Creation Template Type ID */
- NULL, /* File-Creation Template Create */
- NULL, /* File-Creation Template Access */
- H5Ccopy, /* File-Creation Template Copy */
- NULL, /* File-Creation Template FindName */
- NULL, /* File-Creation Template NameLen */
- NULL, /* File-Creation Template GetName */
- NULL, /* File-Creation Template SetName */
- NULL, /* File-Creation Template Search */
- NULL, /* File-Creation Template Index */
- NULL, /* File-Creation Template Flush */
- NULL, /* File-Creation Template Delete */
- NULL, /* File-Creation Template GetParent */
- NULL, /* File-Creation Template GetFile */
- H5Cclose /* File-Creation Template Release */
+static meta_func_t meta_func_arr[] =
+{
+ { /* Template object meta-functions (defined in H5C.c) */
+ H5_TEMPLATE_0, /* File-Creation Template Type ID */
+ NULL, /* File-Creation Template Create */
+ NULL, /* File-Creation Template Access */
+ H5Ccopy, /* File-Creation Template Copy */
+ NULL, /* File-Creation Template FindName */
+ NULL, /* File-Creation Template NameLen */
+ NULL, /* File-Creation Template GetName */
+ NULL, /* File-Creation Template SetName */
+ NULL, /* File-Creation Template Search */
+ NULL, /* File-Creation Template Index */
+ NULL, /* File-Creation Template Flush */
+ NULL, /* File-Creation Template Delete */
+ NULL, /* File-Creation Template GetParent */
+ NULL, /* File-Creation Template GetFile */
+ H5Cclose /* File-Creation Template Release */
},
- { /* Datatype object meta-functions (defined in H5T.c) */
- H5_DATATYPE, /* Datatype Type ID */
- NULL, /* Datatype Create */
- NULL, /* Datatype Access */
- H5Tcopy, /* Dataspace Copy */
- NULL, /* Datatype FindName */
- NULL, /* Datatype NameLen */
- NULL, /* Datatype GetName */
- NULL, /* Datatype SetName */
- NULL, /* Datatype Search */
- NULL, /* Datatype Index */
- NULL, /* Datatype Flush */
- NULL, /* Datatype Delete */
- NULL, /* Datatype GetParent */
- NULL, /* Datatype GetFile */
- H5Tclose /* Datatype Release */
+ { /* Datatype object meta-functions (defined in H5T.c) */
+ H5_DATATYPE, /* Datatype Type ID */
+ NULL, /* Datatype Create */
+ NULL, /* Datatype Access */
+ H5Tcopy, /* Dataspace Copy */
+ NULL, /* Datatype FindName */
+ NULL, /* Datatype NameLen */
+ NULL, /* Datatype GetName */
+ NULL, /* Datatype SetName */
+ NULL, /* Datatype Search */
+ NULL, /* Datatype Index */
+ NULL, /* Datatype Flush */
+ NULL, /* Datatype Delete */
+ NULL, /* Datatype GetParent */
+ NULL, /* Datatype GetFile */
+ H5Tclose /* Datatype Release */
},
- { /* Dimensionality object meta-functions (defined in H5P.c) */
- H5_DATASPACE, /* Dimensionality Type ID */
- NULL, /* Dimensionality Create */
- NULL, /* Dimensionality Access */
- NULL, /* Dimensionality Copy */
- NULL, /* Dimensionality FindName */
- NULL, /* Dimensionality NameLen */
- NULL, /* Dimensionality GetName */
- NULL, /* Dimensionality SetName */
- NULL, /* Dimensionality Search */
- NULL, /* Dimensionality Index */
- NULL, /* Dimensionality Flush */
- NULL, /* Dimensionality Delete */
- NULL, /* Dimensionality GetParent */
- NULL, /* Dimensionality GetFile */
- H5Pclose /* Dimensionality Release */
+ { /* Dimensionality object meta-functions (defined in H5P.c) */
+ H5_DATASPACE, /* Dimensionality Type ID */
+ NULL, /* Dimensionality Create */
+ NULL, /* Dimensionality Access */
+ NULL, /* Dimensionality Copy */
+ NULL, /* Dimensionality FindName */
+ NULL, /* Dimensionality NameLen */
+ NULL, /* Dimensionality GetName */
+ NULL, /* Dimensionality SetName */
+ NULL, /* Dimensionality Search */
+ NULL, /* Dimensionality Index */
+ NULL, /* Dimensionality Flush */
+ NULL, /* Dimensionality Delete */
+ NULL, /* Dimensionality GetParent */
+ NULL, /* Dimensionality GetFile */
+ H5Pclose /* Dimensionality Release */
},
- { /* Dataset object meta-functions (defined in H5D.c) */
- H5_DATASET, /* Dataset Type ID */
- NULL, /* Dataset Create */
- NULL, /* Dataset Access */
- NULL, /* Dataset Copy */
- H5D_find_name, /* Dataset FindName */
- NULL, /* Dataset NameLen */
- NULL, /* Dataset GetName */
- NULL, /* Dataset SetName */
- NULL, /* Dataset Search */
- NULL, /* Dataset Index */
- NULL, /* Dataset Flush */
- NULL, /* Dataset Delete */
- NULL, /* Dataset GetParent */
- NULL, /* Dataset GetFile */
- H5Dclose /* Dataset Release */
+ { /* Dataset object meta-functions (defined in H5D.c) */
+ H5_DATASET, /* Dataset Type ID */
+ NULL, /* Dataset Create */
+ NULL, /* Dataset Access */
+ NULL, /* Dataset Copy */
+ H5D_find_name, /* Dataset FindName */
+ NULL, /* Dataset NameLen */
+ NULL, /* Dataset GetName */
+ NULL, /* Dataset SetName */
+ NULL, /* Dataset Search */
+ NULL, /* Dataset Index */
+ NULL, /* Dataset Flush */
+ NULL, /* Dataset Delete */
+ NULL, /* Dataset GetParent */
+ NULL, /* Dataset GetFile */
+ H5Dclose /* Dataset Release */
},
- };
+};
/* Interface initialization */
-static intn interface_initialize_g = FALSE;
-#define INTERFACE_INIT H5M_init_interface
-static herr_t H5M_init_interface(void);
+static intn interface_initialize_g = FALSE;
+#define INTERFACE_INIT H5M_init_interface
+static herr_t H5M_init_interface(void);
/*--------------------------------------------------------------------------
NAME
@@ -148,13 +149,14 @@ MODIFICATIONS
Changed the FUNC variable value to H5M_init_interface.
--------------------------------------------------------------------------*/
-static herr_t H5M_init_interface(void)
+static herr_t
+H5M_init_interface(void)
{
- herr_t ret_value = SUCCEED;
- FUNC_ENTER (H5M_init_interface, FAIL);
+ herr_t ret_value = SUCCEED;
+ FUNC_ENTER(H5M_init_interface, FAIL);
FUNC_LEAVE(ret_value);
-} /* H5M_init_interface */
+} /* H5M_init_interface */
/*--------------------------------------------------------------------------
NAME
@@ -163,19 +165,19 @@ static herr_t H5M_init_interface(void)
Find the type of meta-object to issue a method call on
USAGE
intn H5M_find_type(type)
- hobjtype_t type; IN: Type of object to create
+ hobjtype_t type; IN: Type of object to create
RETURNS
Returns the index of the type in the array of methods on success, or FAIL
- on failure.
+ on failure.
DESCRIPTION
- This function performs a search to find the index of the type of a
+ This function performs a search to find the index of the type of a
meta-object in the array of function pointers.
--------------------------------------------------------------------------*/
static intn
-H5M_find_type (group_t type)
+H5M_find_type(group_t type)
{
- intn i; /* local counting variable */
- intn ret_value = FAIL;
+ intn i; /* local counting variable */
+ intn ret_value = FAIL;
FUNC_ENTER(H5M_find_type, FAIL);
@@ -186,20 +188,17 @@ H5M_find_type (group_t type)
* Currently this uses a stright linear search, which can easily be changed
* to a binary search when it becomes too slow.
*/
- for(i=0; i<(sizeof(meta_func_arr)/sizeof(meta_func_t)); i++)
- if(type==meta_func_arr[i].type)
- HGOTO_DONE(i);
-
-done:
- if(ret_value == FAIL)
- { /* Error condition cleanup */
+ for (i = 0; i < (sizeof(meta_func_arr) / sizeof(meta_func_t)); i++)
+ if (type == meta_func_arr[i].type)
+ HGOTO_DONE(i);
- } /* end if */
+ done:
+ if (ret_value == FAIL) { /* Error condition cleanup */
+ } /* end if */
/* Normal function cleanup */
-
FUNC_LEAVE(ret_value);
-} /* end H5M_find_type() */
+} /* end H5M_find_type() */
/*--------------------------------------------------------------------------
NAME
@@ -208,45 +207,43 @@ done:
Start access to an existing HDF5 object.
USAGE
hid_t H5Maccess(owner_id)
- hid_t oid; IN: OID of the object to access.
+ hid_t oid; IN: OID of the object to access.
RETURNS
Returns ID (atom) on success, FAIL on failure
DESCRIPTION
- This function re-directs the object's access into the appropriate
+ This function re-directs the object's access into the appropriate
interface, as defined by the function pointers in hdf5fptr.h
--------------------------------------------------------------------------*/
-hid_t H5Maccess(hid_t oid)
+hid_t
+H5Maccess(hid_t oid)
{
- group_t group;
- intn i; /* local counting variable */
- hid_t ret_value = SUCCEED;
+ group_t group;
+ intn i; /* local counting variable */
+ hid_t ret_value = SUCCEED;
FUNC_ENTER(H5Maccess, FAIL);
/* Atom group for incoming object */
- group = H5Aatom_group (oid);
+ group = H5Aatom_group(oid);
/* Clear errors and check args and all the boring stuff. */
H5ECLEAR;
- if(group<=BADGROUP || group>=MAXGROUP)
- HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "bad group");
-
- i=H5M_find_type(group);
- if(meta_func_arr[i].access==NULL)
- HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL,
- "no access method");
- ret_value=(meta_func_arr[i].access)(oid);
+ if (group <= BADGROUP || group >= MAXGROUP)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "bad group");
-done:
- if(ret_value == FAIL)
- { /* Error condition cleanup */
+ i = H5M_find_type(group);
+ if (meta_func_arr[i].access == NULL)
+ HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL,
+ "no access method");
+ ret_value = (meta_func_arr[i].access) (oid);
- } /* end if */
+ done:
+ if (ret_value == FAIL) { /* Error condition cleanup */
+ } /* end if */
/* Normal function cleanup */
-
FUNC_LEAVE(ret_value);
-} /* end H5Maccess() */
+} /* end H5Maccess() */
/*--------------------------------------------------------------------------
NAME
@@ -255,41 +252,39 @@ done:
Copy an HDF5 object.
USAGE
hid_t H5Mcopy(oid)
- hid_t oid; IN: Object to copy
+ hid_t oid; IN: Object to copy
RETURNS
SUCCEED/FAIL
DESCRIPTION
- This function re-directs the object's copy into the appropriate
+ This function re-directs the object's copy into the appropriate
interface, as defined by the function pointers in hdf5fptr.h
--------------------------------------------------------------------------*/
-hid_t H5Mcopy(hid_t oid)
+hid_t
+H5Mcopy(hid_t oid)
{
- group_t group=H5Aatom_group(oid); /* Atom group for incoming object */
- intn i; /* local counting variable */
- herr_t ret_value = SUCCEED;
+ group_t group = H5Aatom_group(oid); /* Atom group for incoming object */
+ intn i; /* local counting variable */
+ herr_t ret_value = SUCCEED;
FUNC_ENTER(H5Mcopy, FAIL);
/* Clear errors and check args and all the boring stuff. */
H5ECLEAR;
- if(group<=BADGROUP || group>=MAXGROUP)
- HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "bad group");
-
- i=H5M_find_type(group);
- if(meta_func_arr[i].copy==NULL)
- HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "no copy method");
- ret_value=(meta_func_arr[i].copy)(oid);
+ if (group <= BADGROUP || group >= MAXGROUP)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "bad group");
-done:
- if(ret_value == FAIL)
- { /* Error condition cleanup */
+ i = H5M_find_type(group);
+ if (meta_func_arr[i].copy == NULL)
+ HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "no copy method");
+ ret_value = (meta_func_arr[i].copy) (oid);
- } /* end if */
+ done:
+ if (ret_value == FAIL) { /* Error condition cleanup */
+ } /* end if */
/* Normal function cleanup */
-
FUNC_LEAVE(ret_value);
-} /* end H5Mcopy() */
+} /* end H5Mcopy() */
/*--------------------------------------------------------------------------
NAME
@@ -298,53 +293,50 @@ done:
Find an HDF5 object by name.
USAGE
hid_t H5Mfind_name(owner_id, type, name)
- hid_t owner_id; IN: Group/file in which to search
- hobjtype_t type; IN: Type of object to search names of
- const char *name; IN: Name of the object to search for
+ hid_t owner_id; IN: Group/file in which to search
+ hobjtype_t type; IN: Type of object to search names of
+ const char *name; IN: Name of the object to search for
RETURNS
Returns ID (atom) on success, FAIL on failure
DESCRIPTION
- This function re-directs the object's "find name" into the appropriate
+ This function re-directs the object's "find name" into the appropriate
interface, as defined by the function pointers in hdf5fptr.h
--------------------------------------------------------------------------*/
hid_t
-H5Mfind_name (hid_t owner_id, group_t type, const char *name)
+H5Mfind_name(hid_t owner_id, group_t type, const char *name)
{
#ifdef OLD_WAY
- group_t group=H5Aatom_group(owner_id); /* Atom group for incoming object */
+ group_t group = H5Aatom_group(owner_id); /* Atom group for incoming object */
#endif /* OLD_WAY */
- intn i; /* local counting variable */
- hid_t ret_value = SUCCEED;
+ intn i; /* local counting variable */
+ hid_t ret_value = SUCCEED;
FUNC_ENTER(H5Mfind_name, FAIL);
/* Clear errors and check args and all the boring stuff. */
H5ECLEAR;
#ifdef OLD_WAY
- if(group<=BADGROUP || group>=MAXGROUP)
- HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL);
+ if (group <= BADGROUP || group >= MAXGROUP)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL);
- i=H5M_find_type(group);
+ i = H5M_find_type(group);
#else /* OLD_WAY */
- if(type<=BADGROUP || type>=MAXGROUP)
- HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "bad group");
+ if (type <= BADGROUP || type >= MAXGROUP)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "bad group");
- i=H5M_find_type(type);
+ i = H5M_find_type(type);
#endif /* OLD_WAY */
- if(meta_func_arr[i].find_name==NULL)
- HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "no open method");
- ret_value=(meta_func_arr[i].find_name)(owner_id,type,name);
-
-done:
- if(ret_value == FAIL)
- { /* Error condition cleanup */
+ if (meta_func_arr[i].find_name == NULL)
+ HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "no open method");
+ ret_value = (meta_func_arr[i].find_name) (owner_id, type, name);
- } /* end if */
+ done:
+ if (ret_value == FAIL) { /* Error condition cleanup */
+ } /* end if */
/* Normal function cleanup */
-
FUNC_LEAVE(ret_value);
-} /* end H5Mfind_name() */
+} /* end H5Mfind_name() */
/*--------------------------------------------------------------------------
NAME
@@ -353,41 +345,39 @@ done:
Determine the length of the name of an HDF5 object.
USAGE
uint32 H5Mname_len(oid)
- hid_t oid; IN: Object to get name's length
+ hid_t oid; IN: Object to get name's length
RETURNS
SUCCEED/FAIL
DESCRIPTION
- This function re-directs the object's "name length" into the appropriate
+ This function re-directs the object's "name length" into the appropriate
interface, as defined by the function pointers in hdf5fptr.h
--------------------------------------------------------------------------*/
-uint32 H5Mname_len(hid_t oid)
+uint32
+H5Mname_len(hid_t oid)
{
- group_t group=H5Aatom_group(oid); /* Atom group for incoming object */
- intn i; /* local counting variable */
- herr_t ret_value = SUCCEED;
+ group_t group = H5Aatom_group(oid); /* Atom group for incoming object */
+ intn i; /* local counting variable */
+ herr_t ret_value = SUCCEED;
FUNC_ENTER(H5Mname_len, FAIL);
/* Clear errors and check args and all the boring stuff. */
H5ECLEAR;
- if(group<=BADGROUP || group>=MAXGROUP)
- HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "bad group");
-
- i=H5M_find_type(group);
- if(meta_func_arr[i].name_len==NULL)
- HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "no name_len method");
- ret_value=(meta_func_arr[i].name_len)(oid);
+ if (group <= BADGROUP || group >= MAXGROUP)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "bad group");
-done:
- if(ret_value == FAIL)
- { /* Error condition cleanup */
+ i = H5M_find_type(group);
+ if (meta_func_arr[i].name_len == NULL)
+ HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "no name_len method");
+ ret_value = (meta_func_arr[i].name_len) (oid);
- } /* end if */
+ done:
+ if (ret_value == FAIL) { /* Error condition cleanup */
+ } /* end if */
/* Normal function cleanup */
-
FUNC_LEAVE(ret_value);
-} /* end H5Mname_len() */
+} /* end H5Mname_len() */
/*--------------------------------------------------------------------------
NAME
@@ -396,43 +386,41 @@ done:
Get the name of an HDF5 object.
USAGE
herr_t H5Mget_name(oid, name)
- hid_t oid; IN: Object to retreive name of
- char *name; OUT: Buffer to place object's name in
+ hid_t oid; IN: Object to retreive name of
+ char *name; OUT: Buffer to place object's name in
RETURNS
SUCCEED/FAIL
DESCRIPTION
- This function re-directs the object's "get name" into the appropriate
+ This function re-directs the object's "get name" into the appropriate
interface, as defined by the function pointers in hdf5fptr.h
--------------------------------------------------------------------------*/
-herr_t H5Mget_name(hid_t oid, char *name)
+herr_t
+H5Mget_name(hid_t oid, char *name)
{
- group_t group=H5Aatom_group(oid); /* Atom group for incoming object */
- intn i; /* local counting variable */
- hid_t ret_value = SUCCEED;
+ group_t group = H5Aatom_group(oid); /* Atom group for incoming object */
+ intn i; /* local counting variable */
+ hid_t ret_value = SUCCEED;
FUNC_ENTER(H5Mget_name, FAIL);
/* Clear errors and check args and all the boring stuff. */
H5ECLEAR;
- if(group<=BADGROUP || group>=MAXGROUP)
- HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "bad group");
-
- i=H5M_find_type(group);
- if(meta_func_arr[i].get_name==NULL)
- HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL,
- "no get_name method");
- ret_value=(meta_func_arr[i].get_name)(oid,name);
+ if (group <= BADGROUP || group >= MAXGROUP)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "bad group");
-done:
- if(ret_value == FAIL)
- { /* Error condition cleanup */
+ i = H5M_find_type(group);
+ if (meta_func_arr[i].get_name == NULL)
+ HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL,
+ "no get_name method");
+ ret_value = (meta_func_arr[i].get_name) (oid, name);
- } /* end if */
+ done:
+ if (ret_value == FAIL) { /* Error condition cleanup */
+ } /* end if */
/* Normal function cleanup */
-
FUNC_LEAVE(ret_value);
-} /* end H5Mget_name() */
+} /* end H5Mget_name() */
/*--------------------------------------------------------------------------
NAME
@@ -441,43 +429,41 @@ done:
Set the name of an HDF5 object.
USAGE
herr_t H5Mget_name(oid, name)
- hid_t oid; IN: Object to set name of
- const char *name; IN: Name to use for object
+ hid_t oid; IN: Object to set name of
+ const char *name; IN: Name to use for object
RETURNS
SUCCEED/FAIL
DESCRIPTION
- This function re-directs the object's "set name" into the appropriate
+ This function re-directs the object's "set name" into the appropriate
interface, as defined by the function pointers in hdf5fptr.h
--------------------------------------------------------------------------*/
-herr_t H5Mset_name(hid_t oid, const char *name)
+herr_t
+H5Mset_name(hid_t oid, const char *name)
{
- group_t group=H5Aatom_group(oid); /* Atom group for incoming object */
- intn i; /* local counting variable */
- hid_t ret_value = SUCCEED;
+ group_t group = H5Aatom_group(oid); /* Atom group for incoming object */
+ intn i; /* local counting variable */
+ hid_t ret_value = SUCCEED;
FUNC_ENTER(H5Mset_name, FAIL);
/* Clear errors and check args and all the boring stuff. */
H5ECLEAR;
- if(group<=BADGROUP || group>=MAXGROUP)
- HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "bad group");
-
- i=H5M_find_type(group);
- if(meta_func_arr[i].set_name==NULL)
- HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL,
- "no set_name method");
- ret_value=(meta_func_arr[i].set_name)(oid,name);
+ if (group <= BADGROUP || group >= MAXGROUP)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "bad group");
-done:
- if(ret_value == FAIL)
- { /* Error condition cleanup */
+ i = H5M_find_type(group);
+ if (meta_func_arr[i].set_name == NULL)
+ HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL,
+ "no set_name method");
+ ret_value = (meta_func_arr[i].set_name) (oid, name);
- } /* end if */
+ done:
+ if (ret_value == FAIL) { /* Error condition cleanup */
+ } /* end if */
/* Normal function cleanup */
-
FUNC_LEAVE(ret_value);
-} /* end H5Mset_name() */
+} /* end H5Mset_name() */
/*--------------------------------------------------------------------------
NAME
@@ -486,44 +472,41 @@ done:
Wildcard search for an HDF5 object by name.
USAGE
hid_t H5Mfind_name(owner_id, type, name)
- hid_t owner_id; IN: Group/file in which to search
- hobjtype_t type; IN: Type of object to search names of
- const char *name; IN: Name of the object to search for
+ hid_t owner_id; IN: Group/file in which to search
+ hobjtype_t type; IN: Type of object to search names of
+ const char *name; IN: Name of the object to search for
RETURNS
Returns ID (atom) on success, FAIL on failure
DESCRIPTION
- This function re-directs the object's "search" into the appropriate
+ This function re-directs the object's "search" into the appropriate
interface, as defined by the function pointers in hdf5fptr.h
--------------------------------------------------------------------------*/
hid_t
-H5Msearch (hid_t oid, group_t type, const char *name)
+H5Msearch(hid_t oid, group_t type, const char *name)
{
- group_t group=H5Aatom_group(oid); /* Atom group for incoming object */
- intn i; /* local counting variable */
- hid_t ret_value = SUCCEED;
+ group_t group = H5Aatom_group(oid); /* Atom group for incoming object */
+ intn i; /* local counting variable */
+ hid_t ret_value = SUCCEED;
FUNC_ENTER(H5Msearch, FAIL);
/* Clear errors and check args and all the boring stuff. */
H5ECLEAR;
- if(group<=BADGROUP || group>=MAXGROUP)
- HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "bad group");
+ if (group <= BADGROUP || group >= MAXGROUP)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "bad group");
- i=H5M_find_type(group);
- if(meta_func_arr[i].search==NULL)
- HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "no search method");
- ret_value=(meta_func_arr[i].search)(oid,type,name);
+ i = H5M_find_type(group);
+ if (meta_func_arr[i].search == NULL)
+ HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "no search method");
+ ret_value = (meta_func_arr[i].search) (oid, type, name);
-done:
- if(ret_value == FAIL)
- { /* Error condition cleanup */
-
- } /* end if */
+ done:
+ if (ret_value == FAIL) { /* Error condition cleanup */
+ } /* end if */
/* Normal function cleanup */
-
FUNC_LEAVE(ret_value);
-} /* end H5Msearch() */
+} /* end H5Msearch() */
/*--------------------------------------------------------------------------
NAME
@@ -532,44 +515,41 @@ done:
Get an HDF5 object by index.
USAGE
hid_t H5Mindex(oid, type, idx)
- hid_t oid; IN: Group/file in which to find items
- hobjtype_t type; IN: Type of object to get
- uint32 idx; IN: Index of the object to get
+ hid_t oid; IN: Group/file in which to find items
+ hobjtype_t type; IN: Type of object to get
+ uint32 idx; IN: Index of the object to get
RETURNS
Returns ID (atom) on success, FAIL on failure
DESCRIPTION
- This function re-directs the object's "index" into the appropriate
+ This function re-directs the object's "index" into the appropriate
interface, as defined by the function pointers in hdf5fptr.h
--------------------------------------------------------------------------*/
hid_t
-H5Mindex (hid_t oid, group_t type, uint32 idx)
+H5Mindex(hid_t oid, group_t type, uint32 idx)
{
- group_t group=H5Aatom_group(oid); /* Atom group for incoming object */
- intn i; /* local counting variable */
- hid_t ret_value = SUCCEED;
+ group_t group = H5Aatom_group(oid); /* Atom group for incoming object */
+ intn i; /* local counting variable */
+ hid_t ret_value = SUCCEED;
FUNC_ENTER(H5Mindex, FAIL);
/* Clear errors and check args and all the boring stuff. */
H5ECLEAR;
- if(group<=BADGROUP || group>=MAXGROUP)
- HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "bad group");
+ if (group <= BADGROUP || group >= MAXGROUP)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "bad group");
- i=H5M_find_type(group);
- if(meta_func_arr[i].index==NULL)
- HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "no index method");
- ret_value=(meta_func_arr[i].index)(oid,type,idx);
+ i = H5M_find_type(group);
+ if (meta_func_arr[i].index == NULL)
+ HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "no index method");
+ ret_value = (meta_func_arr[i].index) (oid, type, idx);
-done:
- if(ret_value == FAIL)
- { /* Error condition cleanup */
-
- } /* end if */
+ done:
+ if (ret_value == FAIL) { /* Error condition cleanup */
+ } /* end if */
/* Normal function cleanup */
-
FUNC_LEAVE(ret_value);
-} /* end H5Mindex() */
+} /* end H5Mindex() */
/*--------------------------------------------------------------------------
NAME
@@ -578,43 +558,41 @@ done:
Flush an HDF5 object out to a file.
USAGE
hid_t H5Mflush(oid)
- hid_t oid; IN: Object to flush
+ hid_t oid; IN: Object to flush
RETURNS
SUCCEED/FAIL
DESCRIPTION
- This function re-directs the object's flush into the appropriate
+ This function re-directs the object's flush into the appropriate
interface, as defined by the function pointers in hdf5fptr.h
--------------------------------------------------------------------------*/
-hid_t H5Mflush(hid_t oid)
+hid_t
+H5Mflush(hid_t oid)
{
- group_t group; /* Atom group for incoming object */
- intn i; /* local counting variable */
- herr_t ret_value = SUCCEED;
+ group_t group; /* Atom group for incoming object */
+ intn i; /* local counting variable */
+ herr_t ret_value = SUCCEED;
FUNC_ENTER(H5Mflush, FAIL); /* Insert function initialization code and variables */
/* Clear errors and check args and all the boring stuff. */
H5ECLEAR;
- group=H5Aatom_group(oid); /* look up group for incoming object */
- if(group<=BADGROUP || group>=MAXGROUP)
- HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "bad group");
+ group = H5Aatom_group(oid); /* look up group for incoming object */
+ if (group <= BADGROUP || group >= MAXGROUP)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "bad group");
/* Find correct function pointer set from static array */
- i=H5M_find_type(group);
- if(meta_func_arr[i].flush==NULL)
- HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "no flush method");
- ret_value=(meta_func_arr[i].flush)(oid);
+ i = H5M_find_type(group);
+ if (meta_func_arr[i].flush == NULL)
+ HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "no flush method");
+ ret_value = (meta_func_arr[i].flush) (oid);
-done:
- if(ret_value == FAIL)
- { /* Error condition cleanup */
-
- } /* end if */
+ done:
+ if (ret_value == FAIL) { /* Error condition cleanup */
+ } /* end if */
/* Normal function cleanup */
-
- FUNC_LEAVE(ret_value); /* Insert function prologue code */
-} /* end H5Mflush() */
+ FUNC_LEAVE(ret_value); /* Insert function prologue code */
+} /* end H5Mflush() */
/*--------------------------------------------------------------------------
NAME
@@ -623,42 +601,40 @@ done:
Delete an HDF5 object from a file.
USAGE
herr_t H5Mdelete(oid)
- hid_t oid; IN: Object to delete
+ hid_t oid; IN: Object to delete
RETURNS
SUCCEED/FAIL
DESCRIPTION
- This function re-directs the object's delete into the appropriate
+ This function re-directs the object's delete into the appropriate
interface, as defined by the function pointers in hdf5fptr.h. Deleting
an object implicitly ends access to it.
--------------------------------------------------------------------------*/
-herr_t H5Mdelete(hid_t oid)
+herr_t
+H5Mdelete(hid_t oid)
{
- group_t group=H5Aatom_group(oid); /* Atom group for incoming object */
- intn i; /* local counting variable */
- herr_t ret_value = SUCCEED;
+ group_t group = H5Aatom_group(oid); /* Atom group for incoming object */
+ intn i; /* local counting variable */
+ herr_t ret_value = SUCCEED;
FUNC_ENTER(H5Mdelete, FAIL);
/* Clear errors and check args and all the boring stuff. */
H5ECLEAR;
- if(group<=BADGROUP || group>=MAXGROUP)
- HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "bad group");
+ if (group <= BADGROUP || group >= MAXGROUP)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "bad group");
- i=H5M_find_type(group);
- if(meta_func_arr[i].delete==NULL)
- HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "no delete method");
- ret_value=(meta_func_arr[i].delete)(oid);
+ i = H5M_find_type(group);
+ if (meta_func_arr[i].delete == NULL)
+ HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "no delete method");
+ ret_value = (meta_func_arr[i].delete) (oid);
-done:
- if(ret_value == FAIL)
- { /* Error condition cleanup */
-
- } /* end if */
+ done:
+ if (ret_value == FAIL) { /* Error condition cleanup */
+ } /* end if */
/* Normal function cleanup */
-
FUNC_LEAVE(ret_value);
-} /* end H5Mdelete() */
+} /* end H5Mdelete() */
/*--------------------------------------------------------------------------
NAME
@@ -667,42 +643,40 @@ done:
Get the parent ID an HDF5 object.
USAGE
hid_t H5Mget_parent(oid)
- hid_t oid; IN: Object to query
+ hid_t oid; IN: Object to query
RETURNS
SUCCEED/FAIL
DESCRIPTION
- This function re-directs the object's query into the appropriate
+ This function re-directs the object's query into the appropriate
interface, as defined by the function pointers in hdf5fptr.h
--------------------------------------------------------------------------*/
-hid_t H5Mget_parent(hid_t oid)
+hid_t
+H5Mget_parent(hid_t oid)
{
- group_t group=H5Aatom_group(oid); /* Atom group for incoming object */
- intn i; /* local counting variable */
- herr_t ret_value = SUCCEED;
+ group_t group = H5Aatom_group(oid); /* Atom group for incoming object */
+ intn i; /* local counting variable */
+ herr_t ret_value = SUCCEED;
FUNC_ENTER(H5Mget_parent, FAIL);
/* Clear errors and check args and all the boring stuff. */
H5ECLEAR;
- if(group<=BADGROUP || group>=MAXGROUP)
- HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "bad group");
+ if (group <= BADGROUP || group >= MAXGROUP)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "bad group");
- i=H5M_find_type(group);
- if(meta_func_arr[i].get_parent==NULL)
- HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL,
- "no get_parent method");
- ret_value=(meta_func_arr[i].get_parent)(oid);
+ i = H5M_find_type(group);
+ if (meta_func_arr[i].get_parent == NULL)
+ HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL,
+ "no get_parent method");
+ ret_value = (meta_func_arr[i].get_parent) (oid);
-done:
- if(ret_value == FAIL)
- { /* Error condition cleanup */
-
- } /* end if */
+ done:
+ if (ret_value == FAIL) { /* Error condition cleanup */
+ } /* end if */
/* Normal function cleanup */
-
FUNC_LEAVE(ret_value);
-} /* end H5Mget_parent() */
+} /* end H5Mget_parent() */
/*--------------------------------------------------------------------------
NAME
@@ -711,42 +685,40 @@ done:
Get the file ID an HDF5 object.
USAGE
hid_t H5Mget_file(oid)
- hid_t oid; IN: Object to query
+ hid_t oid; IN: Object to query
RETURNS
SUCCEED/FAIL
DESCRIPTION
- This function re-directs the object's query into the appropriate
+ This function re-directs the object's query into the appropriate
interface, as defined by the function pointers in hdf5fptr.h
--------------------------------------------------------------------------*/
-hid_t H5Mget_file(hid_t oid)
+hid_t
+H5Mget_file(hid_t oid)
{
- group_t group=H5Aatom_group(oid); /* Atom group for incoming object */
- intn i; /* local counting variable */
- herr_t ret_value = SUCCEED;
+ group_t group = H5Aatom_group(oid); /* Atom group for incoming object */
+ intn i; /* local counting variable */
+ herr_t ret_value = SUCCEED;
FUNC_ENTER(H5Mget_file, FAIL);
/* Clear errors and check args and all the boring stuff. */
H5ECLEAR;
- if(group<=BADGROUP || group>=MAXGROUP)
- HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "bad group");
+ if (group <= BADGROUP || group >= MAXGROUP)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "bad group");
- i=H5M_find_type(group);
- if(meta_func_arr[i].get_file==NULL)
- HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL,
- "no get_file method");
- ret_value=(meta_func_arr[i].get_file)(oid);
+ i = H5M_find_type(group);
+ if (meta_func_arr[i].get_file == NULL)
+ HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL,
+ "no get_file method");
+ ret_value = (meta_func_arr[i].get_file) (oid);
-done:
- if(ret_value == FAIL)
- { /* Error condition cleanup */
-
- } /* end if */
+ done:
+ if (ret_value == FAIL) { /* Error condition cleanup */
+ } /* end if */
/* Normal function cleanup */
-
FUNC_LEAVE(ret_value);
-} /* end H5Mget_file() */
+} /* end H5Mget_file() */
/*--------------------------------------------------------------------------
NAME
@@ -755,39 +727,36 @@ done:
Release access to an HDF5 object.
USAGE
herr_t H5Mclose(oid)
- hid_t oid; IN: Object to release access to
+ hid_t oid; IN: Object to release access to
RETURNS
SUCCEED/FAIL
DESCRIPTION
- This function re-directs the object's release into the appropriate
+ This function re-directs the object's release into the appropriate
interface, as defined by the function pointers in hdf5fptr.h
--------------------------------------------------------------------------*/
-herr_t H5Mclose(hid_t oid)
+herr_t
+H5Mclose(hid_t oid)
{
- group_t group=H5Aatom_group(oid); /* Atom group for incoming object */
- intn i; /* local counting variable */
- herr_t ret_value = SUCCEED;
+ group_t group = H5Aatom_group(oid); /* Atom group for incoming object */
+ intn i; /* local counting variable */
+ herr_t ret_value = SUCCEED;
FUNC_ENTER(H5Mclose, FAIL);
/* Clear errors and check args and all the boring stuff. */
H5ECLEAR;
- if(group<=BADGROUP || group>=MAXGROUP)
- HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "bad group");
+ if (group <= BADGROUP || group >= MAXGROUP)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "bad group");
- i=H5M_find_type(group);
- if(meta_func_arr[i].close==NULL)
- HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "no close method");
- ret_value=(meta_func_arr[i].close)(oid);
+ i = H5M_find_type(group);
+ if (meta_func_arr[i].close == NULL)
+ HGOTO_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, FAIL, "no close method");
+ ret_value = (meta_func_arr[i].close) (oid);
-done:
- if(ret_value == FAIL)
- { /* Error condition cleanup */
-
- } /* end if */
+ done:
+ if (ret_value == FAIL) { /* Error condition cleanup */
+ } /* end if */
/* Normal function cleanup */
-
FUNC_LEAVE(ret_value);
}
-
diff --git a/src/H5MF.c b/src/H5MF.c
index 036e929..6e0c257 100644
--- a/src/H5MF.c
+++ b/src/H5MF.c
@@ -1,19 +1,19 @@
/*-------------------------------------------------------------------------
- * Copyright (C) 1997 National Center for Supercomputing Applications.
+ * Copyright (C) 1997 National Center for Supercomputing Applications.
* All rights reserved.
*
*-------------------------------------------------------------------------
*
- * Created: H5MF.c
- * Jul 11 1997
- * Robb Matzke <matzke@llnl.gov>
+ * Created: H5MF.c
+ * Jul 11 1997
+ * Robb Matzke <matzke@llnl.gov>
*
- * Purpose: File memory management functions.
+ * Purpose: File memory management functions.
*
* Modifications:
*
- * Robb Matzke, 5 Aug 1997
- * Added calls to H5E.
+ * Robb Matzke, 5 Aug 1997
+ * Added calls to H5E.
*
*-------------------------------------------------------------------------
*/
@@ -22,106 +22,103 @@
#include <H5Fprivate.h>
#include <H5MFprivate.h>
-#define PABLO_MASK H5MF_mask
+#define PABLO_MASK H5MF_mask
/* Is the interface initialized? */
-static intn interface_initialize_g = FALSE;
-#define INTERFACE_INIT NULL
-
+static intn interface_initialize_g = FALSE;
+#define INTERFACE_INIT NULL
/*-------------------------------------------------------------------------
- * Function: H5MF_alloc
+ * Function: H5MF_alloc
*
- * Purpose: Allocate at least SIZE bytes of file memory and return
- * the address where that contiguous chunk of file memory
- * exists. The allocation operation should be either H5MF_META or
- * H5MF_RAW depending on the purpose for which the storage is
- * being requested.
+ * Purpose: Allocate at least SIZE bytes of file memory and return
+ * the address where that contiguous chunk of file memory
+ * exists. The allocation operation should be either H5MF_META or
+ * H5MF_RAW depending on the purpose for which the storage is
+ * being requested.
*
- * Return: Success: SUCCEED. The file address of new chunk is
- * returned through the ADDR argument.
+ * Return: Success: SUCCEED. The file address of new chunk is
+ * returned through the ADDR argument.
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jul 11 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jul 11 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
-H5MF_alloc (H5F_t *f, intn op, size_t size, haddr_t *addr/*out*/)
+H5MF_alloc(H5F_t *f, intn op, size_t size, haddr_t *addr /*out */ )
{
- haddr_t tmp_addr;
-
- FUNC_ENTER (H5MF_alloc, FAIL);
+ haddr_t tmp_addr;
- /* check arguments */
- assert (f);
- assert (H5MF_META==op || H5MF_RAW==op);
- assert (size>0);
- assert (addr);
+ FUNC_ENTER(H5MF_alloc, FAIL);
- /*
- * Eventually we'll maintain a free list(s) and try to satisfy requests
- * from there. But for now we just allocate more memory from the end of
- * the file.
- */
- if (H5F_low_extend (f->shared->lf, op, size, addr/*out*/)<0) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "low level mem management failed");
- }
- /* Convert from absolute to relative */
- addr->offset -= f->shared->base_addr.offset;
+ /* check arguments */
+ assert(f);
+ assert(H5MF_META == op || H5MF_RAW == op);
+ assert(size > 0);
+ assert(addr);
- /* Did we extend the size of the hdf5 data? */
- tmp_addr = *addr;
- H5F_addr_inc (&tmp_addr, size);
- if (H5F_addr_gt (&tmp_addr, &(f->shared->hdf5_eof))) {
- f->shared->hdf5_eof = tmp_addr;
- }
-
- FUNC_LEAVE (SUCCEED);
-}
+ /*
+ * Eventually we'll maintain a free list(s) and try to satisfy requests
+ * from there. But for now we just allocate more memory from the end of
+ * the file.
+ */
+ if (H5F_low_extend(f->shared->lf, op, size, addr /*out */ ) < 0) {
+ HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "low level mem management failed");
+ }
+ /* Convert from absolute to relative */
+ addr->offset -= f->shared->base_addr.offset;
+ /* Did we extend the size of the hdf5 data? */
+ tmp_addr = *addr;
+ H5F_addr_inc(&tmp_addr, size);
+ if (H5F_addr_gt(&tmp_addr, &(f->shared->hdf5_eof))) {
+ f->shared->hdf5_eof = tmp_addr;
+ }
+ FUNC_LEAVE(SUCCEED);
+}
/*-------------------------------------------------------------------------
- * Function: H5MF_free
+ * Function: H5MF_free
*
- * Purpose: Frees part of a file, making that part of the file
- * available for reuse.
+ * Purpose: Frees part of a file, making that part of the file
+ * available for reuse.
*
- * Note: This version of the function doesn't do anything.
+ * Note: This version of the function doesn't do anything.
*
- * Return: Success: 0
+ * Return: Success: 0
*
- * Failure: -1
+ * Failure: -1
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jul 17 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jul 17 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
-H5MF_free (H5F_t *f, const haddr_t *addr, size_t size)
+H5MF_free(H5F_t *f, const haddr_t *addr, size_t size)
{
- FUNC_ENTER (H5MF_free, FAIL);
+ FUNC_ENTER(H5MF_free, FAIL);
- /* check arguments */
- assert (f);
- if (!addr || !H5F_addr_defined (addr) || 0==size) HRETURN (SUCCEED);
- assert (!H5F_addr_zerop (addr));
+ /* check arguments */
+ assert(f);
+ if (!addr || !H5F_addr_defined(addr) || 0 == size)
+ HRETURN(SUCCEED);
+ assert(!H5F_addr_zerop(addr));
#ifndef NDEBUG
- fprintf (stderr, "H5MF_free: lost %lu bytes of file storage\n",
- (unsigned long)size);
+ fprintf(stderr, "H5MF_free: lost %lu bytes of file storage\n",
+ (unsigned long) size);
#endif
- FUNC_LEAVE (SUCCEED);
+ FUNC_LEAVE(SUCCEED);
}
-
diff --git a/src/H5MFprivate.h b/src/H5MFprivate.h
index 470db89..d797780 100644
--- a/src/H5MFprivate.h
+++ b/src/H5MFprivate.h
@@ -1,16 +1,16 @@
/*-------------------------------------------------------------------------
- * Copyright (C) 1997 National Center for Supercomputing Applications.
+ * Copyright (C) 1997 National Center for Supercomputing Applications.
* All rights reserved.
*
*-------------------------------------------------------------------------
*
- * Created: H5MFprivate.h
- * Jul 11 1997
- * Robb Matzke <matzke@llnl.gov>
+ * Created: H5MFprivate.h
+ * Jul 11 1997
+ * Robb Matzke <matzke@llnl.gov>
*
- * Purpose: Private header file for file memory management.
+ * Purpose: Private header file for file memory management.
*
- * Modifications:
+ * Modifications:
*
*-------------------------------------------------------------------------
*/
@@ -22,13 +22,13 @@
#include <H5private.h>
#include <H5Fprivate.h>
-#define H5MF_META 0 /*request storage for meta data */
-#define H5MF_RAW 1 /*request storage for raw data */
+#define H5MF_META 0 /*request storage for meta data */
+#define H5MF_RAW 1 /*request storage for raw data */
/*
* Library prototypes...
*/
-herr_t H5MF_alloc (H5F_t *f, intn, size_t size, haddr_t *addr/*out*/);
-herr_t H5MF_free (H5F_t *f, const haddr_t *addr, size_t size);
+herr_t H5MF_alloc(H5F_t *f, intn, size_t size, haddr_t *addr /*out */ );
+herr_t H5MF_free(H5F_t *f, const haddr_t *addr, size_t size);
#endif
diff --git a/src/H5MFpublic.h b/src/H5MFpublic.h
index 4a89c25..5b59f5f 100644
--- a/src/H5MFpublic.h
+++ b/src/H5MFpublic.h
@@ -1,17 +1,17 @@
/*-------------------------------------------------------------------------
- * Copyright (C) 1997 National Center for Supercomputing Applications.
+ * Copyright (C) 1997 National Center for Supercomputing Applications.
* All rights reserved.
*
*-------------------------------------------------------------------------
*
- * Created: H5MFproto.h
- * Jul 11 1997
- * Robb Matzke <matzke@llnl.gov>
+ * Created: H5MFproto.h
+ * Jul 11 1997
+ * Robb Matzke <matzke@llnl.gov>
*
- * Purpose: Public declarations for the H5MF (file memory
- * management) package.
+ * Purpose: Public declarations for the H5MF (file memory
+ * management) package.
*
- * Modifications:
+ * Modifications:
*
*-------------------------------------------------------------------------
*/
@@ -22,11 +22,11 @@
#include <H5public.h>
#ifdef __cplusplus
-extern "C" {
+extern "C" {
#endif
#ifdef __cplusplus
}
-#endif
#endif
+#endif
diff --git a/src/H5MM.c b/src/H5MM.c
index b8682c4..645798e 100644
--- a/src/H5MM.c
+++ b/src/H5MM.c
@@ -1,183 +1,181 @@
/*-------------------------------------------------------------------------
- * Copyright (C) 1997 National Center for Supercomputing Applications.
+ * Copyright (C) 1997 National Center for Supercomputing Applications.
* All rights reserved.
*
*-------------------------------------------------------------------------
*
- * Created: H5MM.c
- * Jul 10 1997
- * Robb Matzke <matzke@llnl.gov>
+ * Created: H5MM.c
+ * Jul 10 1997
+ * Robb Matzke <matzke@llnl.gov>
*
- * Purpose: Memory management functions.
+ * Purpose: Memory management functions.
*
- * Modifications:
+ * Modifications:
*
*-------------------------------------------------------------------------
*/
#include <H5private.h>
#include <H5MMprivate.h>
-
/*-------------------------------------------------------------------------
- * Function: H5MM_xmalloc
+ * Function: H5MM_xmalloc
*
- * Purpose: Just like malloc(3) except it aborts on an error.
+ * Purpose: Just like malloc(3) except it aborts on an error.
*
- * Return: Success: Ptr to new memory.
+ * Return: Success: Ptr to new memory.
*
- * Failure: abort()
+ * Failure: abort()
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jul 10 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jul 10 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-void *
-H5MM_xmalloc (size_t size)
+void *
+H5MM_xmalloc(size_t size)
{
- void *mem = HDmalloc (size);
- assert (mem);
- return mem;
+ void *mem = HDmalloc(size);
+ assert(mem);
+ return mem;
}
-
/*-------------------------------------------------------------------------
- * Function: H5MM_xcalloc
+ * Function: H5MM_xcalloc
*
- * Purpose: Just like calloc(3) except it aborts on an error.
+ * Purpose: Just like calloc(3) except it aborts on an error.
*
- * Return: Success: Ptr to memory.
+ * Return: Success: Ptr to memory.
*
- * Failure: abort()
+ * Failure: abort()
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jul 10 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jul 10 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-void *
-H5MM_xcalloc (size_t n, size_t size)
+void *
+H5MM_xcalloc(size_t n, size_t size)
{
- void *mem = HDcalloc (n, size);
- assert (mem);
- return mem;
+ void *mem = HDcalloc(n, size);
+ assert(mem);
+ return mem;
}
-
/*-------------------------------------------------------------------------
- * Function: H5MM_xrealloc
+ * Function: H5MM_xrealloc
*
- * Purpose: Just like the POSIX version of realloc(3) exept it aborts
- * on an error. Specifically, the following calls are
- * equivalent
+ * Purpose: Just like the POSIX version of realloc(3) exept it aborts
+ * on an error. Specifically, the following calls are
+ * equivalent
*
- * H5MM_xrealloc (NULL, size) <==> H5MM_xmalloc (size)
- * H5MM_xrealloc (ptr, 0) <==> H5MM_xfree (ptr)
- * H5MM_xrealloc (NULL, 0) <==> NULL
+ * H5MM_xrealloc (NULL, size) <==> H5MM_xmalloc (size)
+ * H5MM_xrealloc (ptr, 0) <==> H5MM_xfree (ptr)
+ * H5MM_xrealloc (NULL, 0) <==> NULL
*
- * Return: Success: Ptr to new memory or NULL if the memory
- * was freed.
+ * Return: Success: Ptr to new memory or NULL if the memory
+ * was freed.
*
- * Failure: abort()
+ * Failure: abort()
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jul 10 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jul 10 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-void *
-H5MM_xrealloc (void *mem, size_t size)
+void *
+H5MM_xrealloc(void *mem, size_t size)
{
- if (!mem) {
- if (0==size) return NULL;
- mem = H5MM_xmalloc (size);
-
- } else if (0==size) {
- mem = H5MM_xfree (mem);
+ if (!mem) {
+ if (0 == size)
+ return NULL;
+ mem = H5MM_xmalloc(size);
- } else {
- mem = HDrealloc (mem, size);
- assert (mem);
- }
+ } else if (0 == size) {
+ mem = H5MM_xfree(mem);
- return mem;
-}
+ } else {
+ mem = HDrealloc(mem, size);
+ assert(mem);
+ }
+ return mem;
+}
/*-------------------------------------------------------------------------
- * Function: H5MM_strdup
+ * Function: H5MM_strdup
*
- * Purpose: Duplicates a string. If the string to be duplicated is the
- * null pointer, then return null. If the string to be duplicated
- * is the empty string then return a new empty string.
+ * Purpose: Duplicates a string. If the string to be duplicated is the
+ * null pointer, then return null. If the string to be duplicated
+ * is the empty string then return a new empty string.
*
- * Return: Success: Ptr to a new string (or null if no string).
+ * Return: Success: Ptr to a new string (or null if no string).
*
- * Failure: abort()
+ * Failure: abort()
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jul 10 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jul 10 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-char *
-H5MM_xstrdup (const char *s)
+char *
+H5MM_xstrdup(const char *s)
{
- char *mem;
+ char *mem;
- if (!s) return NULL;
- mem = H5MM_xmalloc (HDstrlen (s)+1);
- HDstrcpy (mem, s);
- return mem;
+ if (!s)
+ return NULL;
+ mem = H5MM_xmalloc(HDstrlen(s) + 1);
+ HDstrcpy(mem, s);
+ return mem;
}
-
/*-------------------------------------------------------------------------
- * Function: H5MM_xfree
+ * Function: H5MM_xfree
*
- * Purpose: Just like free(3) except null pointers are allowed as
- * arguments, and the return value (always NULL) can be
- * assigned to the pointer whose memory was just freed:
+ * Purpose: Just like free(3) except null pointers are allowed as
+ * arguments, and the return value (always NULL) can be
+ * assigned to the pointer whose memory was just freed:
*
- * thing = H5MM_xfree (thing);
+ * thing = H5MM_xfree (thing);
*
- * Return: Success: NULL
+ * Return: Success: NULL
*
- * Failure: never fails
+ * Failure: never fails
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jul 10 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jul 10 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-void *
-H5MM_xfree (const void *mem)
+void *
+H5MM_xfree(const void *mem)
{
- /*
- * free(3) takes a non-const pointer as an argument even though
- * conceptually the argument could be a constant because by time
- * free() mucks with it's contents, it should already be free :-)
- * Instead of passing a const arg to free, which generates a
- * compiler warning, we cast it to a non-const arg first. With
- * gcc, this results in a warning only if -Wcast-qual is turned on.
- */
- void *non_const_mem = (void *)mem;
-
- if (mem) HDfree (non_const_mem);
- return NULL;
+ /*
+ * free(3) takes a non-const pointer as an argument even though
+ * conceptually the argument could be a constant because by time
+ * free() mucks with it's contents, it should already be free :-)
+ * Instead of passing a const arg to free, which generates a
+ * compiler warning, we cast it to a non-const arg first. With
+ * gcc, this results in a warning only if -Wcast-qual is turned on.
+ */
+ void *non_const_mem = (void *) mem;
+
+ if (mem)
+ HDfree(non_const_mem);
+ return NULL;
}
diff --git a/src/H5MMprivate.h b/src/H5MMprivate.h
index 7e95d70..5312df8 100644
--- a/src/H5MMprivate.h
+++ b/src/H5MMprivate.h
@@ -1,16 +1,16 @@
/*-------------------------------------------------------------------------
- * Copyright (C) 1997 National Center for Supercomputing Applications.
+ * Copyright (C) 1997 National Center for Supercomputing Applications.
* All rights reserved.
*
*-------------------------------------------------------------------------
*
- * Created: H5MMprivate.h
- * Jul 10 1997
- * Robb Matzke <matzke@llnl.gov>
+ * Created: H5MMprivate.h
+ * Jul 10 1997
+ * Robb Matzke <matzke@llnl.gov>
*
- * Purpose: Private header for memory management.
+ * Purpose: Private header for memory management.
*
- * Modifications:
+ * Modifications:
*
*-------------------------------------------------------------------------
*/
@@ -24,11 +24,10 @@
/*
* Library prototypes...
*/
-void *H5MM_xmalloc (size_t size);
-void *H5MM_xcalloc (size_t n, size_t size);
-void *H5MM_xrealloc (void *mem, size_t size);
-char *H5MM_xstrdup (const char *s);
-void *H5MM_xfree (const void *mem);
-
+void *H5MM_xmalloc(size_t size);
+void *H5MM_xcalloc(size_t n, size_t size);
+void *H5MM_xrealloc(void *mem, size_t size);
+char *H5MM_xstrdup(const char *s);
+void *H5MM_xfree(const void *mem);
#endif
diff --git a/src/H5MMpublic.h b/src/H5MMpublic.h
index 5a2ab26..d0241c9 100644
--- a/src/H5MMpublic.h
+++ b/src/H5MMpublic.h
@@ -1,17 +1,17 @@
/*-------------------------------------------------------------------------
- * Copyright (C) 1997 National Center for Supercomputing Applications.
+ * Copyright (C) 1997 National Center for Supercomputing Applications.
* All rights reserved.
*
*-------------------------------------------------------------------------
*
- * Created: H5MMproto.h
- * Jul 10 1997
- * Robb Matzke <matzke@llnl.gov>
+ * Created: H5MMproto.h
+ * Jul 10 1997
+ * Robb Matzke <matzke@llnl.gov>
*
- * Purpose: Public declarations for the H5MM (memory management)
- * package.
+ * Purpose: Public declarations for the H5MM (memory management)
+ * package.
*
- * Modifications:
+ * Modifications:
*
*-------------------------------------------------------------------------
*/
@@ -22,11 +22,11 @@
#include <H5public.h>
#ifdef __cplusplus
-extern "C" {
+extern "C" {
#endif
#ifdef __cplusplus
}
-#endif
#endif
+#endif
diff --git a/src/H5Mprivate.h b/src/H5Mprivate.h
index 3620df2..badc741 100644
--- a/src/H5Mprivate.h
+++ b/src/H5Mprivate.h
@@ -18,7 +18,7 @@
#ifndef _H5Mprivate_H
#define _H5Mprivate_H
-#include <H5Mpublic.h> /* Include Public Definitions */
+#include <H5Mpublic.h> /* Include Public Definitions */
/* Private headers needed by this file */
#include <H5private.h>
@@ -27,26 +27,23 @@
* A function table record for accessing interfaces which use the "meta"
* interface to create/open/close objects.
*/
-typedef struct meta_func_t
- {
- group_t type; /* Object type this interface is for */
- hid_t (*create) (hid_t , group_t, const char *); /* Object creation function */
- hid_t (*access) (hid_t ); /* Object access function */
- hid_t (*copy) (hid_t ); /* Object copy function */
- hid_t (*find_name) (hid_t , group_t, const char *); /* Find first object */
- uint32 (*name_len) (hid_t ); /* Get length of object name */
- herr_t (*get_name) (hid_t , char *); /* Get object name */
- herr_t (*set_name) (hid_t , const char *); /* Set object name */
- hid_t (*search) (hid_t , group_t, const char *); /* Search for list of objects */
- hid_t (*index) (hid_t , group_t, uint32); /* Get the OID for the n'th object */
- herr_t (*flush) (hid_t ); /* Flush the object to disk */
- herr_t (*delete) (hid_t ); /* Delete an object from file */
- hid_t (*get_parent) (hid_t ); /* Get the parent object of an object */
- hid_t (*get_file) (hid_t ); /* Get the file ID of an object */
- herr_t (*close) (hid_t ); /* End access to an object */
- }
-meta_func_t;
-
+typedef struct meta_func_t {
+ group_t type; /* Object type this interface is for */
+ hid_t (*create) (hid_t, group_t, const char *); /* Object creation function */
+ hid_t (*access) (hid_t); /* Object access function */
+ hid_t (*copy) (hid_t); /* Object copy function */
+ hid_t (*find_name) (hid_t, group_t, const char *); /* Find first object */
+ uint32 (*name_len) (hid_t); /* Get length of object name */
+ herr_t (*get_name) (hid_t, char *); /* Get object name */
+ herr_t (*set_name) (hid_t, const char *); /* Set object name */
+ hid_t (*search) (hid_t, group_t, const char *); /* Search for list of objects */
+ hid_t (*index) (hid_t, group_t, uint32); /* Get the OID for the n'th object */
+ herr_t (*flush) (hid_t); /* Flush the object to disk */
+ herr_t (*delete) (hid_t); /* Delete an object from file */
+ hid_t (*get_parent) (hid_t); /* Get the parent object of an object */
+ hid_t (*get_file) (hid_t); /* Get the file ID of an object */
+ herr_t (*close) (hid_t); /* End access to an object */
+} meta_func_t;
/* Private functions, not part of the publicly documented API */
diff --git a/src/H5Mpublic.h b/src/H5Mpublic.h
index 8d5b905..93947e0 100644
--- a/src/H5Mpublic.h
+++ b/src/H5Mpublic.h
@@ -21,30 +21,29 @@
/* Public headers needed by this file */
#include <H5public.h>
-#include <H5Cpublic.h> /*for hobjtype_t defn*/
-
+#include <H5Cpublic.h> /*for hobjtype_t defn */
#ifdef __cplusplus
-extern "C" {
+extern "C" {
#endif
/* Functions in H5M.c */
-hid_t H5Maccess(hid_t oid);
-hid_t H5Mcopy(hid_t oid);
-hid_t H5Mfind_name(hid_t oid, group_t type, const char *name);
-uint32 H5Mname_len(hid_t oid);
-herr_t H5Mget_name(hid_t oid, char *name);
-herr_t H5Mset_name(hid_t oid, const char *name);
-hid_t H5Msearch(hid_t oid, group_t type, const char *name);
-hid_t H5Mindex(hid_t oid, group_t type, uint32 idx);
-hid_t H5Mflush(hid_t oid);
-herr_t H5Mdelete(hid_t oid);
-hid_t H5Mget_file(hid_t oid);
-hid_t H5Mget_parent(hid_t oid);
-herr_t H5Mclose(hid_t oid);
+ hid_t H5Maccess(hid_t oid);
+ hid_t H5Mcopy(hid_t oid);
+ hid_t H5Mfind_name(hid_t oid, group_t type, const char *name);
+ uint32 H5Mname_len(hid_t oid);
+ herr_t H5Mget_name(hid_t oid, char *name);
+ herr_t H5Mset_name(hid_t oid, const char *name);
+ hid_t H5Msearch(hid_t oid, group_t type, const char *name);
+ hid_t H5Mindex(hid_t oid, group_t type, uint32 idx);
+ hid_t H5Mflush(hid_t oid);
+ herr_t H5Mdelete(hid_t oid);
+ hid_t H5Mget_file(hid_t oid);
+ hid_t H5Mget_parent(hid_t oid);
+ herr_t H5Mclose(hid_t oid);
#ifdef __cplusplus
}
-#endif
#endif
+#endif
diff --git a/src/H5O.c b/src/H5O.c
index 18c6b10..d3b9f08 100644
--- a/src/H5O.c
+++ b/src/H5O.c
@@ -1,16 +1,16 @@
/*-------------------------------------------------------------------------
- * Copyright (C) 1997 National Center for Supercomputing Applications.
+ * Copyright (C) 1997 National Center for Supercomputing Applications.
* All rights reserved.
*
*-------------------------------------------------------------------------
*
- * Created: H5O.c
- * Aug 5 1997
- * Robb Matzke <matzke@llnl.gov>
+ * Created: H5O.c
+ * Aug 5 1997
+ * Robb Matzke <matzke@llnl.gov>
*
- * Purpose: Object header virtual functions.
+ * Purpose: Object header virtual functions.
*
- * Modifications:
+ * Modifications:
*
*-------------------------------------------------------------------------
*/
@@ -22,52 +22,55 @@
#include <H5MMprivate.h>
#include <H5Oprivate.h>
-#define PABLO_MASK H5O_mask
+#define PABLO_MASK H5O_mask
/* PRIVATE PROTOTYPES */
-static herr_t H5O_flush (H5F_t *f, hbool_t destroy, const haddr_t *addr,
- H5O_t *oh);
-static H5O_t *H5O_load (H5F_t *f, const haddr_t *addr, const void *_udata1,
- void *_udata2);
-static intn H5O_find_in_ohdr (H5F_t *f, const haddr_t *addr,
- const H5O_class_t **type_p, intn sequence);
-static intn H5O_alloc (H5F_t *f, H5O_t *oh, const H5O_class_t *type,
- size_t size);
-static intn H5O_alloc_extend_chunk (H5O_t *oh, intn chunkno, size_t size);
-static intn H5O_alloc_new_chunk (H5F_t *f, H5O_t *oh, size_t size);
+static herr_t H5O_flush(H5F_t *f, hbool_t destroy, const haddr_t *addr,
+ H5O_t *oh);
+static H5O_t *H5O_load(H5F_t *f, const haddr_t *addr, const void *_udata1,
+ void *_udata2);
+static intn H5O_find_in_ohdr(H5F_t *f, const haddr_t *addr,
+ const H5O_class_t **type_p, intn sequence);
+static intn H5O_alloc(H5F_t *f, H5O_t *oh, const H5O_class_t *type,
+ size_t size);
+static intn H5O_alloc_extend_chunk(H5O_t *oh, intn chunkno, size_t size);
+static intn H5O_alloc_new_chunk(H5F_t *f, H5O_t *oh, size_t size);
/* H5O inherits cache-like properties from H5AC */
-static const H5AC_class_t H5AC_OHDR[1] = {{
- H5AC_OHDR_ID,
- (void*(*)(H5F_t*,const haddr_t*,const void*,void*))H5O_load,
- (herr_t(*)(H5F_t*,hbool_t,const haddr_t*,void*))H5O_flush,
-}};
+static const H5AC_class_t H5AC_OHDR[1] =
+{
+ {
+ H5AC_OHDR_ID,
+ (void *(*)(H5F_t *, const haddr_t *, const void *, void *)) H5O_load,
+ (herr_t (*)(H5F_t *, hbool_t, const haddr_t *, void *)) H5O_flush,
+ }};
/* Interface initialization */
-static intn interface_initialize_g = FALSE;
-#define INTERFACE_INIT H5O_init_interface
-static herr_t H5O_init_interface (void);
+static intn interface_initialize_g = FALSE;
+#define INTERFACE_INIT H5O_init_interface
+static herr_t H5O_init_interface(void);
/* ID to type mapping */
-static const H5O_class_t *const message_type_g[] = {
- H5O_NULL, /*0x0000 Null */
- H5O_SDSPACE, /*0x0001 Simple Dimensionality */
- NULL, /*0x0002 Data space (fiber bundle?) */
- H5O_DTYPE, /*0x0003 Data Type */
- NULL, /*0x0004 Not assigned */
- NULL, /*0x0005 Not assigned */
- NULL, /*0x0006 Data storage -- compact object */
- NULL, /*0x0007 Data storage -- external object */
- H5O_LAYOUT, /*0x0008 Data Layout */
- H5O_EFL, /*0x0009 External File List */
- NULL, /*0x000A Not assigned */
- NULL, /*0x000B Data storage -- compressed object */
- NULL, /*0x000C Attribute list */
- H5O_NAME, /*0x000D Object name */
- NULL, /*0x000E Object modification date and time */
- NULL, /*0x000F Shared header message */
- H5O_CONT, /*0x0010 Object header continuation */
- H5O_STAB, /*0x0011 Symbol table */
+static const H5O_class_t *const message_type_g[] =
+{
+ H5O_NULL, /*0x0000 Null */
+ H5O_SDSPACE, /*0x0001 Simple Dimensionality */
+ NULL, /*0x0002 Data space (fiber bundle?) */
+ H5O_DTYPE, /*0x0003 Data Type */
+ NULL, /*0x0004 Not assigned */
+ NULL, /*0x0005 Not assigned */
+ NULL, /*0x0006 Data storage -- compact object */
+ NULL, /*0x0007 Data storage -- external object */
+ H5O_LAYOUT, /*0x0008 Data Layout */
+ H5O_EFL, /*0x0009 External File List */
+ NULL, /*0x000A Not assigned */
+ NULL, /*0x000B Data storage -- compressed object */
+ NULL, /*0x000C Attribute list */
+ H5O_NAME, /*0x000D Object name */
+ NULL, /*0x000E Object modification date and time */
+ NULL, /*0x000F Shared header message */
+ H5O_CONT, /*0x0010 Object header continuation */
+ H5O_STAB, /*0x0011 Symbol table */
};
/*
@@ -75,22 +78,20 @@ static const H5O_class_t *const message_type_g[] = {
* (H5G_type_t) that are called to retrieve constant messages cached in the
* symbol table entry.
*/
-static void *(*H5O_fast_g[H5G_NCACHED])(const H5G_cache_t*,
- const H5O_class_t *,
- void*);
-
-
+static void *(*H5O_fast_g[H5G_NCACHED]) (const H5G_cache_t *,
+ const H5O_class_t *,
+ void *);
/*-------------------------------------------------------------------------
- * Function: H5O_init_interface
+ * Function: H5O_init_interface
*
- * Purpose: Initialize the H5O interface.
+ * Purpose: Initialize the H5O interface.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Tuesday, January 6, 1998
*
* Modifications:
@@ -98,123 +99,119 @@ static void *(*H5O_fast_g[H5G_NCACHED])(const H5G_cache_t*,
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_init_interface (void)
+H5O_init_interface(void)
{
- FUNC_ENTER (H5O_init_interface, FAIL);
+ FUNC_ENTER(H5O_init_interface, FAIL);
- /*
- * Initialize functions that decode messages from symbol table entries.
- */
- H5O_fast_g[H5G_CACHED_STAB] = H5O_stab_fast;
+ /*
+ * Initialize functions that decode messages from symbol table entries.
+ */
+ H5O_fast_g[H5G_CACHED_STAB] = H5O_stab_fast;
- FUNC_LEAVE (SUCCEED);
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5O_create
+ * Function: H5O_create
*
- * Purpose: Creates a new object header, sets the link count
- * to 0, and caches the header. The object header is opened for
- * write access and should eventually be closed by calling
- * H5O_close().
+ * Purpose: Creates a new object header, sets the link count
+ * to 0, and caches the header. The object header is opened for
+ * write access and should eventually be closed by calling
+ * H5O_close().
*
- * Return: Success: SUCCEED, the ENT argument contains
- * information about the object header,
- * including its address.
+ * Return: Success: SUCCEED, the ENT argument contains
+ * information about the object header,
+ * including its address.
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Aug 5 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Aug 5 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
-H5O_create (H5F_t *f, size_t size_hint, H5G_entry_t *ent/*out*/)
+H5O_create(H5F_t *f, size_t size_hint, H5G_entry_t *ent /*out */ )
{
- size_t size; /*total size of object header */
- H5O_t *oh = NULL;
- haddr_t tmp_addr;
-
- FUNC_ENTER (H5O_create, FAIL);
-
- /* check args */
- assert (f);
- assert (ent);
- HDmemset (ent, 0, sizeof(H5G_entry_t));
- if (size_hint<H5O_MIN_SIZE) size_hint = H5O_MIN_SIZE;
- H5O_ALIGN (size_hint, H5O_ALIGNMENT);
-
- /* allocate disk space for header and first chunk */
- size = H5O_SIZEOF_HDR(f) + size_hint;
- if (H5MF_alloc (f, H5MF_META, size, &(ent->header)/*out*/)<0) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "unable to allocate file space for object header hdr");
- }
-
- /* allocate the object header and fill in header fields */
- oh = H5MM_xcalloc (1, sizeof(H5O_t));
- oh->dirty = TRUE;
- oh->version = H5O_VERSION;
- oh->alignment = H5O_ALIGNMENT;
- oh->nlink = 0;
-
- /* create the chunk list and initialize the first chunk */
- oh->nchunks = 1;
- oh->alloc_nchunks = H5O_NCHUNKS;
- oh->chunk = H5MM_xmalloc (oh->alloc_nchunks * sizeof (H5O_chunk_t));
-
- tmp_addr = ent->header;
- H5F_addr_inc (&tmp_addr, H5O_SIZEOF_HDR (f));
- oh->chunk[0].dirty = TRUE;
- oh->chunk[0].addr = tmp_addr;
- oh->chunk[0].size = size_hint;
- oh->chunk[0].image = H5MM_xcalloc (1, size_hint);
-
- /* create the message list and initialize the first message */
- oh->nmesgs = 1;
- oh->alloc_nmesgs = H5O_NMESGS;
- oh->mesg = H5MM_xcalloc (oh->alloc_nmesgs, sizeof(H5O_mesg_t));
-
- oh->mesg[0].type = H5O_NULL;
- oh->mesg[0].dirty = TRUE;
- oh->mesg[0].native = NULL;
- oh->mesg[0].raw = oh->chunk[0].image + 4; /*skip id and size fields */
- oh->mesg[0].raw_size = size_hint - 4;
- oh->mesg[0].chunkno = 0;
-
- /* cache it */
- if (H5AC_set (f, H5AC_OHDR, &(ent->header), oh)<0) {
- H5MM_xfree (oh);
- HRETURN_ERROR (H5E_OHDR, H5E_CANTINIT, FAIL,
- "unable to cache object header");
- }
-
- /* open it */
- if (H5O_open (f, ent)<0) {
- HRETURN_ERROR (H5E_OHDR, H5E_CANTOPENOBJ, FAIL,
- "unable to open object header");
- }
-
- FUNC_LEAVE (SUCCEED);
+ size_t size; /*total size of object header */
+ H5O_t *oh = NULL;
+ haddr_t tmp_addr;
+
+ FUNC_ENTER(H5O_create, FAIL);
+
+ /* check args */
+ assert(f);
+ assert(ent);
+ HDmemset(ent, 0, sizeof(H5G_entry_t));
+ if (size_hint < H5O_MIN_SIZE)
+ size_hint = H5O_MIN_SIZE;
+ H5O_ALIGN(size_hint, H5O_ALIGNMENT);
+
+ /* allocate disk space for header and first chunk */
+ size = H5O_SIZEOF_HDR(f) + size_hint;
+ if (H5MF_alloc(f, H5MF_META, size, &(ent->header) /*out */ ) < 0) {
+ HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "unable to allocate file space for object header hdr");
+ }
+ /* allocate the object header and fill in header fields */
+ oh = H5MM_xcalloc(1, sizeof(H5O_t));
+ oh->dirty = TRUE;
+ oh->version = H5O_VERSION;
+ oh->alignment = H5O_ALIGNMENT;
+ oh->nlink = 0;
+
+ /* create the chunk list and initialize the first chunk */
+ oh->nchunks = 1;
+ oh->alloc_nchunks = H5O_NCHUNKS;
+ oh->chunk = H5MM_xmalloc(oh->alloc_nchunks * sizeof(H5O_chunk_t));
+
+ tmp_addr = ent->header;
+ H5F_addr_inc(&tmp_addr, H5O_SIZEOF_HDR(f));
+ oh->chunk[0].dirty = TRUE;
+ oh->chunk[0].addr = tmp_addr;
+ oh->chunk[0].size = size_hint;
+ oh->chunk[0].image = H5MM_xcalloc(1, size_hint);
+
+ /* create the message list and initialize the first message */
+ oh->nmesgs = 1;
+ oh->alloc_nmesgs = H5O_NMESGS;
+ oh->mesg = H5MM_xcalloc(oh->alloc_nmesgs, sizeof(H5O_mesg_t));
+
+ oh->mesg[0].type = H5O_NULL;
+ oh->mesg[0].dirty = TRUE;
+ oh->mesg[0].native = NULL;
+ oh->mesg[0].raw = oh->chunk[0].image + 4; /*skip id and size fields */
+ oh->mesg[0].raw_size = size_hint - 4;
+ oh->mesg[0].chunkno = 0;
+
+ /* cache it */
+ if (H5AC_set(f, H5AC_OHDR, &(ent->header), oh) < 0) {
+ H5MM_xfree(oh);
+ HRETURN_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL,
+ "unable to cache object header");
+ }
+ /* open it */
+ if (H5O_open(f, ent) < 0) {
+ HRETURN_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL,
+ "unable to open object header");
+ }
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5O_open
+ * Function: H5O_open
*
- * Purpose: Opens an object header which is described by the symbol table
- * entry OBJ_ENT.
+ * Purpose: Opens an object header which is described by the symbol table
+ * entry OBJ_ENT.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Monday, January 5, 1998
*
* Modifications:
@@ -222,37 +219,36 @@ H5O_create (H5F_t *f, size_t size_hint, H5G_entry_t *ent/*out*/)
*-------------------------------------------------------------------------
*/
herr_t
-H5O_open (H5F_t *f, H5G_entry_t *obj_ent)
+H5O_open(H5F_t *f, H5G_entry_t *obj_ent)
{
- FUNC_ENTER (H5O_open, FAIL);
+ FUNC_ENTER(H5O_open, FAIL);
- /* Check args */
- assert (f);
- assert (obj_ent);
+ /* Check args */
+ assert(f);
+ assert(obj_ent);
#ifdef H5O_DEBUG
- fprintf (stderr, ">");
- H5F_addr_print (stderr, &(obj_ent->header));
- fprintf (stderr, "\n");
+ fprintf(stderr, ">");
+ H5F_addr_print(stderr, &(obj_ent->header));
+ fprintf(stderr, "\n");
#endif
- /* Increment open-lock counters */
- obj_ent->file = f;
- obj_ent->file->nopen++;
- FUNC_LEAVE (SUCCEED);
+ /* Increment open-lock counters */
+ obj_ent->file = f;
+ obj_ent->file->nopen++;
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5O_close
+ * Function: H5O_close
*
- * Purpose: Closes an object header that was previously open.
+ * Purpose: Closes an object header that was previously open.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Monday, January 5, 1998
*
* Modifications:
@@ -260,1362 +256,1311 @@ H5O_open (H5F_t *f, H5G_entry_t *obj_ent)
*-------------------------------------------------------------------------
*/
herr_t
-H5O_close (H5G_entry_t *obj_ent)
+H5O_close(H5G_entry_t *obj_ent)
{
- FUNC_ENTER (H5O_close, FAIL);
-
- /* Check args */
- assert (obj_ent);
- assert (obj_ent->file);
- assert (obj_ent->file->nopen>0);
-
- /* Decrement open-lock counters */
- --obj_ent->file->nopen;
-
- /*
- * If the file open-lock count has reached zero and the file has a close
- * pending then close the file.
- */
- if (0==obj_ent->file->nopen && obj_ent->file->close_pending) {
- H5F_close (obj_ent->file);
- }
-
+ FUNC_ENTER(H5O_close, FAIL);
+
+ /* Check args */
+ assert(obj_ent);
+ assert(obj_ent->file);
+ assert(obj_ent->file->nopen > 0);
+
+ /* Decrement open-lock counters */
+ --obj_ent->file->nopen;
+
+ /*
+ * If the file open-lock count has reached zero and the file has a close
+ * pending then close the file.
+ */
+ if (0 == obj_ent->file->nopen && obj_ent->file->close_pending) {
+ H5F_close(obj_ent->file);
+ }
#ifdef H5O_DEBUG
- fprintf (stderr, "<");
- H5F_addr_print (stderr, &(obj_ent->header));
- fprintf (stderr, "\n");
+ fprintf(stderr, "<");
+ H5F_addr_print(stderr, &(obj_ent->header));
+ fprintf(stderr, "\n");
#endif
-
- FUNC_LEAVE (SUCCEED);
-}
+ FUNC_LEAVE(SUCCEED);
+}
/*-------------------------------------------------------------------------
- * Function: H5O_load
+ * Function: H5O_load
*
- * Purpose: Loads an object header from disk.
+ * Purpose: Loads an object header from disk.
*
- * Return: Success: Pointer to the new object header.
+ * Return: Success: Pointer to the new object header.
*
- * Failure: NULL
+ * Failure: NULL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Aug 5 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Aug 5 1997
*
* Modifications:
*
- * Robb Matzke, 30 Aug 1997
- * Plugged memory leaks that occur during error handling.
+ * Robb Matzke, 30 Aug 1997
+ * Plugged memory leaks that occur during error handling.
*
- * Robb Matzke, 7 Jan 1998
- * Able to distinguish between constant and variable messages.
+ * Robb Matzke, 7 Jan 1998
+ * Able to distinguish between constant and variable messages.
*
*-------------------------------------------------------------------------
*/
-static H5O_t *
-H5O_load (H5F_t *f, const haddr_t *addr, const void *_udata1, void *_udata2)
+static H5O_t *
+H5O_load(H5F_t *f, const haddr_t *addr, const void *_udata1, void *_udata2)
{
- H5O_t *oh = NULL;
- H5O_t *ret_value = (void*)1; /*kludge for HGOTO_ERROR*/
- uint8 buf[16], *p;
- size_t hdr_size, mesg_size;
- uintn id;
- intn mesgno, chunkno, curmesg=0, nmesgs;
- haddr_t chunk_addr;
- size_t chunk_size;
- H5O_cont_t *cont=NULL;
- hbool_t constant; /*is message a constant mesg? */
-
-
- FUNC_ENTER (H5O_load, NULL);
-
- /* check args */
- assert (f);
- assert (addr && H5F_addr_defined (addr));
- assert (!_udata1);
- assert (!_udata2);
-
- /* allocate ohdr and init chunk list */
- oh = H5MM_xcalloc (1, sizeof(H5O_t));
-
- /* read fixed-lenth part of object header */
- hdr_size = H5O_SIZEOF_HDR (f);
- if (H5F_block_read (f, addr, hdr_size, buf)<0) {
- HGOTO_ERROR (H5E_OHDR, H5E_READERROR, NULL,
- "unable to read object header");
- }
- p = buf;
-
- /* decode version */
- oh->version = *p++;
- if (H5O_VERSION!=oh->version) {
- HGOTO_ERROR (H5E_OHDR, H5E_VERSION, NULL,
- "bad object header version number");
- }
-
- /* decode alignment */
- oh->alignment = *p++;
- if (4!=oh->alignment) {
- HGOTO_ERROR (H5E_OHDR, H5E_ALIGNMENT, NULL,
- "unsupported object header alignment");
- }
-
- /* decode number of messages */
- UINT16DECODE (p, nmesgs);
-
- /* decode link count */
- UINT32DECODE (p, oh->nlink);
-
- /* decode first chunk info */
- chunk_addr = *addr;
- H5F_addr_inc (&chunk_addr, H5O_SIZEOF_HDR (f));
- UINT32DECODE (p, chunk_size);
-
- /* build the message array */
- oh->alloc_nmesgs = MAX (H5O_NMESGS, nmesgs);
- oh->mesg = H5MM_xcalloc (oh->alloc_nmesgs, sizeof(H5O_mesg_t));
-
- /* read each chunk from disk */
- while (H5F_addr_defined (&chunk_addr)) {
-
- /* increase chunk array size */
- if (oh->nchunks>=oh->alloc_nchunks) {
- oh->alloc_nchunks += H5O_NCHUNKS;
- oh->chunk = H5MM_xrealloc (oh->chunk,
- oh->alloc_nchunks * sizeof(H5O_chunk_t));
- }
-
- /* read the chunk raw data */
- chunkno = oh->nchunks++;
- oh->chunk[chunkno].dirty = FALSE;
- oh->chunk[chunkno].addr = chunk_addr;
- oh->chunk[chunkno].size = chunk_size;
- oh->chunk[chunkno].image = H5MM_xmalloc (chunk_size);
- if (H5F_block_read (f, &chunk_addr, chunk_size,
- oh->chunk[chunkno].image)<0) {
- HGOTO_ERROR (H5E_OHDR, H5E_READERROR, NULL,
- "unable to read object header data");
- }
-
-
- /* load messages from this chunk */
- for (p = oh->chunk[chunkno].image;
- p < oh->chunk[chunkno].image + chunk_size;
- p += mesg_size) {
- UINT16DECODE (p, id);
- UINT16DECODE (p, mesg_size);
-
- /*
- * The message ID field actually contains some bits near the
- * high-order end that are not part of the ID.
- */
- constant = (id & H5O_FLAG_CONSTANT) ? TRUE : FALSE;
- id &= ~H5O_FLAG_BITS;
-
- if (id>=NELMTS(message_type_g) || NULL==message_type_g[id]) {
- HGOTO_ERROR (H5E_OHDR, H5E_BADMESG, NULL,
- "corrupt object header");
- }
- if (p + mesg_size > oh->chunk[chunkno].image + chunk_size) {
- HGOTO_ERROR (H5E_OHDR, H5E_CANTINIT, NULL,
- "corrupt object header");
- }
-
- if (H5O_NULL_ID==id && oh->nmesgs>0 &&
- H5O_NULL_ID==oh->mesg[oh->nmesgs-1].type->id &&
- oh->mesg[oh->nmesgs-1].chunkno==chunkno) {
- /* combine adjacent null messages */
- mesgno = oh->nmesgs - 1;
- oh->mesg[mesgno].raw_size += 4 + mesg_size;
- } else {
- /* new message */
- if (oh->nmesgs>=nmesgs) {
- HGOTO_ERROR (H5E_OHDR, H5E_CANTLOAD, NULL,
- "corrupt object header");
- }
- mesgno = oh->nmesgs++;
- oh->mesg[mesgno].type = message_type_g[id];
- oh->mesg[mesgno].dirty = FALSE;
- oh->mesg[mesgno].constant = constant;
- oh->mesg[mesgno].native = NULL;
- oh->mesg[mesgno].raw = p;
- oh->mesg[mesgno].raw_size = mesg_size;
- oh->mesg[mesgno].chunkno = chunkno;
- }
- }
- assert (p == oh->chunk[chunkno].image + chunk_size);
-
- /* decode next object header continuation message */
- for (H5F_addr_undef (&chunk_addr);
- !H5F_addr_defined (&chunk_addr) && curmesg<oh->nmesgs;
- curmesg++) {
- if (H5O_CONT_ID==oh->mesg[curmesg].type->id) {
- uint8 *p2 = oh->mesg[curmesg].raw;
- cont = (H5O_CONT->decode)(f, oh->mesg[curmesg].raw_size, p2);
- oh->mesg[curmesg].native = cont;
- chunk_addr = cont->addr;
- chunk_size = cont->size;
- cont->chunkno = oh->nchunks; /*the next chunk to allocate*/
- }
- }
- }
-
-done:
- if (!ret_value && oh) {
- /*
- * Free resources.
- */
- int i;
- for (i=0; i<oh->nchunks; i++) {
- oh->chunk[i].image = H5MM_xfree (oh->chunk[i].image);
- }
- oh->chunk = H5MM_xfree (oh->chunk);
- oh->mesg = H5MM_xfree (oh->mesg);
- oh = H5MM_xfree (oh);
- }
-
- FUNC_LEAVE (oh);
+ H5O_t *oh = NULL;
+ H5O_t *ret_value = (void *) 1; /*kludge for HGOTO_ERROR */
+ uint8 buf[16], *p;
+ size_t hdr_size, mesg_size;
+ uintn id;
+ intn mesgno, chunkno, curmesg = 0, nmesgs;
+ haddr_t chunk_addr;
+ size_t chunk_size;
+ H5O_cont_t *cont = NULL;
+ hbool_t constant; /*is message a constant mesg? */
+
+ FUNC_ENTER(H5O_load, NULL);
+
+ /* check args */
+ assert(f);
+ assert(addr && H5F_addr_defined(addr));
+ assert(!_udata1);
+ assert(!_udata2);
+
+ /* allocate ohdr and init chunk list */
+ oh = H5MM_xcalloc(1, sizeof(H5O_t));
+
+ /* read fixed-lenth part of object header */
+ hdr_size = H5O_SIZEOF_HDR(f);
+ if (H5F_block_read(f, addr, hdr_size, buf) < 0) {
+ HGOTO_ERROR(H5E_OHDR, H5E_READERROR, NULL,
+ "unable to read object header");
+ }
+ p = buf;
+
+ /* decode version */
+ oh->version = *p++;
+ if (H5O_VERSION != oh->version) {
+ HGOTO_ERROR(H5E_OHDR, H5E_VERSION, NULL,
+ "bad object header version number");
+ }
+ /* decode alignment */
+ oh->alignment = *p++;
+ if (4 != oh->alignment) {
+ HGOTO_ERROR(H5E_OHDR, H5E_ALIGNMENT, NULL,
+ "unsupported object header alignment");
+ }
+ /* decode number of messages */
+ UINT16DECODE(p, nmesgs);
+
+ /* decode link count */
+ UINT32DECODE(p, oh->nlink);
+
+ /* decode first chunk info */
+ chunk_addr = *addr;
+ H5F_addr_inc(&chunk_addr, H5O_SIZEOF_HDR(f));
+ UINT32DECODE(p, chunk_size);
+
+ /* build the message array */
+ oh->alloc_nmesgs = MAX(H5O_NMESGS, nmesgs);
+ oh->mesg = H5MM_xcalloc(oh->alloc_nmesgs, sizeof(H5O_mesg_t));
+
+ /* read each chunk from disk */
+ while (H5F_addr_defined(&chunk_addr)) {
+
+ /* increase chunk array size */
+ if (oh->nchunks >= oh->alloc_nchunks) {
+ oh->alloc_nchunks += H5O_NCHUNKS;
+ oh->chunk = H5MM_xrealloc(oh->chunk,
+ oh->alloc_nchunks * sizeof(H5O_chunk_t));
+ }
+ /* read the chunk raw data */
+ chunkno = oh->nchunks++;
+ oh->chunk[chunkno].dirty = FALSE;
+ oh->chunk[chunkno].addr = chunk_addr;
+ oh->chunk[chunkno].size = chunk_size;
+ oh->chunk[chunkno].image = H5MM_xmalloc(chunk_size);
+ if (H5F_block_read(f, &chunk_addr, chunk_size,
+ oh->chunk[chunkno].image) < 0) {
+ HGOTO_ERROR(H5E_OHDR, H5E_READERROR, NULL,
+ "unable to read object header data");
+ }
+ /* load messages from this chunk */
+ for (p = oh->chunk[chunkno].image;
+ p < oh->chunk[chunkno].image + chunk_size;
+ p += mesg_size) {
+ UINT16DECODE(p, id);
+ UINT16DECODE(p, mesg_size);
+
+ /*
+ * The message ID field actually contains some bits near the
+ * high-order end that are not part of the ID.
+ */
+ constant = (id & H5O_FLAG_CONSTANT) ? TRUE : FALSE;
+ id &= ~H5O_FLAG_BITS;
+
+ if (id >= NELMTS(message_type_g) || NULL == message_type_g[id]) {
+ HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, NULL,
+ "corrupt object header");
+ }
+ if (p + mesg_size > oh->chunk[chunkno].image + chunk_size) {
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL,
+ "corrupt object header");
+ }
+ if (H5O_NULL_ID == id && oh->nmesgs > 0 &&
+ H5O_NULL_ID == oh->mesg[oh->nmesgs - 1].type->id &&
+ oh->mesg[oh->nmesgs - 1].chunkno == chunkno) {
+ /* combine adjacent null messages */
+ mesgno = oh->nmesgs - 1;
+ oh->mesg[mesgno].raw_size += 4 + mesg_size;
+ } else {
+ /* new message */
+ if (oh->nmesgs >= nmesgs) {
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL,
+ "corrupt object header");
+ }
+ mesgno = oh->nmesgs++;
+ oh->mesg[mesgno].type = message_type_g[id];
+ oh->mesg[mesgno].dirty = FALSE;
+ oh->mesg[mesgno].constant = constant;
+ oh->mesg[mesgno].native = NULL;
+ oh->mesg[mesgno].raw = p;
+ oh->mesg[mesgno].raw_size = mesg_size;
+ oh->mesg[mesgno].chunkno = chunkno;
+ }
+ }
+ assert(p == oh->chunk[chunkno].image + chunk_size);
+
+ /* decode next object header continuation message */
+ for (H5F_addr_undef(&chunk_addr);
+ !H5F_addr_defined(&chunk_addr) && curmesg < oh->nmesgs;
+ curmesg++) {
+ if (H5O_CONT_ID == oh->mesg[curmesg].type->id) {
+ uint8 *p2 = oh->mesg[curmesg].raw;
+ cont = (H5O_CONT->decode) (f, oh->mesg[curmesg].raw_size, p2);
+ oh->mesg[curmesg].native = cont;
+ chunk_addr = cont->addr;
+ chunk_size = cont->size;
+ cont->chunkno = oh->nchunks; /*the next chunk to allocate */
+ }
+ }
+ }
+
+ done:
+ if (!ret_value && oh) {
+ /*
+ * Free resources.
+ */
+ int i;
+ for (i = 0; i < oh->nchunks; i++) {
+ oh->chunk[i].image = H5MM_xfree(oh->chunk[i].image);
+ }
+ oh->chunk = H5MM_xfree(oh->chunk);
+ oh->mesg = H5MM_xfree(oh->mesg);
+ oh = H5MM_xfree(oh);
+ }
+ FUNC_LEAVE(oh);
}
-
/*-------------------------------------------------------------------------
- * Function: H5O_flush
+ * Function: H5O_flush
*
- * Purpose: Flushes (and destroys) an object header.
+ * Purpose: Flushes (and destroys) an object header.
*
- * Return: Success: SUCCESS
+ * Return: Success: SUCCESS
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Aug 5 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Aug 5 1997
*
* Modifications:
*
- * Robb Matzke, 7 Jan 1998
- * Handles constant vs non-constant messages.
+ * Robb Matzke, 7 Jan 1998
+ * Handles constant vs non-constant messages.
*
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_flush (H5F_t *f, hbool_t destroy, const haddr_t *addr, H5O_t *oh)
+H5O_flush(H5F_t *f, hbool_t destroy, const haddr_t *addr, H5O_t *oh)
{
- uint8 buf[16], *p;
- intn i, id;
- H5O_cont_t *cont = NULL;
-
- FUNC_ENTER (H5O_flush, FAIL);
-
- /* check args */
- assert (f);
- assert (addr && H5F_addr_defined (addr));
- assert (oh);
-
- /* flush */
- if (oh->dirty) {
- p = buf;
-
- /* encode version */
- *p++ = oh->version;
-
- /* encode alingment */
- *p++ = oh->alignment;
-
- /* encode number of messages */
- UINT16ENCODE (p, oh->nmesgs);
-
- /* encode link count */
- UINT32ENCODE (p, oh->nlink);
-
- /* encode body size */
- UINT32ENCODE (p, oh->chunk[0].size);
-
- /* write the object header header */
- if (H5F_block_write (f, addr, H5O_SIZEOF_HDR(f), buf)<0) {
- HRETURN_ERROR (H5E_OHDR, H5E_WRITEERROR, FAIL,
- "unable to write object header hdr to disk");
- }
-
- /* encode messages */
- for (i=0; i<oh->nmesgs; i++) {
- if (oh->mesg[i].dirty) {
- p = oh->mesg[i].raw - 4;
-
- /* The message id has some flags in the high-order bits. */
- id = oh->mesg[i].type->id;
- id |= oh->mesg[i].constant ? H5O_FLAG_CONSTANT : 0;
- UINT16ENCODE (p, id);
- UINT16ENCODE (p, oh->mesg[i].raw_size);
-
- if (oh->mesg[i].native) {
- assert (oh->mesg[i].type->encode);
-
- /* allocate file space for chunks that have none yet */
- if (H5O_CONT_ID==oh->mesg[i].type->id &&
- !H5F_addr_defined (&(((H5O_cont_t*)
- (oh->mesg[i].native))->addr))) {
- cont = (H5O_cont_t*)(oh->mesg[i].native);
- assert (cont->chunkno >= 0);
- assert (cont->chunkno < oh->nchunks);
- assert (!H5F_addr_defined(&(oh->chunk[cont->chunkno].addr)));
- cont->size = oh->chunk[cont->chunkno].size;
- if (H5MF_alloc (f, H5MF_META, cont->size,
- &(cont->addr)/*out*/)<0) {
- HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL,
- "unable to allocate space for object "
- "header data");
- }
- oh->chunk[cont->chunkno].addr = cont->addr;
- }
-
- /* encode the message */
- assert (oh->mesg[i].raw >=
- oh->chunk[oh->mesg[i].chunkno].image);
- assert (oh->mesg[i].raw + oh->mesg[i].raw_size <=
- oh->chunk[oh->mesg[i].chunkno].image +
- oh->chunk[oh->mesg[i].chunkno].size);
- if ((oh->mesg[i].type->encode)(f, oh->mesg[i].raw_size,
- oh->mesg[i].raw,
- oh->mesg[i].native)<0) {
- HRETURN_ERROR (H5E_OHDR, H5E_CANTENCODE, FAIL,
- "unable to encode object header message");
- }
- }
- oh->mesg[i].dirty = FALSE;
- oh->chunk[oh->mesg[i].chunkno].dirty = TRUE;
- }
- }
-
- /* write each chunk to disk */
- for (i=0; i<oh->nchunks; i++) {
- if (oh->chunk[i].dirty) {
- assert (H5F_addr_defined (&(oh->chunk[i].addr)));
- if (H5F_block_write (f, &(oh->chunk[i].addr), oh->chunk[i].size,
- oh->chunk[i].image)<0) {
- HRETURN_ERROR (H5E_OHDR, H5E_WRITEERROR, FAIL,
- "unable to write object header data to disk");
- }
- oh->chunk[i].dirty = FALSE;
- }
- }
- oh->dirty = FALSE;
- }
-
-
- if (destroy) {
- /* destroy chunks */
- for (i=0; i<oh->nchunks; i++) {
- oh->chunk[i].image = H5MM_xfree (oh->chunk[i].image);
- }
- oh->chunk = H5MM_xfree (oh->chunk);
-
- /* destroy messages */
- for (i=0; i<oh->nmesgs; i++) {
- H5O_reset (oh->mesg[i].type, oh->mesg[i].native);
- oh->mesg[i].native = H5MM_xfree (oh->mesg[i].native);
- }
- oh->mesg = H5MM_xfree (oh->mesg);
-
- /* destroy object header */
- H5MM_xfree (oh);
- }
-
- FUNC_LEAVE (SUCCEED);
+ uint8 buf[16], *p;
+ intn i, id;
+ H5O_cont_t *cont = NULL;
+
+ FUNC_ENTER(H5O_flush, FAIL);
+
+ /* check args */
+ assert(f);
+ assert(addr && H5F_addr_defined(addr));
+ assert(oh);
+
+ /* flush */
+ if (oh->dirty) {
+ p = buf;
+
+ /* encode version */
+ *p++ = oh->version;
+
+ /* encode alingment */
+ *p++ = oh->alignment;
+
+ /* encode number of messages */
+ UINT16ENCODE(p, oh->nmesgs);
+
+ /* encode link count */
+ UINT32ENCODE(p, oh->nlink);
+
+ /* encode body size */
+ UINT32ENCODE(p, oh->chunk[0].size);
+
+ /* write the object header header */
+ if (H5F_block_write(f, addr, H5O_SIZEOF_HDR(f), buf) < 0) {
+ HRETURN_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL,
+ "unable to write object header hdr to disk");
+ }
+ /* encode messages */
+ for (i = 0; i < oh->nmesgs; i++) {
+ if (oh->mesg[i].dirty) {
+ p = oh->mesg[i].raw - 4;
+
+ /* The message id has some flags in the high-order bits. */
+ id = oh->mesg[i].type->id;
+ id |= oh->mesg[i].constant ? H5O_FLAG_CONSTANT : 0;
+ UINT16ENCODE(p, id);
+ UINT16ENCODE(p, oh->mesg[i].raw_size);
+
+ if (oh->mesg[i].native) {
+ assert(oh->mesg[i].type->encode);
+
+ /* allocate file space for chunks that have none yet */
+ if (H5O_CONT_ID == oh->mesg[i].type->id &&
+ !H5F_addr_defined(&(((H5O_cont_t *)
+ (oh->mesg[i].native))->addr))) {
+ cont = (H5O_cont_t *) (oh->mesg[i].native);
+ assert(cont->chunkno >= 0);
+ assert(cont->chunkno < oh->nchunks);
+ assert(!H5F_addr_defined(&(oh->chunk[cont->chunkno].addr)));
+ cont->size = oh->chunk[cont->chunkno].size;
+ if (H5MF_alloc(f, H5MF_META, cont->size,
+ &(cont->addr) /*out */ ) < 0) {
+ HRETURN_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL,
+ "unable to allocate space for object "
+ "header data");
+ }
+ oh->chunk[cont->chunkno].addr = cont->addr;
+ }
+ /* encode the message */
+ assert(oh->mesg[i].raw >=
+ oh->chunk[oh->mesg[i].chunkno].image);
+ assert(oh->mesg[i].raw + oh->mesg[i].raw_size <=
+ oh->chunk[oh->mesg[i].chunkno].image +
+ oh->chunk[oh->mesg[i].chunkno].size);
+ if ((oh->mesg[i].type->encode) (f, oh->mesg[i].raw_size,
+ oh->mesg[i].raw,
+ oh->mesg[i].native) < 0) {
+ HRETURN_ERROR(H5E_OHDR, H5E_CANTENCODE, FAIL,
+ "unable to encode object header message");
+ }
+ }
+ oh->mesg[i].dirty = FALSE;
+ oh->chunk[oh->mesg[i].chunkno].dirty = TRUE;
+ }
+ }
+
+ /* write each chunk to disk */
+ for (i = 0; i < oh->nchunks; i++) {
+ if (oh->chunk[i].dirty) {
+ assert(H5F_addr_defined(&(oh->chunk[i].addr)));
+ if (H5F_block_write(f, &(oh->chunk[i].addr), oh->chunk[i].size,
+ oh->chunk[i].image) < 0) {
+ HRETURN_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL,
+ "unable to write object header data to disk");
+ }
+ oh->chunk[i].dirty = FALSE;
+ }
+ }
+ oh->dirty = FALSE;
+ }
+ if (destroy) {
+ /* destroy chunks */
+ for (i = 0; i < oh->nchunks; i++) {
+ oh->chunk[i].image = H5MM_xfree(oh->chunk[i].image);
+ }
+ oh->chunk = H5MM_xfree(oh->chunk);
+
+ /* destroy messages */
+ for (i = 0; i < oh->nmesgs; i++) {
+ H5O_reset(oh->mesg[i].type, oh->mesg[i].native);
+ oh->mesg[i].native = H5MM_xfree(oh->mesg[i].native);
+ }
+ oh->mesg = H5MM_xfree(oh->mesg);
+
+ /* destroy object header */
+ H5MM_xfree(oh);
+ }
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5O_reset
+ * Function: H5O_reset
*
- * Purpose: Some message data structures have internal fields that
- * need to be freed. This function does that if appropriate
- * but doesn't free NATIVE.
+ * Purpose: Some message data structures have internal fields that
+ * need to be freed. This function does that if appropriate
+ * but doesn't free NATIVE.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Aug 12 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Aug 12 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
-H5O_reset (const H5O_class_t *type, void *native)
+H5O_reset(const H5O_class_t *type, void *native)
{
- FUNC_ENTER (H5O_reset, FAIL);
-
- if (native) {
- if (type->reset) {
- if ((type->reset)(native)<0) {
- HRETURN_ERROR (H5E_OHDR, H5E_CANTINIT, FAIL,
- "reset method failed");
- }
- } else {
- HDmemset (native, 0, type->native_size);
- }
- }
-
- FUNC_LEAVE (SUCCEED);
+ FUNC_ENTER(H5O_reset, FAIL);
+
+ if (native) {
+ if (type->reset) {
+ if ((type->reset) (native) < 0) {
+ HRETURN_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL,
+ "reset method failed");
+ }
+ } else {
+ HDmemset(native, 0, type->native_size);
+ }
+ }
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5O_link
+ * Function: H5O_link
*
- * Purpose: Adjust the link count for an object header by adding
- * ADJUST to the link count.
+ * Purpose: Adjust the link count for an object header by adding
+ * ADJUST to the link count.
*
- * Return: Success: New link count
+ * Return: Success: New link count
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Aug 5 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Aug 5 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
intn
-H5O_link (H5G_entry_t *ent, intn adjust)
+H5O_link(H5G_entry_t *ent, intn adjust)
{
- H5O_t *oh = NULL;
- intn ret_value = FAIL;
-
- FUNC_ENTER (H5O_link, FAIL);
-
- /* check args */
- assert (ent);
- assert (ent->file);
- assert (H5F_addr_defined (&(ent->header)));
-
- /* get header */
- if (NULL==(oh=H5AC_protect (ent->file, H5AC_OHDR, &(ent->header),
- NULL, NULL))) {
- HGOTO_ERROR (H5E_OHDR, H5E_CANTLOAD, FAIL,
- "unable to load object header");
- }
-
- /* adjust link count */
- if (adjust<0) {
- if (oh->nlink + adjust < 0) {
- HGOTO_ERROR (H5E_OHDR, H5E_LINKCOUNT, FAIL,
- "link count would be negative");
- }
- oh->nlink += adjust;
- } else {
- oh->nlink += adjust;
- }
-
- oh->dirty = TRUE;
- ret_value = oh->nlink;
-
- done:
- if (oh && H5AC_unprotect (ent->file, H5AC_OHDR, &(ent->header), oh)<0) {
- HRETURN_ERROR (H5E_OHDR, H5E_PROTECT, FAIL,
- "unable to release object header");
- }
-
- FUNC_LEAVE (ret_value);
+ H5O_t *oh = NULL;
+ intn ret_value = FAIL;
+
+ FUNC_ENTER(H5O_link, FAIL);
+
+ /* check args */
+ assert(ent);
+ assert(ent->file);
+ assert(H5F_addr_defined(&(ent->header)));
+
+ /* get header */
+ if (NULL == (oh = H5AC_protect(ent->file, H5AC_OHDR, &(ent->header),
+ NULL, NULL))) {
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL,
+ "unable to load object header");
+ }
+ /* adjust link count */
+ if (adjust < 0) {
+ if (oh->nlink + adjust < 0) {
+ HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL,
+ "link count would be negative");
+ }
+ oh->nlink += adjust;
+ } else {
+ oh->nlink += adjust;
+ }
+
+ oh->dirty = TRUE;
+ ret_value = oh->nlink;
+
+ done:
+ if (oh && H5AC_unprotect(ent->file, H5AC_OHDR, &(ent->header), oh) < 0) {
+ HRETURN_ERROR(H5E_OHDR, H5E_PROTECT, FAIL,
+ "unable to release object header");
+ }
+ FUNC_LEAVE(ret_value);
}
-
/*-------------------------------------------------------------------------
- * Function: H5O_read
+ * Function: H5O_read
*
- * Purpose: Reads a message from an object header and returns a pointer
- * to it. The caller will usually supply the memory through
- * MESG and the return value will be MESG. But if MESG is
- * the null pointer, then this function will malloc() memory
- * to hold the result and return its pointer instead.
+ * Purpose: Reads a message from an object header and returns a pointer
+ * to it. The caller will usually supply the memory through
+ * MESG and the return value will be MESG. But if MESG is
+ * the null pointer, then this function will malloc() memory
+ * to hold the result and return its pointer instead.
*
- * Return: Success: Ptr to message in native format.
+ * Return: Success: Ptr to message in native format.
*
- * Failure: NULL
+ * Failure: NULL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Aug 6 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Aug 6 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-void *
-H5O_read (H5G_entry_t *ent, const H5O_class_t *type, intn sequence, void *mesg)
+void *
+H5O_read(H5G_entry_t *ent, const H5O_class_t *type, intn sequence, void *mesg)
{
- H5O_t *oh = NULL;
- void *retval = NULL;
- intn idx;
- H5G_cache_t *cache = NULL;
- H5G_type_t cache_type;
-
- FUNC_ENTER (H5O_read, NULL);
-
- /* check args */
- assert (ent);
- assert (ent->file);
- assert (H5F_addr_defined (&(ent->header)));
- assert (type);
- assert (sequence>=0);
-
- /* can we get it from the symbol table entry? */
- cache = H5G_ent_cache (ent, &cache_type);
- if (H5O_fast_g[cache_type]) {
- retval = (H5O_fast_g[cache_type])(cache, type, mesg);
- if (retval) HRETURN (retval);
- H5ECLEAR; /*don't care, try reading from header*/
- }
-
- /* can we get it from the object header? */
- if ((idx = H5O_find_in_ohdr (ent->file, &(ent->header), &type,
- sequence))<0) {
- HRETURN_ERROR (H5E_OHDR, H5E_NOTFOUND, NULL,
- "unable to find message in object header");
- }
-
- /* copy the message to the user-supplied buffer */
- if (NULL==(oh=H5AC_protect (ent->file, H5AC_OHDR, &(ent->header),
- NULL, NULL))) {
- HRETURN_ERROR (H5E_OHDR, H5E_CANTLOAD, NULL,
- "unable to load object header");
- }
- retval = (type->copy)(oh->mesg[idx].native, mesg);
- if (H5AC_unprotect (ent->file, H5AC_OHDR, &(ent->header), oh)<0) {
- HRETURN_ERROR (H5E_OHDR, H5E_PROTECT, NULL,
- "unable to release object header");
- }
- oh = NULL;
-
- if (!retval) {
- HRETURN_ERROR (H5E_OHDR, H5E_CANTINIT, NULL,
- "unable to copy object header message to user space");
- }
-
- FUNC_LEAVE (retval);
+ H5O_t *oh = NULL;
+ void *retval = NULL;
+ intn idx;
+ H5G_cache_t *cache = NULL;
+ H5G_type_t cache_type;
+
+ FUNC_ENTER(H5O_read, NULL);
+
+ /* check args */
+ assert(ent);
+ assert(ent->file);
+ assert(H5F_addr_defined(&(ent->header)));
+ assert(type);
+ assert(sequence >= 0);
+
+ /* can we get it from the symbol table entry? */
+ cache = H5G_ent_cache(ent, &cache_type);
+ if (H5O_fast_g[cache_type]) {
+ retval = (H5O_fast_g[cache_type]) (cache, type, mesg);
+ if (retval)
+ HRETURN(retval);
+ H5ECLEAR; /*don't care, try reading from header */
+ }
+ /* can we get it from the object header? */
+ if ((idx = H5O_find_in_ohdr(ent->file, &(ent->header), &type,
+ sequence)) < 0) {
+ HRETURN_ERROR(H5E_OHDR, H5E_NOTFOUND, NULL,
+ "unable to find message in object header");
+ }
+ /* copy the message to the user-supplied buffer */
+ if (NULL == (oh = H5AC_protect(ent->file, H5AC_OHDR, &(ent->header),
+ NULL, NULL))) {
+ HRETURN_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL,
+ "unable to load object header");
+ }
+ retval = (type->copy) (oh->mesg[idx].native, mesg);
+ if (H5AC_unprotect(ent->file, H5AC_OHDR, &(ent->header), oh) < 0) {
+ HRETURN_ERROR(H5E_OHDR, H5E_PROTECT, NULL,
+ "unable to release object header");
+ }
+ oh = NULL;
+
+ if (!retval) {
+ HRETURN_ERROR(H5E_OHDR, H5E_CANTINIT, NULL,
+ "unable to copy object header message to user space");
+ }
+ FUNC_LEAVE(retval);
}
-
/*-------------------------------------------------------------------------
- * Function: H5O_find_in_ohdr
+ * Function: H5O_find_in_ohdr
*
- * Purpose: Find a message in the object header without consulting
- * a symbol table entry.
+ * Purpose: Find a message in the object header without consulting
+ * a symbol table entry.
*
- * Return: Success: Index number of message.
+ * Return: Success: Index number of message.
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Aug 6 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Aug 6 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static intn
-H5O_find_in_ohdr (H5F_t *f, const haddr_t *addr, const H5O_class_t **type_p,
- intn sequence)
+H5O_find_in_ohdr(H5F_t *f, const haddr_t *addr, const H5O_class_t **type_p,
+ intn sequence)
{
- H5O_t *oh = NULL;
- int i;
-
- FUNC_ENTER (H5O_find_in_ohdr, FAIL);
-
- /* check args */
- assert (f);
- assert (addr && H5F_addr_defined (addr));
- assert (type_p);
-
- /* load the object header */
- if (NULL==(oh=H5AC_find (f, H5AC_OHDR, addr, NULL, NULL))) {
- HRETURN_ERROR (H5E_OHDR, H5E_CANTLOAD, FAIL,
- "unable to load object header");
- }
-
- /* scan through the messages looking for the right one */
- for (i=0; i<oh->nmesgs; i++) {
- if (*type_p && (*type_p)->id!=oh->mesg[i].type->id) continue;
- if (--sequence<0) break;
- }
- if (sequence>=0) {
- HRETURN_ERROR (H5E_OHDR, H5E_NOTFOUND, FAIL,
- "unable to find object header message");
- }
-
- /* decode the message if necessary */
- if (NULL==oh->mesg[i].native) {
- assert (oh->mesg[i].type->decode);
- oh->mesg[i].native = (oh->mesg[i].type->decode)(f,
- oh->mesg[i].raw_size,
- oh->mesg[i].raw);
- if (NULL==oh->mesg[i].native) {
- HRETURN_ERROR (H5E_OHDR, H5E_CANTDECODE, FAIL,
- "unable to decode message");
- }
- }
-
- /*return the message type */
- *type_p = oh->mesg[i].type;
-
- FUNC_LEAVE (i);
+ H5O_t *oh = NULL;
+ int i;
+
+ FUNC_ENTER(H5O_find_in_ohdr, FAIL);
+
+ /* check args */
+ assert(f);
+ assert(addr && H5F_addr_defined(addr));
+ assert(type_p);
+
+ /* load the object header */
+ if (NULL == (oh = H5AC_find(f, H5AC_OHDR, addr, NULL, NULL))) {
+ HRETURN_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL,
+ "unable to load object header");
+ }
+ /* scan through the messages looking for the right one */
+ for (i = 0; i < oh->nmesgs; i++) {
+ if (*type_p && (*type_p)->id != oh->mesg[i].type->id)
+ continue;
+ if (--sequence < 0)
+ break;
+ }
+ if (sequence >= 0) {
+ HRETURN_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL,
+ "unable to find object header message");
+ }
+ /* decode the message if necessary */
+ if (NULL == oh->mesg[i].native) {
+ assert(oh->mesg[i].type->decode);
+ oh->mesg[i].native = (oh->mesg[i].type->decode) (f,
+ oh->mesg[i].raw_size,
+ oh->mesg[i].raw);
+ if (NULL == oh->mesg[i].native) {
+ HRETURN_ERROR(H5E_OHDR, H5E_CANTDECODE, FAIL,
+ "unable to decode message");
+ }
+ }
+ /*return the message type */
+ *type_p = oh->mesg[i].type;
+
+ FUNC_LEAVE(i);
}
-
/*-------------------------------------------------------------------------
- * Function: H5O_modify
+ * Function: H5O_modify
*
- * Purpose: Modifies an existing message or creates a new message.
- * The cache fields in that symbol table entry ENT are *not*
- * updated, you must do that separately because they often
- * depend on multiple object header messages. Besides, we
- * don't know which messages will be constant and which will
- * not.
+ * Purpose: Modifies an existing message or creates a new message.
+ * The cache fields in that symbol table entry ENT are *not*
+ * updated, you must do that separately because they often
+ * depend on multiple object header messages. Besides, we
+ * don't know which messages will be constant and which will
+ * not.
*
- * The OVERWRITE argument is either a sequence number of a
- * message to overwrite (usually zero) or the constant
- * H5O_NEW_MESSAGE (-1) to indicate that a new message is to
- * be created. If the message to overwrite doesn't exist then
- * it is created (but only if it can be inserted so its sequence
- * number is OVERWRITE; that is, you can create a message with
- * the sequence number 5 if there is no message with sequence
- * number 4).
+ * The OVERWRITE argument is either a sequence number of a
+ * message to overwrite (usually zero) or the constant
+ * H5O_NEW_MESSAGE (-1) to indicate that a new message is to
+ * be created. If the message to overwrite doesn't exist then
+ * it is created (but only if it can be inserted so its sequence
+ * number is OVERWRITE; that is, you can create a message with
+ * the sequence number 5 if there is no message with sequence
+ * number 4).
*
- * Return: Success: The sequence number of the message that
- * was modified or created.
+ * Return: Success: The sequence number of the message that
+ * was modified or created.
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Aug 6 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Aug 6 1997
*
* Modifications:
*
- * Robb Matzke, 7 Jan 1998
- * Handles constant vs non-constant messages. Once a message is made
- * constant it can never become non-constant. Constant messages cannot
- * be modified.
+ * Robb Matzke, 7 Jan 1998
+ * Handles constant vs non-constant messages. Once a message is made
+ * constant it can never become non-constant. Constant messages cannot
+ * be modified.
*
*-------------------------------------------------------------------------
*/
intn
-H5O_modify (H5G_entry_t *ent, const H5O_class_t *type, intn overwrite,
- uintn flags, const void *mesg)
+H5O_modify(H5G_entry_t *ent, const H5O_class_t *type, intn overwrite,
+ uintn flags, const void *mesg)
{
- H5O_t *oh = NULL;
- intn idx, sequence;
- intn ret_value = FAIL;
- size_t size;
-
- FUNC_ENTER (H5O_modify, FAIL);
-
- /* check args */
- assert (ent);
- assert (ent->file);
- assert (H5F_addr_defined (&(ent->header)));
- assert (type);
- assert (mesg);
-
- if (NULL==(oh=H5AC_protect (ent->file, H5AC_OHDR, &(ent->header),
- NULL, NULL))) {
- HGOTO_ERROR (H5E_OHDR, H5E_CANTLOAD, FAIL,
- "unable to load object header");
- }
-
- /* Count similar messages */
- for (idx=0,sequence=-1; idx<oh->nmesgs; idx++) {
- if (type->id != oh->mesg[idx].type->id) continue;
- if (++sequence==overwrite) break;
- }
-
- /* Was the right message found? */
- if (overwrite>=0 &&
- (idx>=oh->nmesgs || sequence!=overwrite)) {
-
- /* But can we insert a new one with this sequence number? */
- if (overwrite==sequence+1) {
- overwrite = -1;
- } else {
- HGOTO_ERROR (H5E_OHDR, H5E_NOTFOUND, FAIL, "message not found");
- }
- }
-
- if (overwrite<0) {
- /* Allocate space for the new message */
- size = (type->raw_size)(ent->file, mesg);
- H5O_ALIGN (size, oh->alignment);
- idx = H5O_alloc (ent->file, oh, type, size);
- if (idx<0) {
- HGOTO_ERROR (H5E_OHDR, H5E_CANTINIT, FAIL,
- "unable to allocate object header space for message");
- }
- sequence++;
-
- } else if (oh->mesg[idx].constant) {
- HGOTO_ERROR (H5E_OHDR, H5E_WRITEERROR, FAIL,
- "unable to modify constant message");
- }
-
- /* Copy the native value into the object header */
- oh->mesg[idx].native = (type->copy)(mesg, oh->mesg[idx].native);
- if (NULL==oh->mesg[idx].native) {
- HGOTO_ERROR (H5E_OHDR, H5E_CANTINIT, FAIL,
- "unable to copy message to object header");
- }
- oh->mesg[idx].constant = (flags & H5O_FLAG_CONSTANT) ? TRUE : FALSE;
- oh->mesg[idx].dirty = TRUE;
- oh->dirty = TRUE;
- ret_value = sequence;
-
- done:
- if (oh && H5AC_unprotect (ent->file, H5AC_OHDR, &(ent->header), oh)<0) {
- HRETURN_ERROR (H5E_OHDR, H5E_PROTECT, FAIL,
- "unable to release object header");
- }
-
- FUNC_LEAVE (ret_value);
+ H5O_t *oh = NULL;
+ intn idx, sequence;
+ intn ret_value = FAIL;
+ size_t size;
+
+ FUNC_ENTER(H5O_modify, FAIL);
+
+ /* check args */
+ assert(ent);
+ assert(ent->file);
+ assert(H5F_addr_defined(&(ent->header)));
+ assert(type);
+ assert(mesg);
+
+ if (NULL == (oh = H5AC_protect(ent->file, H5AC_OHDR, &(ent->header),
+ NULL, NULL))) {
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL,
+ "unable to load object header");
+ }
+ /* Count similar messages */
+ for (idx = 0, sequence = -1; idx < oh->nmesgs; idx++) {
+ if (type->id != oh->mesg[idx].type->id)
+ continue;
+ if (++sequence == overwrite)
+ break;
+ }
+
+ /* Was the right message found? */
+ if (overwrite >= 0 &&
+ (idx >= oh->nmesgs || sequence != overwrite)) {
+
+ /* But can we insert a new one with this sequence number? */
+ if (overwrite == sequence + 1) {
+ overwrite = -1;
+ } else {
+ HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "message not found");
+ }
+ }
+ if (overwrite < 0) {
+ /* Allocate space for the new message */
+ size = (type->raw_size) (ent->file, mesg);
+ H5O_ALIGN(size, oh->alignment);
+ idx = H5O_alloc(ent->file, oh, type, size);
+ if (idx < 0) {
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL,
+ "unable to allocate object header space for message");
+ }
+ sequence++;
+
+ } else if (oh->mesg[idx].constant) {
+ HGOTO_ERROR(H5E_OHDR, H5E_WRITEERROR, FAIL,
+ "unable to modify constant message");
+ }
+ /* Copy the native value into the object header */
+ oh->mesg[idx].native = (type->copy) (mesg, oh->mesg[idx].native);
+ if (NULL == oh->mesg[idx].native) {
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL,
+ "unable to copy message to object header");
+ }
+ oh->mesg[idx].constant = (flags & H5O_FLAG_CONSTANT) ? TRUE : FALSE;
+ oh->mesg[idx].dirty = TRUE;
+ oh->dirty = TRUE;
+ ret_value = sequence;
+
+ done:
+ if (oh && H5AC_unprotect(ent->file, H5AC_OHDR, &(ent->header), oh) < 0) {
+ HRETURN_ERROR(H5E_OHDR, H5E_PROTECT, FAIL,
+ "unable to release object header");
+ }
+ FUNC_LEAVE(ret_value);
}
-
/*-------------------------------------------------------------------------
- * Function: H5O_remove
+ * Function: H5O_remove
*
- * Purpose: Removes the specified message from the object header.
- * If sequence is H5O_ALL (-1) then all messages of the
- * specified type are removed. Removing a message causes
- * the sequence numbers to change for subsequent messages of
- * the same type.
+ * Purpose: Removes the specified message from the object header.
+ * If sequence is H5O_ALL (-1) then all messages of the
+ * specified type are removed. Removing a message causes
+ * the sequence numbers to change for subsequent messages of
+ * the same type.
*
- * No attempt is made to join adjacent free areas of the
- * object header into a single larger free area.
+ * No attempt is made to join adjacent free areas of the
+ * object header into a single larger free area.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Aug 28 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Aug 28 1997
*
* Modifications:
*
- * Robb Matzke, 7 Jan 1998
- * Does not remove constant messages.
+ * Robb Matzke, 7 Jan 1998
+ * Does not remove constant messages.
*
*-------------------------------------------------------------------------
*/
herr_t
-H5O_remove (H5G_entry_t *ent, const H5O_class_t *type, intn sequence)
+H5O_remove(H5G_entry_t *ent, const H5O_class_t *type, intn sequence)
{
- H5O_t *oh = NULL;
- intn i, seq, nfailed=0;
- herr_t ret_value = FAIL;
-
- FUNC_ENTER (H5O_remove, FAIL);
-
- /* check args */
- assert (ent);
- assert (ent->file);
- assert (H5F_addr_defined (&(ent->header)));
- assert (type);
-
- /* load the object header */
- if (NULL==(oh=H5AC_protect (ent->file, H5AC_OHDR, &(ent->header),
- NULL, NULL))) {
- HGOTO_ERROR (H5E_OHDR, H5E_CANTLOAD, FAIL,
- "unable to load object header");
- }
-
- for (i=seq=0; i<oh->nmesgs; i++) {
- if (type->id != oh->mesg[i].type->id) continue;
- if (seq++ == sequence || H5O_ALL==sequence) {
-
- /*
- * Keep track of how many times we failed trying to remove constant
- * messages.
- */
- if (oh->mesg[i].constant) {
- nfailed++;
- continue;
- }
-
- /* change message type to nil and zero it */
- oh->mesg[i].type = H5O_NULL;
- HDmemset (oh->mesg[i].raw, 0, oh->mesg[i].raw_size);
- H5O_reset (type, oh->mesg[i].native);
- oh->mesg[i].native = H5MM_xfree (oh->mesg[i].native);
-
- oh->mesg[i].dirty = TRUE;
- oh->dirty = TRUE;
- }
- }
-
- /* Fail if we tried to remove any constant messages */
- if (nfailed) {
- HGOTO_ERROR (H5E_OHDR, H5E_CANTINIT, FAIL,
- "unable to remove constant message(s)");
- }
-
- ret_value = SUCCEED;
-
- done:
- if (oh && H5AC_unprotect (ent->file, H5AC_OHDR, &(ent->header), oh)<0) {
- HRETURN_ERROR (H5E_OHDR, H5E_PROTECT, FAIL,
- "unable to release object header");
- }
-
- FUNC_LEAVE (ret_value);
+ H5O_t *oh = NULL;
+ intn i, seq, nfailed = 0;
+ herr_t ret_value = FAIL;
+
+ FUNC_ENTER(H5O_remove, FAIL);
+
+ /* check args */
+ assert(ent);
+ assert(ent->file);
+ assert(H5F_addr_defined(&(ent->header)));
+ assert(type);
+
+ /* load the object header */
+ if (NULL == (oh = H5AC_protect(ent->file, H5AC_OHDR, &(ent->header),
+ NULL, NULL))) {
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL,
+ "unable to load object header");
+ }
+ for (i = seq = 0; i < oh->nmesgs; i++) {
+ if (type->id != oh->mesg[i].type->id)
+ continue;
+ if (seq++ == sequence || H5O_ALL == sequence) {
+
+ /*
+ * Keep track of how many times we failed trying to remove constant
+ * messages.
+ */
+ if (oh->mesg[i].constant) {
+ nfailed++;
+ continue;
+ }
+ /* change message type to nil and zero it */
+ oh->mesg[i].type = H5O_NULL;
+ HDmemset(oh->mesg[i].raw, 0, oh->mesg[i].raw_size);
+ H5O_reset(type, oh->mesg[i].native);
+ oh->mesg[i].native = H5MM_xfree(oh->mesg[i].native);
+
+ oh->mesg[i].dirty = TRUE;
+ oh->dirty = TRUE;
+ }
+ }
+
+ /* Fail if we tried to remove any constant messages */
+ if (nfailed) {
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL,
+ "unable to remove constant message(s)");
+ }
+ ret_value = SUCCEED;
+
+ done:
+ if (oh && H5AC_unprotect(ent->file, H5AC_OHDR, &(ent->header), oh) < 0) {
+ HRETURN_ERROR(H5E_OHDR, H5E_PROTECT, FAIL,
+ "unable to release object header");
+ }
+ FUNC_LEAVE(ret_value);
}
-
/*-------------------------------------------------------------------------
- * Function: H5O_alloc_extend_chunk
+ * Function: H5O_alloc_extend_chunk
*
- * Purpose: Extends a chunk which hasn't been allocated on disk yet
- * to make the chunk large enough to contain a message whose
- * data size is at least SIZE bytes.
+ * Purpose: Extends a chunk which hasn't been allocated on disk yet
+ * to make the chunk large enough to contain a message whose
+ * data size is at least SIZE bytes.
*
- * If the last message of the chunk is the null message, then
- * that message will be extended with the chunk. Otherwise a
- * new null message is created.
+ * If the last message of the chunk is the null message, then
+ * that message will be extended with the chunk. Otherwise a
+ * new null message is created.
*
- * Return: Success: Message index for null message which
- * is large enough to hold SIZE bytes.
+ * Return: Success: Message index for null message which
+ * is large enough to hold SIZE bytes.
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Aug 7 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Aug 7 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static intn
-H5O_alloc_extend_chunk (H5O_t *oh, intn chunkno, size_t size)
+H5O_alloc_extend_chunk(H5O_t *oh, intn chunkno, size_t size)
{
- intn idx, i;
- size_t delta;
- uint8 *old_addr;
-
- FUNC_ENTER (H5O_alloc_extend_chunk, FAIL);
-
- /* check args */
- assert (oh);
- assert (chunkno>=0 && chunkno<oh->nchunks);
- assert (size>0);
-
- if (H5F_addr_defined (&(oh->chunk[chunkno].addr))) {
- HRETURN_ERROR (H5E_OHDR, H5E_NOSPACE, FAIL, "chunk is on disk");
- }
-
- /* try to extend a null message */
- for (idx=0; idx<oh->nmesgs; idx++) {
- if (H5O_NULL_ID==oh->mesg[idx].type->id &&
- (oh->mesg[idx].raw + oh->mesg[idx].raw_size ==
- oh->chunk[chunkno].image + oh->chunk[chunkno].size)) {
-
- delta = MAX (H5O_MIN_SIZE, size-oh->mesg[idx].raw_size);
- H5O_ALIGN (delta, oh->alignment);
- oh->mesg[idx].dirty = TRUE;
- oh->mesg[idx].raw_size += delta;
-
- old_addr = oh->chunk[chunkno].image;
-
- /* Be careful not to indroduce garbage */
- oh->chunk[chunkno].image = H5MM_xrealloc (old_addr,
- (oh->chunk[chunkno].size +
- delta));
- HDmemset (oh->chunk[chunkno].image + oh->chunk[chunkno].size,
- 0, delta);
- oh->chunk[chunkno].size += delta;
-
- /* adjust raw addresses for messages of this chunk */
- if (old_addr != oh->chunk[chunkno].image) {
- for (i=0; i<oh->nmesgs; i++) {
- if (oh->mesg[i].chunkno==chunkno) {
- oh->mesg[i].raw = oh->chunk[chunkno].image +
- (oh->mesg[i].raw - old_addr);
- }
- }
- }
- HRETURN (idx);
- }
- }
-
- /* create a new null message */
- if (oh->nmesgs >= oh->alloc_nmesgs) {
- oh->alloc_nmesgs += H5O_NMESGS;
- oh->mesg = H5MM_xrealloc (oh->mesg,
- oh->alloc_nmesgs * sizeof(H5O_mesg_t));
- }
-
- delta = MAX (H5O_MIN_SIZE, 4+size);
- H5O_ALIGN (delta, oh->alignment);
- idx = oh->nmesgs++;
- oh->mesg[idx].type = H5O_NULL;
- oh->mesg[idx].dirty = TRUE;
- oh->mesg[idx].native = NULL;
- oh->mesg[idx].raw = oh->chunk[chunkno].image + oh->chunk[chunkno].size + 4;
- oh->mesg[idx].raw_size = delta-4;
- oh->mesg[idx].chunkno = chunkno;
-
- old_addr = oh->chunk[chunkno].image;
- oh->chunk[chunkno].size += delta;
- oh->chunk[chunkno].image = H5MM_xrealloc (old_addr,
- oh->chunk[chunkno].size);
-
- /* adjust raw addresses for messages of this chunk */
- if (old_addr != oh->chunk[chunkno].image) {
- for (i=0; i<oh->nmesgs; i++) {
- if (oh->mesg[i].chunkno==chunkno) {
- oh->mesg[i].raw = oh->chunk[chunkno].image +
- (oh->mesg[i].raw - old_addr);
- }
- }
- }
-
- FUNC_LEAVE (idx);
+ intn idx, i;
+ size_t delta;
+ uint8 *old_addr;
+
+ FUNC_ENTER(H5O_alloc_extend_chunk, FAIL);
+
+ /* check args */
+ assert(oh);
+ assert(chunkno >= 0 && chunkno < oh->nchunks);
+ assert(size > 0);
+
+ if (H5F_addr_defined(&(oh->chunk[chunkno].addr))) {
+ HRETURN_ERROR(H5E_OHDR, H5E_NOSPACE, FAIL, "chunk is on disk");
+ }
+ /* try to extend a null message */
+ for (idx = 0; idx < oh->nmesgs; idx++) {
+ if (H5O_NULL_ID == oh->mesg[idx].type->id &&
+ (oh->mesg[idx].raw + oh->mesg[idx].raw_size ==
+ oh->chunk[chunkno].image + oh->chunk[chunkno].size)) {
+
+ delta = MAX(H5O_MIN_SIZE, size - oh->mesg[idx].raw_size);
+ H5O_ALIGN(delta, oh->alignment);
+ oh->mesg[idx].dirty = TRUE;
+ oh->mesg[idx].raw_size += delta;
+
+ old_addr = oh->chunk[chunkno].image;
+
+ /* Be careful not to indroduce garbage */
+ oh->chunk[chunkno].image = H5MM_xrealloc(old_addr,
+ (oh->chunk[chunkno].size +
+ delta));
+ HDmemset(oh->chunk[chunkno].image + oh->chunk[chunkno].size,
+ 0, delta);
+ oh->chunk[chunkno].size += delta;
+
+ /* adjust raw addresses for messages of this chunk */
+ if (old_addr != oh->chunk[chunkno].image) {
+ for (i = 0; i < oh->nmesgs; i++) {
+ if (oh->mesg[i].chunkno == chunkno) {
+ oh->mesg[i].raw = oh->chunk[chunkno].image +
+ (oh->mesg[i].raw - old_addr);
+ }
+ }
+ }
+ HRETURN(idx);
+ }
+ }
+
+ /* create a new null message */
+ if (oh->nmesgs >= oh->alloc_nmesgs) {
+ oh->alloc_nmesgs += H5O_NMESGS;
+ oh->mesg = H5MM_xrealloc(oh->mesg,
+ oh->alloc_nmesgs * sizeof(H5O_mesg_t));
+ }
+ delta = MAX(H5O_MIN_SIZE, 4 + size);
+ H5O_ALIGN(delta, oh->alignment);
+ idx = oh->nmesgs++;
+ oh->mesg[idx].type = H5O_NULL;
+ oh->mesg[idx].dirty = TRUE;
+ oh->mesg[idx].native = NULL;
+ oh->mesg[idx].raw = oh->chunk[chunkno].image + oh->chunk[chunkno].size + 4;
+ oh->mesg[idx].raw_size = delta - 4;
+ oh->mesg[idx].chunkno = chunkno;
+
+ old_addr = oh->chunk[chunkno].image;
+ oh->chunk[chunkno].size += delta;
+ oh->chunk[chunkno].image = H5MM_xrealloc(old_addr,
+ oh->chunk[chunkno].size);
+
+ /* adjust raw addresses for messages of this chunk */
+ if (old_addr != oh->chunk[chunkno].image) {
+ for (i = 0; i < oh->nmesgs; i++) {
+ if (oh->mesg[i].chunkno == chunkno) {
+ oh->mesg[i].raw = oh->chunk[chunkno].image +
+ (oh->mesg[i].raw - old_addr);
+ }
+ }
+ }
+ FUNC_LEAVE(idx);
}
-
/*-------------------------------------------------------------------------
- * Function: H5O_alloc_new_chunk
+ * Function: H5O_alloc_new_chunk
*
- * Purpose: Allocates a new chunk for the object header but doen't
- * give the new chunk a file address yet. One of the other
- * chunks will get an object continuation message. If there
- * isn't room in any other chunk for the object continuation
- * message, then some message from another chunk is moved into
- * this chunk to make room.
+ * Purpose: Allocates a new chunk for the object header but doen't
+ * give the new chunk a file address yet. One of the other
+ * chunks will get an object continuation message. If there
+ * isn't room in any other chunk for the object continuation
+ * message, then some message from another chunk is moved into
+ * this chunk to make room.
*
- * Return: Success: Index number of the null message for the
- * new chunk. The null message will be at
- * least SIZE bytes not counting the message
- * ID or size fields.
+ * Return: Success: Index number of the null message for the
+ * new chunk. The null message will be at
+ * least SIZE bytes not counting the message
+ * ID or size fields.
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Aug 7 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Aug 7 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static intn
-H5O_alloc_new_chunk (H5F_t *f, H5O_t *oh, size_t size)
+H5O_alloc_new_chunk(H5F_t *f, H5O_t *oh, size_t size)
{
- size_t cont_size; /*continuation message size */
- intn found_null=(-1); /*best fit null message */
- intn found_other=(-1); /*best fit other message */
- intn idx=FAIL; /*message number return value */
- uint8 *p = NULL; /*ptr into new chunk */
- H5O_cont_t *cont = NULL; /*native continuation message */
- intn i, chunkno;
-
- FUNC_ENTER (H5O_alloc_new_chunk, FAIL);
-
- /* check args */
- assert (oh);
- assert (size>0);
-
- /*
- * Find the smallest null message that will hold an object
- * continuation message. Failing that, find the smallest message
- * that could be moved to make room for the continuation message.
- * Don't ever move continuation message from one chunk to another.
- */
- cont_size = H5F_SIZEOF_ADDR(f) + H5F_SIZEOF_SIZE(f);
- for (i=0; i<oh->nmesgs; i++) {
- if (H5O_NULL_ID == oh->mesg[i].type->id) {
- if (cont_size == oh->mesg[i].raw_size) {
- found_null = i;
- break;
- } else if (oh->mesg[i].raw_size >= cont_size &&
- (found_null<0 ||
- oh->mesg[i].raw_size < oh->mesg[found_null].raw_size)) {
- found_null = i;
- }
- } else if (H5O_CONT_ID == oh->mesg[i].type->id) {
- /*don't consider continuation messages */
- } else if (oh->mesg[i].raw_size >= cont_size &&
- (found_other<0 ||
- oh->mesg[i].raw_size < oh->mesg[found_other].raw_size)) {
- found_other = i;
- }
- }
- assert (found_null>=0 || found_other>=0);
-
- /*
- * If we must move some other message to make room for the null
- * message, then make sure the new chunk has enough room for that
- * other message.
- */
- if (found_null<0) size += 4 + oh->mesg[found_other].raw_size;
-
- /*
- * The total chunk size must include the requested space plus enough
- * for the message header. This must be at least some minimum and a
- * multiple of the alignment size.
- */
- size = MAX (H5O_MIN_SIZE, size+4);
- H5O_ALIGN (size, oh->alignment);
-
- /*
- * Create the new chunk without giving it a file address.
- */
- if (oh->nchunks >= oh->alloc_nchunks) {
- oh->alloc_nchunks += H5O_NCHUNKS;
- oh->chunk = H5MM_xrealloc (oh->chunk,
- oh->alloc_nchunks * sizeof(H5O_chunk_t));
- }
- chunkno = oh->nchunks++;
- oh->chunk[chunkno].dirty = TRUE;
- H5F_addr_undef (&(oh->chunk[chunkno].addr));
- oh->chunk[chunkno].size = size;
- oh->chunk[chunkno].image = p = H5MM_xcalloc (1, size);
-
- /*
- * Make sure we have enough space for all possible new messages
- * that could be generated below.
- */
- if (oh->nmesgs+3 > oh->alloc_nmesgs) {
- oh->alloc_nmesgs += MAX (H5O_NMESGS, 3);
- oh->mesg = H5MM_xrealloc (oh->mesg,
- oh->alloc_nmesgs * sizeof(H5O_mesg_t));
- }
-
- /*
- * Describe the messages of the new chunk.
- */
- if (found_null<0) {
- found_null = i = oh->nmesgs++;
- oh->mesg[i].type = H5O_NULL;
- oh->mesg[i].dirty = TRUE;
- oh->mesg[i].native = NULL;
- oh->mesg[i].raw = oh->mesg[found_other].raw;
- oh->mesg[i].raw_size = oh->mesg[found_other].raw_size;
- oh->mesg[i].chunkno = oh->mesg[found_other].chunkno;
-
- oh->mesg[found_other].dirty = TRUE;
- oh->mesg[found_other].raw = p+4;
- oh->mesg[found_other].chunkno = chunkno;
- p += 4 + oh->mesg[found_other].raw_size;
- size -= 4 + oh->mesg[found_other].raw_size;
- }
-
- idx = oh->nmesgs++;
- oh->mesg[idx].type = H5O_NULL;
- oh->mesg[idx].dirty = TRUE;
- oh->mesg[idx].native = NULL;
- oh->mesg[idx].raw = p+4;
- oh->mesg[idx].raw_size = size-4;
- oh->mesg[idx].chunkno = chunkno;
-
- /*
- * If the null message that will receive the continuation message
- * is larger than the continuation message, then split it into
- * two null messages.
- */
- if (oh->mesg[found_null].raw_size > cont_size) {
- i = oh->nmesgs++;
- oh->mesg[i].type = H5O_NULL;
- oh->mesg[i].dirty = TRUE;
- oh->mesg[i].native = NULL;
- oh->mesg[i].raw = oh->mesg[found_null].raw + cont_size + 4;
- oh->mesg[i].raw_size = oh->mesg[found_null].raw_size - (cont_size+4);
- oh->mesg[i].chunkno = oh->mesg[found_null].chunkno;
-
- oh->mesg[found_null].dirty = TRUE;
- oh->mesg[found_null].raw_size = cont_size;
- }
-
- /*
- * Initialize the continuation message.
- */
- oh->mesg[found_null].type = H5O_CONT;
- oh->mesg[found_null].dirty = TRUE;
- cont = H5MM_xcalloc (1, sizeof(H5O_cont_t));
- H5F_addr_undef (&(cont->addr));
- cont->size = 0;
- cont->chunkno = chunkno;
- oh->mesg[found_null].native = cont;
-
-
- FUNC_LEAVE (idx);
+ size_t cont_size; /*continuation message size */
+ intn found_null = (-1); /*best fit null message */
+ intn found_other = (-1); /*best fit other message */
+ intn idx = FAIL; /*message number return value */
+ uint8 *p = NULL; /*ptr into new chunk */
+ H5O_cont_t *cont = NULL; /*native continuation message */
+ intn i, chunkno;
+
+ FUNC_ENTER(H5O_alloc_new_chunk, FAIL);
+
+ /* check args */
+ assert(oh);
+ assert(size > 0);
+
+ /*
+ * Find the smallest null message that will hold an object
+ * continuation message. Failing that, find the smallest message
+ * that could be moved to make room for the continuation message.
+ * Don't ever move continuation message from one chunk to another.
+ */
+ cont_size = H5F_SIZEOF_ADDR(f) + H5F_SIZEOF_SIZE(f);
+ for (i = 0; i < oh->nmesgs; i++) {
+ if (H5O_NULL_ID == oh->mesg[i].type->id) {
+ if (cont_size == oh->mesg[i].raw_size) {
+ found_null = i;
+ break;
+ } else if (oh->mesg[i].raw_size >= cont_size &&
+ (found_null < 0 ||
+ oh->mesg[i].raw_size < oh->mesg[found_null].raw_size)) {
+ found_null = i;
+ }
+ } else if (H5O_CONT_ID == oh->mesg[i].type->id) {
+ /*don't consider continuation messages */
+ } else if (oh->mesg[i].raw_size >= cont_size &&
+ (found_other < 0 ||
+ oh->mesg[i].raw_size < oh->mesg[found_other].raw_size)) {
+ found_other = i;
+ }
+ }
+ assert(found_null >= 0 || found_other >= 0);
+
+ /*
+ * If we must move some other message to make room for the null
+ * message, then make sure the new chunk has enough room for that
+ * other message.
+ */
+ if (found_null < 0)
+ size += 4 + oh->mesg[found_other].raw_size;
+
+ /*
+ * The total chunk size must include the requested space plus enough
+ * for the message header. This must be at least some minimum and a
+ * multiple of the alignment size.
+ */
+ size = MAX(H5O_MIN_SIZE, size + 4);
+ H5O_ALIGN(size, oh->alignment);
+
+ /*
+ * Create the new chunk without giving it a file address.
+ */
+ if (oh->nchunks >= oh->alloc_nchunks) {
+ oh->alloc_nchunks += H5O_NCHUNKS;
+ oh->chunk = H5MM_xrealloc(oh->chunk,
+ oh->alloc_nchunks * sizeof(H5O_chunk_t));
+ }
+ chunkno = oh->nchunks++;
+ oh->chunk[chunkno].dirty = TRUE;
+ H5F_addr_undef(&(oh->chunk[chunkno].addr));
+ oh->chunk[chunkno].size = size;
+ oh->chunk[chunkno].image = p = H5MM_xcalloc(1, size);
+
+ /*
+ * Make sure we have enough space for all possible new messages
+ * that could be generated below.
+ */
+ if (oh->nmesgs + 3 > oh->alloc_nmesgs) {
+ oh->alloc_nmesgs += MAX(H5O_NMESGS, 3);
+ oh->mesg = H5MM_xrealloc(oh->mesg,
+ oh->alloc_nmesgs * sizeof(H5O_mesg_t));
+ }
+ /*
+ * Describe the messages of the new chunk.
+ */
+ if (found_null < 0) {
+ found_null = i = oh->nmesgs++;
+ oh->mesg[i].type = H5O_NULL;
+ oh->mesg[i].dirty = TRUE;
+ oh->mesg[i].native = NULL;
+ oh->mesg[i].raw = oh->mesg[found_other].raw;
+ oh->mesg[i].raw_size = oh->mesg[found_other].raw_size;
+ oh->mesg[i].chunkno = oh->mesg[found_other].chunkno;
+
+ oh->mesg[found_other].dirty = TRUE;
+ oh->mesg[found_other].raw = p + 4;
+ oh->mesg[found_other].chunkno = chunkno;
+ p += 4 + oh->mesg[found_other].raw_size;
+ size -= 4 + oh->mesg[found_other].raw_size;
+ }
+ idx = oh->nmesgs++;
+ oh->mesg[idx].type = H5O_NULL;
+ oh->mesg[idx].dirty = TRUE;
+ oh->mesg[idx].native = NULL;
+ oh->mesg[idx].raw = p + 4;
+ oh->mesg[idx].raw_size = size - 4;
+ oh->mesg[idx].chunkno = chunkno;
+
+ /*
+ * If the null message that will receive the continuation message
+ * is larger than the continuation message, then split it into
+ * two null messages.
+ */
+ if (oh->mesg[found_null].raw_size > cont_size) {
+ i = oh->nmesgs++;
+ oh->mesg[i].type = H5O_NULL;
+ oh->mesg[i].dirty = TRUE;
+ oh->mesg[i].native = NULL;
+ oh->mesg[i].raw = oh->mesg[found_null].raw + cont_size + 4;
+ oh->mesg[i].raw_size = oh->mesg[found_null].raw_size - (cont_size + 4);
+ oh->mesg[i].chunkno = oh->mesg[found_null].chunkno;
+
+ oh->mesg[found_null].dirty = TRUE;
+ oh->mesg[found_null].raw_size = cont_size;
+ }
+ /*
+ * Initialize the continuation message.
+ */
+ oh->mesg[found_null].type = H5O_CONT;
+ oh->mesg[found_null].dirty = TRUE;
+ cont = H5MM_xcalloc(1, sizeof(H5O_cont_t));
+ H5F_addr_undef(&(cont->addr));
+ cont->size = 0;
+ cont->chunkno = chunkno;
+ oh->mesg[found_null].native = cont;
+
+ FUNC_LEAVE(idx);
}
-
/*-------------------------------------------------------------------------
- * Function: H5O_alloc
+ * Function: H5O_alloc
*
- * Purpose: Allocate enough space in the object header for this message.
+ * Purpose: Allocate enough space in the object header for this message.
*
- * Return: Success: Index of message
+ * Return: Success: Index of message
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Aug 6 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Aug 6 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static intn
-H5O_alloc (H5F_t *f, H5O_t *oh, const H5O_class_t *type, size_t size)
+H5O_alloc(H5F_t *f, H5O_t *oh, const H5O_class_t *type, size_t size)
{
- intn chunkno;
- intn idx;
- intn null_idx;
-
- FUNC_ENTER (H5O_alloc, FAIL);
-
- /* check args */
- assert (oh);
- assert (type);
- H5O_ALIGN (size, oh->alignment);
-
- /* look for a null message which is large enough */
- for (idx=0; idx<oh->nmesgs; idx++) {
- if (H5O_NULL_ID==oh->mesg[idx].type->id &&
- oh->mesg[idx].raw_size>=size) break;
- }
+ intn chunkno;
+ intn idx;
+ intn null_idx;
+
+ FUNC_ENTER(H5O_alloc, FAIL);
+
+ /* check args */
+ assert(oh);
+ assert(type);
+ H5O_ALIGN(size, oh->alignment);
+
+ /* look for a null message which is large enough */
+ for (idx = 0; idx < oh->nmesgs; idx++) {
+ if (H5O_NULL_ID == oh->mesg[idx].type->id &&
+ oh->mesg[idx].raw_size >= size)
+ break;
+ }
#ifdef LATER
- /*
- * Perhaps if we join adjacent null messages we could make one
- * large enough... we leave this as an exercise for future
- * programmers :-) This isn't a high priority because when an
- * object header is read from disk the null messages are combined
- * anyway.
- */
+ /*
+ * Perhaps if we join adjacent null messages we could make one
+ * large enough... we leave this as an exercise for future
+ * programmers :-) This isn't a high priority because when an
+ * object header is read from disk the null messages are combined
+ * anyway.
+ */
#endif
-
- /* if we didn't find one, then allocate more header space */
- if (idx>=oh->nmesgs) {
-
- /*
- * Look for a chunk which hasn't had disk space allocated yet
- * since we can just increase the size of that chunk.
- */
- for (chunkno=0; chunkno<oh->nchunks; chunkno++) {
- if ((idx=H5O_alloc_extend_chunk (oh, chunkno, size))>=0) break;
- H5ECLEAR;
- }
-
- /*
- * Create a new chunk
- */
- if (idx<0) {
- if ((idx=H5O_alloc_new_chunk (f, oh, size))<0) {
- HRETURN_ERROR (H5E_OHDR, H5E_NOSPACE, FAIL,
- "unable to create a new object header data chunk");
- }
- }
- }
-
- /* do we need to split the null message? */
- if (oh->mesg[idx].raw_size > size) {
- assert (oh->mesg[idx].raw_size - size >= 4); /*room for type & size */
-
- if (oh->nmesgs >= oh->alloc_nmesgs) {
- oh->alloc_nmesgs += H5O_NMESGS;
- oh->mesg = H5MM_xrealloc (oh->mesg,
- oh->alloc_nmesgs * sizeof(H5O_mesg_t));
- }
-
- null_idx = oh->nmesgs++;
- oh->mesg[null_idx].type = H5O_NULL;
- oh->mesg[null_idx].dirty = TRUE;
- oh->mesg[null_idx].native = NULL;
- oh->mesg[null_idx].raw = oh->mesg[idx].raw + size + 4;
- oh->mesg[null_idx].raw_size = oh->mesg[idx].raw_size - (size + 4);
- oh->mesg[null_idx].chunkno = oh->mesg[idx].chunkno;
- oh->mesg[idx].raw_size = size;
- }
-
- /* initialize the new message */
- oh->mesg[idx].type = type;
- oh->mesg[idx].dirty = TRUE;
- oh->mesg[idx].native = NULL;
-
- oh->dirty = TRUE;
- FUNC_LEAVE (idx);
+
+ /* if we didn't find one, then allocate more header space */
+ if (idx >= oh->nmesgs) {
+
+ /*
+ * Look for a chunk which hasn't had disk space allocated yet
+ * since we can just increase the size of that chunk.
+ */
+ for (chunkno = 0; chunkno < oh->nchunks; chunkno++) {
+ if ((idx = H5O_alloc_extend_chunk(oh, chunkno, size)) >= 0)
+ break;
+ H5ECLEAR;
+ }
+
+ /*
+ * Create a new chunk
+ */
+ if (idx < 0) {
+ if ((idx = H5O_alloc_new_chunk(f, oh, size)) < 0) {
+ HRETURN_ERROR(H5E_OHDR, H5E_NOSPACE, FAIL,
+ "unable to create a new object header data chunk");
+ }
+ }
+ }
+ /* do we need to split the null message? */
+ if (oh->mesg[idx].raw_size > size) {
+ assert(oh->mesg[idx].raw_size - size >= 4); /*room for type & size */
+
+ if (oh->nmesgs >= oh->alloc_nmesgs) {
+ oh->alloc_nmesgs += H5O_NMESGS;
+ oh->mesg = H5MM_xrealloc(oh->mesg,
+ oh->alloc_nmesgs * sizeof(H5O_mesg_t));
+ }
+ null_idx = oh->nmesgs++;
+ oh->mesg[null_idx].type = H5O_NULL;
+ oh->mesg[null_idx].dirty = TRUE;
+ oh->mesg[null_idx].native = NULL;
+ oh->mesg[null_idx].raw = oh->mesg[idx].raw + size + 4;
+ oh->mesg[null_idx].raw_size = oh->mesg[idx].raw_size - (size + 4);
+ oh->mesg[null_idx].chunkno = oh->mesg[idx].chunkno;
+ oh->mesg[idx].raw_size = size;
+ }
+ /* initialize the new message */
+ oh->mesg[idx].type = type;
+ oh->mesg[idx].dirty = TRUE;
+ oh->mesg[idx].native = NULL;
+
+ oh->dirty = TRUE;
+ FUNC_LEAVE(idx);
}
-
/*-------------------------------------------------------------------------
- * Function: H5O_debug
+ * Function: H5O_debug
*
- * Purpose: Prints debugging info about an object header.
+ * Purpose: Prints debugging info about an object header.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Aug 6 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Aug 6 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
herr_t
-H5O_debug (H5F_t *f, const haddr_t *addr, FILE *stream, intn indent,
- intn fwidth)
+H5O_debug(H5F_t *f, const haddr_t *addr, FILE * stream, intn indent,
+ intn fwidth)
{
- H5O_t *oh = NULL;
- intn i, chunkno;
- size_t mesg_total=0, chunk_total=0;
- int *sequence;
- haddr_t tmp_addr;
- herr_t ret_value = FAIL;
-
- FUNC_ENTER (H5O_debug, FAIL);
-
- /* check args */
- assert (f);
- assert (addr && H5F_addr_defined (addr));
- assert (stream);
- assert (indent>=0);
- assert (fwidth>=0);
-
- if (NULL==(oh=H5AC_protect (f, H5AC_OHDR, addr, NULL, NULL))) {
- HGOTO_ERROR (H5E_OHDR, H5E_CANTLOAD, FAIL,
- "unable to load object header");
- }
-
- /* debug */
- fprintf (stream, "%*sObject Header...\n", indent, "");
-
- fprintf (stream, "%*s%-*s %d\n", indent, "", fwidth,
- "Dirty:",
- (int)(oh->dirty));
- fprintf (stream, "%*s%-*s %d\n", indent, "", fwidth,
- "Version:",
- (int)(oh->version));
- fprintf (stream, "%*s%-*s %d\n", indent, "", fwidth,
- "Alignment:",
- (int)(oh->alignment));
- fprintf (stream, "%*s%-*s %d\n", indent, "", fwidth,
- "Number of links:",
- (int)(oh->nlink));
- fprintf (stream, "%*s%-*s %d (%d)\n", indent, "", fwidth,
- "Number of messages (allocated):",
- (int)(oh->nmesgs), (int)(oh->alloc_nmesgs));
- fprintf (stream, "%*s%-*s %d (%d)\n", indent, "", fwidth,
- "Number of chunks (allocated):",
- (int)(oh->nchunks), (int)(oh->alloc_nchunks));
-
- /* debug each chunk */
- for (i=chunk_total=0; i<oh->nchunks; i++) {
- chunk_total += oh->chunk[i].size;
- fprintf (stream, "%*sChunk %d...\n", indent, "", i);
-
- fprintf (stream, "%*s%-*s %d\n", indent+3, "", MAX(0,fwidth-3),
- "Dirty:",
- (int)(oh->chunk[i].dirty));
-
- fprintf (stream, "%*s%-*s ", indent+3, "", MAX(0,fwidth-3),
- "Address:");
- H5F_addr_print (stream, &(oh->chunk[i].addr));
- fprintf (stream, "\n");
-
- tmp_addr = *addr;
- H5F_addr_inc (&tmp_addr, H5O_SIZEOF_HDR(f));
- if (0==i && H5F_addr_ne (&(oh->chunk[i].addr), &tmp_addr)) {
- fprintf (stream, "*** WRONG ADDRESS!\n");
- }
- fprintf (stream, "%*s%-*s %lu\n", indent+3, "", MAX(0,fwidth-3),
- "Size in bytes:",
- (unsigned long)(oh->chunk[i].size));
- }
-
- /* debug each message */
- sequence = H5MM_xcalloc (NELMTS(message_type_g), sizeof(int));
- for (i=mesg_total=0; i<oh->nmesgs; i++) {
- mesg_total += 4 + oh->mesg[i].raw_size;
- fprintf (stream, "%*sMessage %d...\n", indent, "", i);
-
- /* check for bad message id */
- if (oh->mesg[i].type->id<0 ||
- oh->mesg[i].type->id>=NELMTS(message_type_g)) {
- fprintf (stream, "*** BAD MESSAGE ID 0x%04x\n",
- oh->mesg[i].type->id);
- continue;
- }
-
- /* message name and size */
- fprintf (stream, "%*s%-*s 0x%04x %s(%d)\n",
- indent+3, "", MAX (0, fwidth-3),
- "Message ID:",
- (unsigned)(oh->mesg[i].type->id),
- oh->mesg[i].type->name,
- sequence[oh->mesg[i].type->id]++);
- fprintf (stream, "%*s%-*s %lu\n", indent+3, "", MAX (0, fwidth-3),
- "Raw size in bytes:",
- (unsigned long)(oh->mesg[i].raw_size));
- fprintf (stream, "%*s%-*s %s\n", indent+3, "", MAX (0, fwidth-3),
- "Constant:",
- oh->mesg[i].constant ? "Yes" : "No");
- fprintf (stream, "%*s%-*s %d\n", indent+3, "", MAX(0,fwidth-3),
- "Chunk number:",
- (int)(oh->mesg[i].chunkno));
- chunkno = oh->mesg[i].chunkno;
- if (chunkno<0 || chunkno>=oh->nchunks) {
- fprintf (stream, "*** BAD CHUNK NUMBER\n");
- }
-
- /* check the size */
- if ((oh->mesg[i].raw + oh->mesg[i].raw_size >
- oh->chunk[chunkno].image + oh->chunk[chunkno].size) ||
- (oh->mesg[i].raw < oh->chunk[chunkno].image)) {
- fprintf (stream, "*** BAD MESSAGE RAW ADDRESS\n");
- }
-
- /* decode the message */
- if (NULL==oh->mesg[i].native && oh->mesg[i].type->decode) {
- oh->mesg[i].native = (oh->mesg[i].type->decode)(f,
- oh->mesg[i].raw_size,
- oh->mesg[i].raw);
- }
-
- /* print the message */
- if (oh->mesg[i].type->debug) {
- (oh->mesg[i].type->debug)(f, oh->mesg[i].native, stream, indent+3,
- MAX(0, fwidth-3));
- } else {
- fprintf (stream, "%*sNo info for this message.\n", indent+3, "");
- }
- }
- sequence = H5MM_xfree (sequence);
-
- if (mesg_total != chunk_total) {
- fprintf (stream, "*** TOTAL SIZE DOES NOT MATCH ALLOCATED SIZE!\n");
- }
-
- ret_value = SUCCEED;
-
- done:
- if (oh && H5AC_unprotect (f, H5AC_OHDR, addr, oh)<0) {
- HRETURN_ERROR (H5E_OHDR, H5E_PROTECT, FAIL,
- "unable to release object header");
- }
-
- FUNC_LEAVE (ret_value);
+ H5O_t *oh = NULL;
+ intn i, chunkno;
+ size_t mesg_total = 0, chunk_total = 0;
+ int *sequence;
+ haddr_t tmp_addr;
+ herr_t ret_value = FAIL;
+
+ FUNC_ENTER(H5O_debug, FAIL);
+
+ /* check args */
+ assert(f);
+ assert(addr && H5F_addr_defined(addr));
+ assert(stream);
+ assert(indent >= 0);
+ assert(fwidth >= 0);
+
+ if (NULL == (oh = H5AC_protect(f, H5AC_OHDR, addr, NULL, NULL))) {
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL,
+ "unable to load object header");
+ }
+ /* debug */
+ fprintf(stream, "%*sObject Header...\n", indent, "");
+
+ fprintf(stream, "%*s%-*s %d\n", indent, "", fwidth,
+ "Dirty:",
+ (int) (oh->dirty));
+ fprintf(stream, "%*s%-*s %d\n", indent, "", fwidth,
+ "Version:",
+ (int) (oh->version));
+ fprintf(stream, "%*s%-*s %d\n", indent, "", fwidth,
+ "Alignment:",
+ (int) (oh->alignment));
+ fprintf(stream, "%*s%-*s %d\n", indent, "", fwidth,
+ "Number of links:",
+ (int) (oh->nlink));
+ fprintf(stream, "%*s%-*s %d (%d)\n", indent, "", fwidth,
+ "Number of messages (allocated):",
+ (int) (oh->nmesgs), (int) (oh->alloc_nmesgs));
+ fprintf(stream, "%*s%-*s %d (%d)\n", indent, "", fwidth,
+ "Number of chunks (allocated):",
+ (int) (oh->nchunks), (int) (oh->alloc_nchunks));
+
+ /* debug each chunk */
+ for (i = chunk_total = 0; i < oh->nchunks; i++) {
+ chunk_total += oh->chunk[i].size;
+ fprintf(stream, "%*sChunk %d...\n", indent, "", i);
+
+ fprintf(stream, "%*s%-*s %d\n", indent + 3, "", MAX(0, fwidth - 3),
+ "Dirty:",
+ (int) (oh->chunk[i].dirty));
+
+ fprintf(stream, "%*s%-*s ", indent + 3, "", MAX(0, fwidth - 3),
+ "Address:");
+ H5F_addr_print(stream, &(oh->chunk[i].addr));
+ fprintf(stream, "\n");
+
+ tmp_addr = *addr;
+ H5F_addr_inc(&tmp_addr, H5O_SIZEOF_HDR(f));
+ if (0 == i && H5F_addr_ne(&(oh->chunk[i].addr), &tmp_addr)) {
+ fprintf(stream, "*** WRONG ADDRESS!\n");
+ }
+ fprintf(stream, "%*s%-*s %lu\n", indent + 3, "", MAX(0, fwidth - 3),
+ "Size in bytes:",
+ (unsigned long) (oh->chunk[i].size));
+ }
+
+ /* debug each message */
+ sequence = H5MM_xcalloc(NELMTS(message_type_g), sizeof(int));
+ for (i = mesg_total = 0; i < oh->nmesgs; i++) {
+ mesg_total += 4 + oh->mesg[i].raw_size;
+ fprintf(stream, "%*sMessage %d...\n", indent, "", i);
+
+ /* check for bad message id */
+ if (oh->mesg[i].type->id < 0 ||
+ oh->mesg[i].type->id >= NELMTS(message_type_g)) {
+ fprintf(stream, "*** BAD MESSAGE ID 0x%04x\n",
+ oh->mesg[i].type->id);
+ continue;
+ }
+ /* message name and size */
+ fprintf(stream, "%*s%-*s 0x%04x %s(%d)\n",
+ indent + 3, "", MAX(0, fwidth - 3),
+ "Message ID:",
+ (unsigned) (oh->mesg[i].type->id),
+ oh->mesg[i].type->name,
+ sequence[oh->mesg[i].type->id]++);
+ fprintf(stream, "%*s%-*s %lu\n", indent + 3, "", MAX(0, fwidth - 3),
+ "Raw size in bytes:",
+ (unsigned long) (oh->mesg[i].raw_size));
+ fprintf(stream, "%*s%-*s %s\n", indent + 3, "", MAX(0, fwidth - 3),
+ "Constant:",
+ oh->mesg[i].constant ? "Yes" : "No");
+ fprintf(stream, "%*s%-*s %d\n", indent + 3, "", MAX(0, fwidth - 3),
+ "Chunk number:",
+ (int) (oh->mesg[i].chunkno));
+ chunkno = oh->mesg[i].chunkno;
+ if (chunkno < 0 || chunkno >= oh->nchunks) {
+ fprintf(stream, "*** BAD CHUNK NUMBER\n");
+ }
+ /* check the size */
+ if ((oh->mesg[i].raw + oh->mesg[i].raw_size >
+ oh->chunk[chunkno].image + oh->chunk[chunkno].size) ||
+ (oh->mesg[i].raw < oh->chunk[chunkno].image)) {
+ fprintf(stream, "*** BAD MESSAGE RAW ADDRESS\n");
+ }
+ /* decode the message */
+ if (NULL == oh->mesg[i].native && oh->mesg[i].type->decode) {
+ oh->mesg[i].native = (oh->mesg[i].type->decode) (f,
+ oh->mesg[i].raw_size,
+ oh->mesg[i].raw);
+ }
+ /* print the message */
+ if (oh->mesg[i].type->debug) {
+ (oh->mesg[i].type->debug) (f, oh->mesg[i].native, stream, indent + 3,
+ MAX(0, fwidth - 3));
+ } else {
+ fprintf(stream, "%*sNo info for this message.\n", indent + 3, "");
+ }
+ }
+ sequence = H5MM_xfree(sequence);
+
+ if (mesg_total != chunk_total) {
+ fprintf(stream, "*** TOTAL SIZE DOES NOT MATCH ALLOCATED SIZE!\n");
+ }
+ ret_value = SUCCEED;
+
+ done:
+ if (oh && H5AC_unprotect(f, H5AC_OHDR, addr, oh) < 0) {
+ HRETURN_ERROR(H5E_OHDR, H5E_PROTECT, FAIL,
+ "unable to release object header");
+ }
+ FUNC_LEAVE(ret_value);
}
diff --git a/src/H5Ocont.c b/src/H5Ocont.c
index b5b3715..058075d 100644
--- a/src/H5Ocont.c
+++ b/src/H5Ocont.c
@@ -1,19 +1,19 @@
/*-------------------------------------------------------------------------
- * Copyright (C) 1997 National Center for Supercomputing Applications.
+ * Copyright (C) 1997 National Center for Supercomputing Applications.
* All rights reserved.
*
*-------------------------------------------------------------------------
*
- * Created: H5Ocont.c
- * Aug 6 1997
- * Robb Matzke <matzke@llnl.gov>
+ * Created: H5Ocont.c
+ * Aug 6 1997
+ * Robb Matzke <matzke@llnl.gov>
*
- * Purpose: The object header continuation message. This
- * message is only generated and read from within
- * the H5O package. Therefore, do not change
- * any definitions in this file!
+ * Purpose: The object header continuation message. This
+ * message is only generated and read from within
+ * the H5O package. Therefore, do not change
+ * any definitions in this file!
*
- * Modifications:
+ * Modifications:
*
*-------------------------------------------------------------------------
*/
@@ -22,152 +22,151 @@
#include <H5MMprivate.h>
#include <H5Oprivate.h>
-#define PABLO_MASK H5O_cont_mask
+#define PABLO_MASK H5O_cont_mask
/* PRIVATE PROTOTYPES */
-static void *H5O_cont_decode (H5F_t *f, size_t raw_size, const uint8 *p);
-static herr_t H5O_cont_encode (H5F_t *f, size_t size, uint8 *p,
- const void *_mesg);
-static herr_t H5O_cont_debug (H5F_t *f, const void *_mesg, FILE *stream,
- intn indent, intn fwidth);
+static void *H5O_cont_decode(H5F_t *f, size_t raw_size, const uint8 *p);
+static herr_t H5O_cont_encode(H5F_t *f, size_t size, uint8 *p,
+ const void *_mesg);
+static herr_t H5O_cont_debug(H5F_t *f, const void *_mesg, FILE * stream,
+ intn indent, intn fwidth);
/* This message derives from H5O */
-const H5O_class_t H5O_CONT[1] = {{
- H5O_CONT_ID, /*message id number */
- "hdr continuation", /*message name for debugging */
- sizeof (H5O_cont_t), /*native message size */
- H5O_cont_decode, /*decode message */
- H5O_cont_encode, /*encode message */
- NULL, /*no copy method */
- NULL, /*no size method */
- NULL, /*default reset method */
- H5O_cont_debug, /*debugging */
-}};
+const H5O_class_t H5O_CONT[1] =
+{
+ {
+ H5O_CONT_ID, /*message id number */
+ "hdr continuation", /*message name for debugging */
+ sizeof(H5O_cont_t), /*native message size */
+ H5O_cont_decode, /*decode message */
+ H5O_cont_encode, /*encode message */
+ NULL, /*no copy method */
+ NULL, /*no size method */
+ NULL, /*default reset method */
+ H5O_cont_debug, /*debugging */
+ }};
/* Interface initialization */
-static intn interface_initialize_g = FALSE;
-#define INTERFACE_INIT NULL
-
+static intn interface_initialize_g = FALSE;
+#define INTERFACE_INIT NULL
/*-------------------------------------------------------------------------
- * Function: H5O_cont_decode
+ * Function: H5O_cont_decode
*
- * Purpose: Decode the raw header continuation message.
+ * Purpose: Decode the raw header continuation message.
*
- * Return: Success: Ptr to the new native message
+ * Return: Success: Ptr to the new native message
*
- * Failure: NULL
+ * Failure: NULL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Aug 6 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Aug 6 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-static void *
-H5O_cont_decode (H5F_t *f, size_t raw_size, const uint8 *p)
+static void *
+H5O_cont_decode(H5F_t *f, size_t raw_size, const uint8 *p)
{
- H5O_cont_t *cont = NULL;
-
- FUNC_ENTER (H5O_cont_decode, NULL);
+ H5O_cont_t *cont = NULL;
- /* check args */
- assert (f);
- assert (raw_size == H5F_SIZEOF_ADDR(f) + H5F_SIZEOF_SIZE(f));
- assert (p);
+ FUNC_ENTER(H5O_cont_decode, NULL);
- /* decode */
- cont = H5MM_xcalloc (1, sizeof(H5O_cont_t));
- H5F_addr_decode (f, &p, &(cont->addr));
- H5F_decode_length (f, p, cont->size);
+ /* check args */
+ assert(f);
+ assert(raw_size == H5F_SIZEOF_ADDR(f) + H5F_SIZEOF_SIZE(f));
+ assert(p);
- FUNC_LEAVE ((void*)cont);
-}
+ /* decode */
+ cont = H5MM_xcalloc(1, sizeof(H5O_cont_t));
+ H5F_addr_decode(f, &p, &(cont->addr));
+ H5F_decode_length(f, p, cont->size);
+ FUNC_LEAVE((void *) cont);
+}
/*-------------------------------------------------------------------------
- * Function: H5O_cont_encode
+ * Function: H5O_cont_encode
*
- * Purpose: Encodes a continuation message.
+ * Purpose: Encodes a continuation message.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Aug 7 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Aug 7 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_cont_encode (H5F_t *f, size_t size, uint8 *p, const void *_mesg)
+H5O_cont_encode(H5F_t *f, size_t size, uint8 *p, const void *_mesg)
{
- const H5O_cont_t *cont = (const H5O_cont_t *)_mesg;
+ const H5O_cont_t *cont = (const H5O_cont_t *) _mesg;
- FUNC_ENTER (H5O_cont_encode, FAIL);
+ FUNC_ENTER(H5O_cont_encode, FAIL);
- /* check args */
- assert (f);
- assert (size == H5F_SIZEOF_ADDR(f) + H5F_SIZEOF_SIZE(f));
- assert (p);
- assert (cont);
+ /* check args */
+ assert(f);
+ assert(size == H5F_SIZEOF_ADDR(f) + H5F_SIZEOF_SIZE(f));
+ assert(p);
+ assert(cont);
- /* encode */
- H5F_addr_encode (f, &p, &(cont->addr));
- H5F_encode_length (f, p, cont->size);
+ /* encode */
+ H5F_addr_encode(f, &p, &(cont->addr));
+ H5F_encode_length(f, p, cont->size);
- FUNC_LEAVE (SUCCEED);
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5O_cont_debug
+ * Function: H5O_cont_debug
*
- * Purpose: Prints debugging info.
+ * Purpose: Prints debugging info.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Aug 6 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Aug 6 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_cont_debug (H5F_t *f, const void *_mesg, FILE *stream,
- intn indent, intn fwidth)
+H5O_cont_debug(H5F_t *f, const void *_mesg, FILE * stream,
+ intn indent, intn fwidth)
{
- const H5O_cont_t *cont = (const H5O_cont_t *)_mesg;
-
- FUNC_ENTER (H5O_cont_debug, FAIL);
-
- /* check args */
- assert (f);
- assert (cont);
- assert (stream);
- assert (indent>=0);
- assert (fwidth>=0);
-
- fprintf (stream, "%*s%-*s ", indent, "", fwidth,
- "Continuation address:");
- H5F_addr_print (stream, &(cont->addr));
- fprintf (stream, "\n");
-
- fprintf (stream, "%*s%-*s %lu\n", indent, "", fwidth,
- "Continuation size in bytes:",
- (unsigned long)(cont->size));
- fprintf (stream, "%*s%-*s %d\n", indent, "", fwidth,
- "Points to chunk number:",
- (int)(cont->chunkno));
-
- FUNC_LEAVE (SUCCEED);
+ const H5O_cont_t *cont = (const H5O_cont_t *) _mesg;
+
+ FUNC_ENTER(H5O_cont_debug, FAIL);
+
+ /* check args */
+ assert(f);
+ assert(cont);
+ assert(stream);
+ assert(indent >= 0);
+ assert(fwidth >= 0);
+
+ fprintf(stream, "%*s%-*s ", indent, "", fwidth,
+ "Continuation address:");
+ H5F_addr_print(stream, &(cont->addr));
+ fprintf(stream, "\n");
+
+ fprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth,
+ "Continuation size in bytes:",
+ (unsigned long) (cont->size));
+ fprintf(stream, "%*s%-*s %d\n", indent, "", fwidth,
+ "Points to chunk number:",
+ (int) (cont->chunkno));
+
+ FUNC_LEAVE(SUCCEED);
}
diff --git a/src/H5Odtype.c b/src/H5Odtype.c
index 35105de..4315717 100644
--- a/src/H5Odtype.c
+++ b/src/H5Odtype.c
@@ -11,12 +11,12 @@
****************************************************************************/
#ifdef RCSID
-static char RcsId[] = "@(#)$Revision$";
+static char RcsId[] = "@(#)$Revision$";
#endif
/* $Id$ */
-#define H5T_PACKAGE /*prevent warning from including H5Tpkg.h */
+#define H5T_PACKAGE /*prevent warning from including H5Tpkg.h */
#include <H5private.h>
#include <H5Eprivate.h>
@@ -25,46 +25,47 @@ static char RcsId[] = "@(#)$Revision$";
#include <H5Oprivate.h>
#include <H5Tpkg.h>
-#define PABLO_MASK H5O_dtype_mask
+#define PABLO_MASK H5O_dtype_mask
/* PRIVATE PROTOTYPES */
-static herr_t H5O_dtype_encode (H5F_t *f, size_t raw_size, uint8 *p,
- const void *mesg);
-static void *H5O_dtype_decode (H5F_t *f, size_t raw_size, const uint8 *p);
-static void *H5O_dtype_copy (const void *_mesg, void *_dest);
-static size_t H5O_dtype_size (H5F_t *f, const void *_mesg);
-static herr_t H5O_dtype_reset (void *_mesg);
-static herr_t H5O_dtype_debug (H5F_t *f, const void *_mesg,
- FILE *stream, intn indent, intn fwidth);
+static herr_t H5O_dtype_encode(H5F_t *f, size_t raw_size, uint8 *p,
+ const void *mesg);
+static void *H5O_dtype_decode(H5F_t *f, size_t raw_size, const uint8 *p);
+static void *H5O_dtype_copy(const void *_mesg, void *_dest);
+static size_t H5O_dtype_size(H5F_t *f, const void *_mesg);
+static herr_t H5O_dtype_reset(void *_mesg);
+static herr_t H5O_dtype_debug(H5F_t *f, const void *_mesg,
+ FILE * stream, intn indent, intn fwidth);
/* This message derives from H5O */
-const H5O_class_t H5O_DTYPE[1] = {{
- H5O_DTYPE_ID, /* message id number */
- "data_type", /* message name for debugging */
- sizeof (H5T_t), /* native message size */
- H5O_dtype_decode, /* decode message */
- H5O_dtype_encode, /* encode message */
- H5O_dtype_copy, /* copy the native value */
- H5O_dtype_size, /* size of raw message */
- H5O_dtype_reset, /* reset method */
- H5O_dtype_debug, /* debug the message */
-}};
+const H5O_class_t H5O_DTYPE[1] =
+{
+ {
+ H5O_DTYPE_ID, /* message id number */
+ "data_type", /* message name for debugging */
+ sizeof(H5T_t), /* native message size */
+ H5O_dtype_decode, /* decode message */
+ H5O_dtype_encode, /* encode message */
+ H5O_dtype_copy, /* copy the native value */
+ H5O_dtype_size, /* size of raw message */
+ H5O_dtype_reset, /* reset method */
+ H5O_dtype_debug, /* debug the message */
+ }};
/* Interface initialization */
-static hbool_t interface_initialize_g = FALSE;
-#define INTERFACE_INIT NULL
-
+static hbool_t interface_initialize_g = FALSE;
+#define INTERFACE_INIT NULL
/*-------------------------------------------------------------------------
- * Function: H5O_dtype_decode_helper
+ * Function: H5O_dtype_decode_helper
*
- * Purpose: Decodes a data type
+ * Purpose: Decodes a data type
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Monday, December 8, 1997
*
* Modifications:
@@ -72,126 +73,126 @@ static hbool_t interface_initialize_g = FALSE;
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_dtype_decode_helper (const uint8 **pp, H5T_t *dt)
+H5O_dtype_decode_helper(const uint8 **pp, H5T_t *dt)
{
- uintn flags, perm_word;
- intn i, j;
-
- FUNC_ENTER (H5O_dtype_decode_helper, FAIL);
-
- /* check args */
- assert (pp && *pp);
- assert (dt);
-
- /* decode */
- UINT32DECODE (*pp, flags);
- dt->type = flags & 0xff;
- flags >>= 8;
- UINT32DECODE (*pp, dt->size);
-
- switch (dt->type) {
- case H5T_INTEGER:
- /*
- * Integer types...
- */
- dt->u.atomic.order = (flags & 0x1) ? H5T_ORDER_BE : H5T_ORDER_LE;
- dt->u.atomic.lsb_pad = (flags & 0x2) ? H5T_PAD_ONE : H5T_PAD_ZERO;
- dt->u.atomic.msb_pad = (flags & 0x4) ? H5T_PAD_ONE : H5T_PAD_ZERO;
- dt->u.atomic.u.i.sign = (flags & 0x8) ? H5T_SGN_2 : H5T_SGN_NONE;
- UINT16DECODE (*pp, dt->u.atomic.offset);
- UINT16DECODE (*pp, dt->u.atomic.prec);
- break;
-
- case H5T_FLOAT:
- /*
- * Floating-point types...
- */
- dt->u.atomic.order = (flags & 0x1) ? H5T_ORDER_BE : H5T_ORDER_LE;
- dt->u.atomic.lsb_pad = (flags & 0x2) ? H5T_PAD_ONE : H5T_PAD_ZERO;
- dt->u.atomic.msb_pad = (flags & 0x4) ? H5T_PAD_ONE : H5T_PAD_ZERO;
- dt->u.atomic.u.f.pad = (flags & 0x8) ? H5T_PAD_ONE : H5T_PAD_ZERO;
- switch ((flags>>4) & 0x03) {
- case 0:
- dt->u.atomic.u.f.norm = H5T_NORM_NONE;
- break;
- case 1:
- dt->u.atomic.u.f.norm = H5T_NORM_MSBSET;
- break;
- case 2:
- dt->u.atomic.u.f.norm = H5T_NORM_IMPLIED;
- break;
- default:
- HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "unknown floating-point normalization");
- }
- dt->u.atomic.u.f.sign = (flags>>8) & 0xff;
- UINT16DECODE (*pp, dt->u.atomic.offset);
- UINT16DECODE (*pp, dt->u.atomic.prec);
- dt->u.atomic.u.f.epos = *(*pp)++;
- dt->u.atomic.u.f.esize = *(*pp)++;
- assert (dt->u.atomic.u.f.esize>0);
- dt->u.atomic.u.f.mpos = *(*pp)++;
- dt->u.atomic.u.f.msize = *(*pp)++;
- assert (dt->u.atomic.u.f.msize>0);
- UINT32DECODE (*pp, dt->u.atomic.u.f.ebias);
- break;
-
- case H5T_COMPOUND:
- /*
- * Compound data types...
- */
- dt->u.compnd.nmembs = flags & 0xffff;
- assert (dt->u.compnd.nmembs>0);
- dt->u.compnd.nalloc = dt->u.compnd.nmembs;
- dt->u.compnd.memb = H5MM_xcalloc (dt->u.compnd.nalloc,
- sizeof(H5T_member_t));
- for (i=0; i<dt->u.compnd.nmembs; i++) {
- dt->u.compnd.memb[i].name = H5MM_xstrdup (*pp);
- *pp += ((strlen (*pp)+8)/8) * 8; /*multiple of 8 w/ null terminator*/
- UINT32DECODE (*pp, dt->u.compnd.memb[i].offset);
- dt->u.compnd.memb[i].ndims = *(*pp)++;
- assert (dt->u.compnd.memb[i].ndims<=4);
- *pp += 3; /*reserved bytes*/
- for (j=0; j<dt->u.compnd.memb[i].ndims; j++) {
- UINT32DECODE (*pp, dt->u.compnd.memb[i].dim[j]);
- }
- UINT32DECODE (*pp, perm_word);
- dt->u.compnd.memb[i].perm[0] = (perm_word >> 0) & 0xff;
- dt->u.compnd.memb[i].perm[1] = (perm_word >> 8) & 0xff;
- dt->u.compnd.memb[i].perm[2] = (perm_word >> 16) & 0xff;
- dt->u.compnd.memb[i].perm[3] = (perm_word >> 24) & 0xff;
- if (H5O_dtype_decode_helper (pp, &(dt->u.compnd.memb[i].type))<0 ||
- H5T_COMPOUND==dt->u.compnd.memb[i].type.type) {
- for (j=0; j<=i; j++) H5MM_xfree (dt->u.compnd.memb[i].name);
- H5MM_xfree (dt->u.compnd.memb);
- HRETURN_ERROR (H5E_DATATYPE, H5E_CANTDECODE, FAIL,
- "can't decode member type");
- }
- }
- break;
-
- default:
- if (flags) {
- HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "class flags are non-zero");
- }
- break;
- }
-
- FUNC_LEAVE (SUCCEED);
+ uintn flags, perm_word;
+ intn i, j;
+
+ FUNC_ENTER(H5O_dtype_decode_helper, FAIL);
+
+ /* check args */
+ assert(pp && *pp);
+ assert(dt);
+
+ /* decode */
+ UINT32DECODE(*pp, flags);
+ dt->type = flags & 0xff;
+ flags >>= 8;
+ UINT32DECODE(*pp, dt->size);
+
+ switch (dt->type) {
+ case H5T_INTEGER:
+ /*
+ * Integer types...
+ */
+ dt->u.atomic.order = (flags & 0x1) ? H5T_ORDER_BE : H5T_ORDER_LE;
+ dt->u.atomic.lsb_pad = (flags & 0x2) ? H5T_PAD_ONE : H5T_PAD_ZERO;
+ dt->u.atomic.msb_pad = (flags & 0x4) ? H5T_PAD_ONE : H5T_PAD_ZERO;
+ dt->u.atomic.u.i.sign = (flags & 0x8) ? H5T_SGN_2 : H5T_SGN_NONE;
+ UINT16DECODE(*pp, dt->u.atomic.offset);
+ UINT16DECODE(*pp, dt->u.atomic.prec);
+ break;
+
+ case H5T_FLOAT:
+ /*
+ * Floating-point types...
+ */
+ dt->u.atomic.order = (flags & 0x1) ? H5T_ORDER_BE : H5T_ORDER_LE;
+ dt->u.atomic.lsb_pad = (flags & 0x2) ? H5T_PAD_ONE : H5T_PAD_ZERO;
+ dt->u.atomic.msb_pad = (flags & 0x4) ? H5T_PAD_ONE : H5T_PAD_ZERO;
+ dt->u.atomic.u.f.pad = (flags & 0x8) ? H5T_PAD_ONE : H5T_PAD_ZERO;
+ switch ((flags >> 4) & 0x03) {
+ case 0:
+ dt->u.atomic.u.f.norm = H5T_NORM_NONE;
+ break;
+ case 1:
+ dt->u.atomic.u.f.norm = H5T_NORM_MSBSET;
+ break;
+ case 2:
+ dt->u.atomic.u.f.norm = H5T_NORM_IMPLIED;
+ break;
+ default:
+ HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
+ "unknown floating-point normalization");
+ }
+ dt->u.atomic.u.f.sign = (flags >> 8) & 0xff;
+ UINT16DECODE(*pp, dt->u.atomic.offset);
+ UINT16DECODE(*pp, dt->u.atomic.prec);
+ dt->u.atomic.u.f.epos = *(*pp)++;
+ dt->u.atomic.u.f.esize = *(*pp)++;
+ assert(dt->u.atomic.u.f.esize > 0);
+ dt->u.atomic.u.f.mpos = *(*pp)++;
+ dt->u.atomic.u.f.msize = *(*pp)++;
+ assert(dt->u.atomic.u.f.msize > 0);
+ UINT32DECODE(*pp, dt->u.atomic.u.f.ebias);
+ break;
+
+ case H5T_COMPOUND:
+ /*
+ * Compound data types...
+ */
+ dt->u.compnd.nmembs = flags & 0xffff;
+ assert(dt->u.compnd.nmembs > 0);
+ dt->u.compnd.nalloc = dt->u.compnd.nmembs;
+ dt->u.compnd.memb = H5MM_xcalloc(dt->u.compnd.nalloc,
+ sizeof(H5T_member_t));
+ for (i = 0; i < dt->u.compnd.nmembs; i++) {
+ dt->u.compnd.memb[i].name = H5MM_xstrdup(*pp);
+ *pp += ((strlen(*pp) + 8) / 8) * 8; /*multiple of 8 w/ null terminator */
+ UINT32DECODE(*pp, dt->u.compnd.memb[i].offset);
+ dt->u.compnd.memb[i].ndims = *(*pp)++;
+ assert(dt->u.compnd.memb[i].ndims <= 4);
+ *pp += 3; /*reserved bytes */
+ for (j = 0; j < dt->u.compnd.memb[i].ndims; j++) {
+ UINT32DECODE(*pp, dt->u.compnd.memb[i].dim[j]);
+ }
+ UINT32DECODE(*pp, perm_word);
+ dt->u.compnd.memb[i].perm[0] = (perm_word >> 0) & 0xff;
+ dt->u.compnd.memb[i].perm[1] = (perm_word >> 8) & 0xff;
+ dt->u.compnd.memb[i].perm[2] = (perm_word >> 16) & 0xff;
+ dt->u.compnd.memb[i].perm[3] = (perm_word >> 24) & 0xff;
+ if (H5O_dtype_decode_helper(pp, &(dt->u.compnd.memb[i].type)) < 0 ||
+ H5T_COMPOUND == dt->u.compnd.memb[i].type.type) {
+ for (j = 0; j <= i; j++)
+ H5MM_xfree(dt->u.compnd.memb[i].name);
+ H5MM_xfree(dt->u.compnd.memb);
+ HRETURN_ERROR(H5E_DATATYPE, H5E_CANTDECODE, FAIL,
+ "can't decode member type");
+ }
+ }
+ break;
+
+ default:
+ if (flags) {
+ HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
+ "class flags are non-zero");
+ }
+ break;
+ }
+
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5O_dtype_encode_helper
+ * Function: H5O_dtype_encode_helper
*
- * Purpose: Encodes a data type.
+ * Purpose: Encodes a data type.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Monday, December 8, 1997
*
* Modifications:
@@ -199,191 +200,193 @@ H5O_dtype_decode_helper (const uint8 **pp, H5T_t *dt)
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_dtype_encode_helper (uint8 **pp, const H5T_t *dt)
+H5O_dtype_encode_helper(uint8 **pp, const H5T_t *dt)
{
- uintn flags = 0;
- uintn perm_word;
- char *hdr = *pp;
- intn i, j, n;
-
- FUNC_ENTER (H5O_dtype_encode_helper, FAIL);
-
- /* check args */
- assert (pp && *pp);
- assert (dt);
-
- /* skip the type and class bit field for now */
- *pp += 4;
- UINT32ENCODE (*pp, dt->size);
-
- switch (dt->type) {
- case H5T_INTEGER:
- /*
- * Integer data types...
- */
- switch (dt->u.atomic.order) {
- case H5T_ORDER_LE:
- break; /*nothing*/
- case H5T_ORDER_BE:
- flags |= 0x01;
- break;
- default:
- HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "byte order is not supported in file format yet");
- }
-
- switch (dt->u.atomic.lsb_pad) {
- case H5T_PAD_ZERO:
- break; /*nothing*/
- case H5T_PAD_ONE:
- flags |= 0x02;
- break;
- default:
- HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "bit padding is not supported in file format yet");
- }
-
- switch (dt->u.atomic.msb_pad) {
- case H5T_PAD_ZERO:
- break; /*nothing*/
- case H5T_PAD_ONE:
- flags |= 0x04;
- break;
- default:
- HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "bit padding is not supported in file format yet");
- }
-
- switch (dt->u.atomic.u.i.sign) {
- case H5T_SGN_NONE:
- break; /*nothing*/
- case H5T_SGN_2:
- flags |= 0x08;
- break;
- default:
- HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "sign scheme is not supported in file format yet");
- }
-
- UINT16ENCODE (*pp, dt->u.atomic.offset);
- UINT16ENCODE (*pp, dt->u.atomic.prec);
- break;
-
- case H5T_FLOAT:
- /*
- * Floating-point types...
- */
- switch (dt->u.atomic.order) {
- case H5T_ORDER_LE:
- break; /*nothing*/
- case H5T_ORDER_BE:
- flags |= 0x01;
- break;
- default:
- HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "byte order is not supported in file format yet");
- }
-
- switch (dt->u.atomic.lsb_pad) {
- case H5T_PAD_ZERO:
- break; /*nothing*/
- case H5T_PAD_ONE:
- flags |= 0x02;
- break;
- default:
- HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "bit padding is not supported in file format yet");
- }
-
- switch (dt->u.atomic.msb_pad) {
- case H5T_PAD_ZERO:
- break; /*nothing*/
- case H5T_PAD_ONE:
- flags |= 0x04;
- break;
- default:
- HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "bit padding is not supported in file format yet");
- }
-
- switch (dt->u.atomic.u.f.pad) {
- case H5T_PAD_ZERO:
- break; /*nothing*/
- case H5T_PAD_ONE:
- flags |= 0x08;
- break;
- default:
- HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "bit padding is not supported in file format yet");
- }
-
- switch (dt->u.atomic.u.f.norm) {
- case H5T_NORM_NONE:
- break; /*nothing*/
- case H5T_NORM_MSBSET:
- flags |= 0x10;
- break;
- case H5T_NORM_IMPLIED:
- flags |= 0x20;
- break;
- default:
- HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "normalization scheme is not supported in file "
- "format yet");
- }
-
- flags |= (dt->u.atomic.u.f.sign << 8) & 0xff00;
- UINT16ENCODE (*pp, dt->u.atomic.offset);
- UINT16ENCODE (*pp, dt->u.atomic.prec);
- *(*pp)++ = dt->u.atomic.u.f.epos;
- *(*pp)++ = dt->u.atomic.u.f.esize;
- *(*pp)++ = dt->u.atomic.u.f.mpos;
- *(*pp)++ = dt->u.atomic.u.f.msize;
- UINT32ENCODE (*pp, dt->u.atomic.u.f.ebias);
- break;
-
- case H5T_COMPOUND:
- /*
- * Compound data types...
- */
- flags = dt->u.compnd.nmembs & 0xffff;
- for (i=0; i<dt->u.compnd.nmembs; i++) {
- n = strlen (dt->u.compnd.memb[i].name);
- for (j=0; j<=n && j%8; j++) {
- if (j<n) *(*pp)++ = dt->u.compnd.memb[i].name[j];
- else *(*pp)++ = '\0';
- }
- UINT32ENCODE (*pp, dt->u.compnd.memb[i].offset);
- *(*pp)++ = dt->u.compnd.memb[i].ndims;
- assert (dt->u.compnd.memb[i].ndims<=4);
- *(*pp)++ = '\0';
- *(*pp)++ = '\0';
- *(*pp)++ = '\0';
- for (j=0; j<dt->u.compnd.memb[i].ndims; j++) {
- UINT32ENCODE (*pp, dt->u.compnd.memb[i].dim[j]);
- }
- for (j=0, perm_word=0; j<dt->u.compnd.memb[i].ndims; j++) {
- perm_word |= dt->u.compnd.memb[i].perm[j] << (8*j);
- }
- UINT32ENCODE (*pp, perm_word);
- if (H5O_dtype_encode_helper (pp, &(dt->u.compnd.memb[i].type))<0) {
- HRETURN_ERROR (H5E_DATATYPE, H5E_CANTENCODE, FAIL,
- "can't encode member type");
- }
- }
- break;
-
- default:
- /*nothing*/
- break;
- }
-
- *hdr++ = dt->type;
- *hdr++ = (flags >> 0) & 0xff;
- *hdr++ = (flags >> 8) & 0xff;
- *hdr++ = (flags >> 16) & 0xff;
-
- FUNC_LEAVE (SUCCEED);
+ uintn flags = 0;
+ uintn perm_word;
+ char *hdr = *pp;
+ intn i, j, n;
+
+ FUNC_ENTER(H5O_dtype_encode_helper, FAIL);
+
+ /* check args */
+ assert(pp && *pp);
+ assert(dt);
+
+ /* skip the type and class bit field for now */
+ *pp += 4;
+ UINT32ENCODE(*pp, dt->size);
+
+ switch (dt->type) {
+ case H5T_INTEGER:
+ /*
+ * Integer data types...
+ */
+ switch (dt->u.atomic.order) {
+ case H5T_ORDER_LE:
+ break; /*nothing */
+ case H5T_ORDER_BE:
+ flags |= 0x01;
+ break;
+ default:
+ HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
+ "byte order is not supported in file format yet");
+ }
+
+ switch (dt->u.atomic.lsb_pad) {
+ case H5T_PAD_ZERO:
+ break; /*nothing */
+ case H5T_PAD_ONE:
+ flags |= 0x02;
+ break;
+ default:
+ HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
+ "bit padding is not supported in file format yet");
+ }
+
+ switch (dt->u.atomic.msb_pad) {
+ case H5T_PAD_ZERO:
+ break; /*nothing */
+ case H5T_PAD_ONE:
+ flags |= 0x04;
+ break;
+ default:
+ HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
+ "bit padding is not supported in file format yet");
+ }
+
+ switch (dt->u.atomic.u.i.sign) {
+ case H5T_SGN_NONE:
+ break; /*nothing */
+ case H5T_SGN_2:
+ flags |= 0x08;
+ break;
+ default:
+ HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
+ "sign scheme is not supported in file format yet");
+ }
+
+ UINT16ENCODE(*pp, dt->u.atomic.offset);
+ UINT16ENCODE(*pp, dt->u.atomic.prec);
+ break;
+
+ case H5T_FLOAT:
+ /*
+ * Floating-point types...
+ */
+ switch (dt->u.atomic.order) {
+ case H5T_ORDER_LE:
+ break; /*nothing */
+ case H5T_ORDER_BE:
+ flags |= 0x01;
+ break;
+ default:
+ HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
+ "byte order is not supported in file format yet");
+ }
+
+ switch (dt->u.atomic.lsb_pad) {
+ case H5T_PAD_ZERO:
+ break; /*nothing */
+ case H5T_PAD_ONE:
+ flags |= 0x02;
+ break;
+ default:
+ HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
+ "bit padding is not supported in file format yet");
+ }
+
+ switch (dt->u.atomic.msb_pad) {
+ case H5T_PAD_ZERO:
+ break; /*nothing */
+ case H5T_PAD_ONE:
+ flags |= 0x04;
+ break;
+ default:
+ HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
+ "bit padding is not supported in file format yet");
+ }
+
+ switch (dt->u.atomic.u.f.pad) {
+ case H5T_PAD_ZERO:
+ break; /*nothing */
+ case H5T_PAD_ONE:
+ flags |= 0x08;
+ break;
+ default:
+ HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
+ "bit padding is not supported in file format yet");
+ }
+
+ switch (dt->u.atomic.u.f.norm) {
+ case H5T_NORM_NONE:
+ break; /*nothing */
+ case H5T_NORM_MSBSET:
+ flags |= 0x10;
+ break;
+ case H5T_NORM_IMPLIED:
+ flags |= 0x20;
+ break;
+ default:
+ HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
+ "normalization scheme is not supported in file "
+ "format yet");
+ }
+
+ flags |= (dt->u.atomic.u.f.sign << 8) & 0xff00;
+ UINT16ENCODE(*pp, dt->u.atomic.offset);
+ UINT16ENCODE(*pp, dt->u.atomic.prec);
+ *(*pp)++ = dt->u.atomic.u.f.epos;
+ *(*pp)++ = dt->u.atomic.u.f.esize;
+ *(*pp)++ = dt->u.atomic.u.f.mpos;
+ *(*pp)++ = dt->u.atomic.u.f.msize;
+ UINT32ENCODE(*pp, dt->u.atomic.u.f.ebias);
+ break;
+
+ case H5T_COMPOUND:
+ /*
+ * Compound data types...
+ */
+ flags = dt->u.compnd.nmembs & 0xffff;
+ for (i = 0; i < dt->u.compnd.nmembs; i++) {
+ n = strlen(dt->u.compnd.memb[i].name);
+ for (j = 0; j <= n && j % 8; j++) {
+ if (j < n)
+ *(*pp)++ = dt->u.compnd.memb[i].name[j];
+ else
+ *(*pp)++ = '\0';
+ }
+ UINT32ENCODE(*pp, dt->u.compnd.memb[i].offset);
+ *(*pp)++ = dt->u.compnd.memb[i].ndims;
+ assert(dt->u.compnd.memb[i].ndims <= 4);
+ *(*pp)++ = '\0';
+ *(*pp)++ = '\0';
+ *(*pp)++ = '\0';
+ for (j = 0; j < dt->u.compnd.memb[i].ndims; j++) {
+ UINT32ENCODE(*pp, dt->u.compnd.memb[i].dim[j]);
+ }
+ for (j = 0, perm_word = 0; j < dt->u.compnd.memb[i].ndims; j++) {
+ perm_word |= dt->u.compnd.memb[i].perm[j] << (8 * j);
+ }
+ UINT32ENCODE(*pp, perm_word);
+ if (H5O_dtype_encode_helper(pp, &(dt->u.compnd.memb[i].type)) < 0) {
+ HRETURN_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL,
+ "can't encode member type");
+ }
+ }
+ break;
+
+ default:
+ /*nothing */
+ break;
+ }
+
+ *hdr++ = dt->type;
+ *hdr++ = (flags >> 0) & 0xff;
+ *hdr++ = (flags >> 8) & 0xff;
+ *hdr++ = (flags >> 16) & 0xff;
+
+ FUNC_LEAVE(SUCCEED);
}
/*--------------------------------------------------------------------------
@@ -404,28 +407,28 @@ H5O_dtype_encode_helper (uint8 **pp, const H5T_t *dt)
into a struct in memory native format. The struct is allocated within this
function using malloc() and is returned to the caller.
--------------------------------------------------------------------------*/
-static void *
-H5O_dtype_decode (H5F_t *f, size_t raw_size, const uint8 *p)
+static void *
+H5O_dtype_decode(H5F_t *f, size_t raw_size, const uint8 *p)
{
- H5T_t *dt = NULL;
-
- FUNC_ENTER (H5O_dtype_decode, NULL);
-
- /* check args */
- assert (f);
- assert (raw_size>0);
- assert (p);
-
- dt = H5MM_xcalloc (1, sizeof(H5T_t));
-
- if (H5O_dtype_decode_helper (&p, dt)<0) {
- H5MM_xfree (dt);
- HRETURN_ERROR (H5E_DATATYPE, H5E_CANTDECODE, NULL,
- "can't decode type");
- }
- assert (raw_size==H5O_dtype_size (f, (void*)dt));
-
- FUNC_LEAVE (dt);
+ H5T_t *dt = NULL;
+
+ FUNC_ENTER(H5O_dtype_decode, NULL);
+
+ /* check args */
+ assert(f);
+ assert(raw_size > 0);
+ assert(p);
+
+ dt = H5MM_xcalloc(1, sizeof(H5T_t));
+
+ if (H5O_dtype_decode_helper(&p, dt) < 0) {
+ H5MM_xfree(dt);
+ HRETURN_ERROR(H5E_DATATYPE, H5E_CANTDECODE, NULL,
+ "can't decode type");
+ }
+ assert(raw_size == H5O_dtype_size(f, (void *) dt));
+
+ FUNC_LEAVE(dt);
}
/*--------------------------------------------------------------------------
@@ -446,25 +449,24 @@ H5O_dtype_decode (H5F_t *f, size_t raw_size, const uint8 *p)
message in the "raw" disk form.
--------------------------------------------------------------------------*/
static herr_t
-H5O_dtype_encode (H5F_t *f, size_t raw_size, uint8 *p, const void *mesg)
+H5O_dtype_encode(H5F_t *f, size_t raw_size, uint8 *p, const void *mesg)
{
- const H5T_t *dt = (const H5T_t *)mesg;
-
- FUNC_ENTER (H5O_dtype_encode, FAIL);
-
- /* check args */
- assert (f);
- assert (raw_size==H5O_dtype_size (f, mesg));
- assert (p);
- assert (dt);
-
- /* encode */
- if (H5O_dtype_encode_helper (&p, dt)<0) {
- HRETURN_ERROR (H5E_DATATYPE, H5E_CANTENCODE, FAIL,
- "can't encode type");
- }
-
- FUNC_LEAVE (SUCCEED);
+ const H5T_t *dt = (const H5T_t *) mesg;
+
+ FUNC_ENTER(H5O_dtype_encode, FAIL);
+
+ /* check args */
+ assert(f);
+ assert(raw_size == H5O_dtype_size(f, mesg));
+ assert(p);
+ assert(dt);
+
+ /* encode */
+ if (H5O_dtype_encode_helper(&p, dt) < 0) {
+ HRETURN_ERROR(H5E_DATATYPE, H5E_CANTENCODE, FAIL,
+ "can't encode type");
+ }
+ FUNC_LEAVE(SUCCEED);
}
/*--------------------------------------------------------------------------
@@ -475,39 +477,37 @@ H5O_dtype_encode (H5F_t *f, size_t raw_size, uint8 *p, const void *mesg)
USAGE
void *H5O_dtype_copy(mesg, dest)
const void *mesg; IN: Pointer to the source simple datatype
- struct
- const void *dest; IN: Pointer to the destination simple
- datatype struct
+ struct
+ const void *dest; IN: Pointer to the destination simple
+ datatype struct
RETURNS
Pointer to DEST on success, NULL on failure
DESCRIPTION
This function copies a native (memory) simple datatype message,
allocating the destination structure if necessary.
--------------------------------------------------------------------------*/
-static void *
-H5O_dtype_copy (const void *_src, void *_dst)
+static void *
+H5O_dtype_copy(const void *_src, void *_dst)
{
- const H5T_t *src = (const H5T_t *)_src;
- H5T_t *dst = NULL;
-
- FUNC_ENTER (H5O_dtype_copy, NULL);
-
- /* check args */
- assert (src);
-
- /* copy */
- if (NULL==(dst=H5T_copy (src))) {
- HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, NULL, "can't copy type");
- }
-
- /* was result already allocated? */
- if (_dst) {
- *((H5T_t*)_dst) = *dst;
- H5MM_xfree (dst);
- dst = (H5T_t*)_dst;
- }
-
- FUNC_LEAVE ((void*)dst);
+ const H5T_t *src = (const H5T_t *) _src;
+ H5T_t *dst = NULL;
+
+ FUNC_ENTER(H5O_dtype_copy, NULL);
+
+ /* check args */
+ assert(src);
+
+ /* copy */
+ if (NULL == (dst = H5T_copy(src))) {
+ HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "can't copy type");
+ }
+ /* was result already allocated? */
+ if (_dst) {
+ *((H5T_t *) _dst) = *dst;
+ H5MM_xfree(dst);
+ dst = (H5T_t *) _dst;
+ }
+ FUNC_LEAVE((void *) dst);
}
/*--------------------------------------------------------------------------
@@ -527,54 +527,52 @@ H5O_dtype_copy (const void *_src, void *_dst)
portion of the message). It doesn't take into account alignment.
--------------------------------------------------------------------------*/
static size_t
-H5O_dtype_size (H5F_t *f, const void *mesg)
+H5O_dtype_size(H5F_t *f, const void *mesg)
{
- intn i;
- size_t ret_value = 8;
- const H5T_t *dt = (const H5T_t *)mesg;
-
- FUNC_ENTER (H5O_dtype_size, FAIL);
-
- assert (mesg);
-
- switch (dt->type) {
- case H5T_INTEGER:
- ret_value += 4;
- break;
-
- case H5T_FLOAT:
- ret_value += 12;
- break;
-
- case H5T_COMPOUND:
- for (i=0; i<dt->u.compnd.nmembs; i++) {
- ret_value += ((HDstrlen (dt->u.compnd.memb[i].name)+8)/8)*8;
- ret_value += 12 + dt->u.compnd.memb[i].ndims * 4;
- ret_value += H5O_dtype_size (f, &(dt->u.compnd.memb[i].type));
- }
- break;
-
- default:
- /*no properties*/
- break;
- }
-
-
- FUNC_LEAVE (ret_value);
-}
+ intn i;
+ size_t ret_value = 8;
+ const H5T_t *dt = (const H5T_t *) mesg;
+
+ FUNC_ENTER(H5O_dtype_size, FAIL);
+
+ assert(mesg);
+ switch (dt->type) {
+ case H5T_INTEGER:
+ ret_value += 4;
+ break;
+
+ case H5T_FLOAT:
+ ret_value += 12;
+ break;
+
+ case H5T_COMPOUND:
+ for (i = 0; i < dt->u.compnd.nmembs; i++) {
+ ret_value += ((HDstrlen(dt->u.compnd.memb[i].name) + 8) / 8) * 8;
+ ret_value += 12 + dt->u.compnd.memb[i].ndims * 4;
+ ret_value += H5O_dtype_size(f, &(dt->u.compnd.memb[i].type));
+ }
+ break;
+
+ default:
+ /*no properties */
+ break;
+ }
+
+ FUNC_LEAVE(ret_value);
+}
/*-------------------------------------------------------------------------
- * Function: H5O_dtype_reset
+ * Function: H5O_dtype_reset
*
- * Purpose: Frees resources within a data type message, but doesn't free
- * the message itself.
+ * Purpose: Frees resources within a data type message, but doesn't free
+ * the message itself.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Tuesday, December 9, 1997
*
* Modifications:
@@ -582,21 +580,20 @@ H5O_dtype_size (H5F_t *f, const void *mesg)
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_dtype_reset (void *_mesg)
+H5O_dtype_reset(void *_mesg)
{
- H5T_t *dt = (H5T_t *)_mesg;
- H5T_t *tmp = NULL;
-
- FUNC_ENTER (H5O_dtype_reset, FAIL);
-
- if (dt) {
- tmp = H5MM_xmalloc (sizeof(H5T_t));
- *tmp = *dt;
- H5T_close (tmp);
- HDmemset (dt, 0, sizeof(H5T_t));
- }
-
- FUNC_LEAVE (SUCCEED);
+ H5T_t *dt = (H5T_t *) _mesg;
+ H5T_t *tmp = NULL;
+
+ FUNC_ENTER(H5O_dtype_reset, FAIL);
+
+ if (dt) {
+ tmp = H5MM_xmalloc(sizeof(H5T_t));
+ *tmp = *dt;
+ H5T_close(tmp);
+ HDmemset(dt, 0, sizeof(H5T_t));
+ }
+ FUNC_LEAVE(SUCCEED);
}
/*--------------------------------------------------------------------------
@@ -608,7 +605,7 @@ H5O_dtype_reset (void *_mesg)
void *H5O_dtype_debug(f, mesg, stream, indent, fwidth)
H5F_t *f; IN: pointer to the HDF5 file struct
const void *mesg; IN: Pointer to the source simple datatype
- struct
+ struct
FILE *stream; IN: Pointer to the stream for output data
intn indent; IN: Amount to indent information by
intn fwidth; IN: Field width (?)
@@ -619,233 +616,233 @@ H5O_dtype_reset (void *_mesg)
parameter.
--------------------------------------------------------------------------*/
static herr_t
-H5O_dtype_debug (H5F_t *f, const void *mesg, FILE *stream,
- intn indent, intn fwidth)
+H5O_dtype_debug(H5F_t *f, const void *mesg, FILE * stream,
+ intn indent, intn fwidth)
{
- const H5T_t *dt = (const H5T_t *)mesg;
- const char *s;
- char buf[256];
- intn i, j;
-
- FUNC_ENTER (H5O_dtype_debug, FAIL);
-
- /* check args */
- assert (f);
- assert (dt);
- assert (stream);
- assert (indent>=0);
- assert (fwidth>=0);
-
- switch (dt->type) {
- case H5T_INTEGER:
- s = "integer";
- break;
- case H5T_FLOAT:
- s = "floating-point";
- break;
- case H5T_TIME:
- s = "date and time";
- break;
- case H5T_STRING:
- s = "text string";
- break;
- case H5T_BITFIELD:
- s = "bit field";
- break;
- case H5T_OPAQUE:
- s = "opaque";
- break;
- case H5T_COMPOUND:
- s = "compound";
- break;
- default:
- sprintf (buf, "H5T_CLASS_%d", (int)(dt->type));
- s = buf;
- break;
- }
- fprintf (stream, "%*s%-*s %s\n", indent, "", fwidth,
- "Type class:",
- s);
-
- fprintf (stream, "%*s%-*s %lu byte%s\n", indent, "", fwidth,
- "Size:",
- (unsigned long)(dt->size), 1==dt->size?"":"s");
-
- if (H5T_COMPOUND==dt->type) {
- fprintf (stream, "%*s%-*s %d\n", indent, "", fwidth,
- "Number of members:",
- dt->u.compnd.nmembs);
- for (i=0; i<dt->u.compnd.nmembs; i++) {
- sprintf (buf, "Member %d:", i);
- fprintf (stream, "%*s%-*s %s\n", indent, "", fwidth,
- buf,
- dt->u.compnd.memb[i].name);
- fprintf (stream, "%*s%-*s %lu\n", indent+3, "", MAX (0, fwidth-3),
- "Byte offset:",
- (unsigned long)(dt->u.compnd.memb[i].offset));
- fprintf (stream, "%*s%-*s %d%s\n", indent+3, "", MAX (0, fwidth-3),
- "Dimensionality:",
- dt->u.compnd.memb[i].ndims,
- 0==dt->u.compnd.memb[i].ndims?" (scalar)":"");
- if (dt->u.compnd.memb[i].ndims>0) {
- fprintf (stream, "%*s%-*s {", indent+3, "", MAX (0, fwidth-3),
- "Size:");
- for (j=0; j<dt->u.compnd.memb[i].ndims; j++) {
- fprintf (stream, "%s%lu", j?", ":"",
- (unsigned long)(dt->u.compnd.memb[i].dim[j]));
- }
- fprintf (stream, "}\n");
- fprintf (stream, "%*s%-*s {", indent+3, "", MAX (0, fwidth-3),
- "Permutation:");
- for (j=0; j<dt->u.compnd.memb[i].ndims; j++) {
- fprintf (stream, "%s%lu", j?", ":"",
- (unsigned long)(dt->u.compnd.memb[i].perm[j]));
- }
- fprintf (stream, "}\n");
- }
- H5O_dtype_debug (f, &(dt->u.compnd.memb[i].type), stream,
- indent+3, MAX (0, fwidth-3));
- }
- } else {
- switch (dt->u.atomic.order) {
- case H5T_ORDER_LE:
- s = "little endian";
- break;
- case H5T_ORDER_BE:
- s = "big endian";
- break;
- case H5T_ORDER_VAX:
- s = "VAX";
- break;
- case H5T_ORDER_NONE:
- s = "none";
- break;
- default:
- sprintf (buf, "H5T_ORDER_%d", dt->u.atomic.order);
- s = buf;
- break;
- }
- fprintf (stream, "%*s%-*s %s\n", indent, "", fwidth,
- "Byte order:",
- s);
-
- fprintf (stream, "%*s%-*s %lu bit%s\n", indent, "", fwidth,
- "Precision:",
- (unsigned long)(dt->u.atomic.prec),
- 1==dt->u.atomic.prec?"":"s");
-
- fprintf (stream, "%*s%-*s %lu bit%s\n", indent, "", fwidth,
- "Offset:",
- (unsigned long)(dt->u.atomic.offset),
- 1==dt->u.atomic.offset?"":"s");
-
- switch (dt->u.atomic.lsb_pad) {
- case H5T_PAD_ZERO:
- s = "zero";
- break;
- case H5T_PAD_ONE:
- s = "one";
- break;
- default:
- s = "pad?";
- break;
- }
- fprintf (stream, "%*s%-*s %s\n", indent, "", fwidth,
- "Low pad type:", s);
-
- switch (dt->u.atomic.msb_pad) {
- case H5T_PAD_ZERO:
- s = "zero";
- break;
- case H5T_PAD_ONE:
- s = "one";
- break;
- default:
- s = "pad?";
- break;
- }
- fprintf (stream, "%*s%-*s %s\n", indent, "", fwidth,
- "High pad type:", s);
-
- if (H5T_FLOAT==dt->type) {
- switch (dt->u.atomic.u.f.pad) {
- case H5T_PAD_ZERO:
- s = "zero";
- break;
- case H5T_PAD_ONE:
- s = "one";
- break;
- default:
- if (dt->u.atomic.u.f.pad<0) {
- sprintf (buf, "H5T_PAD_%d", -(dt->u.atomic.u.f.pad));
- } else {
- sprintf (buf, "bit-%d", dt->u.atomic.u.f.pad);
- }
- s = buf;
- break;
- }
- fprintf (stream, "%*s%-*s %s\n", indent, "", fwidth,
- "Internal pad type:", s);
-
- switch (dt->u.atomic.u.f.norm) {
- case H5T_NORM_IMPLIED:
- s = "implied";
- break;
- case H5T_NORM_MSBSET:
- s = "msb set";
- break;
- case H5T_NORM_NONE:
- s = "none";
- break;
- default:
- sprintf (buf, "H5T_NORM_%d", (int)(dt->u.atomic.u.f.norm));
- s = buf;
- }
- fprintf (stream, "%*s%-*s %s\n", indent, "", fwidth,
- "Normalization:", s);
-
- fprintf (stream, "%*s%-*s %lu\n", indent, "", fwidth,
- "Sign bit location:",
- (unsigned long)(dt->u.atomic.u.f.sign));
-
- fprintf (stream, "%*s%-*s %lu\n", indent, "", fwidth,
- "Exponent location:",
- (unsigned long)(dt->u.atomic.u.f.epos));
-
- fprintf (stream, "%*s%-*s 0x%08lx\n", indent, "", fwidth,
- "Exponent bias:",
- (unsigned long)(dt->u.atomic.u.f.ebias));
-
- fprintf (stream, "%*s%-*s %lu\n", indent, "", fwidth,
- "Exponent size:",
- (unsigned long)(dt->u.atomic.u.f.esize));
-
- fprintf (stream, "%*s%-*s %lu\n", indent, "", fwidth,
- "Mantissa location:",
- (unsigned long)(dt->u.atomic.u.f.mpos));
-
- fprintf (stream, "%*s%-*s %lu\n", indent, "", fwidth,
- "Mantissa size:",
- (unsigned long)(dt->u.atomic.u.f.msize));
-
- } else if (H5T_INTEGER==dt->type) {
- switch (dt->u.atomic.u.i.sign) {
- case H5T_SGN_NONE:
- s = "none";
- break;
- case H5T_SGN_2:
- s = "2's comp";
- break;
- default:
- sprintf (buf, "H5T_SGN_%d", (int)(dt->u.atomic.u.i.sign));
- s = buf;
- break;
- }
- fprintf (stream, "%*s%-*s %s\n", indent, "", fwidth,
- "Sign scheme:", s);
-
- }
- }
-
- FUNC_LEAVE (SUCCEED);
+ const H5T_t *dt = (const H5T_t *) mesg;
+ const char *s;
+ char buf[256];
+ intn i, j;
+
+ FUNC_ENTER(H5O_dtype_debug, FAIL);
+
+ /* check args */
+ assert(f);
+ assert(dt);
+ assert(stream);
+ assert(indent >= 0);
+ assert(fwidth >= 0);
+
+ switch (dt->type) {
+ case H5T_INTEGER:
+ s = "integer";
+ break;
+ case H5T_FLOAT:
+ s = "floating-point";
+ break;
+ case H5T_TIME:
+ s = "date and time";
+ break;
+ case H5T_STRING:
+ s = "text string";
+ break;
+ case H5T_BITFIELD:
+ s = "bit field";
+ break;
+ case H5T_OPAQUE:
+ s = "opaque";
+ break;
+ case H5T_COMPOUND:
+ s = "compound";
+ break;
+ default:
+ sprintf(buf, "H5T_CLASS_%d", (int) (dt->type));
+ s = buf;
+ break;
+ }
+ fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
+ "Type class:",
+ s);
+
+ fprintf(stream, "%*s%-*s %lu byte%s\n", indent, "", fwidth,
+ "Size:",
+ (unsigned long) (dt->size), 1 == dt->size ? "" : "s");
+
+ if (H5T_COMPOUND == dt->type) {
+ fprintf(stream, "%*s%-*s %d\n", indent, "", fwidth,
+ "Number of members:",
+ dt->u.compnd.nmembs);
+ for (i = 0; i < dt->u.compnd.nmembs; i++) {
+ sprintf(buf, "Member %d:", i);
+ fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
+ buf,
+ dt->u.compnd.memb[i].name);
+ fprintf(stream, "%*s%-*s %lu\n", indent + 3, "", MAX(0, fwidth - 3),
+ "Byte offset:",
+ (unsigned long) (dt->u.compnd.memb[i].offset));
+ fprintf(stream, "%*s%-*s %d%s\n", indent + 3, "", MAX(0, fwidth - 3),
+ "Dimensionality:",
+ dt->u.compnd.memb[i].ndims,
+ 0 == dt->u.compnd.memb[i].ndims ? " (scalar)" : "");
+ if (dt->u.compnd.memb[i].ndims > 0) {
+ fprintf(stream, "%*s%-*s {", indent + 3, "", MAX(0, fwidth - 3),
+ "Size:");
+ for (j = 0; j < dt->u.compnd.memb[i].ndims; j++) {
+ fprintf(stream, "%s%lu", j ? ", " : "",
+ (unsigned long) (dt->u.compnd.memb[i].dim[j]));
+ }
+ fprintf(stream, "}\n");
+ fprintf(stream, "%*s%-*s {", indent + 3, "", MAX(0, fwidth - 3),
+ "Permutation:");
+ for (j = 0; j < dt->u.compnd.memb[i].ndims; j++) {
+ fprintf(stream, "%s%lu", j ? ", " : "",
+ (unsigned long) (dt->u.compnd.memb[i].perm[j]));
+ }
+ fprintf(stream, "}\n");
+ }
+ H5O_dtype_debug(f, &(dt->u.compnd.memb[i].type), stream,
+ indent + 3, MAX(0, fwidth - 3));
+ }
+ } else {
+ switch (dt->u.atomic.order) {
+ case H5T_ORDER_LE:
+ s = "little endian";
+ break;
+ case H5T_ORDER_BE:
+ s = "big endian";
+ break;
+ case H5T_ORDER_VAX:
+ s = "VAX";
+ break;
+ case H5T_ORDER_NONE:
+ s = "none";
+ break;
+ default:
+ sprintf(buf, "H5T_ORDER_%d", dt->u.atomic.order);
+ s = buf;
+ break;
+ }
+ fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
+ "Byte order:",
+ s);
+
+ fprintf(stream, "%*s%-*s %lu bit%s\n", indent, "", fwidth,
+ "Precision:",
+ (unsigned long) (dt->u.atomic.prec),
+ 1 == dt->u.atomic.prec ? "" : "s");
+
+ fprintf(stream, "%*s%-*s %lu bit%s\n", indent, "", fwidth,
+ "Offset:",
+ (unsigned long) (dt->u.atomic.offset),
+ 1 == dt->u.atomic.offset ? "" : "s");
+
+ switch (dt->u.atomic.lsb_pad) {
+ case H5T_PAD_ZERO:
+ s = "zero";
+ break;
+ case H5T_PAD_ONE:
+ s = "one";
+ break;
+ default:
+ s = "pad?";
+ break;
+ }
+ fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
+ "Low pad type:", s);
+
+ switch (dt->u.atomic.msb_pad) {
+ case H5T_PAD_ZERO:
+ s = "zero";
+ break;
+ case H5T_PAD_ONE:
+ s = "one";
+ break;
+ default:
+ s = "pad?";
+ break;
+ }
+ fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
+ "High pad type:", s);
+
+ if (H5T_FLOAT == dt->type) {
+ switch (dt->u.atomic.u.f.pad) {
+ case H5T_PAD_ZERO:
+ s = "zero";
+ break;
+ case H5T_PAD_ONE:
+ s = "one";
+ break;
+ default:
+ if (dt->u.atomic.u.f.pad < 0) {
+ sprintf(buf, "H5T_PAD_%d", -(dt->u.atomic.u.f.pad));
+ } else {
+ sprintf(buf, "bit-%d", dt->u.atomic.u.f.pad);
+ }
+ s = buf;
+ break;
+ }
+ fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
+ "Internal pad type:", s);
+
+ switch (dt->u.atomic.u.f.norm) {
+ case H5T_NORM_IMPLIED:
+ s = "implied";
+ break;
+ case H5T_NORM_MSBSET:
+ s = "msb set";
+ break;
+ case H5T_NORM_NONE:
+ s = "none";
+ break;
+ default:
+ sprintf(buf, "H5T_NORM_%d", (int) (dt->u.atomic.u.f.norm));
+ s = buf;
+ }
+ fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
+ "Normalization:", s);
+
+ fprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth,
+ "Sign bit location:",
+ (unsigned long) (dt->u.atomic.u.f.sign));
+
+ fprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth,
+ "Exponent location:",
+ (unsigned long) (dt->u.atomic.u.f.epos));
+
+ fprintf(stream, "%*s%-*s 0x%08lx\n", indent, "", fwidth,
+ "Exponent bias:",
+ (unsigned long) (dt->u.atomic.u.f.ebias));
+
+ fprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth,
+ "Exponent size:",
+ (unsigned long) (dt->u.atomic.u.f.esize));
+
+ fprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth,
+ "Mantissa location:",
+ (unsigned long) (dt->u.atomic.u.f.mpos));
+
+ fprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth,
+ "Mantissa size:",
+ (unsigned long) (dt->u.atomic.u.f.msize));
+
+ } else if (H5T_INTEGER == dt->type) {
+ switch (dt->u.atomic.u.i.sign) {
+ case H5T_SGN_NONE:
+ s = "none";
+ break;
+ case H5T_SGN_2:
+ s = "2's comp";
+ break;
+ default:
+ sprintf(buf, "H5T_SGN_%d", (int) (dt->u.atomic.u.i.sign));
+ s = buf;
+ break;
+ }
+ fprintf(stream, "%*s%-*s %s\n", indent, "", fwidth,
+ "Sign scheme:", s);
+
+ }
+ }
+
+ FUNC_LEAVE(SUCCEED);
}
diff --git a/src/H5Oefl.c b/src/H5Oefl.c
index 70e156e..8f8f0b1 100644
--- a/src/H5Oefl.c
+++ b/src/H5Oefl.c
@@ -10,93 +10,92 @@
#include <H5MMprivate.h>
#include <H5Oprivate.h>
-#define PABLO_MASK H5O_efl_mask
+#define PABLO_MASK H5O_efl_mask
/* PRIVATE PROTOTYPES */
-static void *H5O_efl_decode (H5F_t *f, size_t raw_size, const uint8 *p);
-static herr_t H5O_efl_encode (H5F_t *f, size_t size, uint8 *p,
- const void *_mesg);
-static void *H5O_efl_copy (const void *_mesg, void *_dest);
-static size_t H5O_efl_size (H5F_t *f, const void *_mesg);
-static herr_t H5O_efl_reset (void *_mesg);
-static herr_t H5O_efl_debug (H5F_t *f, const void *_mesg, FILE *stream,
- intn indent, intn fwidth);
+static void *H5O_efl_decode(H5F_t *f, size_t raw_size, const uint8 *p);
+static herr_t H5O_efl_encode(H5F_t *f, size_t size, uint8 *p,
+ const void *_mesg);
+static void *H5O_efl_copy(const void *_mesg, void *_dest);
+static size_t H5O_efl_size(H5F_t *f, const void *_mesg);
+static herr_t H5O_efl_reset(void *_mesg);
+static herr_t H5O_efl_debug(H5F_t *f, const void *_mesg, FILE * stream,
+ intn indent, intn fwidth);
/* This message derives from H5O */
-const H5O_class_t H5O_EFL[1] = {{
- H5O_EFL_ID, /*message id number */
- "external file list", /*message name for debugging */
- sizeof(H5O_efl_t), /*native message size */
- H5O_efl_decode, /*decode message */
- H5O_efl_encode, /*encode message */
- H5O_efl_copy, /*copy native value */
- H5O_efl_size, /*size of message on disk */
- H5O_efl_reset, /*reset method */
- H5O_efl_debug, /*debug the message */
-}};
-
+const H5O_class_t H5O_EFL[1] =
+{
+ {
+ H5O_EFL_ID, /*message id number */
+ "external file list", /*message name for debugging */
+ sizeof(H5O_efl_t), /*native message size */
+ H5O_efl_decode, /*decode message */
+ H5O_efl_encode, /*encode message */
+ H5O_efl_copy, /*copy native value */
+ H5O_efl_size, /*size of message on disk */
+ H5O_efl_reset, /*reset method */
+ H5O_efl_debug, /*debug the message */
+ }};
/* Interface initialization */
-static hbool_t interface_initialize_g = FALSE;
-#define INTERFACE_INIT NULL
-
+static hbool_t interface_initialize_g = FALSE;
+#define INTERFACE_INIT NULL
/*-------------------------------------------------------------------------
- * Function: H5O_efl_decode
+ * Function: H5O_efl_decode
*
- * Purpose: Decode an external file list message and return a pointer to
- * the message (and some other data).
+ * Purpose: Decode an external file list message and return a pointer to
+ * the message (and some other data).
*
- * Return: Success: Ptr to a new message struct.
+ * Return: Success: Ptr to a new message struct.
*
- * Failure: NULL
+ * Failure: NULL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Tuesday, November 25, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-static void *
-H5O_efl_decode (H5F_t *f, size_t raw_size, const uint8 *p)
+static void *
+H5O_efl_decode(H5F_t *f, size_t raw_size, const uint8 *p)
{
- H5O_efl_t *mesg = NULL;
- int i;
+ H5O_efl_t *mesg = NULL;
+ int i;
- FUNC_ENTER (H5O_efl_decode, NULL);
+ FUNC_ENTER(H5O_efl_decode, NULL);
- /* check args */
- assert (f);
- assert (p);
+ /* check args */
+ assert(f);
+ assert(p);
- /* decode */
- mesg = H5MM_xcalloc (1, sizeof(H5O_efl_t));
- H5F_addr_decode (f, &p, &(mesg->heap_addr));
- UINT32DECODE (p, mesg->nalloc);
- assert (mesg->nalloc>0);
- UINT32DECODE (p, mesg->nused);
- assert (mesg->nused<=mesg->nalloc);
+ /* decode */
+ mesg = H5MM_xcalloc(1, sizeof(H5O_efl_t));
+ H5F_addr_decode(f, &p, &(mesg->heap_addr));
+ UINT32DECODE(p, mesg->nalloc);
+ assert(mesg->nalloc > 0);
+ UINT32DECODE(p, mesg->nused);
+ assert(mesg->nused <= mesg->nalloc);
- mesg->offset = H5MM_xmalloc (mesg->nalloc * sizeof(size_t));
- for (i=0; i<mesg->nused; i++) {
- UINT32DECODE (p, mesg->offset[i]);
- }
+ mesg->offset = H5MM_xmalloc(mesg->nalloc * sizeof(size_t));
+ for (i = 0; i < mesg->nused; i++) {
+ UINT32DECODE(p, mesg->offset[i]);
+ }
- FUNC_LEAVE (mesg);
+ FUNC_LEAVE(mesg);
}
-
/*-------------------------------------------------------------------------
- * Function: H5O_efl_encode
+ * Function: H5O_efl_encode
*
- * Purpose: Encodes a message
+ * Purpose: Encodes a message
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Tuesday, November 25, 1997
*
* Modifications:
@@ -104,91 +103,88 @@ H5O_efl_decode (H5F_t *f, size_t raw_size, const uint8 *p)
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_efl_encode (H5F_t *f, size_t raw_size, uint8 *p, const void *_mesg)
+H5O_efl_encode(H5F_t *f, size_t raw_size, uint8 *p, const void *_mesg)
{
- const H5O_efl_t *mesg = (const H5O_efl_t *)_mesg;
- int i;
-
- FUNC_ENTER (H5O_efl_encode, FAIL);
-
- /* check args */
- assert (f);
- assert (mesg);
- assert (raw_size == H5O_efl_size (f, _mesg));
- assert (p);
-
- /* encode */
- H5F_addr_encode (f, &p, &(mesg->heap_addr));
- UINT32ENCODE (p, mesg->nalloc);
- UINT32ENCODE (p, mesg->nused);
- for (i=0; i<mesg->nused; i++) {
- UINT32ENCODE (p, mesg->offset[i]);
- }
-
- FUNC_LEAVE (SUCCEED);
+ const H5O_efl_t *mesg = (const H5O_efl_t *) _mesg;
+ int i;
+
+ FUNC_ENTER(H5O_efl_encode, FAIL);
+
+ /* check args */
+ assert(f);
+ assert(mesg);
+ assert(raw_size == H5O_efl_size(f, _mesg));
+ assert(p);
+
+ /* encode */
+ H5F_addr_encode(f, &p, &(mesg->heap_addr));
+ UINT32ENCODE(p, mesg->nalloc);
+ UINT32ENCODE(p, mesg->nused);
+ for (i = 0; i < mesg->nused; i++) {
+ UINT32ENCODE(p, mesg->offset[i]);
+ }
+
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5O_efl_copy
+ * Function: H5O_efl_copy
*
- * Purpose: Copies a message from _MESG to _DEST, allocating _DEST if
- * necessary.
+ * Purpose: Copies a message from _MESG to _DEST, allocating _DEST if
+ * necessary.
*
- * Return: Success: Ptr to _DEST
+ * Return: Success: Ptr to _DEST
*
- * Failure: NULL
+ * Failure: NULL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Tuesday, November 25, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-static void *
-H5O_efl_copy (const void *_mesg, void *_dest)
+static void *
+H5O_efl_copy(const void *_mesg, void *_dest)
{
- const H5O_efl_t *mesg = (const H5O_efl_t *)_mesg;
- H5O_efl_t *dest = (H5O_efl_t *)_dest;
- int i;
-
- FUNC_ENTER (H5O_efl_copy, NULL);
-
- /* check args */
- assert (mesg);
- if (!dest) {
- dest = H5MM_xcalloc (1, sizeof(H5O_efl_t));
- dest->offset = H5MM_xmalloc (mesg->nalloc * sizeof(size_t));
- } else if (dest->nalloc<mesg->nalloc) {
- H5MM_xfree (dest->offset);
- dest->offset = H5MM_xmalloc (mesg->nalloc * sizeof(size_t));
- }
-
- dest->heap_addr = mesg->heap_addr;
- dest->nalloc = mesg->nalloc;
- dest->nused = mesg->nused;
-
- for (i=0; i<mesg->nused; i++) {
- dest->offset[i] = mesg->offset[i];
- }
-
- FUNC_LEAVE ((void*)dest);
+ const H5O_efl_t *mesg = (const H5O_efl_t *) _mesg;
+ H5O_efl_t *dest = (H5O_efl_t *) _dest;
+ int i;
+
+ FUNC_ENTER(H5O_efl_copy, NULL);
+
+ /* check args */
+ assert(mesg);
+ if (!dest) {
+ dest = H5MM_xcalloc(1, sizeof(H5O_efl_t));
+ dest->offset = H5MM_xmalloc(mesg->nalloc * sizeof(size_t));
+ } else if (dest->nalloc < mesg->nalloc) {
+ H5MM_xfree(dest->offset);
+ dest->offset = H5MM_xmalloc(mesg->nalloc * sizeof(size_t));
+ }
+ dest->heap_addr = mesg->heap_addr;
+ dest->nalloc = mesg->nalloc;
+ dest->nused = mesg->nused;
+
+ for (i = 0; i < mesg->nused; i++) {
+ dest->offset[i] = mesg->offset[i];
+ }
+
+ FUNC_LEAVE((void *) dest);
}
-
/*-------------------------------------------------------------------------
- * Function: H5O_efl_size
+ * Function: H5O_efl_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 message alignment.
+ * 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 message alignment.
*
- * Return: Success: Message data size in bytes.
+ * Return: Success: Message data size in bytes.
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Tuesday, November 25, 1997
*
* Modifications:
@@ -196,37 +192,36 @@ H5O_efl_copy (const void *_mesg, void *_dest)
*-------------------------------------------------------------------------
*/
static size_t
-H5O_efl_size (H5F_t *f, const void *_mesg)
+H5O_efl_size(H5F_t *f, const void *_mesg)
{
- const H5O_efl_t *mesg = (const H5O_efl_t *)_mesg;
- size_t ret_value = FAIL;
+ const H5O_efl_t *mesg = (const H5O_efl_t *) _mesg;
+ size_t ret_value = FAIL;
- FUNC_ENTER (H5O_efl_size, FAIL);
+ FUNC_ENTER(H5O_efl_size, FAIL);
- /* check args */
- assert (f);
- assert (mesg);
+ /* check args */
+ assert(f);
+ assert(mesg);
- ret_value = H5F_SIZEOF_ADDR (f) + /*heap address */
- 4 + /*num slots allocated */
- 4 + /*num slots used */
- mesg->nalloc * 4; /*name offsets in heap */
+ ret_value = H5F_SIZEOF_ADDR(f) + /*heap address */
+ 4 + /*num slots allocated */
+ 4 + /*num slots used */
+ mesg->nalloc * 4; /*name offsets in heap */
- FUNC_LEAVE (ret_value);
+ FUNC_LEAVE(ret_value);
}
-
/*-------------------------------------------------------------------------
- * Function: H5O_efl_reset
+ * Function: H5O_efl_reset
*
- * Purpose: Frees internal pointers and resets the message to an
- * initialial state.
+ * Purpose: Frees internal pointers and resets the message to an
+ * initialial state.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Tuesday, November 25, 1997
*
* Modifications:
@@ -234,33 +229,32 @@ H5O_efl_size (H5F_t *f, const void *_mesg)
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_efl_reset (void *_mesg)
+H5O_efl_reset(void *_mesg)
{
- H5O_efl_t *mesg = (H5O_efl_t *)_mesg;
+ H5O_efl_t *mesg = (H5O_efl_t *) _mesg;
- FUNC_ENTER (H5O_efl_reset, FAIL);
+ FUNC_ENTER(H5O_efl_reset, FAIL);
- /* check args */
- assert (mesg);
+ /* check args */
+ assert(mesg);
- /* reset */
- mesg->nused = mesg->nalloc = 0;
- mesg->offset = H5MM_xfree (mesg->offset);
+ /* reset */
+ mesg->nused = mesg->nalloc = 0;
+ mesg->offset = H5MM_xfree(mesg->offset);
- FUNC_LEAVE (SUCCEED);
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5O_efl_debug
+ * Function: H5O_efl_debug
*
- * Purpose: Prints debugging info for a message.
+ * Purpose: Prints debugging info for a message.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Tuesday, November 25, 1997
*
* Modifications:
@@ -268,37 +262,37 @@ H5O_efl_reset (void *_mesg)
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_efl_debug (H5F_t *f, const void *_mesg, FILE *stream, intn indent,
- intn fwidth)
+H5O_efl_debug(H5F_t *f, const void *_mesg, FILE * stream, intn indent,
+ intn fwidth)
{
- const H5O_efl_t *mesg = (const H5O_efl_t *)_mesg;
- char buf[64];
- intn i;
-
- FUNC_ENTER (H5O_efl_debug, FAIL);
-
- /* check args */
- assert (f);
- assert (mesg);
- assert (stream);
- assert (indent>=0);
- assert (fwidth>=0);
-
- fprintf (stream, "%*s%-*s ", indent, "", fwidth,
- "Heap address:");
- H5F_addr_print (stream, &(mesg->heap_addr));
- fprintf (stream, "\n");
-
- fprintf (stream, "%*s%-*s %u/%u\n", indent, "", fwidth,
- "Slots used/allocated:",
- mesg->nused, mesg->nalloc);
-
- for (i=0; i<mesg->nused; i++) {
- sprintf (buf, "Name %d:", i+1);
- fprintf (stream, "%*s%-*s %lu\n", indent, "", fwidth,
- buf,
- (unsigned long)(mesg->offset[i]));
- }
-
- FUNC_LEAVE (SUCCEED);
+ const H5O_efl_t *mesg = (const H5O_efl_t *) _mesg;
+ char buf[64];
+ intn i;
+
+ FUNC_ENTER(H5O_efl_debug, FAIL);
+
+ /* check args */
+ assert(f);
+ assert(mesg);
+ assert(stream);
+ assert(indent >= 0);
+ assert(fwidth >= 0);
+
+ fprintf(stream, "%*s%-*s ", indent, "", fwidth,
+ "Heap address:");
+ H5F_addr_print(stream, &(mesg->heap_addr));
+ fprintf(stream, "\n");
+
+ fprintf(stream, "%*s%-*s %u/%u\n", indent, "", fwidth,
+ "Slots used/allocated:",
+ mesg->nused, mesg->nalloc);
+
+ for (i = 0; i < mesg->nused; i++) {
+ sprintf(buf, "Name %d:", i + 1);
+ fprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth,
+ buf,
+ (unsigned long) (mesg->offset[i]));
+ }
+
+ FUNC_LEAVE(SUCCEED);
}
diff --git a/src/H5Olayout.c b/src/H5Olayout.c
index 0d1ed2e..a3d66d6 100644
--- a/src/H5Olayout.c
+++ b/src/H5Olayout.c
@@ -2,10 +2,10 @@
* Copyright (C) 1997 NCSA
* All rights reserved.
*
- * Programmer: Robb Matzke <matzke@llnl.gov>
- * Wednesday, October 8, 1997
+ * Programmer: Robb Matzke <matzke@llnl.gov>
+ * Wednesday, October 8, 1997
*
- * Purpose: Messages related to data layout.
+ * Purpose: Messages related to data layout.
*/
#include <H5private.h>
#include <H5Dprivate.h>
@@ -14,94 +14,94 @@
#include <H5Oprivate.h>
/* PRIVATE PROTOTYPES */
-static void *H5O_layout_decode (H5F_t *f, size_t raw_size, const uint8 *p);
-static herr_t H5O_layout_encode (H5F_t *f, size_t size, uint8 *p,
- const void *_mesg);
-static void *H5O_layout_copy (const void *_mesg, void *_dest);
-static size_t H5O_layout_size (H5F_t *f, const void *_mesg);
-static herr_t H5O_layout_debug (H5F_t *f, const void *_mesg, FILE *stream,
- intn indent, intn fwidth);
+static void *H5O_layout_decode(H5F_t *f, size_t raw_size, const uint8 *p);
+static herr_t H5O_layout_encode(H5F_t *f, size_t size, uint8 *p,
+ const void *_mesg);
+static void *H5O_layout_copy(const void *_mesg, void *_dest);
+static size_t H5O_layout_size(H5F_t *f, const void *_mesg);
+static herr_t H5O_layout_debug(H5F_t *f, const void *_mesg, FILE * stream,
+ intn indent, intn fwidth);
/* This message derives from H5O */
-const H5O_class_t H5O_LAYOUT[1] = {{
- H5O_LAYOUT_ID, /*message id number */
- "layout", /*message name for debugging */
- sizeof(H5O_layout_t), /*native message size */
- H5O_layout_decode, /*decode message */
- H5O_layout_encode, /*encode message */
- H5O_layout_copy, /*copy the native value */
- H5O_layout_size, /*size of message on disk */
- NULL, /*reset method */
- H5O_layout_debug, /*debug the message */
-}};
+const H5O_class_t H5O_LAYOUT[1] =
+{
+ {
+ H5O_LAYOUT_ID, /*message id number */
+ "layout", /*message name for debugging */
+ sizeof(H5O_layout_t), /*native message size */
+ H5O_layout_decode, /*decode message */
+ H5O_layout_encode, /*encode message */
+ H5O_layout_copy, /*copy the native value */
+ H5O_layout_size, /*size of message on disk */
+ NULL, /*reset method */
+ H5O_layout_debug, /*debug the message */
+ }};
/* Interface initialization */
-#define PABLO_MASK H5O_layout_mask
-static hbool_t interface_initialize_g = FALSE;
-#define INTERFACE_INIT NULL
-
+#define PABLO_MASK H5O_layout_mask
+static hbool_t interface_initialize_g = FALSE;
+#define INTERFACE_INIT NULL
/*-------------------------------------------------------------------------
- * Function: H5O_layout_decode
+ * Function: H5O_layout_decode
*
- * Purpose: Decode an data layout message and return a pointer to a
- * new one created with malloc().
+ * Purpose: Decode an data layout message and return a pointer to a
+ * new one created with malloc().
*
- * Return: Success: Ptr to new message in native order.
+ * Return: Success: Ptr to new message in native order.
*
- * Failure: NULL
+ * Failure: NULL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, October 8, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-static void *
-H5O_layout_decode (H5F_t *f, size_t raw_size, const uint8 *p)
+static void *
+H5O_layout_decode(H5F_t *f, size_t raw_size, const uint8 *p)
{
- H5O_layout_t *mesg = NULL;
- intn i;
-
- FUNC_ENTER (H5O_layout_decode, NULL);
-
- /* check args */
- assert (f);
- assert (p);
-
- /* decode */
- mesg = H5MM_xcalloc (1, sizeof(H5O_layout_t));
- H5F_addr_decode (f, &p, &(mesg->addr));
- mesg->ndims = *p++;
- assert (raw_size == H5O_layout_size (f, mesg));
-
- /* Layout class */
- mesg->type = *p++;
- assert (H5D_CONTIGUOUS==mesg->type || H5D_CHUNKED==mesg->type);
-
- /* Reserved bytes */
- p += 6;
-
- /* Read the size */
- for (i=0; i<mesg->ndims; i++) {
- UINT32DECODE (p, mesg->dim[i]);
- }
-
- FUNC_LEAVE (mesg);
-}
+ H5O_layout_t *mesg = NULL;
+ intn i;
+
+ FUNC_ENTER(H5O_layout_decode, NULL);
+
+ /* check args */
+ assert(f);
+ assert(p);
+
+ /* decode */
+ mesg = H5MM_xcalloc(1, sizeof(H5O_layout_t));
+ H5F_addr_decode(f, &p, &(mesg->addr));
+ mesg->ndims = *p++;
+ assert(raw_size == H5O_layout_size(f, mesg));
+
+ /* Layout class */
+ mesg->type = *p++;
+ assert(H5D_CONTIGUOUS == mesg->type || H5D_CHUNKED == mesg->type);
+
+ /* Reserved bytes */
+ p += 6;
+
+ /* Read the size */
+ for (i = 0; i < mesg->ndims; i++) {
+ UINT32DECODE(p, mesg->dim[i]);
+ }
+ FUNC_LEAVE(mesg);
+}
/*-------------------------------------------------------------------------
- * Function: H5O_layout_encode
+ * Function: H5O_layout_encode
*
- * Purpose: Encodes a message.
+ * Purpose: Encodes a message.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, October 8, 1997
*
* Modifications:
@@ -109,89 +109,89 @@ H5O_layout_decode (H5F_t *f, size_t raw_size, const uint8 *p)
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_layout_encode (H5F_t *f, size_t raw_size, uint8 *p, const void *_mesg)
+H5O_layout_encode(H5F_t *f, size_t raw_size, uint8 *p, const void *_mesg)
{
- const H5O_layout_t *mesg = (const H5O_layout_t *)_mesg;
- int i;
+ const H5O_layout_t *mesg = (const H5O_layout_t *) _mesg;
+ int i;
- FUNC_ENTER (H5O_layout_encode, FAIL);
+ FUNC_ENTER(H5O_layout_encode, FAIL);
- /* check args */
- assert (f);
- assert (mesg);
- assert (mesg->ndims>0 && mesg->ndims<=H5O_LAYOUT_NDIMS);
- assert (raw_size == H5O_layout_size (f, _mesg));
- assert (p);
+ /* check args */
+ assert(f);
+ assert(mesg);
+ assert(mesg->ndims > 0 && mesg->ndims <= H5O_LAYOUT_NDIMS);
+ assert(raw_size == H5O_layout_size(f, _mesg));
+ assert(p);
- /* data or B-tree address */
- H5F_addr_encode (f, &p, &(mesg->addr));
+ /* data or B-tree address */
+ H5F_addr_encode(f, &p, &(mesg->addr));
- /* number of dimensions */
- *p++ = mesg->ndims;
+ /* number of dimensions */
+ *p++ = mesg->ndims;
- /* layout class */
- *p++ = mesg->type;
+ /* layout class */
+ *p++ = mesg->type;
- /* reserved bytes should be zero */
- for (i=0; i<6; i++) *p++ = 0;
+ /* reserved bytes should be zero */
+ for (i = 0; i < 6; i++)
+ *p++ = 0;
- /* dimension size */
- for (i=0; i<mesg->ndims; i++) {
- UINT32ENCODE (p, mesg->dim[i]);
- }
+ /* dimension size */
+ for (i = 0; i < mesg->ndims; i++) {
+ UINT32ENCODE(p, mesg->dim[i]);
+ }
- FUNC_LEAVE (SUCCEED);
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5O_layout_copy
+ * Function: H5O_layout_copy
*
- * Purpose: Copies a message from _MESG to _DEST, allocating _DEST if
- * necessary.
+ * Purpose: Copies a message from _MESG to _DEST, allocating _DEST if
+ * necessary.
*
- * Return: Success: Ptr to _DEST
+ * Return: Success: Ptr to _DEST
*
- * Failure: NULL
+ * Failure: NULL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, October 8, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-static void *
-H5O_layout_copy (const void *_mesg, void *_dest)
+static void *
+H5O_layout_copy(const void *_mesg, void *_dest)
{
- const H5O_layout_t *mesg = (const H5O_layout_t *)_mesg;
- H5O_layout_t *dest = (H5O_layout_t *)_dest;
+ const H5O_layout_t *mesg = (const H5O_layout_t *) _mesg;
+ H5O_layout_t *dest = (H5O_layout_t *) _dest;
- FUNC_ENTER (H5O_layout_copy, NULL);
+ FUNC_ENTER(H5O_layout_copy, NULL);
- /* check args */
- assert (mesg);
- if (!dest) dest = H5MM_xcalloc (1, sizeof(H5O_layout_t));
+ /* check args */
+ assert(mesg);
+ if (!dest)
+ dest = H5MM_xcalloc(1, sizeof(H5O_layout_t));
- /* copy */
- *dest = *mesg;
+ /* copy */
+ *dest = *mesg;
- FUNC_LEAVE ((void*)dest);
+ FUNC_LEAVE((void *) dest);
}
-
/*-------------------------------------------------------------------------
- * Function: H5O_layout_size
+ * Function: H5O_layout_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 message alignment.
+ * 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 message alignment.
*
- * Return: Success: Message data size in bytes
+ * Return: Success: Message data size in bytes
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, October 8, 1997
*
* Modifications:
@@ -199,38 +199,37 @@ H5O_layout_copy (const void *_mesg, void *_dest)
*-------------------------------------------------------------------------
*/
static size_t
-H5O_layout_size (H5F_t *f, const void *_mesg)
+H5O_layout_size(H5F_t *f, const void *_mesg)
{
- const H5O_layout_t *mesg = (const H5O_layout_t *)_mesg;
- size_t ret_value = FAIL;
-
- FUNC_ENTER (H5O_layout_size, FAIL);
-
- /* check args */
- assert (f);
- assert (mesg);
- assert (mesg->ndims>0 && mesg->ndims<=H5O_LAYOUT_NDIMS);
-
- ret_value = H5F_SIZEOF_ADDR (f) + /* B-tree address */
- 1 + /* max dimension index */
- 1 + /* layout class number */
- 6 + /* reserved bytes */
- mesg->ndims * 4; /* alignment */
-
- FUNC_LEAVE (ret_value);
-}
+ const H5O_layout_t *mesg = (const H5O_layout_t *) _mesg;
+ size_t ret_value = FAIL;
+
+ FUNC_ENTER(H5O_layout_size, FAIL);
+ /* check args */
+ assert(f);
+ assert(mesg);
+ assert(mesg->ndims > 0 && mesg->ndims <= H5O_LAYOUT_NDIMS);
+
+ ret_value = H5F_SIZEOF_ADDR(f) + /* B-tree address */
+ 1 + /* max dimension index */
+ 1 + /* layout class number */
+ 6 + /* reserved bytes */
+ mesg->ndims * 4; /* alignment */
+
+ FUNC_LEAVE(ret_value);
+}
/*-------------------------------------------------------------------------
- * Function: H5O_layout_debug
+ * Function: H5O_layout_debug
*
- * Purpose: Prints debugging info for a message.
+ * Purpose: Prints debugging info for a message.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, October 8, 1997
*
* Modifications:
@@ -238,39 +237,38 @@ H5O_layout_size (H5F_t *f, const void *_mesg)
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_layout_debug (H5F_t *f, const void *_mesg, FILE *stream, intn indent,
- intn fwidth)
+H5O_layout_debug(H5F_t *f, const void *_mesg, FILE * stream, intn indent,
+ intn fwidth)
{
- const H5O_layout_t *mesg = (const H5O_layout_t *)_mesg;
- intn i;
-
- FUNC_ENTER (H5O_layout_debug, FAIL);
-
- /* check args */
- assert (f);
- assert (mesg);
- assert (stream);
- assert (indent>=0);
- assert (fwidth>=0);
-
- fprintf (stream, "%*s%-*s ", indent, "", fwidth,
- H5D_CHUNKED==mesg->type?"B-tree address:":"Data address:");
- H5F_addr_print (stream, &(mesg->addr));
- fprintf (stream, "\n");
-
- fprintf (stream, "%*s%-*s %lu\n", indent, "", fwidth,
- "Number of dimensions:",
- (unsigned long)(mesg->ndims));
-
- /* Size */
- fprintf (stream, "%*s%-*s {", indent, "", fwidth,
- "Size:");
- for (i=0; i<mesg->ndims; i++) {
- fprintf (stream, "%s%lu", i?", ":"",
- (unsigned long)(mesg->dim[i]));
- }
- fprintf (stream, "}\n");
-
- FUNC_LEAVE (SUCCEED);
+ const H5O_layout_t *mesg = (const H5O_layout_t *) _mesg;
+ intn i;
+
+ FUNC_ENTER(H5O_layout_debug, FAIL);
+
+ /* check args */
+ assert(f);
+ assert(mesg);
+ assert(stream);
+ assert(indent >= 0);
+ assert(fwidth >= 0);
+
+ fprintf(stream, "%*s%-*s ", indent, "", fwidth,
+ H5D_CHUNKED == mesg->type ? "B-tree address:" : "Data address:");
+ H5F_addr_print(stream, &(mesg->addr));
+ fprintf(stream, "\n");
+
+ fprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth,
+ "Number of dimensions:",
+ (unsigned long) (mesg->ndims));
+
+ /* Size */
+ fprintf(stream, "%*s%-*s {", indent, "", fwidth,
+ "Size:");
+ for (i = 0; i < mesg->ndims; i++) {
+ fprintf(stream, "%s%lu", i ? ", " : "",
+ (unsigned long) (mesg->dim[i]));
+ }
+ fprintf(stream, "}\n");
+
+ FUNC_LEAVE(SUCCEED);
}
-
diff --git a/src/H5Oname.c b/src/H5Oname.c
index 58fc849..51fddc2 100644
--- a/src/H5Oname.c
+++ b/src/H5Oname.c
@@ -1,16 +1,16 @@
/*-------------------------------------------------------------------------
- * Copyright (C) 1997 National Center for Supercomputing Applications.
+ * Copyright (C) 1997 National Center for Supercomputing Applications.
* All rights reserved.
*
*-------------------------------------------------------------------------
*
- * Created: H5Oname.c
- * Aug 12 1997
- * Robb Matzke <matzke@llnl.gov>
+ * Created: H5Oname.c
+ * Aug 12 1997
+ * Robb Matzke <matzke@llnl.gov>
*
- * Purpose: Object name message.
+ * Purpose: Object name message.
*
- * Modifications:
+ * Modifications:
*
*-------------------------------------------------------------------------
*/
@@ -19,263 +19,260 @@
#include <H5MMprivate.h>
#include <H5Oprivate.h>
-#define PABLO_MASK H5O_name_mask
+#define PABLO_MASK H5O_name_mask
/* PRIVATE PROTOTYPES */
-static void *H5O_name_decode (H5F_t *f, size_t raw_size, const uint8 *p);
-static herr_t H5O_name_encode (H5F_t *f, size_t raw_size, uint8 *p,
- const void *_mesg);
-static void *H5O_name_copy (const void *_mesg, void *_dest);
-static size_t H5O_name_size (H5F_t *f, const void *_mesg);
-static herr_t H5O_name_reset (void *_mesg);
-static herr_t H5O_name_debug (H5F_t *f, const void *_mesg, FILE *stream,
- intn indent, intn fwidth);
+static void *H5O_name_decode(H5F_t *f, size_t raw_size, const uint8 *p);
+static herr_t H5O_name_encode(H5F_t *f, size_t raw_size, uint8 *p,
+ const void *_mesg);
+static void *H5O_name_copy(const void *_mesg, void *_dest);
+static size_t H5O_name_size(H5F_t *f, const void *_mesg);
+static herr_t H5O_name_reset(void *_mesg);
+static herr_t H5O_name_debug(H5F_t *f, const void *_mesg, FILE * stream,
+ intn indent, intn fwidth);
/* This message derives from H5O */
-const H5O_class_t H5O_NAME[1] = {{
- H5O_NAME_ID, /*message id number */
- "name", /*message name for debugging */
- sizeof (H5O_name_t), /*native message size */
- H5O_name_decode, /*decode message */
- H5O_name_encode, /*encode message */
- H5O_name_copy, /*copy the native value */
- H5O_name_size, /*raw message size */
- H5O_name_reset, /*free internal memory */
- H5O_name_debug, /*debug the message */
-}};
+const H5O_class_t H5O_NAME[1] =
+{
+ {
+ H5O_NAME_ID, /*message id number */
+ "name", /*message name for debugging */
+ sizeof(H5O_name_t), /*native message size */
+ H5O_name_decode, /*decode message */
+ H5O_name_encode, /*encode message */
+ H5O_name_copy, /*copy the native value */
+ H5O_name_size, /*raw message size */
+ H5O_name_reset, /*free internal memory */
+ H5O_name_debug, /*debug the message */
+ }};
/* Interface initialization */
-static hbool_t interface_initialize_g = FALSE;
-#define INTERFACE_INIT NULL
-
+static hbool_t interface_initialize_g = FALSE;
+#define INTERFACE_INIT NULL
/*-------------------------------------------------------------------------
- * Function: H5O_name_decode
+ * Function: H5O_name_decode
*
- * Purpose: Decode a name message and return a pointer to a new
- * native message struct.
+ * Purpose: Decode a name message and return a pointer to a new
+ * native message struct.
*
- * Return: Success: Ptr to new message in native struct.
+ * Return: Success: Ptr to new message in native struct.
*
- * Failure: NULL
+ * Failure: NULL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Aug 12 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Aug 12 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-static void *
-H5O_name_decode (H5F_t *f, size_t raw_size, const uint8 *p)
+static void *
+H5O_name_decode(H5F_t *f, size_t raw_size, const uint8 *p)
{
- H5O_name_t *mesg;
- char *s;
+ H5O_name_t *mesg;
+ char *s;
- FUNC_ENTER (H5O_name_decode, NULL);
+ FUNC_ENTER(H5O_name_decode, NULL);
- /* check args */
- assert (f);
- assert (p);
+ /* check args */
+ assert(f);
+ assert(p);
- /* decode */
- mesg = H5MM_xcalloc (1, sizeof(H5O_name_t));
- s = H5MM_xmalloc (raw_size);
- HDmemcpy (s, p, raw_size);
- mesg->s = s;
+ /* decode */
+ mesg = H5MM_xcalloc(1, sizeof(H5O_name_t));
+ s = H5MM_xmalloc(raw_size);
+ HDmemcpy(s, p, raw_size);
+ mesg->s = s;
- FUNC_LEAVE (mesg);
+ FUNC_LEAVE(mesg);
}
-
/*-------------------------------------------------------------------------
- * Function: H5O_name_encode
+ * Function: H5O_name_encode
*
- * Purpose: Encodes a name message.
+ * Purpose: Encodes a name message.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Aug 12 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Aug 12 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_name_encode (H5F_t *f, size_t raw_size, uint8 *p, const void *_mesg)
+H5O_name_encode(H5F_t *f, size_t raw_size, uint8 *p, const void *_mesg)
{
- const H5O_name_t *mesg = (const H5O_name_t *)_mesg;
- size_t size;
+ const H5O_name_t *mesg = (const H5O_name_t *) _mesg;
+ size_t size;
- FUNC_ENTER (H5O_name_encode, FAIL);
+ FUNC_ENTER(H5O_name_encode, FAIL);
- /* check args */
- assert (f);
- assert (p);
- assert (mesg && mesg->s);
+ /* check args */
+ assert(f);
+ assert(p);
+ assert(mesg && mesg->s);
- /* message size */
- size = HDstrlen (mesg->s)+1;
- assert (size<=raw_size);
+ /* message size */
+ size = HDstrlen(mesg->s) + 1;
+ assert(size <= raw_size);
- /* encode */
- HDmemcpy (p, mesg->s, size);
- HDmemset (p+size, 0, raw_size-size);
+ /* encode */
+ HDmemcpy(p, mesg->s, size);
+ HDmemset(p + size, 0, raw_size - size);
- FUNC_LEAVE (SUCCEED);
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5O_name_copy
+ * Function: H5O_name_copy
*
- * Purpose: Copies a message from _MESG to _DEST, allocating _DEST if
- * necessary.
+ * Purpose: Copies a message from _MESG to _DEST, allocating _DEST if
+ * necessary.
*
- * Return: Success: Ptr to _DEST
+ * Return: Success: Ptr to _DEST
*
- * Failure: NULL
+ * Failure: NULL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Aug 12 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Aug 12 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-static void *
-H5O_name_copy (const void *_mesg, void *_dest)
+static void *
+H5O_name_copy(const void *_mesg, void *_dest)
{
- const H5O_name_t *mesg = (const H5O_name_t *)_mesg;
- H5O_name_t *dest = (H5O_name_t *)_dest;
+ const H5O_name_t *mesg = (const H5O_name_t *) _mesg;
+ H5O_name_t *dest = (H5O_name_t *) _dest;
- FUNC_ENTER (H5O_name_copy, NULL);
+ FUNC_ENTER(H5O_name_copy, NULL);
- /* check args */
- assert (mesg);
- if (!dest) dest = H5MM_xcalloc (1, sizeof(H5O_name_t));
+ /* check args */
+ assert(mesg);
+ if (!dest)
+ dest = H5MM_xcalloc(1, sizeof(H5O_name_t));
- /* copy */
- *dest = *mesg;
- dest->s = H5MM_xstrdup (mesg->s);
+ /* copy */
+ *dest = *mesg;
+ dest->s = H5MM_xstrdup(mesg->s);
- FUNC_LEAVE ((void*)dest);
+ FUNC_LEAVE((void *) dest);
}
-
/*-------------------------------------------------------------------------
- * Function: H5O_name_size
+ * Function: H5O_name_size
*
- * Purpose: Returns the size of the raw message in bytes not
- * counting the message typ or size fields, but only the data
- * fields. This function doesn't take into account
- * alignment.
+ * Purpose: Returns the size of the raw message in bytes not
+ * counting the message typ or size fields, but only the data
+ * fields. This function doesn't take into account
+ * alignment.
*
- * Return: Success: Message data size in bytes w/o alignment.
+ * Return: Success: Message data size in bytes w/o alignment.
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Aug 12 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Aug 12 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static size_t
-H5O_name_size (H5F_t *f, const void *_mesg)
+H5O_name_size(H5F_t *f, const void *_mesg)
{
- const H5O_name_t *mesg = (const H5O_name_t *)_mesg;
- size_t size;
-
- FUNC_ENTER (H5O_name_size, FAIL);
+ const H5O_name_t *mesg = (const H5O_name_t *) _mesg;
+ size_t size;
- /* check args */
- assert (f);
- assert (mesg);
+ FUNC_ENTER(H5O_name_size, FAIL);
- size = mesg->s ? HDstrlen (mesg->s)+1 : 0;
- FUNC_LEAVE (size);
-}
+ /* check args */
+ assert(f);
+ assert(mesg);
+ size = mesg->s ? HDstrlen(mesg->s) + 1 : 0;
+ FUNC_LEAVE(size);
+}
/*-------------------------------------------------------------------------
- * Function: H5O_name_reset
+ * Function: H5O_name_reset
*
- * Purpose: Frees internal pointers and resets the message to an
- * initial state.
+ * Purpose: Frees internal pointers and resets the message to an
+ * initial state.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Aug 12 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Aug 12 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_name_reset (void *_mesg)
+H5O_name_reset(void *_mesg)
{
- H5O_name_t *mesg = (H5O_name_t *)_mesg;
-
- FUNC_ENTER (H5O_name_reset, FAIL);
+ H5O_name_t *mesg = (H5O_name_t *) _mesg;
- /* check args */
- assert (mesg);
+ FUNC_ENTER(H5O_name_reset, FAIL);
- /* reset */
- mesg->s = H5MM_xfree (mesg->s);
-
- FUNC_LEAVE (SUCCEED);
-}
+ /* check args */
+ assert(mesg);
+ /* reset */
+ mesg->s = H5MM_xfree(mesg->s);
+
+ FUNC_LEAVE(SUCCEED);
+}
/*-------------------------------------------------------------------------
- * Function: H5O_name_debug
+ * Function: H5O_name_debug
*
- * Purpose: Prints debugging info for the message.
+ * Purpose: Prints debugging info for the message.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Aug 12 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Aug 12 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_name_debug (H5F_t *f, const void *_mesg, FILE *stream,
- intn indent, intn fwidth)
+H5O_name_debug(H5F_t *f, const void *_mesg, FILE * stream,
+ intn indent, intn fwidth)
{
- const H5O_name_t *mesg = (const H5O_name_t *)_mesg;
+ const H5O_name_t *mesg = (const H5O_name_t *) _mesg;
- FUNC_ENTER (H5O_name_debug, FAIL);
+ FUNC_ENTER(H5O_name_debug, FAIL);
- /* check args */
- assert (f);
- assert (mesg);
- assert (stream);
- assert (indent>=0);
- assert (fwidth>=0);
+ /* check args */
+ assert(f);
+ assert(mesg);
+ assert(stream);
+ assert(indent >= 0);
+ assert(fwidth >= 0);
- fprintf (stream, "%*s%-*s `%s'\n", indent, "", fwidth,
- "Name:",
- mesg->s);
+ fprintf(stream, "%*s%-*s `%s'\n", indent, "", fwidth,
+ "Name:",
+ mesg->s);
- FUNC_LEAVE (SUCCEED);
+ FUNC_LEAVE(SUCCEED);
}
diff --git a/src/H5Onull.c b/src/H5Onull.c
index 8c3919a..9fdc53c 100644
--- a/src/H5Onull.c
+++ b/src/H5Onull.c
@@ -1,33 +1,35 @@
/*-------------------------------------------------------------------------
- * Copyright (C) 1997 National Center for Supercomputing Applications.
+ * Copyright (C) 1997 National Center for Supercomputing Applications.
* All rights reserved.
*
*-------------------------------------------------------------------------
*
- * Created: H5Onull.c
- * Aug 6 1997
- * Robb Matzke <matzke@llnl.gov>
+ * Created: H5Onull.c
+ * Aug 6 1997
+ * Robb Matzke <matzke@llnl.gov>
*
- * Purpose: The null message.
+ * Purpose: The null message.
*
- * Modifications:
+ * Modifications:
*
*-------------------------------------------------------------------------
*/
#include <H5private.h>
#include <H5Oprivate.h>
-#define PABLO_MASK H5O_null_mask
+#define PABLO_MASK H5O_null_mask
/* This message derives from H5O */
-const H5O_class_t H5O_NULL[1] = {{
- H5O_NULL_ID, /*message id number */
- "null", /*message name for debugging */
- 0, /*native message size */
- NULL, /*no decode method */
- NULL, /*no encode method */
- NULL, /*no copy method */
- NULL, /*no size method */
- NULL, /*no reset method */
- NULL, /*no debug method */
-}};
+const H5O_class_t H5O_NULL[1] =
+{
+ {
+ H5O_NULL_ID, /*message id number */
+ "null", /*message name for debugging */
+ 0, /*native message size */
+ NULL, /*no decode method */
+ NULL, /*no encode method */
+ NULL, /*no copy method */
+ NULL, /*no size method */
+ NULL, /*no reset method */
+ NULL, /*no debug method */
+ }};
diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h
index cf23fc6..b570b30 100644
--- a/src/H5Oprivate.h
+++ b/src/H5Oprivate.h
@@ -1,16 +1,16 @@
/*-------------------------------------------------------------------------
- * Copyright (C) 1997 National Center for Supercomputing Applications.
+ * Copyright (C) 1997 National Center for Supercomputing Applications.
* All rights reserved.
*
*-------------------------------------------------------------------------
*
- * Created: H5Oprivate.h
- * Aug 5 1997
- * Robb Matzke <matzke@llnl.gov>
+ * Created: H5Oprivate.h
+ * Aug 5 1997
+ * Robb Matzke <matzke@llnl.gov>
*
- * Purpose: Object header private include file.
+ * Purpose: Object header private include file.
*
- * Modifications:
+ * Modifications:
*
*-------------------------------------------------------------------------
*/
@@ -25,166 +25,164 @@
#include <H5Tprivate.h>
#include <H5Pprivate.h>
-#define H5O_MIN_SIZE 32 /*min obj header data size */
-#define H5O_NMESGS 32 /*initial number of messages */
-#define H5O_NCHUNKS 8 /*initial number of chunks */
-#define H5O_NEW_MESG (-1) /*new message */
-#define H5O_ALL (-1) /*delete all messages of type */
+#define H5O_MIN_SIZE 32 /*min obj header data size */
+#define H5O_NMESGS 32 /*initial number of messages */
+#define H5O_NCHUNKS 8 /*initial number of chunks */
+#define H5O_NEW_MESG (-1) /*new message */
+#define H5O_ALL (-1) /*delete all messages of type */
/* Flags which are part of the message id */
-#define H5O_FLAG_CONSTANT 0x8000
-#define H5O_FLAG_BITS 0x8000
+#define H5O_FLAG_CONSTANT 0x8000
+#define H5O_FLAG_BITS 0x8000
-#define H5O_VERSION 1
-#define H5O_ALIGNMENT 4
-#define H5O_ALIGN(X,A) ((X)=(A)*(((X)+(A)-1)/(A)))
+#define H5O_VERSION 1
+#define H5O_ALIGNMENT 4
+#define H5O_ALIGN(X,A) ((X)=(A)*(((X)+(A)-1)/(A)))
-#define H5O_SIZEOF_HDR(F) \
- (1 + /*version number */ \
- 1 + /*alignment */ \
- 2 + /*number of messages */ \
- 4 + /*reference count */ \
- 4) /*header data size */
+#define H5O_SIZEOF_HDR(F) \
+ (1 + /*version number */ \
+ 1 + /*alignment */ \
+ 2 + /*number of messages */ \
+ 4 + /*reference count */ \
+ 4) /*header data size */
typedef struct H5O_class_t {
- intn id; /*message type ID on disk */
- const char *name; /*message name for debugging */
- size_t native_size; /*size of native message */
- void *(*decode)(H5F_t*,size_t,const uint8*);
- herr_t (*encode)(H5F_t*,size_t,uint8*,const void*);
- void *(*copy)(const void*,void*); /*copy native value */
- size_t (*raw_size)(H5F_t*,const void*); /*sizeof raw val */
- herr_t (*reset)(void*); /*free nested data structures */
- herr_t (*debug)(H5F_t*,const void*, FILE*, intn, intn);
+ intn id; /*message type ID on disk */
+ const char *name; /*message name for debugging */
+ size_t native_size; /*size of native message */
+ void *(*decode) (H5F_t *, size_t, const uint8 *);
+ herr_t (*encode) (H5F_t *, size_t, uint8 *, const void *);
+ void *(*copy) (const void *, void *); /*copy native value */
+ size_t (*raw_size) (H5F_t *, const void *); /*sizeof raw val */
+ herr_t (*reset) (void *); /*free nested data structures */
+ herr_t (*debug) (H5F_t *, const void *, FILE *, intn, intn);
} H5O_class_t;
typedef struct H5O_mesg_t {
- const H5O_class_t *type; /*type of message */
- hbool_t dirty; /*raw out of date wrt native */
- hbool_t constant; /*is message constant? */
- void *native; /*native format message */
- uint8 *raw; /*ptr to raw data */
- size_t raw_size; /*size with alignment */
- intn chunkno; /*chunk number for this mesg */
+ const H5O_class_t *type; /*type of message */
+ hbool_t dirty; /*raw out of date wrt native */
+ hbool_t constant; /*is message constant? */
+ void *native; /*native format message */
+ uint8 *raw; /*ptr to raw data */
+ size_t raw_size; /*size with alignment */
+ intn chunkno; /*chunk number for this mesg */
} H5O_mesg_t;
typedef struct H5O_chunk_t {
- hbool_t dirty; /*dirty flag */
- haddr_t addr; /*chunk file address */
- size_t size; /*chunk size */
- uint8 *image; /*image of file */
+ hbool_t dirty; /*dirty flag */
+ haddr_t addr; /*chunk file address */
+ size_t size; /*chunk size */
+ uint8 *image; /*image of file */
} H5O_chunk_t;
-
+
typedef struct H5O_t {
- hbool_t dirty; /*out of data wrt disk */
- intn version; /*version number */
- intn alignment; /*message alignment */
- intn nlink; /*link count */
- intn nmesgs; /*number of messages */
- intn alloc_nmesgs; /*number of message slots */
- H5O_mesg_t *mesg; /*array of messages */
- intn nchunks; /*number of chunks */
- intn alloc_nchunks; /*chunks allocated */
- H5O_chunk_t *chunk; /*array of chunks */
+ hbool_t dirty; /*out of data wrt disk */
+ intn version; /*version number */
+ intn alignment; /*message alignment */
+ intn nlink; /*link count */
+ intn nmesgs; /*number of messages */
+ intn alloc_nmesgs; /*number of message slots */
+ H5O_mesg_t *mesg; /*array of messages */
+ intn nchunks; /*number of chunks */
+ intn alloc_nchunks; /*chunks allocated */
+ H5O_chunk_t *chunk; /*array of chunks */
} H5O_t;
/*
* Null Message.
*/
-#define H5O_NULL_ID 0x0000
+#define H5O_NULL_ID 0x0000
extern const H5O_class_t H5O_NULL[1];
/*
* Simple Data Space Message.
*/
-#define H5O_SDSPACE_ID 0x0001
+#define H5O_SDSPACE_ID 0x0001
extern const H5O_class_t H5O_SDSPACE[1];
/* operates on an H5P_simple_t struct */
/*
* Data Type Message.
*/
-#define H5O_DTYPE_ID 0x0003
+#define H5O_DTYPE_ID 0x0003
extern const H5O_class_t H5O_DTYPE[1];
/* operates on an H5T_t struct */
/*
* Data Layout Message
*/
-#define H5O_LAYOUT_ID 0x0008
-#define H5O_LAYOUT_NDIMS 32
+#define H5O_LAYOUT_ID 0x0008
+#define H5O_LAYOUT_NDIMS 32
extern const H5O_class_t H5O_LAYOUT[1];
typedef struct H5O_layout_t {
- int type; /*type of layout, H5D_layout_t */
- haddr_t addr; /*file address of data or B-tree*/
- uintn ndims; /*num dimensions in stored data */
- size_t dim[H5O_LAYOUT_NDIMS]; /*size of data or chunk */
+ int type; /*type of layout, H5D_layout_t */
+ haddr_t addr; /*file address of data or B-tree */
+ uintn ndims; /*num dimensions in stored data */
+ size_t dim[H5O_LAYOUT_NDIMS]; /*size of data or chunk */
} H5O_layout_t;
/*
* External File List Message
*/
-#define H5O_EFL_ID 0x0009
+#define H5O_EFL_ID 0x0009
extern const H5O_class_t H5O_EFL[1];
typedef struct H5O_efl_t {
- haddr_t heap_addr; /*Address of name heap */
- uintn nalloc; /*Number of slots allocated */
- uintn nused; /*Number of slots used */
- size_t *offset; /*Array of name offsets in heap */
+ haddr_t heap_addr; /*Address of name heap */
+ uintn nalloc; /*Number of slots allocated */
+ uintn nused; /*Number of slots used */
+ size_t *offset; /*Array of name offsets in heap */
} H5O_efl_t;
/*
* Object name message.
*/
-#define H5O_NAME_ID 0x000d
+#define H5O_NAME_ID 0x000d
extern const H5O_class_t H5O_NAME[1];
typedef struct H5O_name_t {
- const char *s; /*ptr to malloc'd memory */
+ const char *s; /*ptr to malloc'd memory */
} H5O_name_t;
/*
* Object header continuation message.
*/
-#define H5O_CONT_ID 0x0010
+#define H5O_CONT_ID 0x0010
extern const H5O_class_t H5O_CONT[1];
typedef struct H5O_cont_t {
- haddr_t addr; /*address of continuation block */
- size_t size; /*size of continuation block */
+ haddr_t addr; /*address of continuation block */
+ size_t size; /*size of continuation block */
- /* the following field(s) do not appear on disk */
- intn chunkno; /*chunk this mesg refers to */
+ /* the following field(s) do not appear on disk */
+ intn chunkno; /*chunk this mesg refers to */
} H5O_cont_t;
/*
* Symbol table message.
*/
-#define H5O_STAB_ID 0x0011
+#define H5O_STAB_ID 0x0011
extern const H5O_class_t H5O_STAB[1];
-void *H5O_stab_fast (const H5G_cache_t *cache, const H5O_class_t *type,
- void *_mesg);
+void *H5O_stab_fast(const H5G_cache_t *cache, const H5O_class_t *type,
+ void *_mesg);
typedef struct H5O_stab_t {
- haddr_t btree_addr; /*address of B-tree */
- haddr_t heap_addr; /*address of name heap */
+ haddr_t btree_addr; /*address of B-tree */
+ haddr_t heap_addr; /*address of name heap */
} H5O_stab_t;
-
-
-herr_t H5O_create (H5F_t *f, size_t size_hint, H5G_entry_t *ent/*out*/);
-herr_t H5O_open (H5F_t *f, H5G_entry_t *ent);
-herr_t H5O_close (H5G_entry_t *ent);
-intn H5O_link ( H5G_entry_t *ent, intn adjust);
-void *H5O_read (H5G_entry_t *ent, const H5O_class_t *type, intn sequence,
- void *mesg);
-intn H5O_modify (H5G_entry_t *ent, const H5O_class_t *type, intn overwrite,
- uintn flags, const void *mesg);
-herr_t H5O_remove (H5G_entry_t *ent, const H5O_class_t *type, intn sequence);
-herr_t H5O_reset (const H5O_class_t *type, void *native);
-herr_t H5O_debug (H5F_t *f, const haddr_t *addr, FILE *stream,
- intn indent, intn fwidth);
+herr_t H5O_create(H5F_t *f, size_t size_hint, H5G_entry_t *ent /*out */ );
+herr_t H5O_open(H5F_t *f, H5G_entry_t *ent);
+herr_t H5O_close(H5G_entry_t *ent);
+intn H5O_link(H5G_entry_t *ent, intn adjust);
+void *H5O_read(H5G_entry_t *ent, const H5O_class_t *type, intn sequence,
+ void *mesg);
+intn H5O_modify(H5G_entry_t *ent, const H5O_class_t *type, intn overwrite,
+ uintn flags, const void *mesg);
+herr_t H5O_remove(H5G_entry_t *ent, const H5O_class_t *type, intn sequence);
+herr_t H5O_reset(const H5O_class_t *type, void *native);
+herr_t H5O_debug(H5F_t *f, const haddr_t *addr, FILE * stream,
+ intn indent, intn fwidth);
#endif
diff --git a/src/H5Opublic.h b/src/H5Opublic.h
index 4b7b110..999a1f7 100644
--- a/src/H5Opublic.h
+++ b/src/H5Opublic.h
@@ -1,17 +1,17 @@
/*-------------------------------------------------------------------------
- * Copyright (C) 1997 National Center for Supercomputing Applications.
+ * Copyright (C) 1997 National Center for Supercomputing Applications.
* All rights reserved.
*
*-------------------------------------------------------------------------
*
- * Created: H5Oproto.h
- * Aug 5 1997
- * Robb Matzke <matzke@llnl.gov>
+ * Created: H5Oproto.h
+ * Aug 5 1997
+ * Robb Matzke <matzke@llnl.gov>
*
- * Purpose: Public declarations for the H5O (object header)
- * package.
+ * Purpose: Public declarations for the H5O (object header)
+ * package.
*
- * Modifications:
+ * Modifications:
*
*-------------------------------------------------------------------------
*/
@@ -22,11 +22,11 @@
#include <H5public.h>
#ifdef __cplusplus
-extern "C" {
+extern "C" {
#endif
#ifdef __cplusplus
}
-#endif
#endif
+#endif
diff --git a/src/H5Osdspace.c b/src/H5Osdspace.c
index 7797ae3..26330df 100644
--- a/src/H5Osdspace.c
+++ b/src/H5Osdspace.c
@@ -1,17 +1,17 @@
/****************************************************************************
-* NCSA HDF *
-* Software Development Group *
-* National Center for Supercomputing Applications *
-* University of Illinois at Urbana-Champaign *
-* 605 E. Springfield, Champaign IL 61820 *
-* *
-* For conditions of distribution and use, see the accompanying *
-* hdf/COPYING file. *
-* *
+* NCSA HDF *
+* Software Development Group *
+* National Center for Supercomputing Applications *
+* University of Illinois at Urbana-Champaign *
+* 605 E. Springfield, Champaign IL 61820 *
+* *
+* For conditions of distribution and use, see the accompanying *
+* hdf/COPYING file. *
+* *
****************************************************************************/
#ifdef RCSID
-static char RcsId[] = "@(#)$Revision$";
+static char RcsId[] = "@(#)$Revision$";
#endif
/* $Id$ */
@@ -22,32 +22,34 @@ static char RcsId[] = "@(#)$Revision$";
#include <H5MMprivate.h>
#include <H5Oprivate.h>
-#define PABLO_MASK H5O_sdspace_mask
+#define PABLO_MASK H5O_sdspace_mask
/* PRIVATE PROTOTYPES */
-static void *H5O_sdspace_decode (H5F_t *f, size_t raw_size, const uint8 *p);
-static herr_t H5O_sdspace_encode (H5F_t *f, size_t size, uint8 *p,
- const void *_mesg);
-static void *H5O_sdspace_copy (const void *_mesg, void *_dest);
-static size_t H5O_sdspace_size (H5F_t *f, const void *_mesg);
-static herr_t H5O_sdspace_debug (H5F_t *f, const void *_mesg,
- FILE *stream, intn indent, intn fwidth);
+static void *H5O_sdspace_decode(H5F_t *f, size_t raw_size, const uint8 *p);
+static herr_t H5O_sdspace_encode(H5F_t *f, size_t size, uint8 *p,
+ const void *_mesg);
+static void *H5O_sdspace_copy(const void *_mesg, void *_dest);
+static size_t H5O_sdspace_size(H5F_t *f, const void *_mesg);
+static herr_t H5O_sdspace_debug(H5F_t *f, const void *_mesg,
+ FILE * stream, intn indent, intn fwidth);
/* This message derives from H5O */
-const H5O_class_t H5O_SDSPACE[1] = {{
- H5O_SDSPACE_ID, /* message id number */
- "simple_dspace", /* message name for debugging */
- sizeof (H5P_simple_t), /* native message size */
- H5O_sdspace_decode, /* decode message */
- H5O_sdspace_encode, /* encode message */
- H5O_sdspace_copy, /* copy the native value */
- H5O_sdspace_size, /* size of symbol table entry */
- NULL, /* default reset method */
- H5O_sdspace_debug, /* debug the message */
-}};
+const H5O_class_t H5O_SDSPACE[1] =
+{
+ {
+ H5O_SDSPACE_ID, /* message id number */
+ "simple_dspace", /* message name for debugging */
+ sizeof(H5P_simple_t), /* native message size */
+ H5O_sdspace_decode, /* decode message */
+ H5O_sdspace_encode, /* encode message */
+ H5O_sdspace_copy, /* copy the native value */
+ H5O_sdspace_size, /* size of symbol table entry */
+ NULL, /* default reset method */
+ H5O_sdspace_debug, /* debug the message */
+ }};
/* Is the interface initialized? */
-static hbool_t interface_initialize_g = FALSE;
+static hbool_t interface_initialize_g = FALSE;
#define INTERFACE_INIT NULL
/*--------------------------------------------------------------------------
@@ -55,68 +57,61 @@ static hbool_t interface_initialize_g = FALSE;
H5O_sdspace_decode
PURPOSE
Decode a simple dimensionality message and return a pointer to a memory
- struct with the decoded information
+ struct with the decoded information
USAGE
void *H5O_sdspace_decode(f, raw_size, p)
- H5F_t *f; IN: pointer to the HDF5 file struct
- size_t raw_size; IN: size of the raw information buffer
- const uint8 *p; IN: the raw information buffer
+ H5F_t *f; IN: pointer to the HDF5 file struct
+ size_t raw_size; IN: size of the raw information buffer
+ const uint8 *p; IN: the raw information buffer
RETURNS
Pointer to the new message in native order on success, NULL on failure
DESCRIPTION
- This function decodes the "raw" disk form of a simple dimensionality
+ This function decodes the "raw" disk form of a simple dimensionality
message into a struct in memory native format. The struct is allocated
within this function using malloc() and is returned to the caller.
--------------------------------------------------------------------------*/
-static void *
-H5O_sdspace_decode (H5F_t *f, size_t raw_size, const uint8 *p)
+static void *
+H5O_sdspace_decode(H5F_t *f, size_t raw_size, const uint8 *p)
{
- H5P_simple_t *sdim=NULL; /* New simple dimensionality structure */
- uintn u; /* local counting variable */
-
- FUNC_ENTER (H5O_sdspace_decode, NULL);
+ H5P_simple_t *sdim = NULL; /* New simple dimensionality structure */
+ uintn u; /* local counting variable */
+
+ FUNC_ENTER(H5O_sdspace_decode, NULL);
/* check args */
- assert (f);
- assert (raw_size >= 8); /* at least the rank and flags must be present */
- assert (p);
+ assert(f);
+ assert(raw_size >= 8); /* at least the rank and flags must be present */
+ assert(p);
/* decode */
- if((sdim = H5MM_xcalloc (1, sizeof(H5P_simple_t)))!=NULL)
- {
- UINT32DECODE(p,sdim->rank);
- UINT32DECODE(p,sdim->dim_flags);
- if(sdim->rank>0)
- {
- sdim->size=H5MM_xmalloc(sizeof(uint32)*sdim->rank);
- for(u=0; u<sdim->rank; u++)
- UINT32DECODE(p,sdim->size[u]);
- if(sdim->dim_flags&0x01)
- {
- sdim->max=H5MM_xmalloc(sizeof(uint32)*sdim->rank);
- for(u=0; u<sdim->rank; u++)
- UINT32DECODE(p,sdim->max[u]);
- } /* end if */
- if(sdim->dim_flags&0x02)
- {
- sdim->perm=H5MM_xmalloc(sizeof(uint32)*sdim->rank);
- for(u=0; u<sdim->rank; u++)
- UINT32DECODE(p,sdim->perm[u]);
- } /* end if */
- } /* end if */
- } /* end if */
-
+ if ((sdim = H5MM_xcalloc(1, sizeof(H5P_simple_t))) != NULL) {
+ UINT32DECODE(p, sdim->rank);
+ UINT32DECODE(p, sdim->dim_flags);
+ if (sdim->rank > 0) {
+ sdim->size = H5MM_xmalloc(sizeof(uint32) * sdim->rank);
+ for (u = 0; u < sdim->rank; u++)
+ UINT32DECODE(p, sdim->size[u]);
+ if (sdim->dim_flags & 0x01) {
+ sdim->max = H5MM_xmalloc(sizeof(uint32) * sdim->rank);
+ for (u = 0; u < sdim->rank; u++)
+ UINT32DECODE(p, sdim->max[u]);
+ } /* end if */
+ if (sdim->dim_flags & 0x02) {
+ sdim->perm = H5MM_xmalloc(sizeof(uint32) * sdim->rank);
+ for (u = 0; u < sdim->rank; u++)
+ UINT32DECODE(p, sdim->perm[u]);
+ } /* end if */
+ } /* end if */
+ } /* end if */
+
#ifdef LATER
-done:
+ done:
#endif /* LATER */
- if(sdim == NULL)
- { /* Error condition cleanup */
-
- } /* end if */
+ if (sdim == NULL) { /* Error condition cleanup */
+ } /* end if */
/* Normal function cleanup */
-
- FUNC_LEAVE (sdim);
+ FUNC_LEAVE(sdim);
}
/*--------------------------------------------------------------------------
@@ -126,50 +121,46 @@ done:
Encode a simple dimensionality message
USAGE
herr_t H5O_sdspace_encode(f, raw_size, p, mesg)
- H5F_t *f; IN: pointer to the HDF5 file struct
- size_t raw_size; IN: size of the raw information buffer
- const uint8 *p; IN: the raw information buffer
- const void *mesg; IN: Pointer to the simple dimensionality struct
+ H5F_t *f; IN: pointer to the HDF5 file struct
+ size_t raw_size; IN: size of the raw information buffer
+ const uint8 *p; IN: the raw information buffer
+ const void *mesg; IN: Pointer to the simple dimensionality struct
RETURNS
SUCCEED/FAIL
DESCRIPTION
- This function encodes the native memory form of the simple
+ This function encodes the native memory form of the simple
dimensionality message in the "raw" disk form.
--------------------------------------------------------------------------*/
static herr_t
-H5O_sdspace_encode (H5F_t *f, size_t raw_size, uint8 *p, const void *mesg)
+H5O_sdspace_encode(H5F_t *f, size_t raw_size, uint8 *p, const void *mesg)
{
- const H5P_simple_t *sdim = (const H5P_simple_t *)mesg;
- uintn u; /* Local counting variable */
+ const H5P_simple_t *sdim = (const H5P_simple_t *) mesg;
+ uintn u; /* Local counting variable */
- FUNC_ENTER (H5O_sdspace_encode, FAIL);
+ FUNC_ENTER(H5O_sdspace_encode, FAIL);
/* check args */
- assert (f);
- assert (raw_size >= 8); /* at least the rank & flags must be present */
- assert (p);
- assert (sdim);
+ assert(f);
+ assert(raw_size >= 8); /* at least the rank & flags must be present */
+ assert(p);
+ assert(sdim);
/* encode */
- UINT32ENCODE(p,sdim->rank);
- UINT32ENCODE(p,sdim->dim_flags);
- if(sdim->rank>0)
- {
- for(u=0; u<sdim->rank; u++)
- UINT32ENCODE(p,sdim->size[u]);
- if(sdim->dim_flags&0x01)
- {
- for(u=0; u<sdim->rank; u++)
- UINT32ENCODE(p,sdim->max[u]);
- } /* end if */
- if(sdim->dim_flags&0x02)
- {
- for(u=0; u<sdim->rank; u++)
- UINT32ENCODE(p,sdim->perm[u]);
- } /* end if */
- } /* end if */
-
- FUNC_LEAVE (SUCCEED);
+ UINT32ENCODE(p, sdim->rank);
+ UINT32ENCODE(p, sdim->dim_flags);
+ if (sdim->rank > 0) {
+ for (u = 0; u < sdim->rank; u++)
+ UINT32ENCODE(p, sdim->size[u]);
+ if (sdim->dim_flags & 0x01) {
+ for (u = 0; u < sdim->rank; u++)
+ UINT32ENCODE(p, sdim->max[u]);
+ } /* end if */
+ if (sdim->dim_flags & 0x02) {
+ for (u = 0; u < sdim->rank; u++)
+ UINT32ENCODE(p, sdim->perm[u]);
+ } /* end if */
+ } /* end if */
+ FUNC_LEAVE(SUCCEED);
}
/*--------------------------------------------------------------------------
@@ -179,49 +170,48 @@ H5O_sdspace_encode (H5F_t *f, size_t raw_size, uint8 *p, const void *mesg)
Copies a message from MESG to DEST, allocating DEST if necessary.
USAGE
void *H5O_sdspace_copy(mesg, dest)
- const void *mesg; IN: Pointer to the source simple dimensionality struct
- const void *dest; IN: Pointer to the destination simple dimensionality struct
+ const void *mesg; IN: Pointer to the source simple dimensionality struct
+ const void *dest; IN: Pointer to the destination simple dimensionality struct
RETURNS
Pointer to DEST on success, NULL on failure
DESCRIPTION
- This function copies a native (memory) simple dimensionality message,
+ This function copies a native (memory) simple dimensionality message,
allocating the destination structure if necessary.
--------------------------------------------------------------------------*/
-static void *
-H5O_sdspace_copy (const void *mesg, void *dest)
+static void *
+H5O_sdspace_copy(const void *mesg, void *dest)
{
- const H5P_simple_t *src = (const H5P_simple_t *)mesg;
- H5P_simple_t *dst = (H5P_simple_t *)dest;
-
- FUNC_ENTER (H5O_sdspace_copy, NULL);
+ const H5P_simple_t *src = (const H5P_simple_t *) mesg;
+ H5P_simple_t *dst = (H5P_simple_t *) dest;
- /* check args */
- assert (src);
- if (!dst)
- dst = H5MM_xcalloc (1, sizeof(H5P_simple_t));
+ FUNC_ENTER(H5O_sdspace_copy, NULL);
- /* deep copy -- pointed-to values are copied also */
- HDmemcpy(dst,src,sizeof(H5P_simple_t));
- if (src->size) dst->size = H5MM_xcalloc (src->rank, sizeof(uint32));
- if (src->max) dst->max = H5MM_xcalloc (src->rank, sizeof(uint32));
- if (src->perm) dst->perm = H5MM_xcalloc (src->rank, sizeof(uint32));
-
- if(src->rank>0)
- {
- HDmemcpy(dst->size,src->size,src->rank*sizeof(uint32));
- /* Check for maximum dimensions and copy those */
- if((src->dim_flags&0x01)>0)
- {
- HDmemcpy(dst->max,src->max,src->rank*sizeof(uint32));
- } /* end if */
- /* Check for dimension permutation and copy those */
- if((src->dim_flags&0x02)>0)
- {
- HDmemcpy(dst->perm,src->perm,src->rank*sizeof(uint32));
- } /* end if */
- } /* end if */
-
- FUNC_LEAVE ((void*)dst);
+ /* check args */
+ assert(src);
+ if (!dst)
+ dst = H5MM_xcalloc(1, sizeof(H5P_simple_t));
+
+ /* deep copy -- pointed-to values are copied also */
+ HDmemcpy(dst, src, sizeof(H5P_simple_t));
+ if (src->size)
+ dst->size = H5MM_xcalloc(src->rank, sizeof(uint32));
+ if (src->max)
+ dst->max = H5MM_xcalloc(src->rank, sizeof(uint32));
+ if (src->perm)
+ dst->perm = H5MM_xcalloc(src->rank, sizeof(uint32));
+
+ if (src->rank > 0) {
+ HDmemcpy(dst->size, src->size, src->rank * sizeof(uint32));
+ /* Check for maximum dimensions and copy those */
+ if ((src->dim_flags & 0x01) > 0) {
+ HDmemcpy(dst->max, src->max, src->rank * sizeof(uint32));
+ } /* end if */
+ /* Check for dimension permutation and copy those */
+ if ((src->dim_flags & 0x02) > 0) {
+ HDmemcpy(dst->perm, src->perm, src->rank * sizeof(uint32));
+ } /* end if */
+ } /* end if */
+ FUNC_LEAVE((void *) dst);
}
/*--------------------------------------------------------------------------
@@ -231,28 +221,28 @@ H5O_sdspace_copy (const void *mesg, void *dest)
Return the raw message size in bytes
USAGE
void *H5O_sdspace_copy(f, mesg)
- H5F_t *f; IN: pointer to the HDF5 file struct
- const void *mesg; IN: Pointer to the source simple dimensionality struct
+ H5F_t *f; IN: pointer to the HDF5 file struct
+ const void *mesg; IN: Pointer to the source simple dimensionality struct
RETURNS
Size of message on success, FAIL on failure
DESCRIPTION
- This function returns the size of the raw simple dimensionality message on
+ This function returns the size of the raw simple dimensionality message on
success. (Not counting the message type or size fields, only the data
portion of the message). It doesn't take into account alignment.
--------------------------------------------------------------------------*/
static size_t
-H5O_sdspace_size (H5F_t *f, const void *mesg)
+H5O_sdspace_size(H5F_t *f, const void *mesg)
{
- const H5P_simple_t *sdim = (const H5P_simple_t *)mesg;
- size_t ret_value=8; /* all dimensionality messages are at least 8 bytes long (rank and flags) */
+ const H5P_simple_t *sdim = (const H5P_simple_t *) mesg;
+ size_t ret_value = 8; /* all dimensionality messages are at least 8 bytes long (rank and flags) */
- FUNC_ENTER (H5O_sim_dtype_size, FAIL);
+ FUNC_ENTER(H5O_sim_dtype_size, FAIL);
- ret_value+=sdim->rank*4; /* add in the dimension sizes */
- ret_value+=((sdim->dim_flags&0x01)>0)*sdim->rank*4; /* add in the space for the maximum dimensions, if they are present */
- ret_value+=((sdim->dim_flags&0x02)>0)*sdim->rank*4; /* add in the space for the dimension permutations, if they are present */
+ ret_value += sdim->rank * 4; /* add in the dimension sizes */
+ ret_value += ((sdim->dim_flags & 0x01) > 0) * sdim->rank * 4; /* add in the space for the maximum dimensions, if they are present */
+ ret_value += ((sdim->dim_flags & 0x02) > 0) * sdim->rank * 4; /* add in the space for the dimension permutations, if they are present */
- FUNC_LEAVE (ret_value);
+ FUNC_LEAVE(ret_value);
}
/*--------------------------------------------------------------------------
@@ -262,54 +252,53 @@ H5O_sdspace_size (H5F_t *f, const void *mesg)
Prints debugging information for a simple dimensionality message
USAGE
void *H5O_sdspace_debug(f, mesg, stream, indent, fwidth)
- H5F_t *f; IN: pointer to the HDF5 file struct
- const void *mesg; IN: Pointer to the source simple dimensionality struct
- FILE *stream; IN: Pointer to the stream for output data
- intn indent; IN: Amount to indent information by
- intn fwidth; IN: Field width (?)
+ H5F_t *f; IN: pointer to the HDF5 file struct
+ const void *mesg; IN: Pointer to the source simple dimensionality struct
+ FILE *stream; IN: Pointer to the stream for output data
+ intn indent; IN: Amount to indent information by
+ intn fwidth; IN: Field width (?)
RETURNS
SUCCEED/FAIL
DESCRIPTION
- This function prints debugging output to the stream passed as a
+ This function prints debugging output to the stream passed as a
parameter.
--------------------------------------------------------------------------*/
static herr_t
-H5O_sdspace_debug (H5F_t *f, const void *mesg, FILE *stream,
- intn indent, intn fwidth)
+H5O_sdspace_debug(H5F_t *f, const void *mesg, FILE * stream,
+ intn indent, intn fwidth)
{
- const H5P_simple_t *sdim = (const H5P_simple_t *)mesg;
- uintn u; /* local counting variable */
-
- FUNC_ENTER (H5O_sdspace_debug, FAIL);
+ const H5P_simple_t *sdim = (const H5P_simple_t *) mesg;
+ uintn u; /* local counting variable */
- /* check args */
- assert (f);
- assert (sdim);
- assert (stream);
- assert (indent>=0);
- assert (fwidth>=0);
+ FUNC_ENTER(H5O_sdspace_debug, FAIL);
- fprintf (stream, "%*s%-*s %lu\n", indent, "", fwidth,
- "Rank:",
- (unsigned long)(sdim->rank));
- fprintf (stream, "%*s%-*s %lx\n", indent, "", fwidth,
- "Flags:",
- (unsigned long)(sdim->dim_flags));
- for(u=0; u<sdim->rank; u++)
- fprintf (stream, "%*s%-*s %lx\n", indent, "", fwidth,
- "Dim Size:",
- (unsigned long)(sdim->size[u]));
- if(sdim->dim_flags&0x01)
- for(u=0; u<sdim->rank; u++)
- fprintf (stream, "%*s%-*s %lx\n", indent, "", fwidth,
- "Dim Max:",
- (unsigned long)(sdim->max[u]));
- if(sdim->dim_flags&0x02)
- for(u=0; u<sdim->rank; u++)
- fprintf (stream, "%*s%-*s %lx\n", indent, "", fwidth,
- "Dim Perm:",
- (unsigned long)(sdim->perm[u]));
-
- FUNC_LEAVE (SUCCEED);
+ /* check args */
+ assert(f);
+ assert(sdim);
+ assert(stream);
+ assert(indent >= 0);
+ assert(fwidth >= 0);
+
+ fprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth,
+ "Rank:",
+ (unsigned long) (sdim->rank));
+ fprintf(stream, "%*s%-*s %lx\n", indent, "", fwidth,
+ "Flags:",
+ (unsigned long) (sdim->dim_flags));
+ for (u = 0; u < sdim->rank; u++)
+ fprintf(stream, "%*s%-*s %lx\n", indent, "", fwidth,
+ "Dim Size:",
+ (unsigned long) (sdim->size[u]));
+ if (sdim->dim_flags & 0x01)
+ for (u = 0; u < sdim->rank; u++)
+ fprintf(stream, "%*s%-*s %lx\n", indent, "", fwidth,
+ "Dim Max:",
+ (unsigned long) (sdim->max[u]));
+ if (sdim->dim_flags & 0x02)
+ for (u = 0; u < sdim->rank; u++)
+ fprintf(stream, "%*s%-*s %lx\n", indent, "", fwidth,
+ "Dim Perm:",
+ (unsigned long) (sdim->perm[u]));
+
+ FUNC_LEAVE(SUCCEED);
}
-
diff --git a/src/H5Ostab.c b/src/H5Ostab.c
index 60aaa1d..e1a5d0a 100644
--- a/src/H5Ostab.c
+++ b/src/H5Ostab.c
@@ -1,16 +1,16 @@
/*-------------------------------------------------------------------------
- * Copyright (C) 1997 National Center for Supercomputing Applications.
+ * Copyright (C) 1997 National Center for Supercomputing Applications.
* All rights reserved.
*
*-------------------------------------------------------------------------
*
- * Created: H5Ostab.c
- * Aug 6 1997
- * Robb Matzke <matzke@llnl.gov>
+ * Created: H5Ostab.c
+ * Aug 6 1997
+ * Robb Matzke <matzke@llnl.gov>
*
- * Purpose: Symbol table messages.
+ * Purpose: Symbol table messages.
*
- * Modifications:
+ * Modifications:
*
*-------------------------------------------------------------------------
*/
@@ -20,259 +20,256 @@
#include <H5MMprivate.h>
#include <H5Oprivate.h>
-#define PABLO_MASK H5O_stab_mask
+#define PABLO_MASK H5O_stab_mask
/* PRIVATE PROTOTYPES */
-static void *H5O_stab_decode (H5F_t *f, size_t raw_size, const uint8 *p);
-static herr_t H5O_stab_encode (H5F_t *f, size_t size, 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);
+static void *H5O_stab_decode(H5F_t *f, size_t raw_size, const uint8 *p);
+static herr_t H5O_stab_encode(H5F_t *f, size_t size, 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 */
- H5O_stab_debug, /*debug the message */
-}};
+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 */
+ H5O_stab_debug, /*debug the message */
+ }};
/* Interface initialization */
-static hbool_t interface_initialize_g = FALSE;
-#define INTERFACE_INIT NULL
-
+static hbool_t interface_initialize_g = FALSE;
+#define INTERFACE_INIT NULL
/*-------------------------------------------------------------------------
- * Function: H5O_stab_decode
+ * Function: H5O_stab_decode
*
- * Purpose: Decode a symbol table message and return a pointer to
- * a new one created with malloc().
+ * 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.
+ * Return: Success: Ptr to new message in native order.
*
- * Failure: NULL
+ * Failure: NULL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Aug 6 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Aug 6 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-static void *
-H5O_stab_decode (H5F_t *f, size_t raw_size, const uint8 *p)
+static void *
+H5O_stab_decode(H5F_t *f, size_t raw_size, const uint8 *p)
{
- H5O_stab_t *stab;
-
- FUNC_ENTER (H5O_stab_decode, NULL);
+ H5O_stab_t *stab;
- /* check args */
- assert (f);
- assert (raw_size == 2*H5F_SIZEOF_ADDR(f));
- assert (p);
+ FUNC_ENTER(H5O_stab_decode, NULL);
- /* 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));
+ /* check args */
+ assert(f);
+ assert(raw_size == 2 * H5F_SIZEOF_ADDR(f));
+ assert(p);
- FUNC_LEAVE (stab);
-}
+ /* 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
+ * Function: H5O_stab_encode
*
- * Purpose: Encodes a symbol table message.
+ * Purpose: Encodes a symbol table message.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Aug 6 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Aug 6 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_stab_encode (H5F_t *f, size_t raw_size, uint8 *p, const void *_mesg)
+H5O_stab_encode(H5F_t *f, size_t raw_size, uint8 *p, const void *_mesg)
{
- const H5O_stab_t *stab = (const H5O_stab_t *)_mesg;
+ const H5O_stab_t *stab = (const H5O_stab_t *) _mesg;
- FUNC_ENTER (H5O_stab_encode, FAIL);
+ FUNC_ENTER(H5O_stab_encode, FAIL);
- /* check args */
- assert (f);
- assert (raw_size == 2 * H5F_SIZEOF_ADDR(f));
- assert (p);
- assert (stab);
+ /* check args */
+ assert(f);
+ assert(raw_size == 2 * H5F_SIZEOF_ADDR(f));
+ assert(p);
+ assert(stab);
- /* encode */
- H5F_addr_encode (f, &p, &(stab->btree_addr));
- H5F_addr_encode (f, &p, &(stab->heap_addr));
+ /* encode */
+ H5F_addr_encode(f, &p, &(stab->btree_addr));
+ H5F_addr_encode(f, &p, &(stab->heap_addr));
- FUNC_LEAVE (SUCCEED);
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5O_stab_fast
+ * Function: H5O_stab_fast
*
- * Purpose: Initializes a new message struct with info from the cache of
- * a symbol table entry.
+ * 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.
+ * Return: Success: Ptr to message struct, allocated if none
+ * supplied.
*
- * Failure: NULL
+ * Failure: NULL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Aug 6 1997
+ * 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)
+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);
+ H5O_stab_t *stab = NULL;
- /* check args */
- assert (cache);
- assert (type);
+ FUNC_ENTER(H5O_stab_fast, NULL);
- 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;
- }
+ /* check args */
+ assert(cache);
+ assert(type);
- FUNC_LEAVE (stab);
+ 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
+ * Function: H5O_stab_copy
*
- * Purpose: Copies a message from _MESG to _DEST, allocating _DEST if
- * necessary.
+ * Purpose: Copies a message from _MESG to _DEST, allocating _DEST if
+ * necessary.
*
- * Return: Success: Ptr to _DEST
+ * Return: Success: Ptr to _DEST
*
- * Failure: NULL
+ * Failure: NULL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Aug 6 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Aug 6 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-static void *
-H5O_stab_copy (const void *_mesg, void *_dest)
+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);
+ const H5O_stab_t *stab = (const H5O_stab_t *) _mesg;
+ H5O_stab_t *dest = (H5O_stab_t *) _dest;
- /* check args */
- assert (stab);
- if (!dest) dest = H5MM_xcalloc (1, sizeof(H5O_stab_t));
+ FUNC_ENTER(H5O_stab_copy, NULL);
- /* copy */
- *dest = *stab;
+ /* check args */
+ assert(stab);
+ if (!dest)
+ dest = H5MM_xcalloc(1, sizeof(H5O_stab_t));
- FUNC_LEAVE ((void*)dest);
-}
+ /* copy */
+ *dest = *stab;
+ FUNC_LEAVE((void *) dest);
+}
/*-------------------------------------------------------------------------
- * Function: H5O_stab_size
+ * 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.
+ * 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.
+ * Return: Success: Message data size in bytes without alignment.
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Aug 6 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Aug 6 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static size_t
-H5O_stab_size (H5F_t *f, const void *_mesg)
+H5O_stab_size(H5F_t *f, const void *_mesg)
{
- FUNC_ENTER (H5O_stab_size, FAIL);
- FUNC_LEAVE (2 * H5F_SIZEOF_ADDR(f));
+ FUNC_ENTER(H5O_stab_size, FAIL);
+ FUNC_LEAVE(2 * H5F_SIZEOF_ADDR(f));
}
-
/*-------------------------------------------------------------------------
- * Function: H5O_stab_debug
+ * Function: H5O_stab_debug
*
- * Purpose: Prints debugging info for a symbol table message.
+ * Purpose: Prints debugging info for a symbol table message.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Aug 6 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Aug 6 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static herr_t
-H5O_stab_debug (H5F_t *f, const void *_mesg, FILE *stream, intn indent,
- intn fwidth)
+H5O_stab_debug(H5F_t *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);
+ 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");
- /* check args */
- assert (f);
- assert (stab);
- assert (stream);
- assert (indent>=0);
- assert (fwidth>=0);
+ fprintf(stream, "%*s%-*s ", indent, "", fwidth,
+ "Name heap address:");
+ H5F_addr_print(stream, &(stab->heap_addr));
+ fprintf(stream, "\n");
- 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);
+ FUNC_LEAVE(SUCCEED);
}
-
diff --git a/src/H5P.c b/src/H5P.c
index b7266ce..4ea8117 100644
--- a/src/H5P.c
+++ b/src/H5P.c
@@ -11,26 +11,25 @@
****************************************************************************/
#ifdef RCSID
-static char RcsId[] = "@(#)$Revision$";
+static char RcsId[] = "@(#)$Revision$";
#endif
/* $Id$ */
+#include <H5private.h> /* Generic Functions */
+#include <H5Aprivate.h> /* Atom Functions */
+#include <H5Eprivate.h> /* Error handling */
+#include <H5MMprivate.h> /* Memory Management functions */
+#include <H5Oprivate.h> /*object headers */
+#include <H5Pprivate.h> /* Data-space functions */
-#include <H5private.h> /* Generic Functions */
-#include <H5Aprivate.h> /* Atom Functions */
-#include <H5Eprivate.h> /* Error handling */
-#include <H5MMprivate.h> /* Memory Management functions */
-#include <H5Oprivate.h> /*object headers */
-#include <H5Pprivate.h> /* Data-space functions */
-
-#define PABLO_MASK H5P_mask
+#define PABLO_MASK H5P_mask
/* Interface initialization */
-static intn interface_initialize_g = FALSE;
-#define INTERFACE_INIT H5P_init_interface
-static herr_t H5P_init_interface (void);
-static void H5P_term_interface (void);
+static intn interface_initialize_g = FALSE;
+#define INTERFACE_INIT H5P_init_interface
+static herr_t H5P_init_interface(void);
+static void H5P_term_interface(void);
/*--------------------------------------------------------------------------
NAME
@@ -45,19 +44,18 @@ DESCRIPTION
--------------------------------------------------------------------------*/
static herr_t
-H5P_init_interface (void)
+H5P_init_interface(void)
{
- herr_t ret_value = SUCCEED;
- FUNC_ENTER (H5P_init_interface, FAIL);
-
- /* Initialize the atom group for the file IDs */
- if ((ret_value=H5Ainit_group (H5_DATASPACE, H5A_DATASPACEID_HASHSIZE,
- H5P_RESERVED_ATOMS,
- (herr_t (*)(void*))H5P_close))!=FAIL) {
- ret_value=H5_add_exit(&H5P_term_interface);
- }
-
- FUNC_LEAVE (ret_value);
+ herr_t ret_value = SUCCEED;
+ FUNC_ENTER(H5P_init_interface, FAIL);
+
+ /* Initialize the atom group for the file IDs */
+ if ((ret_value = H5Ainit_group(H5_DATASPACE, H5A_DATASPACEID_HASHSIZE,
+ H5P_RESERVED_ATOMS,
+ (herr_t (*)(void *)) H5P_close)) != FAIL) {
+ ret_value = H5_add_exit(&H5P_term_interface);
+ }
+ FUNC_LEAVE(ret_value);
}
/*--------------------------------------------------------------------------
@@ -78,24 +76,23 @@ H5P_init_interface (void)
REVISION LOG
--------------------------------------------------------------------------*/
static void
-H5P_term_interface (void)
+H5P_term_interface(void)
{
- H5Adestroy_group (H5_DATASPACE);
+ H5Adestroy_group(H5_DATASPACE);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Pcreate
+ * Function: H5Pcreate
*
- * Purpose: Creates a new data space object and opens it for access.
+ * Purpose: Creates a new data space object and opens it for access.
*
- * Return: Success: The ID for the new data space object.
+ * Return: Success: The ID for the new data space object.
*
- * Failure: FAIL
+ * Failure: FAIL
*
* Errors:
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Tuesday, December 9, 1997
*
* Modifications:
@@ -103,62 +100,59 @@ H5P_term_interface (void)
*-------------------------------------------------------------------------
*/
hid_t
-H5Pcreate (H5P_class_t type)
+H5Pcreate(H5P_class_t type)
{
- H5P_t *ds = NULL;
- hid_t ret_value = FAIL;
-
- FUNC_ENTER (H5Pcreate, FAIL);
- H5ECLEAR;
+ H5P_t *ds = NULL;
+ hid_t ret_value = FAIL;
- ds = H5MM_xcalloc (1, sizeof(H5P_t));
- ds->type = type;
-
- switch (type) {
- case H5P_SCALAR:
- /*void*/
- break;
-
- case H5P_SIMPLE:
- ds->u.simple.rank = 0;
- break;
-
- case H5P_COMPLEX:
- HGOTO_ERROR (H5E_DATASPACE, H5E_UNSUPPORTED, FAIL,
- "complex types are not supported yet");
-
- default:
- HGOTO_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL,
- "unknown data space type");
- }
-
- /* Register the new data space and get an ID for it */
- if ((ret_value = H5Aregister_atom (H5_DATASPACE, ds))<0) {
- HGOTO_ERROR (H5E_ATOM, H5E_CANTREGISTER, FAIL,
- "unable to register data space for ID");
- }
-
- done:
- if (ret_value<0) {
- H5MM_xfree (ds);
- }
-
- FUNC_LEAVE (ret_value);
-}
+ FUNC_ENTER(H5Pcreate, FAIL);
+ H5ECLEAR;
+ ds = H5MM_xcalloc(1, sizeof(H5P_t));
+ ds->type = type;
+
+ switch (type) {
+ case H5P_SCALAR:
+ /*void */
+ break;
+
+ case H5P_SIMPLE:
+ ds->u.simple.rank = 0;
+ break;
+
+ case H5P_COMPLEX:
+ HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL,
+ "complex types are not supported yet");
+
+ default:
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ "unknown data space type");
+ }
+
+ /* Register the new data space and get an ID for it */
+ if ((ret_value = H5Aregister_atom(H5_DATASPACE, ds)) < 0) {
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL,
+ "unable to register data space for ID");
+ }
+ done:
+ if (ret_value < 0) {
+ H5MM_xfree(ds);
+ }
+ FUNC_LEAVE(ret_value);
+}
/*-------------------------------------------------------------------------
- * Function: H5Pclose
+ * Function: H5Pclose
*
- * Purpose: Release access to a data space object.
+ * Purpose: Release access to a data space object.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
* Errors:
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Tuesday, December 9, 1997
*
* Modifications:
@@ -166,36 +160,33 @@ H5Pcreate (H5P_class_t type)
*-------------------------------------------------------------------------
*/
herr_t
-H5Pclose (hid_t space_id)
+H5Pclose(hid_t space_id)
{
- FUNC_ENTER (H5Pclose, FAIL);
- H5ECLEAR;
-
- /* check args */
- if (H5_DATASPACE!=H5Aatom_group (space_id) ||
- NULL==H5Aatom_object (space_id)) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
- }
-
- /* When the reference count reaches zero the resources are freed */
- if (H5A_dec_ref (space_id)<0) {
- HRETURN_ERROR (H5E_ATOM, H5E_BADATOM, FAIL, "problem freeing id");
- }
+ FUNC_ENTER(H5Pclose, FAIL);
+ H5ECLEAR;
- FUNC_LEAVE (SUCCEED);
+ /* check args */
+ if (H5_DATASPACE != H5Aatom_group(space_id) ||
+ NULL == H5Aatom_object(space_id)) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
+ }
+ /* When the reference count reaches zero the resources are freed */
+ if (H5A_dec_ref(space_id) < 0) {
+ HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "problem freeing id");
+ }
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5P_close
+ * Function: H5P_close
*
- * Purpose: Releases all memory associated with a data space.
+ * Purpose: Releases all memory associated with a data space.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Tuesday, December 9, 1997
*
* Modifications:
@@ -203,116 +194,114 @@ H5Pclose (hid_t space_id)
*-------------------------------------------------------------------------
*/
herr_t
-H5P_close (H5P_t *ds)
+H5P_close(H5P_t *ds)
{
- FUNC_ENTER (H5P_close, FAIL);
-
- assert (ds);
-
- switch (ds->type) {
- case H5P_SCALAR:
- /*void*/
- break;
-
- case H5P_SIMPLE:
- H5MM_xfree (ds->u.simple.size);
- H5MM_xfree (ds->u.simple.max);
- H5MM_xfree (ds->u.simple.perm);
- break;
-
- case H5P_COMPLEX:
- /* nothing */
- break;
-
- default:
- assert ("unknown data space type" && 0);
- break;
- }
- H5MM_xfree (ds);
-
- FUNC_LEAVE (SUCCEED);
-}
+ FUNC_ENTER(H5P_close, FAIL);
+
+ assert(ds);
+
+ switch (ds->type) {
+ case H5P_SCALAR:
+ /*void */
+ break;
+
+ case H5P_SIMPLE:
+ H5MM_xfree(ds->u.simple.size);
+ H5MM_xfree(ds->u.simple.max);
+ H5MM_xfree(ds->u.simple.perm);
+ break;
+
+ case H5P_COMPLEX:
+ /* nothing */
+ break;
+ default:
+ assert("unknown data space type" && 0);
+ break;
+ }
+ H5MM_xfree(ds);
+
+ FUNC_LEAVE(SUCCEED);
+}
/*-------------------------------------------------------------------------
- * Function: H5P_copy
+ * Function: H5P_copy
*
- * Purpose: Copies a data space.
+ * Purpose: Copies a data space.
*
- * Return: Success: A pointer to a new copy of SRC
+ * Return: Success: A pointer to a new copy of SRC
*
- * Failure: NULL
+ * Failure: NULL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Thursday, December 4, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-H5P_t *
-H5P_copy (const H5P_t *src)
+H5P_t *
+H5P_copy(const H5P_t *src)
{
- H5P_t *dst = NULL;
- int i;
-
- FUNC_ENTER (H5P_copy, NULL);
-
- dst = H5MM_xmalloc (sizeof(H5P_t));
- *dst = *src;
-
- switch (dst->type) {
- case H5P_SCALAR:
- /*void*/
- break;
-
- case H5P_SIMPLE:
- if (dst->u.simple.size) {
- dst->u.simple.size = H5MM_xmalloc (dst->u.simple.rank *
- sizeof(dst->u.simple.size[0]));
- for (i=0; i<dst->u.simple.rank; i++) {
- dst->u.simple.size[i] = src->u.simple.size[i];
- }
- }
- if (dst->u.simple.max) {
- dst->u.simple.max = H5MM_xmalloc (dst->u.simple.rank *
- sizeof(dst->u.simple.max[0]));
- for (i=0; i<dst->u.simple.rank; i++) {
- dst->u.simple.max[i] = src->u.simple.max[i];
- }
- }
- if (dst->u.simple.perm) {
- dst->u.simple.perm = H5MM_xmalloc (dst->u.simple.rank *
- sizeof(dst->u.simple.perm[0]));
- for (i=0; i<dst->u.simple.rank; i++) {
- dst->u.simple.perm[i] = src->u.simple.perm[i];
- }
- }
- break;
-
- case H5P_COMPLEX:
- /*void*/
- break;
-
- default:
- assert ("unknown data space type" && 0);
- break;
- }
-
- FUNC_LEAVE (dst);
+ H5P_t *dst = NULL;
+ int i;
+
+ FUNC_ENTER(H5P_copy, NULL);
+
+ dst = H5MM_xmalloc(sizeof(H5P_t));
+ *dst = *src;
+
+ switch (dst->type) {
+ case H5P_SCALAR:
+ /*void */
+ break;
+
+ case H5P_SIMPLE:
+ if (dst->u.simple.size) {
+ dst->u.simple.size = H5MM_xmalloc(dst->u.simple.rank *
+ sizeof(dst->u.simple.size[0]));
+ for (i = 0; i < dst->u.simple.rank; i++) {
+ dst->u.simple.size[i] = src->u.simple.size[i];
+ }
+ }
+ if (dst->u.simple.max) {
+ dst->u.simple.max = H5MM_xmalloc(dst->u.simple.rank *
+ sizeof(dst->u.simple.max[0]));
+ for (i = 0; i < dst->u.simple.rank; i++) {
+ dst->u.simple.max[i] = src->u.simple.max[i];
+ }
+ }
+ if (dst->u.simple.perm) {
+ dst->u.simple.perm = H5MM_xmalloc(dst->u.simple.rank *
+ sizeof(dst->u.simple.perm[0]));
+ for (i = 0; i < dst->u.simple.rank; i++) {
+ dst->u.simple.perm[i] = src->u.simple.perm[i];
+ }
+ }
+ break;
+
+ case H5P_COMPLEX:
+ /*void */
+ break;
+
+ default:
+ assert("unknown data space type" && 0);
+ break;
+ }
+
+ FUNC_LEAVE(dst);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Pget_npoints
+ * Function: H5Pget_npoints
*
- * Purpose: Determines how many data points a data set has.
+ * Purpose: Determines how many data points a data set has.
*
- * Return: Success: Number of data points in the data set.
+ * Return: Success: Number of data points in the data set.
*
- * Failure: 0
+ * Failure: 0
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Tuesday, December 9, 1997
*
* Modifications:
@@ -320,36 +309,34 @@ H5P_copy (const H5P_t *src)
*-------------------------------------------------------------------------
*/
size_t
-H5Pget_npoints (hid_t space_id)
+H5Pget_npoints(hid_t space_id)
{
- H5P_t *ds = NULL;
- size_t ret_value = 0;
-
- FUNC_ENTER(H5Pget_npoints, 0);
- H5ECLEAR;
+ H5P_t *ds = NULL;
+ size_t ret_value = 0;
- /* check args */
- if (H5_DATASPACE!=H5Aatom_group (space_id) ||
- NULL==(ds=H5Aatom_object (space_id))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, 0, "not a data space");
- }
+ FUNC_ENTER(H5Pget_npoints, 0);
+ H5ECLEAR;
- ret_value = H5P_get_npoints (ds);
+ /* check args */
+ if (H5_DATASPACE != H5Aatom_group(space_id) ||
+ NULL == (ds = H5Aatom_object(space_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a data space");
+ }
+ ret_value = H5P_get_npoints(ds);
- FUNC_LEAVE (ret_value);
+ FUNC_LEAVE(ret_value);
}
-
/*-------------------------------------------------------------------------
- * Function: H5P_get_npoints
+ * Function: H5P_get_npoints
*
- * Purpose: Determines how many data points a data set has.
+ * Purpose: Determines how many data points a data set has.
*
- * Return: Success: Number of data points in the data set.
+ * Return: Success: Number of data points in the data set.
*
- * Failure: 0
+ * Failure: 0
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Tuesday, December 9, 1997
*
* Modifications:
@@ -357,51 +344,50 @@ H5Pget_npoints (hid_t space_id)
*-------------------------------------------------------------------------
*/
size_t
-H5P_get_npoints (const H5P_t *ds)
+H5P_get_npoints(const H5P_t *ds)
{
- size_t ret_value = 0;
- intn i;
-
- FUNC_ENTER(H5P_get_npoints, 0);
+ size_t ret_value = 0;
+ intn i;
- /* check args */
- assert (ds);
+ FUNC_ENTER(H5P_get_npoints, 0);
- switch (ds->type) {
- case H5P_SCALAR:
- ret_value = 1;
- break;
+ /* check args */
+ assert(ds);
- case H5P_SIMPLE:
- for (ret_value=1, i=0; i<ds->u.simple.rank; i++) {
- ret_value *= ds->u.simple.size[i];
- }
- break;
+ switch (ds->type) {
+ case H5P_SCALAR:
+ ret_value = 1;
+ break;
- case H5P_COMPLEX:
- HRETURN_ERROR (H5E_DATASPACE, H5E_UNSUPPORTED, 0,
- "complex data spaces are not supported yet");
+ case H5P_SIMPLE:
+ for (ret_value = 1, i = 0; i < ds->u.simple.rank; i++) {
+ ret_value *= ds->u.simple.size[i];
+ }
+ break;
- default:
- assert ("unknown data space class" && 0);
- HRETURN_ERROR (H5E_DATASPACE, H5E_UNSUPPORTED, 0,
- "internal error (unknown data space class)");
- }
+ case H5P_COMPLEX:
+ HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, 0,
+ "complex data spaces are not supported yet");
- FUNC_LEAVE (ret_value);
-}
+ default:
+ assert("unknown data space class" && 0);
+ HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, 0,
+ "internal error (unknown data space class)");
+ }
+ FUNC_LEAVE(ret_value);
+}
/*-------------------------------------------------------------------------
- * Function: H5Pget_ndims
+ * Function: H5Pget_ndims
*
- * Purpose: Determines the dimensionality of a data space.
+ * Purpose: Determines the dimensionality of a data space.
*
- * Return: Success: The number of dimensions in a data space.
+ * Return: Success: The number of dimensions in a data space.
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Thursday, December 11, 1997
*
* Modifications:
@@ -409,37 +395,35 @@ H5P_get_npoints (const H5P_t *ds)
*-------------------------------------------------------------------------
*/
intn
-H5Pget_ndims (hid_t space_id)
+H5Pget_ndims(hid_t space_id)
{
- H5P_t *ds = NULL;
- size_t ret_value = 0;
-
- FUNC_ENTER(H5Pget_ndims, FAIL);
- H5ECLEAR;
+ H5P_t *ds = NULL;
+ size_t ret_value = 0;
- /* check args */
- if (H5_DATASPACE!=H5Aatom_group (space_id) ||
- NULL==(ds=H5Aatom_object (space_id))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
- }
+ FUNC_ENTER(H5Pget_ndims, FAIL);
+ H5ECLEAR;
- ret_value = H5P_get_ndims (ds);
+ /* check args */
+ if (H5_DATASPACE != H5Aatom_group(space_id) ||
+ NULL == (ds = H5Aatom_object(space_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
+ }
+ ret_value = H5P_get_ndims(ds);
- FUNC_LEAVE (ret_value);
+ FUNC_LEAVE(ret_value);
}
-
/*-------------------------------------------------------------------------
- * Function: H5P_get_ndims
+ * Function: H5P_get_ndims
*
- * Purpose: Returns the number of dimensions in a data space.
+ * Purpose: Returns the number of dimensions in a data space.
*
- * Return: Success: Non-negative number of dimensions. Zero
- * implies a scalar.
+ * Return: Success: Non-negative number of dimensions. Zero
+ * implies a scalar.
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Thursday, December 11, 1997
*
* Modifications:
@@ -447,50 +431,49 @@ H5Pget_ndims (hid_t space_id)
*-------------------------------------------------------------------------
*/
intn
-H5P_get_ndims (const H5P_t *ds)
+H5P_get_ndims(const H5P_t *ds)
{
- intn ret_value = FAIL;
-
- FUNC_ENTER (H5P_get_ndims, FAIL);
+ intn ret_value = FAIL;
- /* check args */
- assert (ds);
+ FUNC_ENTER(H5P_get_ndims, FAIL);
- switch (ds->type) {
- case H5P_SCALAR:
- ret_value = 0;
- break;
+ /* check args */
+ assert(ds);
- case H5P_SIMPLE:
- ret_value = ds->u.simple.rank;
- break;
+ switch (ds->type) {
+ case H5P_SCALAR:
+ ret_value = 0;
+ break;
- case H5P_COMPLEX:
- HRETURN_ERROR (H5E_DATASPACE, H5E_UNSUPPORTED, FAIL,
- "complex data spaces are not supported yet");
+ case H5P_SIMPLE:
+ ret_value = ds->u.simple.rank;
+ break;
- default:
- assert ("unknown data space class" && 0);
- HRETURN_ERROR (H5E_DATASPACE, H5E_UNSUPPORTED, FAIL,
- "internal error (unknown data space class)");
- }
+ case H5P_COMPLEX:
+ HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL,
+ "complex data spaces are not supported yet");
- FUNC_LEAVE (ret_value);
-}
+ default:
+ assert("unknown data space class" && 0);
+ HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL,
+ "internal error (unknown data space class)");
+ }
+ FUNC_LEAVE(ret_value);
+}
/*-------------------------------------------------------------------------
- * Function: H5Pget_dims
+ * Function: H5Pget_dims
*
- * Purpose: Returns the size in each dimension of a data space DS through
- * the DIMS argument.
+ * Purpose: Returns the size in each dimension of a data space DS through
+ * the DIMS argument.
*
- * Return: Success: Number of dimensions, the same value as
- * returned by H5Pget_ndims().
+ * Return: Success: Number of dimensions, the same value as
+ * returned by H5Pget_ndims().
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Thursday, December 11, 1997
*
* Modifications:
@@ -498,42 +481,39 @@ H5P_get_ndims (const H5P_t *ds)
*-------------------------------------------------------------------------
*/
intn
-H5Pget_dims (hid_t space_id, size_t dims[]/*out*/)
+H5Pget_dims(hid_t space_id, size_t dims[] /*out */ )
{
-
- H5P_t *ds = NULL;
- size_t ret_value = 0;
-
- FUNC_ENTER(H5Pget_dims, FAIL);
- H5ECLEAR;
-
- /* check args */
- if (H5_DATASPACE!=H5Aatom_group (space_id) ||
- NULL==(ds=H5Aatom_object (space_id))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
- }
- if (!dims) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no output buffer");
- }
-
- ret_value = H5P_get_dims (ds, dims);
+ H5P_t *ds = NULL;
+ size_t ret_value = 0;
- FUNC_LEAVE (ret_value);
-}
+ FUNC_ENTER(H5Pget_dims, FAIL);
+ H5ECLEAR;
+ /* check args */
+ if (H5_DATASPACE != H5Aatom_group(space_id) ||
+ NULL == (ds = H5Aatom_object(space_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space");
+ }
+ if (!dims) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no output buffer");
+ }
+ ret_value = H5P_get_dims(ds, dims);
+
+ FUNC_LEAVE(ret_value);
+}
/*-------------------------------------------------------------------------
- * Function: H5P_get_dims
+ * Function: H5P_get_dims
*
- * Purpose: Returns the size in each dimension of a data space. This
- * function may not be meaningful for all types of data spaces.
+ * Purpose: Returns the size in each dimension of a data space. This
+ * function may not be meaningful for all types of data spaces.
*
- * Return: Success: Number of dimensions. Zero implies scalar.
+ * Return: Success: Number of dimensions. Zero implies scalar.
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Thursday, December 11, 1997
*
* Modifications:
@@ -541,54 +521,53 @@ H5Pget_dims (hid_t space_id, size_t dims[]/*out*/)
*-------------------------------------------------------------------------
*/
intn
-H5P_get_dims (const H5P_t *ds, size_t dims[])
+H5P_get_dims(const H5P_t *ds, size_t dims[])
{
- intn ret_value = FAIL;
- intn i;
-
- FUNC_ENTER (H5P_get_dims, FAIL);
-
- /* check args */
- assert (ds);
- assert (dims);
-
- switch (ds->type) {
- case H5P_SCALAR:
- ret_value = 0;
- break;
-
- case H5P_SIMPLE:
- ret_value = ds->u.simple.rank;
- for (i=0; i<ret_value; i++) {
- dims[i] = ds->u.simple.size[i];
- }
- break;
-
- case H5P_COMPLEX:
- HRETURN_ERROR (H5E_DATASPACE, H5E_UNSUPPORTED, FAIL,
- "complex data spaces are not supported yet");
-
- default:
- assert ("unknown data space class" && 0);
- HRETURN_ERROR (H5E_DATASPACE, H5E_UNSUPPORTED, FAIL,
- "internal error (unknown data space class)");
- }
-
- FUNC_LEAVE (ret_value);
-}
+ intn ret_value = FAIL;
+ intn i;
+ FUNC_ENTER(H5P_get_dims, FAIL);
+
+ /* check args */
+ assert(ds);
+ assert(dims);
+
+ switch (ds->type) {
+ case H5P_SCALAR:
+ ret_value = 0;
+ break;
+
+ case H5P_SIMPLE:
+ ret_value = ds->u.simple.rank;
+ for (i = 0; i < ret_value; i++) {
+ dims[i] = ds->u.simple.size[i];
+ }
+ break;
+
+ case H5P_COMPLEX:
+ HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL,
+ "complex data spaces are not supported yet");
+
+ default:
+ assert("unknown data space class" && 0);
+ HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL,
+ "internal error (unknown data space class)");
+ }
+
+ FUNC_LEAVE(ret_value);
+}
/*-------------------------------------------------------------------------
- * Function: H5P_modify
+ * Function: H5P_modify
*
- * Purpose: Updates a data space by writing a message to an object
- * header.
+ * Purpose: Updates a data space by writing a message to an object
+ * header.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Tuesday, December 9, 1997
*
* Modifications:
@@ -596,92 +575,89 @@ H5P_get_dims (const H5P_t *ds, size_t dims[])
*-------------------------------------------------------------------------
*/
herr_t
-H5P_modify (H5F_t *f, H5G_entry_t *ent, const H5P_t *ds)
+H5P_modify(H5F_t *f, H5G_entry_t *ent, const H5P_t *ds)
{
- FUNC_ENTER (H5O_modify, FAIL);
-
- assert (f);
- assert (ent);
- assert (ds);
-
- switch (ds->type) {
- case H5P_SCALAR:
- HRETURN_ERROR (H5E_DATASPACE, H5E_UNSUPPORTED, FAIL,
- "scalar data spaces are not implemented yet");
-
- case H5P_SIMPLE:
- if (H5O_modify (ent, H5O_SDSPACE, 0, 0, &(ds->u.simple))<0) {
- HRETURN_ERROR (H5E_DATASPACE, H5E_CANTINIT, FAIL,
- "can't update simple data space message");
- }
- break;
-
- case H5P_COMPLEX:
- HRETURN_ERROR (H5E_DATASPACE, H5E_UNSUPPORTED, FAIL,
- "complex data spaces are not implemented yet");
-
- default:
- assert ("unknown data space class" && 0);
- break;
- }
-
- FUNC_LEAVE (SUCCEED);
+ FUNC_ENTER(H5O_modify, FAIL);
+
+ assert(f);
+ assert(ent);
+ assert(ds);
+
+ switch (ds->type) {
+ case H5P_SCALAR:
+ HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL,
+ "scalar data spaces are not implemented yet");
+
+ case H5P_SIMPLE:
+ if (H5O_modify(ent, H5O_SDSPACE, 0, 0, &(ds->u.simple)) < 0) {
+ HRETURN_ERROR(H5E_DATASPACE, H5E_CANTINIT, FAIL,
+ "can't update simple data space message");
+ }
+ break;
+
+ case H5P_COMPLEX:
+ HRETURN_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL,
+ "complex data spaces are not implemented yet");
+
+ default:
+ assert("unknown data space class" && 0);
+ break;
+ }
+
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5P_read
+ * Function: H5P_read
*
- * Purpose: Reads the data space from an object header.
+ * Purpose: Reads the data space from an object header.
*
- * Return: Success: Pointer to a new data space.
+ * Return: Success: Pointer to a new data space.
*
- * Failure: NULL
+ * Failure: NULL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Tuesday, December 9, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-H5P_t *
-H5P_read (H5F_t *f, H5G_entry_t *ent)
+H5P_t *
+H5P_read(H5F_t *f, H5G_entry_t *ent)
{
- H5P_t *ds = NULL;
-
- FUNC_ENTER (H5P_read, NULL);
+ H5P_t *ds = NULL;
- /* check args */
- assert (f);
- assert (ent);
+ FUNC_ENTER(H5P_read, NULL);
- ds = H5MM_xcalloc (1, sizeof(H5P_t));
+ /* check args */
+ assert(f);
+ assert(ent);
- if (H5O_read (ent, H5O_SDSPACE, 0, &(ds->u.simple))) {
- ds->type = H5P_SIMPLE;
-
- } else {
- ds->type = H5P_SCALAR;
- }
+ ds = H5MM_xcalloc(1, sizeof(H5P_t));
- FUNC_LEAVE (ds);
-}
+ if (H5O_read(ent, H5O_SDSPACE, 0, &(ds->u.simple))) {
+ ds->type = H5P_SIMPLE;
+ } else {
+ ds->type = H5P_SCALAR;
+ }
+ FUNC_LEAVE(ds);
+}
/*-------------------------------------------------------------------------
- * Function: H5P_cmp
+ * Function: H5P_cmp
*
- * Purpose: Compares two data spaces.
+ * Purpose: Compares two data spaces.
*
- * Return: Success: 0 if DS1 and DS2 are the same.
- * <0 if DS1 is less than DS2.
- * >0 if DS1 is greater than DS2.
+ * Return: Success: 0 if DS1 and DS2 are the same.
+ * <0 if DS1 is less than DS2.
+ * >0 if DS1 is greater than DS2.
*
- * Failure: 0, never fails
+ * Failure: 0, never fails
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, December 10, 1997
*
* Modifications:
@@ -689,51 +665,58 @@ H5P_read (H5F_t *f, H5G_entry_t *ent)
*-------------------------------------------------------------------------
*/
intn
-H5P_cmp (const H5P_t *ds1, const H5P_t *ds2)
+H5P_cmp(const H5P_t *ds1, const H5P_t *ds2)
{
- intn i;
-
- FUNC_ENTER (H5P_cmp, 0);
-
- /* check args */
- assert (ds1);
- assert (ds2);
-
- /* compare */
- if (ds1->type < ds2->type) HRETURN (-1);
- if (ds1->type > ds2->type) HRETURN (1);
-
- switch (ds1->type) {
- case H5P_SIMPLE:
- if (ds1->u.simple.rank < ds2->u.simple.rank) HRETURN (-1);
- if (ds1->u.simple.rank > ds2->u.simple.rank) HRETURN (1);
-
- /* don't compare flags */
-
- for (i=0; i<ds1->u.simple.rank; i++) {
- if (ds1->u.simple.size[i] < ds2->u.simple.size[i]) HRETURN (-1);
- if (ds1->u.simple.size[i] > ds2->u.simple.size[i]) HRETURN (1);
- }
-
- /* don't compare max dimensions */
-
- for (i=0; i<ds1->u.simple.rank; i++) {
- if ((ds1->u.simple.perm?ds1->u.simple.perm[i]:i) <
- (ds2->u.simple.perm?ds2->u.simple.perm[i]:i)) HRETURN (-1);
- if ((ds1->u.simple.perm?ds2->u.simple.perm[i]:i) >
- (ds2->u.simple.perm?ds2->u.simple.perm[i]:i)) HRETURN (1);
- }
-
- break;
-
- default:
- assert ("not implemented yet" && 0);
- }
-
- FUNC_LEAVE (0);
+ intn i;
+
+ FUNC_ENTER(H5P_cmp, 0);
+
+ /* check args */
+ assert(ds1);
+ assert(ds2);
+
+ /* compare */
+ if (ds1->type < ds2->type)
+ HRETURN(-1);
+ if (ds1->type > ds2->type)
+ HRETURN(1);
+
+ switch (ds1->type) {
+ case H5P_SIMPLE:
+ if (ds1->u.simple.rank < ds2->u.simple.rank)
+ HRETURN(-1);
+ if (ds1->u.simple.rank > ds2->u.simple.rank)
+ HRETURN(1);
+
+ /* don't compare flags */
+
+ for (i = 0; i < ds1->u.simple.rank; i++) {
+ if (ds1->u.simple.size[i] < ds2->u.simple.size[i])
+ HRETURN(-1);
+ if (ds1->u.simple.size[i] > ds2->u.simple.size[i])
+ HRETURN(1);
+ }
+
+ /* don't compare max dimensions */
+
+ for (i = 0; i < ds1->u.simple.rank; i++) {
+ if ((ds1->u.simple.perm ? ds1->u.simple.perm[i] : i) <
+ (ds2->u.simple.perm ? ds2->u.simple.perm[i] : i))
+ HRETURN(-1);
+ if ((ds1->u.simple.perm ? ds2->u.simple.perm[i] : i) >
+ (ds2->u.simple.perm ? ds2->u.simple.perm[i] : i))
+ HRETURN(1);
+ }
+
+ break;
+
+ default:
+ assert("not implemented yet" && 0);
+ }
+
+ FUNC_LEAVE(0);
}
-
/*--------------------------------------------------------------------------
NAME
H5P_is_simple
@@ -749,9 +732,9 @@ H5P_cmp (const H5P_t *ds1, const H5P_t *ds2)
has orthogonal, evenly spaced dimensions.
--------------------------------------------------------------------------*/
hbool_t
-H5P_is_simple (const H5P_t *sdim)
+H5P_is_simple(const H5P_t *sdim)
{
- hbool_t ret_value = BFAIL;
+ hbool_t ret_value = BFAIL;
FUNC_ENTER(H5P_is_simple, UFAIL);
@@ -759,8 +742,7 @@ H5P_is_simple (const H5P_t *sdim)
H5ECLEAR;
assert(sdim);
- ret_value=sdim->type==H5P_SIMPLE ? BTRUE : BFALSE; /* Currently all dataspaces are simple, but check anyway */
-
+ ret_value = sdim->type == H5P_SIMPLE ? BTRUE : BFALSE; /* Currently all dataspaces are simple, but check anyway */
FUNC_LEAVE(ret_value);
}
@@ -779,29 +761,27 @@ H5P_is_simple (const H5P_t *sdim)
This function determines the if a dataspace is "simple". ie. if it
has orthogonal, evenly spaced dimensions.
--------------------------------------------------------------------------*/
-hbool_t H5Pis_simple(hid_t sid)
+hbool_t
+H5Pis_simple(hid_t sid)
{
- H5P_t *space=NULL; /* dataspace to modify */
- hbool_t ret_value = BFAIL;
+ H5P_t *space = NULL; /* dataspace to modify */
+ hbool_t ret_value = BFAIL;
FUNC_ENTER(H5Pis_simple, BFAIL);
/* Clear errors and check args and all the boring stuff. */
H5ECLEAR;
- if((space=H5Aatom_object(sid))==NULL)
+ if ((space = H5Aatom_object(sid)) == NULL)
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a data space");
- ret_value=H5P_is_simple(space);
+ ret_value = H5P_is_simple(space);
-done:
- if(ret_value == BFAIL)
- { /* Error condition cleanup */
-
- } /* end if */
+ done:
+ if (ret_value == BFAIL) { /* Error condition cleanup */
+ } /* end if */
/* Normal function cleanup */
-
FUNC_LEAVE(ret_value);
}
@@ -827,11 +807,11 @@ done:
be unlimited in size.
--------------------------------------------------------------------------*/
herr_t
-H5Pset_space (hid_t sid, intn rank, const size_t *dims)
+H5Pset_space(hid_t sid, intn rank, const size_t *dims)
{
- H5P_t *space=NULL; /* dataspace to modify */
- intn u; /* local counting variable */
- herr_t ret_value = SUCCEED;
+ H5P_t *space = NULL; /* dataspace to modify */
+ intn u; /* local counting variable */
+ herr_t ret_value = SUCCEED;
FUNC_ENTER(H5Pset_space, FAIL);
@@ -839,82 +819,76 @@ H5Pset_space (hid_t sid, intn rank, const size_t *dims)
H5ECLEAR;
/* Get the object */
- if((space=H5Aatom_object(sid))==NULL)
+ if ((space = H5Aatom_object(sid)) == NULL)
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "not a data space");
- if(rank>0 && dims==NULL)
+ if (rank > 0 && dims == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid rank");
/* shift out of the previous state to a "simple" dataspace */
- switch(space->type)
- {
- case H5P_SIMPLE:
- /* do nothing */
- break;
-
- case H5P_COMPLEX:
- /*
- * eventually this will destroy whatever "complex" dataspace info
- * is retained, right now it's an error
- */
- /* Fall through to report error */
-
- default:
- HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL,
- "unknown data space class");
- } /* end switch */
- space->type=H5P_SIMPLE;
-
- if(rank==0)
- { /* scalar variable */
- space->u.simple.rank=0; /* set to scalar rank */
- space->u.simple.dim_flags=0; /* no maximum dimensions or dimension permutations */
- if(space->u.simple.size!=NULL)
- space->u.simple.size=H5MM_xfree(space->u.simple.size);
- if(space->u.simple.max!=NULL)
- space->u.simple.max=H5MM_xfree(space->u.simple.max);
- if(space->u.simple.perm!=NULL)
- space->u.simple.max=H5MM_xfree(space->u.simple.perm);
- } /* end if */
- else
- {
+ switch (space->type) {
+ case H5P_SIMPLE:
+ /* do nothing */
+ break;
+
+ case H5P_COMPLEX:
+ /*
+ * eventually this will destroy whatever "complex" dataspace info
+ * is retained, right now it's an error
+ */
+ /* Fall through to report error */
+
+ default:
+ HGOTO_ERROR(H5E_DATASPACE, H5E_BADVALUE, FAIL,
+ "unknown data space class");
+ } /* end switch */
+ space->type = H5P_SIMPLE;
+
+ if (rank == 0) { /* scalar variable */
+ space->u.simple.rank = 0; /* set to scalar rank */
+ space->u.simple.dim_flags = 0; /* no maximum dimensions or dimension permutations */
+ if (space->u.simple.size != NULL)
+ space->u.simple.size = H5MM_xfree(space->u.simple.size);
+ if (space->u.simple.max != NULL)
+ space->u.simple.max = H5MM_xfree(space->u.simple.max);
+ if (space->u.simple.perm != NULL)
+ space->u.simple.max = H5MM_xfree(space->u.simple.perm);
+ }
+ /* end if */
+ else {
/* Reset the dataspace flags */
- space->u.simple.dim_flags=0;
+ space->u.simple.dim_flags = 0;
/* Free the old space for now */
- if(space->u.simple.size!=NULL)
- space->u.simple.size=H5MM_xfree(space->u.simple.size);
- if(space->u.simple.max!=NULL)
- space->u.simple.max=H5MM_xfree(space->u.simple.max);
- if(space->u.simple.perm!=NULL)
- space->u.simple.perm=H5MM_xfree(space->u.simple.perm);
+ if (space->u.simple.size != NULL)
+ space->u.simple.size = H5MM_xfree(space->u.simple.size);
+ if (space->u.simple.max != NULL)
+ space->u.simple.max = H5MM_xfree(space->u.simple.max);
+ if (space->u.simple.perm != NULL)
+ space->u.simple.perm = H5MM_xfree(space->u.simple.perm);
/* Set the rank and copy the dims */
- space->u.simple.rank=rank;
- space->u.simple.size = H5MM_xcalloc (rank, sizeof(size_t));
- HDmemcpy(space->u.simple.size,dims,sizeof(size_t)*rank);
+ space->u.simple.rank = rank;
+ space->u.simple.size = H5MM_xcalloc(rank, sizeof(size_t));
+ HDmemcpy(space->u.simple.size, dims, sizeof(size_t) * rank);
/* check if there are unlimited dimensions and create the maximum dims array */
- for(u=0; u<rank; u++)
- if(dims[u]==0)
- {
- if(u>0)
- HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL,
- "unlimited dimensions not in the lowest "
- "dimensionality");
- space->u.simple.max = H5MM_xcalloc (rank, sizeof(size_t));
- HDmemcpy(space->u.simple.max,dims,sizeof(size_t)*rank);
- space->u.simple.dim_flags|=H5P_VALID_MAX;
+ for (u = 0; u < rank; u++)
+ if (dims[u] == 0) {
+ if (u > 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_UNSUPPORTED, FAIL,
+ "unlimited dimensions not in the lowest "
+ "dimensionality");
+ space->u.simple.max = H5MM_xcalloc(rank, sizeof(size_t));
+ HDmemcpy(space->u.simple.max, dims, sizeof(size_t) * rank);
+ space->u.simple.dim_flags |= H5P_VALID_MAX;
break;
- } /* end if */
- } /* end else */
+ } /* end if */
+ } /* end else */
-done:
- if(ret_value == FAIL)
- { /* Error condition cleanup */
-
- } /* end if */
+ done:
+ if (ret_value == FAIL) { /* Error condition cleanup */
+ } /* end if */
/* Normal function cleanup */
-
FUNC_LEAVE(ret_value);
}
diff --git a/src/H5Pprivate.h b/src/H5Pprivate.h
index 2f530f9..3a2f804 100644
--- a/src/H5Pprivate.h
+++ b/src/H5Pprivate.h
@@ -22,39 +22,39 @@
/* Private headers needed by this file */
#include <H5private.h>
-#include <H5Gprivate.h> /*for H5G_entry_t */
+#include <H5Gprivate.h> /*for H5G_entry_t */
/* Flags to indicate special dataspace features are active */
#define H5P_VALID_MAX 0x01
#define H5P_VALID_PERM 0x02
typedef struct H5P_simple_t {
- intn rank; /*number of dimensions */
- intn dim_flags; /*dimension flags */
- size_t *size; /*dimension sizes */
- size_t *max; /*maximum dimension sizes */
- intn *perm; /*dimension permutations */
+ intn rank; /*number of dimensions */
+ intn dim_flags; /*dimension flags */
+ size_t *size; /*dimension sizes */
+ size_t *max; /*maximum dimension sizes */
+ intn *perm; /*dimension permutations */
} H5P_simple_t;
typedef struct {
- H5P_class_t type; /*type of dimensionality object */
- union {
- H5P_simple_t simple;/*simple dimensionality information */
- } u;
+ H5P_class_t type; /*type of dimensionality object */
+ union {
+ H5P_simple_t simple; /*simple dimensionality information */
+ } u;
} H5P_t;
#define H5P_RESERVED_ATOMS 2
-H5P_t *H5P_copy (const H5P_t *src);
-herr_t H5P_close (H5P_t *ds);
-size_t H5P_get_npoints (const H5P_t *ds);
-intn H5P_get_ndims (const H5P_t *ds);
-intn H5P_get_dims (const H5P_t *ds, size_t dims[]/*out*/);
-herr_t H5P_modify (H5F_t *f, H5G_entry_t *ent, const H5P_t *space);
-H5P_t *H5P_read (H5F_t *f, H5G_entry_t *ent);
-intn H5P_cmp (const H5P_t *ds1, const H5P_t *ds2);
-
-hbool_t H5P_is_simple (const H5P_t *sdim);
-uintn H5P_nelem (const H5P_t *space);
+H5P_t *H5P_copy(const H5P_t *src);
+herr_t H5P_close(H5P_t *ds);
+size_t H5P_get_npoints(const H5P_t *ds);
+intn H5P_get_ndims(const H5P_t *ds);
+intn H5P_get_dims(const H5P_t *ds, size_t dims[] /*out */ );
+herr_t H5P_modify(H5F_t *f, H5G_entry_t *ent, const H5P_t *space);
+H5P_t *H5P_read(H5F_t *f, H5G_entry_t *ent);
+intn H5P_cmp(const H5P_t *ds1, const H5P_t *ds2);
+
+hbool_t H5P_is_simple(const H5P_t *sdim);
+uintn H5P_nelem(const H5P_t *space);
#endif
diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h
index cc87ace..bbf5dc7 100644
--- a/src/H5Ppublic.h
+++ b/src/H5Ppublic.h
@@ -24,33 +24,32 @@
#include <H5Apublic.h>
/* Define atomic datatypes */
-#define H5P_ALL (-2)
+#define H5P_ALL (-2)
/* Different types of dataspaces */
typedef enum H5P_class_t {
- H5P_NO_CLASS =-1, /*error */
- H5P_SCALAR =0, /*scalar variable */
- H5P_SIMPLE =1, /*simple data space */
- H5P_COMPLEX =2 /*complex data space */
+ H5P_NO_CLASS = -1, /*error */
+ H5P_SCALAR = 0, /*scalar variable */
+ H5P_SIMPLE = 1, /*simple data space */
+ H5P_COMPLEX = 2 /*complex data space */
} H5P_class_t;
-
#ifdef __cplusplus
-extern "C" {
+extern "C" {
#endif
/* Functions in H5P.c */
-hid_t H5Pcreate (H5P_class_t type);
-herr_t H5Pclose (hid_t space_id);
-size_t H5Pget_npoints (hid_t space_id);
-intn H5Pget_ndims (hid_t space_id);
-intn H5Pget_dims (hid_t space_id, size_t dims[]);
+ hid_t H5Pcreate(H5P_class_t type);
+ herr_t H5Pclose(hid_t space_id);
+ size_t H5Pget_npoints(hid_t space_id);
+ intn H5Pget_ndims(hid_t space_id);
+ intn H5Pget_dims(hid_t space_id, size_t dims[]);
-hbool_t H5Pis_simple(hid_t space_id);
-herr_t H5Pset_space(hid_t space_id, intn rank, const size_t *dims);
+ hbool_t H5Pis_simple(hid_t space_id);
+ herr_t H5Pset_space(hid_t space_id, intn rank, const size_t *dims);
#ifdef __cplusplus
}
-#endif
#endif
+#endif
diff --git a/src/H5T.c b/src/H5T.c
index 3dd6802..c555147 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -11,65 +11,65 @@
****************************************************************************/
#ifdef RCSID
-static char RcsId[] = "@(#)$Revision$";
+static char RcsId[] = "@(#)$Revision$";
#endif
-#define H5T_PACKAGE /*suppress error about including H5Tpkg */
+#define H5T_PACKAGE /*suppress error about including H5Tpkg */
-#include <H5private.h> /*generic functions */
-#include <H5Aprivate.h> /*atom functions */
-#include <H5Eprivate.h> /*error handling */
-#include <H5Mprivate.h> /*meta data */
-#include <H5MMprivate.h> /*memory management */
-#include <H5Pprivate.h> /*data space */
-#include <H5Tpkg.h> /*data-type functions */
+#include <H5private.h> /*generic functions */
+#include <H5Aprivate.h> /*atom functions */
+#include <H5Eprivate.h> /*error handling */
+#include <H5Mprivate.h> /*meta data */
+#include <H5MMprivate.h> /*memory management */
+#include <H5Pprivate.h> /*data space */
+#include <H5Tpkg.h> /*data-type functions */
-#define PABLO_MASK H5T_mask
+#define PABLO_MASK H5T_mask
-#define H5T_COMPND_INC 64 /*typical max numb of members per struct*/
+#define H5T_COMPND_INC 64 /*typical max numb of members per struct */
/* Interface initialization */
-static intn interface_initialize_g = FALSE;
+static intn interface_initialize_g = FALSE;
#define INTERFACE_INIT H5T_init_interface
-static void H5T_term_interface (void);
+static void H5T_term_interface(void);
/* Predefined types */
-hid_t H5T_NATIVE_CHAR_g = FAIL;
-hid_t H5T_NATIVE_UCHAR_g = FAIL;
-hid_t H5T_NATIVE_SHORT_g = FAIL;
-hid_t H5T_NATIVE_USHORT_g = FAIL;
-hid_t H5T_NATIVE_INT_g = FAIL;
-hid_t H5T_NATIVE_UINT_g = FAIL;
-hid_t H5T_NATIVE_LONG_g = FAIL;
-hid_t H5T_NATIVE_LLONG_g = FAIL;
-hid_t H5T_NATIVE_ULLONG_g = FAIL;
-hid_t H5T_NATIVE_HYPER_g = FAIL;
-hid_t H5T_NATIVE_UHYPER_g = FAIL;
-hid_t H5T_NATIVE_INT8_g = FAIL;
-hid_t H5T_NATIVE_UINT8_g = FAIL;
-hid_t H5T_NATIVE_INT16_g = FAIL;
-hid_t H5T_NATIVE_UINT16_g = FAIL;
-hid_t H5T_NATIVE_INT32_g = FAIL;
-hid_t H5T_NATIVE_UINT32_g = FAIL;
-hid_t H5T_NATIVE_INT64_g = FAIL;
-hid_t H5T_NATIVE_UINT64_g = FAIL;
-hid_t H5T_NATIVE_ULONG_g = FAIL;
-hid_t H5T_NATIVE_FLOAT_g = FAIL;
-hid_t H5T_NATIVE_DOUBLE_g = FAIL;
-hid_t H5T_NATIVE_TIME_g = FAIL;
-hid_t H5T_NATIVE_STRING_g = FAIL;
-hid_t H5T_NATIVE_BITFIELD_g = FAIL;
-hid_t H5T_NATIVE_OPAQUE_g = FAIL;
+hid_t H5T_NATIVE_CHAR_g = FAIL;
+hid_t H5T_NATIVE_UCHAR_g = FAIL;
+hid_t H5T_NATIVE_SHORT_g = FAIL;
+hid_t H5T_NATIVE_USHORT_g = FAIL;
+hid_t H5T_NATIVE_INT_g = FAIL;
+hid_t H5T_NATIVE_UINT_g = FAIL;
+hid_t H5T_NATIVE_LONG_g = FAIL;
+hid_t H5T_NATIVE_LLONG_g = FAIL;
+hid_t H5T_NATIVE_ULLONG_g = FAIL;
+hid_t H5T_NATIVE_HYPER_g = FAIL;
+hid_t H5T_NATIVE_UHYPER_g = FAIL;
+hid_t H5T_NATIVE_INT8_g = FAIL;
+hid_t H5T_NATIVE_UINT8_g = FAIL;
+hid_t H5T_NATIVE_INT16_g = FAIL;
+hid_t H5T_NATIVE_UINT16_g = FAIL;
+hid_t H5T_NATIVE_INT32_g = FAIL;
+hid_t H5T_NATIVE_UINT32_g = FAIL;
+hid_t H5T_NATIVE_INT64_g = FAIL;
+hid_t H5T_NATIVE_UINT64_g = FAIL;
+hid_t H5T_NATIVE_ULONG_g = FAIL;
+hid_t H5T_NATIVE_FLOAT_g = FAIL;
+hid_t H5T_NATIVE_DOUBLE_g = FAIL;
+hid_t H5T_NATIVE_TIME_g = FAIL;
+hid_t H5T_NATIVE_STRING_g = FAIL;
+hid_t H5T_NATIVE_BITFIELD_g = FAIL;
+hid_t H5T_NATIVE_OPAQUE_g = FAIL;
/* The path database */
-static intn H5T_npath_g = 0; /*num paths defined */
-static intn H5T_apath_g = 0; /*num slots allocated */
-static H5T_path_t *H5T_path_g = NULL; /*path array */
+static intn H5T_npath_g = 0; /*num paths defined */
+static intn H5T_apath_g = 0; /*num slots allocated */
+static H5T_path_t *H5T_path_g = NULL; /*path array */
/* The soft conversion function master list */
-static intn H5T_nsoft_g = 0; /*num soft funcs defined*/
-static intn H5T_asoft_g = 0; /*num slots allocated */
-static H5T_soft_t *H5T_soft_g = NULL; /*master soft list */
+static intn H5T_nsoft_g = 0; /*num soft funcs defined */
+static intn H5T_asoft_g = 0; /*num slots allocated */
+static H5T_soft_t *H5T_soft_g = NULL; /*master soft list */
/*--------------------------------------------------------------------------
NAME
@@ -84,170 +84,163 @@ DESCRIPTION
--------------------------------------------------------------------------*/
herr_t
-H5T_init_interface (void)
+H5T_init_interface(void)
{
- H5T_t *dt = NULL;
- herr_t ret_value = SUCCEED;
-
- interface_initialize_g = TRUE;
- FUNC_ENTER (H5T_init_interface, FAIL);
-
- /* Initialize the atom group for the file IDs */
- if ((ret_value=H5Ainit_group (H5_DATATYPE, H5A_DATATYPEID_HASHSIZE,
- H5T_RESERVED_ATOMS,
- (herr_t (*)(void*))H5T_close))!=FAIL) {
- ret_value=H5_add_exit (&H5T_term_interface);
- }
-
- /*
- * Initialize pre-defined data types that depend on the architecture.
- */
- ret_value = H5T_init ();
-
- /*
- * Initialize pre-define data types that can be derived from
- * architecture-dependent types.
- */
-
- /* INT8 */
- H5T_NATIVE_INT8_g = H5Tcopy (H5T_NATIVE_INT_g);
- H5Tset_size (H5T_NATIVE_INT8_g, 1);
- H5Tset_precision (H5T_NATIVE_INT8_g, 8);
- H5Tlock (H5T_NATIVE_INT8_g);
-
- /* UINT8 */
- H5T_NATIVE_UINT8_g = H5Tcopy (H5T_NATIVE_UINT_g);
- H5Tset_size (H5T_NATIVE_UINT8_g, 1);
- H5Tset_precision (H5T_NATIVE_UINT8_g, 8);
- H5Tlock (H5T_NATIVE_UINT8_g);
-
- /* INT16 */
- H5T_NATIVE_INT16_g = H5Tcopy (H5T_NATIVE_INT_g);
- H5Tset_size (H5T_NATIVE_INT16_g, 2);
- H5Tset_precision (H5T_NATIVE_INT16_g, 16);
- H5Tlock (H5T_NATIVE_INT16_g);
-
- /* UINT16 */
- H5T_NATIVE_UINT16_g = H5Tcopy (H5T_NATIVE_UINT_g);
- H5Tset_size (H5T_NATIVE_UINT16_g, 2);
- H5Tset_precision (H5T_NATIVE_UINT16_g, 16);
- H5Tlock (H5T_NATIVE_UINT16_g);
-
- /* INT32 */
- H5T_NATIVE_INT32_g = H5Tcopy (H5T_NATIVE_INT_g);
- H5Tset_size (H5T_NATIVE_INT32_g, 4);
- H5Tset_precision (H5T_NATIVE_INT32_g, 32);
- H5Tlock (H5T_NATIVE_INT32_g);
-
- /* UINT32 */
- H5T_NATIVE_UINT32_g = H5Tcopy (H5T_NATIVE_UINT_g);
- H5Tset_size (H5T_NATIVE_UINT32_g, 4);
- H5Tset_precision (H5T_NATIVE_UINT32_g, 32);
- H5Tlock (H5T_NATIVE_UINT32_g);
-
- /* INT64 */
- H5T_NATIVE_INT64_g = H5Tcopy (H5T_NATIVE_INT_g);
- H5Tset_size (H5T_NATIVE_INT64_g, 8);
- H5Tset_precision (H5T_NATIVE_INT64_g, 64);
- H5Tlock (H5T_NATIVE_INT64_g);
-
- /* UINT64 */
- H5T_NATIVE_UINT64_g = H5Tcopy (H5T_NATIVE_UINT_g);
- H5Tset_size (H5T_NATIVE_UINT64_g, 8);
- H5Tset_precision (H5T_NATIVE_UINT64_g, 64);
- H5Tlock (H5T_NATIVE_UINT64_g);
-
-
- /*
- * Initialize pre-defined data types that don't depend on architecture.
- */
-
- /* TIME */
- dt = H5MM_xcalloc (1, sizeof(H5T_t));
- dt->locked = TRUE;
- dt->type = H5T_TIME;
- dt->size = 1;
- dt->u.atomic.order = H5Tget_order (H5T_NATIVE_INT_g);
- dt->u.atomic.offset = 0;
- dt->u.atomic.prec = 8*dt->size;
- dt->u.atomic.lsb_pad = H5T_PAD_ZERO;
- dt->u.atomic.msb_pad = H5T_PAD_ZERO;
- if ((H5T_NATIVE_TIME_g = H5Aregister_atom (H5_DATATYPE, dt))<0) {
- HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "can't initialize H5T layer");
- }
-
- /* STRING */
- dt = H5MM_xcalloc (1, sizeof(H5T_t));
- dt->locked = TRUE;
- dt->type = H5T_STRING;
- dt->size = 1;
- dt->u.atomic.order = H5T_ORDER_NONE;
- dt->u.atomic.offset = 0;
- dt->u.atomic.prec = 8*dt->size;
- dt->u.atomic.lsb_pad = H5T_PAD_ZERO;
- dt->u.atomic.msb_pad = H5T_PAD_ZERO;
- dt->u.atomic.u.s.cset = H5T_CSET_ASCII;
- dt->u.atomic.u.s.pad = H5T_STR_NULL;
- if ((H5T_NATIVE_STRING_g = H5Aregister_atom (H5_DATATYPE, dt))<0) {
- HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "can't initialize H5T layer");
- }
-
- /* BITFIELD */
- dt = H5MM_xcalloc (1, sizeof(H5T_t));
- dt->locked = TRUE;
- dt->type = H5T_BITFIELD;
- dt->size = 1;
- dt->u.atomic.order = H5Tget_order (H5T_NATIVE_INT_g);
- dt->u.atomic.offset = 0;
- dt->u.atomic.prec = 8*dt->size;
- dt->u.atomic.lsb_pad = H5T_PAD_ZERO;
- dt->u.atomic.msb_pad = H5T_PAD_ZERO;
- if ((H5T_NATIVE_BITFIELD_g = H5Aregister_atom (H5_DATATYPE, dt))<0) {
- HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "unable to initialize H5T layer");
- }
-
- /* OPAQUE */
- dt = H5MM_xcalloc (1, sizeof(H5T_t));
- dt->locked = TRUE;
- dt->type = H5T_OPAQUE;
- dt->size = 1;
- dt->u.atomic.order = H5T_ORDER_NONE;
- dt->u.atomic.offset = 0;
- dt->u.atomic.prec = 8*dt->size;
- dt->u.atomic.lsb_pad = H5T_PAD_ZERO;
- dt->u.atomic.msb_pad = H5T_PAD_ZERO;
- if ((H5T_NATIVE_OPAQUE_g = H5Aregister_atom (H5_DATATYPE, dt))<0) {
- HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "unable to initialize H5T layer");
- }
-
- /*
- * Define aliases.
- */
- H5T_NATIVE_HYPER_g = H5Tcopy (H5T_NATIVE_LLONG_g);
- H5Tlock (H5T_NATIVE_HYPER_g);
-
- H5T_NATIVE_UHYPER_g = H5Tcopy (H5T_NATIVE_ULLONG_g);
- H5Tlock (H5T_NATIVE_UHYPER_g);
-
- /*
- * Register conversion functions beginning with the most general and
- * ending with the most specific.
- */
-
- if (H5Tregister_soft (H5T_INTEGER, H5T_INTEGER, H5T_conv_order)<0) {
- HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "unable to register conversion function");
- }
- if (H5Tregister_soft (H5T_FLOAT, H5T_FLOAT, H5T_conv_order)<0) {
- HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "unable to register conversion function");
- }
-
- FUNC_LEAVE (ret_value);
+ H5T_t *dt = NULL;
+ herr_t ret_value = SUCCEED;
+
+ interface_initialize_g = TRUE;
+ FUNC_ENTER(H5T_init_interface, FAIL);
+
+ /* Initialize the atom group for the file IDs */
+ if ((ret_value = H5Ainit_group(H5_DATATYPE, H5A_DATATYPEID_HASHSIZE,
+ H5T_RESERVED_ATOMS,
+ (herr_t (*)(void *)) H5T_close)) != FAIL) {
+ ret_value = H5_add_exit(&H5T_term_interface);
+ }
+ /*
+ * Initialize pre-defined data types that depend on the architecture.
+ */
+ ret_value = H5T_init();
+
+ /*
+ * Initialize pre-define data types that can be derived from
+ * architecture-dependent types.
+ */
+
+ /* INT8 */
+ H5T_NATIVE_INT8_g = H5Tcopy(H5T_NATIVE_INT_g);
+ H5Tset_size(H5T_NATIVE_INT8_g, 1);
+ H5Tset_precision(H5T_NATIVE_INT8_g, 8);
+ H5Tlock(H5T_NATIVE_INT8_g);
+
+ /* UINT8 */
+ H5T_NATIVE_UINT8_g = H5Tcopy(H5T_NATIVE_UINT_g);
+ H5Tset_size(H5T_NATIVE_UINT8_g, 1);
+ H5Tset_precision(H5T_NATIVE_UINT8_g, 8);
+ H5Tlock(H5T_NATIVE_UINT8_g);
+
+ /* INT16 */
+ H5T_NATIVE_INT16_g = H5Tcopy(H5T_NATIVE_INT_g);
+ H5Tset_size(H5T_NATIVE_INT16_g, 2);
+ H5Tset_precision(H5T_NATIVE_INT16_g, 16);
+ H5Tlock(H5T_NATIVE_INT16_g);
+
+ /* UINT16 */
+ H5T_NATIVE_UINT16_g = H5Tcopy(H5T_NATIVE_UINT_g);
+ H5Tset_size(H5T_NATIVE_UINT16_g, 2);
+ H5Tset_precision(H5T_NATIVE_UINT16_g, 16);
+ H5Tlock(H5T_NATIVE_UINT16_g);
+
+ /* INT32 */
+ H5T_NATIVE_INT32_g = H5Tcopy(H5T_NATIVE_INT_g);
+ H5Tset_size(H5T_NATIVE_INT32_g, 4);
+ H5Tset_precision(H5T_NATIVE_INT32_g, 32);
+ H5Tlock(H5T_NATIVE_INT32_g);
+
+ /* UINT32 */
+ H5T_NATIVE_UINT32_g = H5Tcopy(H5T_NATIVE_UINT_g);
+ H5Tset_size(H5T_NATIVE_UINT32_g, 4);
+ H5Tset_precision(H5T_NATIVE_UINT32_g, 32);
+ H5Tlock(H5T_NATIVE_UINT32_g);
+
+ /* INT64 */
+ H5T_NATIVE_INT64_g = H5Tcopy(H5T_NATIVE_INT_g);
+ H5Tset_size(H5T_NATIVE_INT64_g, 8);
+ H5Tset_precision(H5T_NATIVE_INT64_g, 64);
+ H5Tlock(H5T_NATIVE_INT64_g);
+
+ /* UINT64 */
+ H5T_NATIVE_UINT64_g = H5Tcopy(H5T_NATIVE_UINT_g);
+ H5Tset_size(H5T_NATIVE_UINT64_g, 8);
+ H5Tset_precision(H5T_NATIVE_UINT64_g, 64);
+ H5Tlock(H5T_NATIVE_UINT64_g);
+
+ /*
+ * Initialize pre-defined data types that don't depend on architecture.
+ */
+
+ /* TIME */
+ dt = H5MM_xcalloc(1, sizeof(H5T_t));
+ dt->locked = TRUE;
+ dt->type = H5T_TIME;
+ dt->size = 1;
+ dt->u.atomic.order = H5Tget_order(H5T_NATIVE_INT_g);
+ dt->u.atomic.offset = 0;
+ dt->u.atomic.prec = 8 * dt->size;
+ dt->u.atomic.lsb_pad = H5T_PAD_ZERO;
+ dt->u.atomic.msb_pad = H5T_PAD_ZERO;
+ if ((H5T_NATIVE_TIME_g = H5Aregister_atom(H5_DATATYPE, dt)) < 0) {
+ HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
+ "can't initialize H5T layer");
+ }
+ /* STRING */
+ dt = H5MM_xcalloc(1, sizeof(H5T_t));
+ dt->locked = TRUE;
+ dt->type = H5T_STRING;
+ dt->size = 1;
+ dt->u.atomic.order = H5T_ORDER_NONE;
+ dt->u.atomic.offset = 0;
+ dt->u.atomic.prec = 8 * dt->size;
+ dt->u.atomic.lsb_pad = H5T_PAD_ZERO;
+ dt->u.atomic.msb_pad = H5T_PAD_ZERO;
+ dt->u.atomic.u.s.cset = H5T_CSET_ASCII;
+ dt->u.atomic.u.s.pad = H5T_STR_NULL;
+ if ((H5T_NATIVE_STRING_g = H5Aregister_atom(H5_DATATYPE, dt)) < 0) {
+ HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
+ "can't initialize H5T layer");
+ }
+ /* BITFIELD */
+ dt = H5MM_xcalloc(1, sizeof(H5T_t));
+ dt->locked = TRUE;
+ dt->type = H5T_BITFIELD;
+ dt->size = 1;
+ dt->u.atomic.order = H5Tget_order(H5T_NATIVE_INT_g);
+ dt->u.atomic.offset = 0;
+ dt->u.atomic.prec = 8 * dt->size;
+ dt->u.atomic.lsb_pad = H5T_PAD_ZERO;
+ dt->u.atomic.msb_pad = H5T_PAD_ZERO;
+ if ((H5T_NATIVE_BITFIELD_g = H5Aregister_atom(H5_DATATYPE, dt)) < 0) {
+ HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
+ "unable to initialize H5T layer");
+ }
+ /* OPAQUE */
+ dt = H5MM_xcalloc(1, sizeof(H5T_t));
+ dt->locked = TRUE;
+ dt->type = H5T_OPAQUE;
+ dt->size = 1;
+ dt->u.atomic.order = H5T_ORDER_NONE;
+ dt->u.atomic.offset = 0;
+ dt->u.atomic.prec = 8 * dt->size;
+ dt->u.atomic.lsb_pad = H5T_PAD_ZERO;
+ dt->u.atomic.msb_pad = H5T_PAD_ZERO;
+ if ((H5T_NATIVE_OPAQUE_g = H5Aregister_atom(H5_DATATYPE, dt)) < 0) {
+ HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
+ "unable to initialize H5T layer");
+ }
+ /*
+ * Define aliases.
+ */
+ H5T_NATIVE_HYPER_g = H5Tcopy(H5T_NATIVE_LLONG_g);
+ H5Tlock(H5T_NATIVE_HYPER_g);
+
+ H5T_NATIVE_UHYPER_g = H5Tcopy(H5T_NATIVE_ULLONG_g);
+ H5Tlock(H5T_NATIVE_UHYPER_g);
+
+ /*
+ * Register conversion functions beginning with the most general and
+ * ending with the most specific.
+ */
+
+ if (H5Tregister_soft(H5T_INTEGER, H5T_INTEGER, H5T_conv_order) < 0) {
+ HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
+ "unable to register conversion function");
+ }
+ if (H5Tregister_soft(H5T_FLOAT, H5T_FLOAT, H5T_conv_order) < 0) {
+ HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
+ "unable to register conversion function");
+ }
+ FUNC_LEAVE(ret_value);
}
/*--------------------------------------------------------------------------
@@ -268,28 +261,27 @@ H5T_init_interface (void)
REVISION LOG
--------------------------------------------------------------------------*/
static void
-H5T_term_interface (void)
+H5T_term_interface(void)
{
- H5Adestroy_group (H5_DATATYPE);
+ H5Adestroy_group(H5_DATATYPE);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Tcreate
+ * Function: H5Tcreate
*
- * Purpose: Create a new type and initialize it to reasonable values.
- * The type is a member of type class TYPE and is SIZE bytes.
+ * Purpose: Create a new type and initialize it to reasonable values.
+ * The type is a member of type class TYPE and is SIZE bytes.
*
- * Return: Success: A new type identifier.
+ * Return: Success: A new type identifier.
*
- * Failure: FAIL
+ * Failure: FAIL
*
* Errors:
- * ARGS BADVALUE Invalid size.
- * DATATYPE CANTINIT Can't create type.
- * DATATYPE CANTREGISTER Can't register data type atom.
+ * ARGS BADVALUE Invalid size.
+ * DATATYPE CANTINIT Can't create type.
+ * DATATYPE CANTREGISTER Can't register data type atom.
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, December 5, 1997
*
* Modifications:
@@ -297,45 +289,41 @@ H5T_term_interface (void)
*-------------------------------------------------------------------------
*/
hid_t
-H5Tcreate (H5T_class_t type, size_t size)
+H5Tcreate(H5T_class_t type, size_t size)
{
- H5T_t *dt = NULL;
- hid_t ret_value = FAIL;
-
- FUNC_ENTER (H5Tcreate, FAIL);
-
- /* check args */
- if (size<=0) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid size");
- }
-
- /* create the type */
- if (NULL==(dt=H5T_create (type, size))) {
- HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't create type");
- }
-
- /* Make it an atom */
- if ((ret_value=H5Aregister_atom (H5_DATATYPE, dt))<0) {
- HRETURN_ERROR (H5E_DATATYPE, H5E_CANTREGISTER, FAIL,
- "can't register data type atom");
- }
-
- FUNC_LEAVE (ret_value);
+ H5T_t *dt = NULL;
+ hid_t ret_value = FAIL;
+
+ FUNC_ENTER(H5Tcreate, FAIL);
+
+ /* check args */
+ if (size <= 0) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid size");
+ }
+ /* create the type */
+ if (NULL == (dt = H5T_create(type, size))) {
+ HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't create type");
+ }
+ /* Make it an atom */
+ if ((ret_value = H5Aregister_atom(H5_DATATYPE, dt)) < 0) {
+ HRETURN_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL,
+ "can't register data type atom");
+ }
+ FUNC_LEAVE(ret_value);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Tcopy
+ * Function: H5Tcopy
*
- * Purpose: Copies a data type. The resulting data type is not locked.
- * The data type should be closed when no longer needed by
- * calling H5Tclose().
+ * Purpose: Copies a data type. The resulting data type is not locked.
+ * The data type should be closed when no longer needed by
+ * calling H5Tclose().
*
- * Return: Success: The ID of a new data type.
+ * Return: Success: The ID of a new data type.
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Tuesday, December 9, 1997
*
* Modifications:
@@ -343,47 +331,43 @@ H5Tcreate (H5T_class_t type, size_t size)
*-------------------------------------------------------------------------
*/
hid_t
-H5Tcopy (hid_t type_id)
+H5Tcopy(hid_t type_id)
{
- H5T_t *dt = NULL;
- H5T_t *new_dt = NULL;
- hid_t ret_value = FAIL;
-
- FUNC_ENTER (H5Tcopy, FAIL);
- H5ECLEAR;
-
- /* check args */
- if (H5_DATATYPE!=H5Aatom_group (type_id) ||
- NULL==(dt=H5Aatom_object (type_id))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
- }
-
- /* copy */
- if (NULL==(new_dt = H5T_copy (dt))) {
- HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't copy");
- }
-
- /* atomize result */
- if ((ret_value=H5Aregister_atom (H5_DATATYPE, new_dt))<0) {
- H5T_close (new_dt);
- HRETURN_ERROR (H5E_DATATYPE, H5E_CANTREGISTER, FAIL,
- "can't register data type atom");
- }
-
- FUNC_LEAVE (ret_value);
+ H5T_t *dt = NULL;
+ H5T_t *new_dt = NULL;
+ hid_t ret_value = FAIL;
+
+ FUNC_ENTER(H5Tcopy, FAIL);
+ H5ECLEAR;
+
+ /* check args */
+ if (H5_DATATYPE != H5Aatom_group(type_id) ||
+ NULL == (dt = H5Aatom_object(type_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ }
+ /* copy */
+ if (NULL == (new_dt = H5T_copy(dt))) {
+ HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't copy");
+ }
+ /* atomize result */
+ if ((ret_value = H5Aregister_atom(H5_DATATYPE, new_dt)) < 0) {
+ H5T_close(new_dt);
+ HRETURN_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL,
+ "can't register data type atom");
+ }
+ FUNC_LEAVE(ret_value);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Tclose
+ * Function: H5Tclose
*
- * Purpose: Frees a data type and all associated memory.
+ * Purpose: Frees a data type and all associated memory.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Tuesday, December 9, 1997
*
* Modifications:
@@ -391,43 +375,40 @@ H5Tcopy (hid_t type_id)
*-------------------------------------------------------------------------
*/
herr_t
-H5Tclose (hid_t type_id)
+H5Tclose(hid_t type_id)
{
- H5T_t *dt = NULL;
-
- FUNC_ENTER (H5Tclose, FAIL);
- H5ECLEAR;
-
- /* check args */
- if (H5_DATATYPE!=H5Aatom_group (type_id) ||
- NULL==(dt=H5Aatom_object (type_id))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
- }
- if (dt->locked) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "predefined data type");
- }
-
- /* When the reference count reaches zero the resources are freed */
- if (H5A_dec_ref (type_id)<0) {
- HRETURN_ERROR (H5E_ATOM, H5E_BADATOM, FAIL, "problem freeing id");
- }
-
- FUNC_LEAVE (SUCCEED);
+ H5T_t *dt = NULL;
+
+ FUNC_ENTER(H5Tclose, FAIL);
+ H5ECLEAR;
+
+ /* check args */
+ if (H5_DATATYPE != H5Aatom_group(type_id) ||
+ NULL == (dt = H5Aatom_object(type_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ }
+ if (dt->locked) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "predefined data type");
+ }
+ /* When the reference count reaches zero the resources are freed */
+ if (H5A_dec_ref(type_id) < 0) {
+ HRETURN_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "problem freeing id");
+ }
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Tequal
+ * Function: H5Tequal
*
- * Purpose: Determines if two data types are equal.
+ * Purpose: Determines if two data types are equal.
*
- * Return: Success: TRUE if equal, FALSE if unequal
+ * Return: Success: TRUE if equal, FALSE if unequal
*
- * Failure: FAIL
+ * Failure: FAIL
*
* Errors:
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, December 10, 1997
*
* Modifications:
@@ -435,43 +416,41 @@ H5Tclose (hid_t type_id)
*-------------------------------------------------------------------------
*/
hbool_t
-H5Tequal (hid_t type1_id, hid_t type2_id)
+H5Tequal(hid_t type1_id, hid_t type2_id)
{
- const H5T_t *dt1 = NULL;
- const H5T_t *dt2 = NULL;
- hbool_t ret_value = FAIL;
-
- FUNC_ENTER (H5Tequal, FAIL);
-
- /* check args */
- if (H5_DATATYPE!=H5Aatom_group (type1_id) ||
- NULL==(dt1=H5Aatom_object (type1_id)) ||
- H5_DATATYPE!=H5Aatom_group (type2_id) ||
- NULL==(dt2=H5Aatom_object (type2_id))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
- }
-
- ret_value = (0==H5T_cmp (dt1, dt2));
-
- FUNC_LEAVE (ret_value);
+ const H5T_t *dt1 = NULL;
+ const H5T_t *dt2 = NULL;
+ hbool_t ret_value = FAIL;
+
+ FUNC_ENTER(H5Tequal, FAIL);
+
+ /* check args */
+ if (H5_DATATYPE != H5Aatom_group(type1_id) ||
+ NULL == (dt1 = H5Aatom_object(type1_id)) ||
+ H5_DATATYPE != H5Aatom_group(type2_id) ||
+ NULL == (dt2 = H5Aatom_object(type2_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ }
+ ret_value = (0 == H5T_cmp(dt1, dt2));
+
+ FUNC_LEAVE(ret_value);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Tlock
+ * Function: H5Tlock
*
- * Purpose: Locks a type, making it read only and non-destructable. This
- * is normally done by the library for predefined data types so
- * the application doesn't inadvertently change or delete a
- * predefined type.
+ * Purpose: Locks a type, making it read only and non-destructable. This
+ * is normally done by the library for predefined data types so
+ * the application doesn't inadvertently change or delete a
+ * predefined type.
*
- * Once a data type is locked it can never be unlocked.
+ * Once a data type is locked it can never be unlocked.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, January 9, 1998
*
* Modifications:
@@ -479,34 +458,32 @@ H5Tequal (hid_t type1_id, hid_t type2_id)
*-------------------------------------------------------------------------
*/
herr_t
-H5Tlock (hid_t type_id)
+H5Tlock(hid_t type_id)
{
- H5T_t *dt = NULL;
-
- FUNC_ENTER (H5Tlock, FAIL);
+ H5T_t *dt = NULL;
- /* Check args */
- if (H5_DATATYPE!=H5Aatom_group (type_id) ||
- NULL==(dt=H5Aatom_object (type_id))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
- }
+ FUNC_ENTER(H5Tlock, FAIL);
- dt->locked = TRUE;
- FUNC_LEAVE (SUCCEED);
+ /* Check args */
+ if (H5_DATATYPE != H5Aatom_group(type_id) ||
+ NULL == (dt = H5Aatom_object(type_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ }
+ dt->locked = TRUE;
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Tget_class
+ * Function: H5Tget_class
*
- * Purpose: Returns the data type class identifier for data type TYPE_ID.
+ * Purpose: Returns the data type class identifier for data type TYPE_ID.
*
- * Return: Success: One of the non-negative data type class
- * constants.
+ * Return: Success: One of the non-negative data type class
+ * constants.
*
- * Failure: H5T_NO_CLASS (-1, same as FAIL)
+ * Failure: H5T_NO_CLASS (-1, same as FAIL)
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Monday, December 8, 1997
*
* Modifications:
@@ -514,35 +491,33 @@ H5Tlock (hid_t type_id)
*-------------------------------------------------------------------------
*/
H5T_class_t
-H5Tget_class (hid_t type_id)
+H5Tget_class(hid_t type_id)
{
- H5T_t *dt = NULL;
-
- FUNC_ENTER (H5Tget_class, H5T_NO_CLASS);
- H5ECLEAR;
+ H5T_t *dt = NULL;
- /* Check args */
- if (H5_DATATYPE!=H5Aatom_group (type_id) ||
- NULL==(dt=H5Aatom_object (type_id))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, H5T_NO_CLASS, "not a data type");
- }
+ FUNC_ENTER(H5Tget_class, H5T_NO_CLASS);
+ H5ECLEAR;
- FUNC_LEAVE (dt->type);
+ /* Check args */
+ if (H5_DATATYPE != H5Aatom_group(type_id) ||
+ NULL == (dt = H5Aatom_object(type_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_NO_CLASS, "not a data type");
+ }
+ FUNC_LEAVE(dt->type);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Tget_size
+ * Function: H5Tget_size
*
- * Purpose: Determines the total size of a data type in bytes.
+ * Purpose: Determines the total size of a data type in bytes.
*
- * Return: Success: Size of the data type in bytes. The size of
- * data type is the size of an instance of that
- * data type.
+ * Return: Success: Size of the data type in bytes. The size of
+ * data type is the size of an instance of that
+ * data type.
*
- * Failure: 0 (valid data types are never zero size)
+ * Failure: 0 (valid data types are never zero size)
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Monday, December 8, 1997
*
* Modifications:
@@ -550,49 +525,47 @@ H5Tget_class (hid_t type_id)
*-------------------------------------------------------------------------
*/
size_t
-H5Tget_size (hid_t type_id)
+H5Tget_size(hid_t type_id)
{
- H5T_t *dt = NULL;
- size_t size;
-
- FUNC_ENTER (H5Tget_size, 0);
- H5ECLEAR;
+ H5T_t *dt = NULL;
+ size_t size;
- /* Check args */
- if (H5_DATATYPE!=H5Aatom_group (type_id) ||
- NULL==(dt=H5Aatom_object (type_id))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, 0, "not a data type");
- }
+ FUNC_ENTER(H5Tget_size, 0);
+ H5ECLEAR;
- /* size */
- size = H5T_get_size (dt);
+ /* Check args */
+ if (H5_DATATYPE != H5Aatom_group(type_id) ||
+ NULL == (dt = H5Aatom_object(type_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a data type");
+ }
+ /* size */
+ size = H5T_get_size(dt);
- FUNC_LEAVE (size);
+ FUNC_LEAVE(size);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Tset_size
+ * Function: H5Tset_size
*
- * Purpose: Sets the total size in bytes for an atomic data type (this
- * operation is not permitted on compound data types). If the
- * size is decreased so that the significant bits of the data
- * type extend beyond the edge of the new size, then the
- * `offset' property is decreased toward zero. If the `offset'
- * becomes zero and the significant bits of the data type still
- * hang over the edge of the new size, then the number of
- * significant bits is decreased.
+ * Purpose: Sets the total size in bytes for an atomic data type (this
+ * operation is not permitted on compound data types). If the
+ * size is decreased so that the significant bits of the data
+ * type extend beyond the edge of the new size, then the
+ * `offset' property is decreased toward zero. If the `offset'
+ * becomes zero and the significant bits of the data type still
+ * hang over the edge of the new size, then the number of
+ * significant bits is decreased.
*
- * Adjusting the size of an H5T_STRING automatically sets the
- * precision to 8*size.
+ * Adjusting the size of an H5T_STRING automatically sets the
+ * precision to 8*size.
*
- * All data types have a positive size.
+ * All data types have a positive size.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
@@ -600,95 +573,96 @@ H5Tget_size (hid_t type_id)
*-------------------------------------------------------------------------
*/
herr_t
-H5Tset_size (hid_t type_id, size_t size)
+H5Tset_size(hid_t type_id, size_t size)
{
- H5T_t *dt = NULL;
- size_t prec, offset;
-
- FUNC_ENTER (H5Tset_size, FAIL);
- H5ECLEAR;
-
- /* Check args */
- if (H5_DATATYPE!=H5Aatom_group (type_id) ||
- NULL==(dt=H5Aatom_object (type_id)) ||
- !H5T_is_atomic (dt)) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not an atomic data type");
- }
- if (dt->locked) {
- HRETURN_ERROR (H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
- }
- if (size<=0) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "size must be positive");
- }
-
- offset = dt->u.atomic.offset;
- prec = dt->u.atomic.prec;
-
- /* Decrement the offset and precision if necessary */
- if (prec > 8*size) offset = 0;
- else if (offset + prec > 8*size) offset = 8*size - prec;
- if (prec > 8*size) prec = 8*size;
-
- /* Make sure that other values are still okay */
- switch (dt->type) {
- case H5T_INTEGER:
- case H5T_TIME:
- case H5T_BITFIELD:
- /* nothing to check */
- break;
-
- case H5T_STRING:
- prec = 8*size;
- offset = 0;
- break;
-
- case H5T_FLOAT:
- /*
- * The sign, mantissa, and exponent fields should be adjusted first
- * when decreasing the size of a floating point type.
- */
- if (dt->u.atomic.u.f.sign >= prec ||
- dt->u.atomic.u.f.epos + dt->u.atomic.u.f.esize > prec ||
- dt->u.atomic.u.f.mpos + dt->u.atomic.u.f.msize > prec) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,
- "adjust sign, mantissa, and exponent fields first");
- }
- break;
-
- case H5T_OPAQUE:
- /*
- * The significant bits of an opaque type are not allowed to change
- * implicitly.
- */
- if (prec != dt->u.atomic.prec) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,
- "unable to change precision of an opaque type");
- }
- break;
-
- default:
- assert ("not implemented yet" && 0);
- }
-
- /* Commit */
- dt->size = size;
- dt->u.atomic.offset = offset;
- dt->u.atomic.prec = prec;
-
- FUNC_LEAVE (SUCCEED);
+ H5T_t *dt = NULL;
+ size_t prec, offset;
+
+ FUNC_ENTER(H5Tset_size, FAIL);
+ H5ECLEAR;
+
+ /* Check args */
+ if (H5_DATATYPE != H5Aatom_group(type_id) ||
+ NULL == (dt = H5Aatom_object(type_id)) ||
+ !H5T_is_atomic(dt)) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an atomic data type");
+ }
+ if (dt->locked) {
+ HRETURN_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
+ }
+ if (size <= 0) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "size must be positive");
+ }
+ offset = dt->u.atomic.offset;
+ prec = dt->u.atomic.prec;
+
+ /* Decrement the offset and precision if necessary */
+ if (prec > 8 * size)
+ offset = 0;
+ else if (offset + prec > 8 * size)
+ offset = 8 * size - prec;
+ if (prec > 8 * size)
+ prec = 8 * size;
+
+ /* Make sure that other values are still okay */
+ switch (dt->type) {
+ case H5T_INTEGER:
+ case H5T_TIME:
+ case H5T_BITFIELD:
+ /* nothing to check */
+ break;
+
+ case H5T_STRING:
+ prec = 8 * size;
+ offset = 0;
+ break;
+
+ case H5T_FLOAT:
+ /*
+ * The sign, mantissa, and exponent fields should be adjusted first
+ * when decreasing the size of a floating point type.
+ */
+ if (dt->u.atomic.u.f.sign >= prec ||
+ dt->u.atomic.u.f.epos + dt->u.atomic.u.f.esize > prec ||
+ dt->u.atomic.u.f.mpos + dt->u.atomic.u.f.msize > prec) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
+ "adjust sign, mantissa, and exponent fields first");
+ }
+ break;
+
+ case H5T_OPAQUE:
+ /*
+ * The significant bits of an opaque type are not allowed to change
+ * implicitly.
+ */
+ if (prec != dt->u.atomic.prec) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
+ "unable to change precision of an opaque type");
+ }
+ break;
+
+ default:
+ assert("not implemented yet" && 0);
+ }
+
+ /* Commit */
+ dt->size = size;
+ dt->u.atomic.offset = offset;
+ dt->u.atomic.prec = prec;
+
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Tget_order
+ * Function: H5Tget_order
*
- * Purpose: Returns the byte order of an atomic data type.
+ * Purpose: Returns the byte order of an atomic data type.
*
- * Return: Success: A byte order constant
+ * Return: Success: A byte order constant
*
- * Failure: H5T_ORDER_ERROR (-1, same as FAIL)
+ * Failure: H5T_ORDER_ERROR (-1, same as FAIL)
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
@@ -696,39 +670,37 @@ H5Tset_size (hid_t type_id, size_t size)
*-------------------------------------------------------------------------
*/
H5T_order_t
-H5Tget_order (hid_t type_id)
+H5Tget_order(hid_t type_id)
{
- H5T_t *dt = NULL;
- H5T_order_t order;
-
- FUNC_ENTER (H5Tget_order, H5T_ORDER_ERROR);
- H5ECLEAR;
-
- /* Check args */
- if (H5_DATATYPE!=H5Aatom_group (type_id) ||
- NULL==(dt=H5Aatom_object (type_id)) ||
- !H5T_is_atomic (dt)) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, H5T_ORDER_ERROR,
- "not an atomic data type");
- }
-
- /* order */
- order = dt->u.atomic.order;
-
- FUNC_LEAVE (order);
+ H5T_t *dt = NULL;
+ H5T_order_t order;
+
+ FUNC_ENTER(H5Tget_order, H5T_ORDER_ERROR);
+ H5ECLEAR;
+
+ /* Check args */
+ if (H5_DATATYPE != H5Aatom_group(type_id) ||
+ NULL == (dt = H5Aatom_object(type_id)) ||
+ !H5T_is_atomic(dt)) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_ORDER_ERROR,
+ "not an atomic data type");
+ }
+ /* order */
+ order = dt->u.atomic.order;
+
+ FUNC_LEAVE(order);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Tset_order
+ * Function: H5Tset_order
*
- * Purpose: Sets the byte order for an atomic data type.
+ * Purpose: Sets the byte order for an atomic data type.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
@@ -736,46 +708,44 @@ H5Tget_order (hid_t type_id)
*-------------------------------------------------------------------------
*/
herr_t
-H5Tset_order (hid_t type_id, H5T_order_t order)
+H5Tset_order(hid_t type_id, H5T_order_t order)
{
- H5T_t *dt = NULL;
-
- FUNC_ENTER (H5Tset_order, FAIL);
- H5ECLEAR;
-
- /* Check args */
- if (H5_DATATYPE!=H5Aatom_group (type_id) ||
- NULL==(dt=H5Aatom_object (type_id)) ||
- !H5T_is_atomic (dt)) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not an atomic data type");
- }
- if (dt->locked) {
- HRETURN_ERROR (H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
- }
- if (order<0 || order>H5T_ORDER_NONE) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "illegal byte order");
- }
-
- /* order */
- dt->u.atomic.order = order;
- FUNC_LEAVE (SUCCEED);
+ H5T_t *dt = NULL;
+
+ FUNC_ENTER(H5Tset_order, FAIL);
+ H5ECLEAR;
+
+ /* Check args */
+ if (H5_DATATYPE != H5Aatom_group(type_id) ||
+ NULL == (dt = H5Aatom_object(type_id)) ||
+ !H5T_is_atomic(dt)) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an atomic data type");
+ }
+ if (dt->locked) {
+ HRETURN_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
+ }
+ if (order < 0 || order > H5T_ORDER_NONE) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal byte order");
+ }
+ /* order */
+ dt->u.atomic.order = order;
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Tget_precision
+ * Function: H5Tget_precision
*
- * Purpose: Gets the precision of an atomic data type. The precision is
- * the number of significant bits which, unless padding is
- * present, is 8 times larger than the value returned by
- * H5Tget_size().
+ * Purpose: Gets the precision of an atomic data type. The precision is
+ * the number of significant bits which, unless padding is
+ * present, is 8 times larger than the value returned by
+ * H5Tget_size().
*
- * Return: Success: Number of significant bits
+ * Return: Success: Number of significant bits
*
- * Failure: 0 (all atomic types have at least one
- * significant bit)
+ * Failure: 0 (all atomic types have at least one
+ * significant bit)
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
@@ -783,52 +753,50 @@ H5Tset_order (hid_t type_id, H5T_order_t order)
*-------------------------------------------------------------------------
*/
size_t
-H5Tget_precision (hid_t type_id)
+H5Tget_precision(hid_t type_id)
{
- H5T_t *dt = NULL;
- size_t prec;
-
- FUNC_ENTER (H5Tget_precision, 0);
- H5ECLEAR;
-
- /* Check args */
- if (H5_DATATYPE!=H5Aatom_group (type_id) ||
- NULL==(dt=H5Aatom_object (type_id)) ||
- !H5T_is_atomic (dt)) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, 0, "not an atomic data type");
- }
-
- /* precision */
- prec = dt->u.atomic.prec;
-
- FUNC_LEAVE (prec);
+ H5T_t *dt = NULL;
+ size_t prec;
+
+ FUNC_ENTER(H5Tget_precision, 0);
+ H5ECLEAR;
+
+ /* Check args */
+ if (H5_DATATYPE != H5Aatom_group(type_id) ||
+ NULL == (dt = H5Aatom_object(type_id)) ||
+ !H5T_is_atomic(dt)) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not an atomic data type");
+ }
+ /* precision */
+ prec = dt->u.atomic.prec;
+
+ FUNC_LEAVE(prec);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Tset_precision
+ * Function: H5Tset_precision
*
- * Purpose: Sets the precision of an atomic data type. The precision is
- * the number of significant bits which, unless padding is
- * present, is 8 times larger than the value returned by
- * H5Tget_size().
+ * Purpose: Sets the precision of an atomic data type. The precision is
+ * the number of significant bits which, unless padding is
+ * present, is 8 times larger than the value returned by
+ * H5Tget_size().
*
- * If the precision is increased then the offset is decreased
- * and then the size is increased to insure that significant
- * bits do not "hang over" the edge of the data type.
+ * If the precision is increased then the offset is decreased
+ * and then the size is increased to insure that significant
+ * bits do not "hang over" the edge of the data type.
*
- * Changing the precision of an H5T_STRING automatically changes
- * the size as well. The precision must be a multiple of 8.
+ * Changing the precision of an H5T_STRING automatically changes
+ * the size as well. The precision must be a multiple of 8.
*
- * When decreasing the precision of a floating point type, set
- * the locations and sizes of the sign, mantissa, and exponent
- * fields first.
+ * When decreasing the precision of a floating point type, set
+ * the locations and sizes of the sign, mantissa, and exponent
+ * fields first.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
@@ -836,105 +804,106 @@ H5Tget_precision (hid_t type_id)
*-------------------------------------------------------------------------
*/
herr_t
-H5Tset_precision (hid_t type_id, size_t prec)
+H5Tset_precision(hid_t type_id, size_t prec)
{
- H5T_t *dt = NULL;
- size_t offset, size;
-
- FUNC_ENTER (H5Tset_prec, FAIL);
- H5ECLEAR;
-
- /* Check args */
- if (H5_DATATYPE!=H5Aatom_group (type_id) ||
- NULL==(dt=H5Aatom_object (type_id)) ||
- !H5T_is_atomic (dt)) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not an atomic data type");
- }
- if (dt->locked) {
- HRETURN_ERROR (H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
- }
- if (prec<=0) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,
- "precision must be positive");
- }
-
- /* Adjust the offset and size */
- offset = dt->u.atomic.offset;
- size = dt->size;
- if (prec > 8*size) offset = 0;
- else if (offset + prec > 8*size) offset = 8*size - prec;
- if (prec > 8*size) size = (prec+7)/8;
-
- /* Check that things are still kosher */
- switch (dt->type) {
- case H5T_INTEGER:
- case H5T_TIME:
- case H5T_BITFIELD:
- case H5T_OPAQUE:
- /* nothing to check */
- break;
-
- case H5T_STRING:
- if (prec % 8) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,
- "precision for this type must be a multiple of 8");
- }
- offset = 0;
- size = prec / 8;
- break;
-
- case H5T_FLOAT:
- /*
- * The sign, mantissa, and exponent fields should be adjusted first
- * when decreasing the precision of a floating point type.
- */
- if (dt->u.atomic.u.f.sign >= prec ||
- dt->u.atomic.u.f.epos + dt->u.atomic.u.f.esize > prec ||
- dt->u.atomic.u.f.mpos + dt->u.atomic.u.f.msize > prec) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,
- "adjust sign, mantissa, and exponent fields first");
- }
- break;
-
- default:
- assert ("not implemented yet" && 0);
- }
-
- /* Commit */
- dt->size = size;
- dt->u.atomic.offset = offset;
- dt->u.atomic.prec = prec;
-
- FUNC_LEAVE (SUCCEED);
+ H5T_t *dt = NULL;
+ size_t offset, size;
+
+ FUNC_ENTER(H5Tset_prec, FAIL);
+ H5ECLEAR;
+
+ /* Check args */
+ if (H5_DATATYPE != H5Aatom_group(type_id) ||
+ NULL == (dt = H5Aatom_object(type_id)) ||
+ !H5T_is_atomic(dt)) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an atomic data type");
+ }
+ if (dt->locked) {
+ HRETURN_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
+ }
+ if (prec <= 0) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
+ "precision must be positive");
+ }
+ /* Adjust the offset and size */
+ offset = dt->u.atomic.offset;
+ size = dt->size;
+ if (prec > 8 * size)
+ offset = 0;
+ else if (offset + prec > 8 * size)
+ offset = 8 * size - prec;
+ if (prec > 8 * size)
+ size = (prec + 7) / 8;
+
+ /* Check that things are still kosher */
+ switch (dt->type) {
+ case H5T_INTEGER:
+ case H5T_TIME:
+ case H5T_BITFIELD:
+ case H5T_OPAQUE:
+ /* nothing to check */
+ break;
+
+ case H5T_STRING:
+ if (prec % 8) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
+ "precision for this type must be a multiple of 8");
+ }
+ offset = 0;
+ size = prec / 8;
+ break;
+
+ case H5T_FLOAT:
+ /*
+ * The sign, mantissa, and exponent fields should be adjusted first
+ * when decreasing the precision of a floating point type.
+ */
+ if (dt->u.atomic.u.f.sign >= prec ||
+ dt->u.atomic.u.f.epos + dt->u.atomic.u.f.esize > prec ||
+ dt->u.atomic.u.f.mpos + dt->u.atomic.u.f.msize > prec) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
+ "adjust sign, mantissa, and exponent fields first");
+ }
+ break;
+
+ default:
+ assert("not implemented yet" && 0);
+ }
+
+ /* Commit */
+ dt->size = size;
+ dt->u.atomic.offset = offset;
+ dt->u.atomic.prec = prec;
+
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Tget_offset
+ * Function: H5Tget_offset
*
- * Purpose: Retrieves the bit offset of the first significant bit. The
- * signficant bits of an atomic datum can be offset from the
- * beginning of the memory for that datum by an amount of
- * padding. The `offset' property specifies the number of bits
- * of padding that appear to the "right of" the value. That is,
- * if we have a 32-bit datum with 16-bits of precision having
- * the value 0x1122 then it will be layed out in memory as (from
- * small byte address toward larger byte addresses):
+ * Purpose: Retrieves the bit offset of the first significant bit. The
+ * signficant bits of an atomic datum can be offset from the
+ * beginning of the memory for that datum by an amount of
+ * padding. The `offset' property specifies the number of bits
+ * of padding that appear to the "right of" the value. That is,
+ * if we have a 32-bit datum with 16-bits of precision having
+ * the value 0x1122 then it will be layed out in memory as (from
+ * small byte address toward larger byte addresses):
*
- * Big Big Little Little
- * Endian Endian Endian Endian
- * offset=0 offset=16 offset=0 offset=16
+ * Big Big Little Little
+ * Endian Endian Endian Endian
+ * offset=0 offset=16 offset=0 offset=16
*
- * 0: [ pad] [0x11] [0x22] [ pad]
- * 1: [ pad] [0x22] [0x11] [ pad]
- * 2: [0x11] [ pad] [ pad] [0x22]
- * 3: [0x22] [ pad] [ pad] [0x11]
+ * 0: [ pad] [0x11] [0x22] [ pad]
+ * 1: [ pad] [0x22] [0x11] [ pad]
+ * 2: [0x11] [ pad] [ pad] [0x22]
+ * 3: [0x22] [ pad] [ pad] [0x11]
*
- * Return: Success: The offset
+ * Return: Success: The offset
*
- * Failure: 0
+ * Failure: 0
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
@@ -942,61 +911,59 @@ H5Tset_precision (hid_t type_id, size_t prec)
*-------------------------------------------------------------------------
*/
size_t
-H5Tget_offset (hid_t type_id)
+H5Tget_offset(hid_t type_id)
{
- H5T_t *dt = NULL;
- size_t offset;
-
- FUNC_ENTER (H5Tget_offset, 0);
- H5ECLEAR;
-
- /* Check args */
- if (H5_DATATYPE!=H5Aatom_group (type_id) ||
- NULL==(dt=H5Aatom_object (type_id)) ||
- !H5T_is_atomic (dt)) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, 0, "not an atomic data type");
- }
-
- /* offset */
- offset = dt->u.atomic.offset;
-
- FUNC_LEAVE (offset);
+ H5T_t *dt = NULL;
+ size_t offset;
+
+ FUNC_ENTER(H5Tget_offset, 0);
+ H5ECLEAR;
+
+ /* Check args */
+ if (H5_DATATYPE != H5Aatom_group(type_id) ||
+ NULL == (dt = H5Aatom_object(type_id)) ||
+ !H5T_is_atomic(dt)) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not an atomic data type");
+ }
+ /* offset */
+ offset = dt->u.atomic.offset;
+
+ FUNC_LEAVE(offset);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Tset_offset
+ * Function: H5Tset_offset
*
- * Purpose: Sets the bit offset of the first significant bit. The
- * signficant bits of an atomic datum can be offset from the
- * beginning of the memory for that datum by an amount of
- * padding. The `offset' property specifies the number of bits
- * of padding that appear to the "right of" the value. That is,
- * if we have a 32-bit datum with 16-bits of precision having
- * the value 0x1122 then it will be layed out in memory as (from
- * small byte address toward larger byte addresses):
+ * Purpose: Sets the bit offset of the first significant bit. The
+ * signficant bits of an atomic datum can be offset from the
+ * beginning of the memory for that datum by an amount of
+ * padding. The `offset' property specifies the number of bits
+ * of padding that appear to the "right of" the value. That is,
+ * if we have a 32-bit datum with 16-bits of precision having
+ * the value 0x1122 then it will be layed out in memory as (from
+ * small byte address toward larger byte addresses):
*
- * Big Big Little Little
- * Endian Endian Endian Endian
- * offset=0 offset=16 offset=0 offset=16
+ * Big Big Little Little
+ * Endian Endian Endian Endian
+ * offset=0 offset=16 offset=0 offset=16
*
- * 0: [ pad] [0x11] [0x22] [ pad]
- * 1: [ pad] [0x22] [0x11] [ pad]
- * 2: [0x11] [ pad] [ pad] [0x22]
- * 3: [0x22] [ pad] [ pad] [0x11]
+ * 0: [ pad] [0x11] [0x22] [ pad]
+ * 1: [ pad] [0x22] [0x11] [ pad]
+ * 2: [0x11] [ pad] [ pad] [0x22]
+ * 3: [0x22] [ pad] [ pad] [0x11]
*
- * If the offset is incremented then the total size is
- * incremented also if necessary to prevent significant bits of
- * the value from hanging over the edge of the data type.
+ * If the offset is incremented then the total size is
+ * incremented also if necessary to prevent significant bits of
+ * the value from hanging over the edge of the data type.
*
- * The offset of an H5T_STRING cannot be set to anything but
- * zero.
+ * The offset of an H5T_STRING cannot be set to anything but
+ * zero.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
@@ -1004,51 +971,48 @@ H5Tget_offset (hid_t type_id)
*-------------------------------------------------------------------------
*/
herr_t
-H5Tset_offset (hid_t type_id, size_t offset)
+H5Tset_offset(hid_t type_id, size_t offset)
{
- H5T_t *dt = NULL;
-
- FUNC_ENTER (H5Tset_offset, FAIL);
- H5ECLEAR;
-
- /* Check args */
- if (H5_DATATYPE!=H5Aatom_group (type_id) ||
- NULL==(dt=H5Aatom_object (type_id)) ||
- !H5T_is_atomic (dt)) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not an atomic data type");
- }
- if (dt->locked) {
- HRETURN_ERROR (H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
- }
- if (H5T_STRING==dt->type && offset!=0) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,
- "offset must be zero for this type");
- }
-
- /* Adjust the size */
- if (offset + dt->u.atomic.prec > 8*dt->size) {
- dt->size = (offset + dt->u.atomic.prec + 7) / 8;
- }
-
- /* Commit */
- dt->u.atomic.offset = offset;
-
- FUNC_LEAVE (SUCCEED);
+ H5T_t *dt = NULL;
+
+ FUNC_ENTER(H5Tset_offset, FAIL);
+ H5ECLEAR;
+
+ /* Check args */
+ if (H5_DATATYPE != H5Aatom_group(type_id) ||
+ NULL == (dt = H5Aatom_object(type_id)) ||
+ !H5T_is_atomic(dt)) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an atomic data type");
+ }
+ if (dt->locked) {
+ HRETURN_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
+ }
+ if (H5T_STRING == dt->type && offset != 0) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
+ "offset must be zero for this type");
+ }
+ /* Adjust the size */
+ if (offset + dt->u.atomic.prec > 8 * dt->size) {
+ dt->size = (offset + dt->u.atomic.prec + 7) / 8;
+ }
+ /* Commit */
+ dt->u.atomic.offset = offset;
+
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Tget_pad
+ * Function: H5Tget_pad
*
- * Purpose: Gets the least significant pad type and the most significant
- * pad type and returns their values through the LSB and MSB
- * arguments, either of which may be the null pointer.
+ * Purpose: Gets the least significant pad type and the most significant
+ * pad type and returns their values through the LSB and MSB
+ * arguments, either of which may be the null pointer.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, January 9, 1998
*
* Modifications:
@@ -1056,38 +1020,38 @@ H5Tset_offset (hid_t type_id, size_t offset)
*-------------------------------------------------------------------------
*/
herr_t
-H5Tget_pad (hid_t type_id, H5T_pad_t *lsb/*out*/, H5T_pad_t *msb/*out*/)
+H5Tget_pad(hid_t type_id, H5T_pad_t *lsb /*out */ , H5T_pad_t *msb /*out */ )
{
- H5T_t *dt = NULL;
-
- FUNC_ENTER (H5Tget_pad, FAIL);
- H5ECLEAR;
-
- /* Check args */
- if (H5_DATATYPE!=H5Aatom_group (type_id) ||
- NULL==(dt=H5Aatom_object (type_id)) ||
- !H5T_is_atomic (dt)) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not an atomic data type");
- }
-
- /* Get values */
- if (lsb) *lsb = dt->u.atomic.lsb_pad;
- if (msb) *msb = dt->u.atomic.msb_pad;
-
- FUNC_LEAVE (SUCCEED);
+ H5T_t *dt = NULL;
+
+ FUNC_ENTER(H5Tget_pad, FAIL);
+ H5ECLEAR;
+
+ /* Check args */
+ if (H5_DATATYPE != H5Aatom_group(type_id) ||
+ NULL == (dt = H5Aatom_object(type_id)) ||
+ !H5T_is_atomic(dt)) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an atomic data type");
+ }
+ /* Get values */
+ if (lsb)
+ *lsb = dt->u.atomic.lsb_pad;
+ if (msb)
+ *msb = dt->u.atomic.msb_pad;
+
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Tset_pad
+ * Function: H5Tset_pad
*
- * Purpose: Sets the LSB and MSB pad types.
+ * Purpose: Sets the LSB and MSB pad types.
*
- * Return: Success:
+ * Return: Success:
*
- * Failure:
+ * Failure:
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, January 9, 1998
*
* Modifications:
@@ -1095,43 +1059,41 @@ H5Tget_pad (hid_t type_id, H5T_pad_t *lsb/*out*/, H5T_pad_t *msb/*out*/)
*-------------------------------------------------------------------------
*/
herr_t
-H5Tset_pad (hid_t type_id, H5T_pad_t lsb, H5T_pad_t msb)
+H5Tset_pad(hid_t type_id, H5T_pad_t lsb, H5T_pad_t msb)
{
- H5T_t *dt = NULL;
-
- FUNC_ENTER (H5Tset_pad, FAIL);
- H5ECLEAR;
-
- /* Check args */
- if (H5_DATATYPE!=H5Aatom_group (type_id) ||
- NULL==(dt=H5Aatom_object (type_id)) ||
- !H5T_is_atomic (dt)) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not an atomic data type");
- }
- if (dt->locked) {
- HRETURN_ERROR (H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
- }
- if (lsb<0 || lsb>=H5T_NPAD || msb<0 || msb>=H5T_NPAD) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid pad type");
- }
-
- dt->u.atomic.lsb_pad = lsb;
- dt->u.atomic.msb_pad = msb;
-
- FUNC_LEAVE (SUCCEED);
+ H5T_t *dt = NULL;
+
+ FUNC_ENTER(H5Tset_pad, FAIL);
+ H5ECLEAR;
+
+ /* Check args */
+ if (H5_DATATYPE != H5Aatom_group(type_id) ||
+ NULL == (dt = H5Aatom_object(type_id)) ||
+ !H5T_is_atomic(dt)) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an atomic data type");
+ }
+ if (dt->locked) {
+ HRETURN_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
+ }
+ if (lsb < 0 || lsb >= H5T_NPAD || msb < 0 || msb >= H5T_NPAD) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid pad type");
+ }
+ dt->u.atomic.lsb_pad = lsb;
+ dt->u.atomic.msb_pad = msb;
+
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Tget_sign
+ * Function: H5Tget_sign
*
- * Purpose: Retrieves the sign type for an integer type.
+ * Purpose: Retrieves the sign type for an integer type.
*
- * Return: Success: The sign type.
+ * Return: Success: The sign type.
*
- * Failure: H5T_SGN_ERROR (-1, same as FAIL)
+ * Failure: H5T_SGN_ERROR (-1, same as FAIL)
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
@@ -1139,39 +1101,37 @@ H5Tset_pad (hid_t type_id, H5T_pad_t lsb, H5T_pad_t msb)
*-------------------------------------------------------------------------
*/
H5T_sign_t
-H5Tget_sign (hid_t type_id)
+H5Tget_sign(hid_t type_id)
{
- H5T_t *dt = NULL;
- H5T_sign_t sign;
-
- FUNC_ENTER (H5Tget_sign, H5T_SGN_ERROR);
- H5ECLEAR;
-
- /* Check args */
- if (H5_DATATYPE!=H5Aatom_group (type_id) ||
- NULL==(dt=H5Aatom_object (type_id)) ||
- H5T_INTEGER!=dt->type) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, H5T_SGN_ERROR,
- "not an integer data type");
- }
-
- /* sign */
- sign = dt->u.atomic.u.i.sign;
-
- FUNC_LEAVE (sign);
+ H5T_t *dt = NULL;
+ H5T_sign_t sign;
+
+ FUNC_ENTER(H5Tget_sign, H5T_SGN_ERROR);
+ H5ECLEAR;
+
+ /* Check args */
+ if (H5_DATATYPE != H5Aatom_group(type_id) ||
+ NULL == (dt = H5Aatom_object(type_id)) ||
+ H5T_INTEGER != dt->type) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_SGN_ERROR,
+ "not an integer data type");
+ }
+ /* sign */
+ sign = dt->u.atomic.u.i.sign;
+
+ FUNC_LEAVE(sign);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Tset_sign
+ * Function: H5Tset_sign
*
- * Purpose: Sets the sign property for an integer.
+ * Purpose: Sets the sign property for an integer.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
@@ -1179,48 +1139,46 @@ H5Tget_sign (hid_t type_id)
*-------------------------------------------------------------------------
*/
herr_t
-H5Tset_sign (hid_t type_id, H5T_sign_t sign)
+H5Tset_sign(hid_t type_id, H5T_sign_t sign)
{
- H5T_t *dt = NULL;
-
- FUNC_ENTER (H5Tset_sign, FAIL);
- H5ECLEAR;
-
- /* Check args */
- if (H5_DATATYPE!=H5Aatom_group (type_id) ||
- NULL==(dt=H5Aatom_object (type_id)) ||
- H5T_INTEGER!=dt->type) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not an integer data type");
- }
- if (dt->locked) {
- HRETURN_ERROR (H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
- }
- if (sign<0 || sign>=H5T_NSGN) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "illegal sign type");
- }
-
- /* sign */
- dt->u.atomic.u.i.sign = sign;
- FUNC_LEAVE (SUCCEED);
+ H5T_t *dt = NULL;
+
+ FUNC_ENTER(H5Tset_sign, FAIL);
+ H5ECLEAR;
+
+ /* Check args */
+ if (H5_DATATYPE != H5Aatom_group(type_id) ||
+ NULL == (dt = H5Aatom_object(type_id)) ||
+ H5T_INTEGER != dt->type) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an integer data type");
+ }
+ if (dt->locked) {
+ HRETURN_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
+ }
+ if (sign < 0 || sign >= H5T_NSGN) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal sign type");
+ }
+ /* sign */
+ dt->u.atomic.u.i.sign = sign;
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Tget_fields
+ * Function: H5Tget_fields
*
- * Purpose: Returns information about the locations of the various bit
- * fields of a floating point data type. The field positions
- * are bit positions in the significant region of the data type.
- * Bits are numbered with the least significant bit number zero.
+ * Purpose: Returns information about the locations of the various bit
+ * fields of a floating point data type. The field positions
+ * are bit positions in the significant region of the data type.
+ * Bits are numbered with the least significant bit number zero.
*
- * Any (or even all) of the arguments can be null pointers.
+ * Any (or even all) of the arguments can be null pointers.
*
- * Return: Success: SUCCEED, field locations and sizes are
- * returned through the arguments.
+ * Return: Success: SUCCEED, field locations and sizes are
+ * returned through the arguments.
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
@@ -1228,50 +1186,53 @@ H5Tset_sign (hid_t type_id, H5T_sign_t sign)
*-------------------------------------------------------------------------
*/
herr_t
-H5Tget_fields (hid_t type_id, size_t *spos/*out*/,
- size_t *epos/*out*/, size_t *esize/*out*/,
- size_t *mpos/*out*/, size_t *msize/*out*/)
+H5Tget_fields(hid_t type_id, size_t *spos /*out */ ,
+ size_t *epos /*out */ , size_t *esize /*out */ ,
+ size_t *mpos /*out */ , size_t *msize /*out */ )
{
- H5T_t *dt = NULL;
-
- FUNC_ENTER (H5Tget_fields, FAIL);
- H5ECLEAR;
-
- /* Check args */
- if (H5_DATATYPE!=H5Aatom_group (type_id) ||
- NULL==(dt=H5Aatom_object (type_id)) ||
- H5T_FLOAT!=dt->type) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL,
- "not a floating-point data type");
- }
-
- /* Get values */
- if (spos) *spos = dt->u.atomic.u.f.sign;
- if (epos) *epos = dt->u.atomic.u.f.epos;
- if (esize) *esize = dt->u.atomic.u.f.esize;
- if (mpos) *mpos = dt->u.atomic.u.f.mpos;
- if (msize) *msize = dt->u.atomic.u.f.msize;
-
- FUNC_LEAVE (SUCCEED);
+ H5T_t *dt = NULL;
+
+ FUNC_ENTER(H5Tget_fields, FAIL);
+ H5ECLEAR;
+
+ /* Check args */
+ if (H5_DATATYPE != H5Aatom_group(type_id) ||
+ NULL == (dt = H5Aatom_object(type_id)) ||
+ H5T_FLOAT != dt->type) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ "not a floating-point data type");
+ }
+ /* Get values */
+ if (spos)
+ *spos = dt->u.atomic.u.f.sign;
+ if (epos)
+ *epos = dt->u.atomic.u.f.epos;
+ if (esize)
+ *esize = dt->u.atomic.u.f.esize;
+ if (mpos)
+ *mpos = dt->u.atomic.u.f.mpos;
+ if (msize)
+ *msize = dt->u.atomic.u.f.msize;
+
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Tset_fields
+ * Function: H5Tset_fields
*
- * Purpose: Sets the locations and sizes of the various floating point
- * bit fields. The field positions are bit positions in the
- * significant region of the data type. Bits are numbered with
- * the least significant bit number zero.
+ * Purpose: Sets the locations and sizes of the various floating point
+ * bit fields. The field positions are bit positions in the
+ * significant region of the data type. Bits are numbered with
+ * the least significant bit number zero.
*
- * Fields are not allowed to extend beyond the number of bits of
- * precision, nor are they allowed to overlap with one another.
- *
- * Return: Success: SUCCEED
+ * Fields are not allowed to extend beyond the number of bits of
+ * precision, nor are they allowed to overlap with one another.
+ *
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
@@ -1279,73 +1240,70 @@ H5Tget_fields (hid_t type_id, size_t *spos/*out*/,
*-------------------------------------------------------------------------
*/
herr_t
-H5Tset_fields (hid_t type_id, size_t spos, size_t epos, size_t esize,
- size_t mpos, size_t msize)
+H5Tset_fields(hid_t type_id, size_t spos, size_t epos, size_t esize,
+ size_t mpos, size_t msize)
{
- H5T_t *dt = NULL;
-
- FUNC_ENTER (H5Tset_fields, FAIL);
- H5ECLEAR;
-
- /* Check args */
- if (H5_DATATYPE!=H5Aatom_group (type_id) ||
- NULL==(dt=H5Aatom_object (type_id)) ||
- H5T_FLOAT!=dt->type) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL,
- "not a floating-point data type");
- }
- if (dt->locked) {
- HRETURN_ERROR (H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
- }
- if (epos<0 || epos+esize>dt->u.atomic.prec) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,
- "exponent bit field size/location is invalid");
- }
- if (mpos<0 || mpos+msize>dt->u.atomic.prec) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,
- "mantissa bit field size/location is invalid");
- }
- if (spos<0 || spos>=dt->u.atomic.prec) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,
- "sign location is not valid");
- }
-
- /* Check for overlap */
- if (spos>=epos && spos<epos+esize) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,
- "sign bit appears within exponent field");
- }
- if (spos>=mpos && spos<mpos+msize) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,
- "sign bit appears within mantissa field");
- }
- if ((mpos<epos && mpos+msize>epos) ||
- (epos<mpos && epos+esize>mpos)) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,
- "exponent and mantissa fields overlap");
- }
-
- /* Commit */
- dt->u.atomic.u.f.sign = spos;
- dt->u.atomic.u.f.epos = epos;
- dt->u.atomic.u.f.mpos = mpos;
- dt->u.atomic.u.f.esize = esize;
- dt->u.atomic.u.f.msize = msize;
-
- FUNC_LEAVE (SUCCEED);
+ H5T_t *dt = NULL;
+
+ FUNC_ENTER(H5Tset_fields, FAIL);
+ H5ECLEAR;
+
+ /* Check args */
+ if (H5_DATATYPE != H5Aatom_group(type_id) ||
+ NULL == (dt = H5Aatom_object(type_id)) ||
+ H5T_FLOAT != dt->type) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ "not a floating-point data type");
+ }
+ if (dt->locked) {
+ HRETURN_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
+ }
+ if (epos < 0 || epos + esize > dt->u.atomic.prec) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
+ "exponent bit field size/location is invalid");
+ }
+ if (mpos < 0 || mpos + msize > dt->u.atomic.prec) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
+ "mantissa bit field size/location is invalid");
+ }
+ if (spos < 0 || spos >= dt->u.atomic.prec) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
+ "sign location is not valid");
+ }
+ /* Check for overlap */
+ if (spos >= epos && spos < epos + esize) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
+ "sign bit appears within exponent field");
+ }
+ if (spos >= mpos && spos < mpos + msize) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
+ "sign bit appears within mantissa field");
+ }
+ if ((mpos < epos && mpos + msize > epos) ||
+ (epos < mpos && epos + esize > mpos)) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
+ "exponent and mantissa fields overlap");
+ }
+ /* Commit */
+ dt->u.atomic.u.f.sign = spos;
+ dt->u.atomic.u.f.epos = epos;
+ dt->u.atomic.u.f.mpos = mpos;
+ dt->u.atomic.u.f.esize = esize;
+ dt->u.atomic.u.f.msize = msize;
+
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Tget_ebias
+ * Function: H5Tget_ebias
*
- * Purpose: Retrieves the exponent bias of a floating-point type.
+ * Purpose: Retrieves the exponent bias of a floating-point type.
*
- * Return: Success: The bias
+ * Return: Success: The bias
*
- * Failure: 0
+ * Failure: 0
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
@@ -1353,39 +1311,37 @@ H5Tset_fields (hid_t type_id, size_t spos, size_t epos, size_t esize,
*-------------------------------------------------------------------------
*/
size_t
-H5Tget_ebias (hid_t type_id)
+H5Tget_ebias(hid_t type_id)
{
- H5T_t *dt = NULL;
- size_t ebias;
-
- FUNC_ENTER (H5Tget_ebias, 0);
- H5ECLEAR;
-
- /* Check args */
- if (H5_DATATYPE!=H5Aatom_group (type_id) ||
- NULL==(dt=H5Aatom_object (type_id)) ||
- H5T_FLOAT!=dt->type) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, 0,
- "not a floating-point data type");
- }
-
- /* bias */
- ebias = dt->u.atomic.u.f.ebias;
-
- FUNC_LEAVE (ebias);
+ H5T_t *dt = NULL;
+ size_t ebias;
+
+ FUNC_ENTER(H5Tget_ebias, 0);
+ H5ECLEAR;
+
+ /* Check args */
+ if (H5_DATATYPE != H5Aatom_group(type_id) ||
+ NULL == (dt = H5Aatom_object(type_id)) ||
+ H5T_FLOAT != dt->type) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, 0,
+ "not a floating-point data type");
+ }
+ /* bias */
+ ebias = dt->u.atomic.u.f.ebias;
+
+ FUNC_LEAVE(ebias);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Tset_ebias
+ * Function: H5Tset_ebias
*
- * Purpose: Sets the exponent bias of a floating-point type.
+ * Purpose: Sets the exponent bias of a floating-point type.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
@@ -1393,41 +1349,39 @@ H5Tget_ebias (hid_t type_id)
*-------------------------------------------------------------------------
*/
herr_t
-H5Tset_ebias (hid_t type_id, size_t ebias)
+H5Tset_ebias(hid_t type_id, size_t ebias)
{
- H5T_t *dt = NULL;
-
- FUNC_ENTER (H5Tset_ebias, FAIL);
- H5ECLEAR;
-
- /* Check args */
- if (H5_DATATYPE!=H5Aatom_group (type_id) ||
- NULL==(dt=H5Aatom_object (type_id)) ||
- H5T_FLOAT!=dt->type) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL,
- "not a floating-point data type");
- }
- if (dt->locked) {
- HRETURN_ERROR (H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
- }
-
- dt->u.atomic.u.f.ebias = ebias;
-
- FUNC_LEAVE (SUCCEED);
+ H5T_t *dt = NULL;
+
+ FUNC_ENTER(H5Tset_ebias, FAIL);
+ H5ECLEAR;
+
+ /* Check args */
+ if (H5_DATATYPE != H5Aatom_group(type_id) ||
+ NULL == (dt = H5Aatom_object(type_id)) ||
+ H5T_FLOAT != dt->type) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ "not a floating-point data type");
+ }
+ if (dt->locked) {
+ HRETURN_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
+ }
+ dt->u.atomic.u.f.ebias = ebias;
+
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Tget_norm
+ * Function: H5Tget_norm
*
- * Purpose: Returns the mantisssa normalization of a floating-point data
- * type.
+ * Purpose: Returns the mantisssa normalization of a floating-point data
+ * type.
*
- * Return: Success: Normalization ID
+ * Return: Success: Normalization ID
*
- * Failure: H5T_NORM_ERROR (-1, same as FAIL)
+ * Failure: H5T_NORM_ERROR (-1, same as FAIL)
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
@@ -1435,40 +1389,38 @@ H5Tset_ebias (hid_t type_id, size_t ebias)
*-------------------------------------------------------------------------
*/
H5T_norm_t
-H5Tget_norm (hid_t type_id)
+H5Tget_norm(hid_t type_id)
{
- H5T_t *dt = NULL;
- H5T_norm_t norm;
-
- FUNC_ENTER (H5Tget_norm, H5T_NORM_ERROR);
- H5ECLEAR;
-
- /* Check args */
- if (H5_DATATYPE!=H5Aatom_group (type_id) ||
- NULL==(dt=H5Aatom_object (type_id)) ||
- H5T_FLOAT!=dt->type) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, H5T_NORM_ERROR,
- "not a floating-point data type");
- }
-
- /* norm */
- norm = dt->u.atomic.u.f.norm;
-
- FUNC_LEAVE (norm);
+ H5T_t *dt = NULL;
+ H5T_norm_t norm;
+
+ FUNC_ENTER(H5Tget_norm, H5T_NORM_ERROR);
+ H5ECLEAR;
+
+ /* Check args */
+ if (H5_DATATYPE != H5Aatom_group(type_id) ||
+ NULL == (dt = H5Aatom_object(type_id)) ||
+ H5T_FLOAT != dt->type) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_NORM_ERROR,
+ "not a floating-point data type");
+ }
+ /* norm */
+ norm = dt->u.atomic.u.f.norm;
+
+ FUNC_LEAVE(norm);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Tset_norm
+ * Function: H5Tset_norm
*
- * Purpose: Sets the mantissa normalization method for a floating point
- * data type.
+ * Purpose: Sets the mantissa normalization method for a floating point
+ * data type.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
@@ -1476,46 +1428,44 @@ H5Tget_norm (hid_t type_id)
*-------------------------------------------------------------------------
*/
herr_t
-H5Tset_norm (hid_t type_id, H5T_norm_t norm)
+H5Tset_norm(hid_t type_id, H5T_norm_t norm)
{
- H5T_t *dt = NULL;
-
- FUNC_ENTER (H5Tset_norm, FAIL);
- H5ECLEAR;
-
- /* Check args */
- if (H5_DATATYPE!=H5Aatom_group (type_id) ||
- NULL==(dt=H5Aatom_object (type_id)) ||
- H5T_FLOAT!=dt->type) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL,
- "not a floating-point data type");
- }
- if (dt->locked) {
- HRETURN_ERROR (H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
- }
- if (norm<0 || norm>H5T_NORM_NONE) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "illegal normalization");
- }
-
- /* norm */
- dt->u.atomic.u.f.norm = norm;
- FUNC_LEAVE (SUCCEED);
+ H5T_t *dt = NULL;
+
+ FUNC_ENTER(H5Tset_norm, FAIL);
+ H5ECLEAR;
+
+ /* Check args */
+ if (H5_DATATYPE != H5Aatom_group(type_id) ||
+ NULL == (dt = H5Aatom_object(type_id)) ||
+ H5T_FLOAT != dt->type) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ "not a floating-point data type");
+ }
+ if (dt->locked) {
+ HRETURN_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
+ }
+ if (norm < 0 || norm > H5T_NORM_NONE) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal normalization");
+ }
+ /* norm */
+ dt->u.atomic.u.f.norm = norm;
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Tget_inpad
+ * Function: H5Tget_inpad
*
- * Purpose: If any internal bits of a floating point type are unused
- * (that is, those significant bits which are not part of the
- * sign, exponent, or mantissa) then they will be filled
- * according to the value of this property.
+ * Purpose: If any internal bits of a floating point type are unused
+ * (that is, those significant bits which are not part of the
+ * sign, exponent, or mantissa) then they will be filled
+ * according to the value of this property.
*
- * Return: Success: The internal padding type.
+ * Return: Success: The internal padding type.
*
- * Failure: H5T_PAD_ERROR (-1, same as FAIL)
+ * Failure: H5T_PAD_ERROR (-1, same as FAIL)
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, January 9, 1998
*
* Modifications:
@@ -1523,42 +1473,40 @@ H5Tset_norm (hid_t type_id, H5T_norm_t norm)
*-------------------------------------------------------------------------
*/
H5T_pad_t
-H5Tget_inpad (hid_t type_id)
+H5Tget_inpad(hid_t type_id)
{
- H5T_t *dt = NULL;
- H5T_pad_t pad;
-
- FUNC_ENTER (H5Tget_inpad, H5T_PAD_ERROR);
- H5ECLEAR;
-
- /* Check args */
- if (H5_DATATYPE!=H5Aatom_group (type_id) ||
- NULL==(dt=H5Aatom_object (type_id)) ||
- H5T_FLOAT!=dt->type) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, H5T_PAD_ERROR,
- "not a floating-point data type");
- }
-
- /* pad */
- pad = dt->u.atomic.u.f.pad;
-
- FUNC_LEAVE (pad);
+ H5T_t *dt = NULL;
+ H5T_pad_t pad;
+
+ FUNC_ENTER(H5Tget_inpad, H5T_PAD_ERROR);
+ H5ECLEAR;
+
+ /* Check args */
+ if (H5_DATATYPE != H5Aatom_group(type_id) ||
+ NULL == (dt = H5Aatom_object(type_id)) ||
+ H5T_FLOAT != dt->type) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_PAD_ERROR,
+ "not a floating-point data type");
+ }
+ /* pad */
+ pad = dt->u.atomic.u.f.pad;
+
+ FUNC_LEAVE(pad);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Tset_inpad
+ * Function: H5Tset_inpad
*
- * Purpose: If any internal bits of a floating point type are unused
- * (that is, those significant bits which are not part of the
- * sign, exponent, or mantissa) then they will be filled
- * according to the value of this property.
+ * Purpose: If any internal bits of a floating point type are unused
+ * (that is, those significant bits which are not part of the
+ * sign, exponent, or mantissa) then they will be filled
+ * according to the value of this property.
*
- * Return: Success:
+ * Return: Success:
*
- * Failure:
+ * Failure:
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, January 9, 1998
*
* Modifications:
@@ -1566,46 +1514,44 @@ H5Tget_inpad (hid_t type_id)
*-------------------------------------------------------------------------
*/
herr_t
-H5Tset_inpad (hid_t type_id, H5T_pad_t pad)
+H5Tset_inpad(hid_t type_id, H5T_pad_t pad)
{
- H5T_t *dt = NULL;
-
- FUNC_ENTER (H5Tset_inpad, FAIL);
- H5ECLEAR;
-
- /* Check args */
- if (H5_DATATYPE!=H5Aatom_group (type_id) ||
- NULL==(dt=H5Aatom_object (type_id)) ||
- H5T_FLOAT!=dt->type) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL,
- "not a floating-point data type");
- }
- if (dt->locked) {
- HRETURN_ERROR (H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
- }
- if (pad<0 || pad>=H5T_NPAD) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,
- "illegal internal pad type");
- }
-
- /* pad */
- dt->u.atomic.u.f.pad = pad;
- FUNC_LEAVE (SUCCEED);
+ H5T_t *dt = NULL;
+
+ FUNC_ENTER(H5Tset_inpad, FAIL);
+ H5ECLEAR;
+
+ /* Check args */
+ if (H5_DATATYPE != H5Aatom_group(type_id) ||
+ NULL == (dt = H5Aatom_object(type_id)) ||
+ H5T_FLOAT != dt->type) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL,
+ "not a floating-point data type");
+ }
+ if (dt->locked) {
+ HRETURN_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
+ }
+ if (pad < 0 || pad >= H5T_NPAD) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
+ "illegal internal pad type");
+ }
+ /* pad */
+ dt->u.atomic.u.f.pad = pad;
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Tget_cset
+ * Function: H5Tget_cset
*
- * Purpose: HDF5 is able to distinguish between character sets of
- * different nationalities and to convert between them to the
- * extent possible.
- *
- * Return: Success: The character set of an H5T_STRING type.
+ * Purpose: HDF5 is able to distinguish between character sets of
+ * different nationalities and to convert between them to the
+ * extent possible.
+ *
+ * Return: Success: The character set of an H5T_STRING type.
*
- * Failure: H5T_CSET_ERROR (-1, same as FAIL)
+ * Failure: H5T_CSET_ERROR (-1, same as FAIL)
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, January 9, 1998
*
* Modifications:
@@ -1613,41 +1559,39 @@ H5Tset_inpad (hid_t type_id, H5T_pad_t pad)
*-------------------------------------------------------------------------
*/
H5T_cset_t
-H5Tget_cset (hid_t type_id)
+H5Tget_cset(hid_t type_id)
{
- H5T_t *dt = NULL;
- H5T_cset_t cset;
-
- FUNC_ENTER (H5Tget_cset, H5T_CSET_ERROR);
- H5ECLEAR;
-
- /* Check args */
- if (H5_DATATYPE!=H5Aatom_group (type_id) ||
- NULL==(dt=H5Aatom_object (type_id)) ||
- H5T_STRING!=dt->type) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, H5T_CSET_ERROR,
- "not a string data type");
- }
-
- /* result */
- cset = dt->u.atomic.u.s.cset;
-
- FUNC_LEAVE (cset);
+ H5T_t *dt = NULL;
+ H5T_cset_t cset;
+
+ FUNC_ENTER(H5Tget_cset, H5T_CSET_ERROR);
+ H5ECLEAR;
+
+ /* Check args */
+ if (H5_DATATYPE != H5Aatom_group(type_id) ||
+ NULL == (dt = H5Aatom_object(type_id)) ||
+ H5T_STRING != dt->type) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_CSET_ERROR,
+ "not a string data type");
+ }
+ /* result */
+ cset = dt->u.atomic.u.s.cset;
+
+ FUNC_LEAVE(cset);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Tset_cset
+ * Function: H5Tset_cset
*
- * Purpose: HDF5 is able to distinguish between character sets of
- * different nationalities and to convert between them to the
- * extent possible.
+ * Purpose: HDF5 is able to distinguish between character sets of
+ * different nationalities and to convert between them to the
+ * extent possible.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, January 9, 1998
*
* Modifications:
@@ -1655,46 +1599,44 @@ H5Tget_cset (hid_t type_id)
*-------------------------------------------------------------------------
*/
herr_t
-H5Tset_cset (hid_t type_id, H5T_cset_t cset)
+H5Tset_cset(hid_t type_id, H5T_cset_t cset)
{
- H5T_t *dt = NULL;
-
- FUNC_ENTER (H5Tset_cset, FAIL);
- H5ECLEAR;
-
- /* Check args */
- if (H5_DATATYPE!=H5Aatom_group (type_id) ||
- NULL==(dt=H5Aatom_object (type_id)) ||
- H5T_STRING!=dt->type) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a string data type");
- }
- if (dt->locked) {
- HRETURN_ERROR (H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
- }
- if (cset<0 || cset>=H5T_NCSET) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,
- "illegal character set type");
- }
-
- /* set */
- dt->u.atomic.u.s.cset = cset;
- FUNC_LEAVE (SUCCEED);
+ H5T_t *dt = NULL;
+
+ FUNC_ENTER(H5Tset_cset, FAIL);
+ H5ECLEAR;
+
+ /* Check args */
+ if (H5_DATATYPE != H5Aatom_group(type_id) ||
+ NULL == (dt = H5Aatom_object(type_id)) ||
+ H5T_STRING != dt->type) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a string data type");
+ }
+ if (dt->locked) {
+ HRETURN_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
+ }
+ if (cset < 0 || cset >= H5T_NCSET) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
+ "illegal character set type");
+ }
+ /* set */
+ dt->u.atomic.u.s.cset = cset;
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Tget_strpad
+ * Function: H5Tget_strpad
*
- * Purpose: The method used to store character strings differs with the
- * programming language: C usually null terminates strings while
- * Fortran left-justifies and space-pads strings. This property
- * defines the storage mechanism for the string.
- *
- * Return: Success: The character set of an H5T_STRING type.
+ * Purpose: The method used to store character strings differs with the
+ * programming language: C usually null terminates strings while
+ * Fortran left-justifies and space-pads strings. This property
+ * defines the storage mechanism for the string.
+ *
+ * Return: Success: The character set of an H5T_STRING type.
*
- * Failure: H5T_STR_ERROR (-1, same as FAIL)
+ * Failure: H5T_STR_ERROR (-1, same as FAIL)
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, January 9, 1998
*
* Modifications:
@@ -1702,42 +1644,40 @@ H5Tset_cset (hid_t type_id, H5T_cset_t cset)
*-------------------------------------------------------------------------
*/
H5T_str_t
-H5Tget_strpad (hid_t type_id)
+H5Tget_strpad(hid_t type_id)
{
- H5T_t *dt = NULL;
- H5T_str_t strpad;
-
- FUNC_ENTER (H5Tget_strpad, H5T_STR_ERROR);
- H5ECLEAR;
-
- /* Check args */
- if (H5_DATATYPE!=H5Aatom_group (type_id) ||
- NULL==(dt=H5Aatom_object (type_id)) ||
- H5T_STRING!=dt->type) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, H5T_STR_ERROR,
- "not a string data type");
- }
-
- /* result */
- strpad = dt->u.atomic.u.s.pad;
-
- FUNC_LEAVE (strpad);
+ H5T_t *dt = NULL;
+ H5T_str_t strpad;
+
+ FUNC_ENTER(H5Tget_strpad, H5T_STR_ERROR);
+ H5ECLEAR;
+
+ /* Check args */
+ if (H5_DATATYPE != H5Aatom_group(type_id) ||
+ NULL == (dt = H5Aatom_object(type_id)) ||
+ H5T_STRING != dt->type) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, H5T_STR_ERROR,
+ "not a string data type");
+ }
+ /* result */
+ strpad = dt->u.atomic.u.s.pad;
+
+ FUNC_LEAVE(strpad);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Tset_strpad
+ * Function: H5Tset_strpad
*
- * Purpose: The method used to store character strings differs with the
- * programming language: C usually null terminates strings while
- * Fortran left-justifies and space-pads strings. This property
- * defines the storage mechanism for the string.
+ * Purpose: The method used to store character strings differs with the
+ * programming language: C usually null terminates strings while
+ * Fortran left-justifies and space-pads strings. This property
+ * defines the storage mechanism for the string.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, January 9, 1998
*
* Modifications:
@@ -1745,45 +1685,43 @@ H5Tget_strpad (hid_t type_id)
*-------------------------------------------------------------------------
*/
herr_t
-H5Tset_strpad (hid_t type_id, H5T_str_t strpad)
+H5Tset_strpad(hid_t type_id, H5T_str_t strpad)
{
- H5T_t *dt = NULL;
-
- FUNC_ENTER (H5Tset_strpad, FAIL);
- H5ECLEAR;
-
- /* Check args */
- if (H5_DATATYPE!=H5Aatom_group (type_id) ||
- NULL==(dt=H5Aatom_object (type_id)) ||
- H5T_STRING!=dt->type) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a string data type");
- }
- if (dt->locked) {
- HRETURN_ERROR (H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
- }
- if (strpad<0 || strpad>=H5T_NSTR) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "illegal string pad type");
- }
-
- /* set */
- dt->u.atomic.u.s.pad = strpad;
- FUNC_LEAVE (SUCCEED);
+ H5T_t *dt = NULL;
+
+ FUNC_ENTER(H5Tset_strpad, FAIL);
+ H5ECLEAR;
+
+ /* Check args */
+ if (H5_DATATYPE != H5Aatom_group(type_id) ||
+ NULL == (dt = H5Aatom_object(type_id)) ||
+ H5T_STRING != dt->type) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a string data type");
+ }
+ if (dt->locked) {
+ HRETURN_ERROR(H5E_ARGS, H5E_CANTINIT, FAIL, "data type is read-only");
+ }
+ if (strpad < 0 || strpad >= H5T_NSTR) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "illegal string pad type");
+ }
+ /* set */
+ dt->u.atomic.u.s.pad = strpad;
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Tget_nmembers
+ * Function: H5Tget_nmembers
*
- * Purpose: Determines how many members compound data type TYPE_ID has.
+ * Purpose: Determines how many members compound data type TYPE_ID has.
*
- * Return: Success: Number of members defined in a compound data
- * type.
+ * Return: Success: Number of members defined in a compound data
+ * type.
*
- * Failure: FAIL
+ * Failure: FAIL
*
* Errors:
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Monday, December 8, 1997
*
* Modifications:
@@ -1791,83 +1729,79 @@ H5Tset_strpad (hid_t type_id, H5T_str_t strpad)
*-------------------------------------------------------------------------
*/
intn
-H5Tget_nmembers (hid_t type_id)
+H5Tget_nmembers(hid_t type_id)
{
-
- H5T_t *dt = NULL;
- FUNC_ENTER (H5Tget_num_members, FAIL);
- H5ECLEAR;
+ H5T_t *dt = NULL;
- /* Check args */
- if (H5_DATATYPE!=H5Aatom_group (type_id) ||
- NULL==(dt=H5Aatom_object (type_id)) ||
- H5T_COMPOUND!=dt->type) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a compound data type");
- }
+ FUNC_ENTER(H5Tget_num_members, FAIL);
+ H5ECLEAR;
- FUNC_LEAVE (dt->u.compnd.nmembs);
+ /* Check args */
+ if (H5_DATATYPE != H5Aatom_group(type_id) ||
+ NULL == (dt = H5Aatom_object(type_id)) ||
+ H5T_COMPOUND != dt->type) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a compound data type");
+ }
+ FUNC_LEAVE(dt->u.compnd.nmembs);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Tget_member_name
+ * Function: H5Tget_member_name
*
- * Purpose: Returns the name of a member of a compound data type.
- * Members are stored in no particular order with numbers 0
- * through N-1 where N is the value returned by
- * H5Tget_nmembers().
+ * Purpose: Returns the name of a member of a compound data type.
+ * Members are stored in no particular order with numbers 0
+ * through N-1 where N is the value returned by
+ * H5Tget_nmembers().
*
- * Return: Success: Ptr to a string allocated with malloc(). The
- * caller is responsible for freeing the string.
+ * Return: Success: Ptr to a string allocated with malloc(). The
+ * caller is responsible for freeing the string.
*
- * Failure: NULL
+ * Failure: NULL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-char *
-H5Tget_member_name (hid_t type_id, int membno)
+char *
+H5Tget_member_name(hid_t type_id, int membno)
{
- H5T_t *dt = NULL;
- char *s = NULL;
-
- FUNC_ENTER (H5Tget_member_name, NULL);
- H5ECLEAR;
-
- /* Check args */
- if (H5_DATATYPE!=H5Aatom_group (type_id) ||
- NULL==(dt=H5Aatom_object (type_id)) ||
- H5T_COMPOUND!=dt->type) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, NULL, "not a compound data type");
- }
- if (membno<0 || membno>=dt->u.compnd.nmembs) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, NULL, "invalid member number");
- }
-
- s = H5MM_xstrdup (dt->u.compnd.memb[membno].name);
- FUNC_LEAVE (s);
+ H5T_t *dt = NULL;
+ char *s = NULL;
+
+ FUNC_ENTER(H5Tget_member_name, NULL);
+ H5ECLEAR;
+
+ /* Check args */
+ if (H5_DATATYPE != H5Aatom_group(type_id) ||
+ NULL == (dt = H5Aatom_object(type_id)) ||
+ H5T_COMPOUND != dt->type) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a compound data type");
+ }
+ if (membno < 0 || membno >= dt->u.compnd.nmembs) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid member number");
+ }
+ s = H5MM_xstrdup(dt->u.compnd.memb[membno].name);
+ FUNC_LEAVE(s);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Tget_member_offset
+ * Function: H5Tget_member_offset
*
- * Purpose: Returns the byte offset of the beginning of a member with
- * respect to the beginning of the compound data type datum.
+ * Purpose: Returns the byte offset of the beginning of a member with
+ * respect to the beginning of the compound data type datum.
*
- * Return: Success: Byte offset.
+ * Return: Success: Byte offset.
*
- * Failure: Zero. Zero is a valid offset, but this
- * function will fail only if a call to
- * H5Tget_member_dims() fails with the same
- * arguments.
+ * Failure: Zero. Zero is a valid offset, but this
+ * function will fail only if a call to
+ * H5Tget_member_dims() fails with the same
+ * arguments.
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
@@ -1875,42 +1809,40 @@ H5Tget_member_name (hid_t type_id, int membno)
*-------------------------------------------------------------------------
*/
size_t
-H5Tget_member_offset (hid_t type_id, int membno)
+H5Tget_member_offset(hid_t type_id, int membno)
{
- H5T_t *dt = NULL;
- size_t offset = 0;
-
- FUNC_ENTER (H5Tget_member_offset, 0);
- H5ECLEAR;
-
- /* Check args */
- if (H5_DATATYPE!=H5Aatom_group (type_id) ||
- NULL==(dt=H5Aatom_object (type_id)) ||
- H5T_COMPOUND!=dt->type) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, 0, "not a compound data type");
- }
- if (membno<0 || membno>=dt->u.compnd.nmembs) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, 0, "invalid member number");
- }
-
- offset = dt->u.compnd.memb[membno].offset;
- FUNC_LEAVE (offset);
+ H5T_t *dt = NULL;
+ size_t offset = 0;
+
+ FUNC_ENTER(H5Tget_member_offset, 0);
+ H5ECLEAR;
+
+ /* Check args */
+ if (H5_DATATYPE != H5Aatom_group(type_id) ||
+ NULL == (dt = H5Aatom_object(type_id)) ||
+ H5T_COMPOUND != dt->type) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a compound data type");
+ }
+ if (membno < 0 || membno >= dt->u.compnd.nmembs) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, 0, "invalid member number");
+ }
+ offset = dt->u.compnd.memb[membno].offset;
+ FUNC_LEAVE(offset);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Tget_member_dims
+ * Function: H5Tget_member_dims
*
- * Purpose: Returns the dimensionality of the member. The dimensions and
- * permuation vector are returned through arguments DIMS and
- * PERM, both arrays of at least four elements. Either (or even
- * both) may be null pointers.
+ * Purpose: Returns the dimensionality of the member. The dimensions and
+ * permuation vector are returned through arguments DIMS and
+ * PERM, both arrays of at least four elements. Either (or even
+ * both) may be null pointers.
*
- * Return: Success: A value between zero and four, inclusive.
+ * Return: Success: A value between zero and four, inclusive.
*
- * Failure: -1
+ * Failure: -1
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
@@ -1918,49 +1850,49 @@ H5Tget_member_offset (hid_t type_id, int membno)
*-------------------------------------------------------------------------
*/
int
-H5Tget_member_dims (hid_t type_id, int membno,
- int dims[]/*out*/, int perm[]/*out*/)
+H5Tget_member_dims(hid_t type_id, int membno,
+ int dims[] /*out */ , int perm[] /*out */ )
{
- H5T_t *dt = NULL;
- intn ndims, i;
-
- FUNC_ENTER (H5Tget_member_dims, FAIL);
- H5ECLEAR;
-
- /* Check args */
- if (H5_DATATYPE!=H5Aatom_group (type_id) ||
- NULL==(dt=H5Aatom_object (type_id)) ||
- H5T_COMPOUND!=dt->type) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a compound data type");
- }
- if (membno<0 || membno>=dt->u.compnd.nmembs) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid member number");
- }
-
- ndims = dt->u.compnd.memb[membno].ndims;
- for (i=0; i<ndims; i++) {
- if (dims[i]) dims[i] = dt->u.compnd.memb[membno].dim[i];
- if (perm[i]) perm[i] = dt->u.compnd.memb[membno].perm[i];
- }
-
- FUNC_LEAVE (ndims);
+ H5T_t *dt = NULL;
+ intn ndims, i;
+
+ FUNC_ENTER(H5Tget_member_dims, FAIL);
+ H5ECLEAR;
+
+ /* Check args */
+ if (H5_DATATYPE != H5Aatom_group(type_id) ||
+ NULL == (dt = H5Aatom_object(type_id)) ||
+ H5T_COMPOUND != dt->type) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a compound data type");
+ }
+ if (membno < 0 || membno >= dt->u.compnd.nmembs) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid member number");
+ }
+ ndims = dt->u.compnd.memb[membno].ndims;
+ for (i = 0; i < ndims; i++) {
+ if (dims[i])
+ dims[i] = dt->u.compnd.memb[membno].dim[i];
+ if (perm[i])
+ perm[i] = dt->u.compnd.memb[membno].perm[i];
+ }
+
+ FUNC_LEAVE(ndims);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Tget_member_type
+ * Function: H5Tget_member_type
*
- * Purpose: Returns the data type of the specified member. The caller
- * should invoke H5Tclose() to release resources associated with
- * the type.
+ * Purpose: Returns the data type of the specified member. The caller
+ * should invoke H5Tclose() to release resources associated with
+ * the type.
*
- * Return: Success: An OID of a copy of the member data type;
- * modifying the returned data type does not
- * modify the member type.
+ * Return: Success: An OID of a copy of the member data type;
+ * modifying the returned data type does not
+ * modify the member type.
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
@@ -1968,61 +1900,58 @@ H5Tget_member_dims (hid_t type_id, int membno,
*-------------------------------------------------------------------------
*/
hid_t
-H5Tget_member_type (hid_t type_id, int membno)
+H5Tget_member_type(hid_t type_id, int membno)
{
- H5T_t *dt = NULL, *memb_dt = NULL;
- hid_t memb_type_id;
-
- FUNC_ENTER (H5Tget_member_type, FAIL);
- H5ECLEAR;
-
- /* Check args */
- if (H5_DATATYPE!=H5Aatom_group (type_id) ||
- NULL==(dt=H5Aatom_object (type_id)) ||
- H5T_COMPOUND!=dt->type) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a compound data type");
- }
- if (membno<0 || membno>=dt->u.compnd.nmembs) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "invalid member number");
- }
-
- /* Copy data type into an atom */
- if (NULL==(memb_dt=H5T_copy (&(dt->u.compnd.memb[membno].type)))) {
- HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "unable to copy member data type");
- }
- if ((memb_type_id=H5Aregister_atom (H5_DATATYPE, memb_dt))<0) {
- H5T_close (memb_dt);
- HRETURN_ERROR (H5E_DATATYPE, H5E_CANTREGISTER, FAIL,
- "can't register data type atom");
- }
-
- FUNC_LEAVE (memb_type_id);
+ H5T_t *dt = NULL, *memb_dt = NULL;
+ hid_t memb_type_id;
+
+ FUNC_ENTER(H5Tget_member_type, FAIL);
+ H5ECLEAR;
+
+ /* Check args */
+ if (H5_DATATYPE != H5Aatom_group(type_id) ||
+ NULL == (dt = H5Aatom_object(type_id)) ||
+ H5T_COMPOUND != dt->type) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a compound data type");
+ }
+ if (membno < 0 || membno >= dt->u.compnd.nmembs) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid member number");
+ }
+ /* Copy data type into an atom */
+ if (NULL == (memb_dt = H5T_copy(&(dt->u.compnd.memb[membno].type)))) {
+ HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
+ "unable to copy member data type");
+ }
+ if ((memb_type_id = H5Aregister_atom(H5_DATATYPE, memb_dt)) < 0) {
+ H5T_close(memb_dt);
+ HRETURN_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL,
+ "can't register data type atom");
+ }
+ FUNC_LEAVE(memb_type_id);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Tinsert
+ * Function: H5Tinsert
*
- * Purpose: Adds another member to the compound data type PARENT_ID. The
- * new member has a NAME which must be unique within the
- * compound data type. The OFFSET argument defines the start of
- * the member in an instance of the compound data type, and
- * MEMBER_ID is the type of the new member.
+ * Purpose: Adds another member to the compound data type PARENT_ID. The
+ * new member has a NAME which must be unique within the
+ * compound data type. The OFFSET argument defines the start of
+ * the member in an instance of the compound data type, and
+ * MEMBER_ID is the type of the new member.
*
- * Note: All members of a compound data type must be atomic; a
- * compound data type cannot have a member which is a compound
- * data type.
+ * Note: All members of a compound data type must be atomic; a
+ * compound data type cannot have a member which is a compound
+ * data type.
*
- * Return: Success: SUCCEED, the PARENT_ID compound data type is
- * modified to include a copy of the member type
- * MEMBER_ID.
+ * Return: Success: SUCCEED, the PARENT_ID compound data type is
+ * modified to include a copy of the member type
+ * MEMBER_ID.
*
- * Failure: FAIL
+ * Failure: FAIL
*
* Errors:
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Monday, December 8, 1997
*
* Modifications:
@@ -2030,51 +1959,48 @@ H5Tget_member_type (hid_t type_id, int membno)
*-------------------------------------------------------------------------
*/
herr_t
-H5Tinsert (hid_t parent_id, const char *name, off_t offset, hid_t member_id)
+H5Tinsert(hid_t parent_id, const char *name, off_t offset, hid_t member_id)
{
- H5T_t *parent = NULL; /*the compound parent data type */
- H5T_t *member = NULL; /*the atomic member type */
-
- FUNC_ENTER (H5Tinsert, FAIL);
- H5ECLEAR;
-
- /* Check args */
- if (H5_DATATYPE!=H5Aatom_group (parent_id) ||
- NULL==(parent=H5Aatom_object (parent_id)) ||
- H5T_COMPOUND!=parent->type) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a compound data type");
- }
- if (parent->locked) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "parent type read-only");
- }
- if (!name || !*name) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no member name");
- }
- if (H5_DATATYPE!=H5Aatom_group (member_id) ||
- NULL==(member=H5Aatom_object (member_id))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
- }
-
- if (H5T_insert (parent, name, offset, member)<0) {
- HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINSERT, FAIL,
- "can't insert member");
- }
-
- FUNC_LEAVE (SUCCEED);
+ H5T_t *parent = NULL; /*the compound parent data type */
+ H5T_t *member = NULL; /*the atomic member type */
+
+ FUNC_ENTER(H5Tinsert, FAIL);
+ H5ECLEAR;
+
+ /* Check args */
+ if (H5_DATATYPE != H5Aatom_group(parent_id) ||
+ NULL == (parent = H5Aatom_object(parent_id)) ||
+ H5T_COMPOUND != parent->type) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a compound data type");
+ }
+ if (parent->locked) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "parent type read-only");
+ }
+ if (!name || !*name) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no member name");
+ }
+ if (H5_DATATYPE != H5Aatom_group(member_id) ||
+ NULL == (member = H5Aatom_object(member_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ }
+ if (H5T_insert(parent, name, offset, member) < 0) {
+ HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL,
+ "can't insert member");
+ }
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Tpack
+ * Function: H5Tpack
*
- * Purpose: Recursively removes padding from within a compound data type
- * to make it more efficient (space-wise) to store that data.
+ * Purpose: Recursively removes padding from within a compound data type
+ * to make it more efficient (space-wise) to store that data.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
@@ -2082,51 +2008,48 @@ H5Tinsert (hid_t parent_id, const char *name, off_t offset, hid_t member_id)
*-------------------------------------------------------------------------
*/
herr_t
-H5Tpack (hid_t type_id)
+H5Tpack(hid_t type_id)
{
- H5T_t *dt = NULL;
-
- FUNC_ENTER (H5Tpack, FAIL);
- H5ECLEAR;
-
- /* Check args */
- if (H5_DATATYPE!=H5Aatom_group (type_id) ||
- NULL==(dt=H5Aatom_object (type_id)) ||
- H5T_COMPOUND!=dt->type) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a compound data type");
- }
- if (dt->locked) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "data type is read-only");
- }
-
- if (H5T_pack (dt)<0) {
- HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "unable to pack compound data type");
- }
-
- FUNC_LEAVE (SUCCEED);
+ H5T_t *dt = NULL;
+
+ FUNC_ENTER(H5Tpack, FAIL);
+ H5ECLEAR;
+
+ /* Check args */
+ if (H5_DATATYPE != H5Aatom_group(type_id) ||
+ NULL == (dt = H5Aatom_object(type_id)) ||
+ H5T_COMPOUND != dt->type) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a compound data type");
+ }
+ if (dt->locked) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "data type is read-only");
+ }
+ if (H5T_pack(dt) < 0) {
+ HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
+ "unable to pack compound data type");
+ }
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Tregister_hard
+ * Function: H5Tregister_hard
*
- * Purpose: Register a hard conversion function for a data type
- * conversion path. The path is specified by the source and
- * destination data types SRC_ID and DST_ID. A conversion path
- * can only have one hard function, so FUNC replaces any
- * previous hard function.
+ * Purpose: Register a hard conversion function for a data type
+ * conversion path. The path is specified by the source and
+ * destination data types SRC_ID and DST_ID. A conversion path
+ * can only have one hard function, so FUNC replaces any
+ * previous hard function.
*
- * If FUNC is the null pointer then any hard function registered
- * for this path is removed from this path. The soft functions
- * are then used when determining which conversion function is
- * appropriate for this path.
+ * If FUNC is the null pointer then any hard function registered
+ * for this path is removed from this path. The soft functions
+ * are then used when determining which conversion function is
+ * appropriate for this path.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, January 9, 1998
*
* Modifications:
@@ -2134,46 +2057,43 @@ H5Tpack (hid_t type_id)
*-------------------------------------------------------------------------
*/
herr_t
-H5Tregister_hard (hid_t src_id, hid_t dst_id, H5T_conv_t func)
+H5Tregister_hard(hid_t src_id, hid_t dst_id, H5T_conv_t func)
{
- H5T_t *src = NULL;
- H5T_t *dst = NULL;
- H5T_path_t *path = NULL;
-
- FUNC_ENTER (H5Tregister_hard, FAIL);
-
- /* Check args */
- if (H5_DATATYPE!=H5Aatom_group (src_id) ||
- NULL==(src=H5Aatom_object (src_id)) ||
- H5_DATATYPE!=H5Aatom_group (dst_id) ||
- NULL==(dst=H5Aatom_object (dst_id))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
- }
-
- /* Locate or create a new conversion path */
- if (NULL==(path=H5T_path_find (src, dst, TRUE))) {
- HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "unable to locate/allocate conversion path");
- }
-
- /* Initialize the hard function */
- path->hard = func;
- FUNC_LEAVE (SUCCEED);
+ H5T_t *src = NULL;
+ H5T_t *dst = NULL;
+ H5T_path_t *path = NULL;
+
+ FUNC_ENTER(H5Tregister_hard, FAIL);
+
+ /* Check args */
+ if (H5_DATATYPE != H5Aatom_group(src_id) ||
+ NULL == (src = H5Aatom_object(src_id)) ||
+ H5_DATATYPE != H5Aatom_group(dst_id) ||
+ NULL == (dst = H5Aatom_object(dst_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ }
+ /* Locate or create a new conversion path */
+ if (NULL == (path = H5T_path_find(src, dst, TRUE))) {
+ HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
+ "unable to locate/allocate conversion path");
+ }
+ /* Initialize the hard function */
+ path->hard = func;
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Tregister_soft
+ * Function: H5Tregister_soft
*
- * Purpose: Registers a soft conversion function by adding it to the end
- * of the master soft list and replacing the soft function in
- * all applicable existing conversion paths.
+ * Purpose: Registers a soft conversion function by adding it to the end
+ * of the master soft list and replacing the soft function in
+ * all applicable existing conversion paths.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Tuesday, January 13, 1998
*
* Modifications:
@@ -2181,74 +2101,73 @@ H5Tregister_hard (hid_t src_id, hid_t dst_id, H5T_conv_t func)
*-------------------------------------------------------------------------
*/
herr_t
-H5Tregister_soft (H5T_class_t src_cls, H5T_class_t dst_cls, H5T_conv_t func)
+H5Tregister_soft(H5T_class_t src_cls, H5T_class_t dst_cls, H5T_conv_t func)
{
- intn i;
- hid_t src_id, dst_id;
-
- FUNC_ENTER (H5Tregister_soft, FAIL);
-
- /* Check args */
- if (src_cls<0 || src_cls>=H5T_NCLASSES ||
- dst_cls<0 || dst_cls>=H5T_NCLASSES) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,
- "illegal source or destination data type class");
- }
- if (!func) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,
- "no soft conversion function specified");
- }
-
- /* Add function to end of master list */
- if (H5T_nsoft_g>=H5T_asoft_g) {
- H5T_asoft_g = MAX (32, 2*H5T_asoft_g);
- H5T_soft_g = H5MM_xrealloc (H5T_soft_g, H5T_asoft_g*sizeof(H5T_soft_t));
- }
- H5T_soft_g[H5T_nsoft_g].src = src_cls;
- H5T_soft_g[H5T_nsoft_g].dst = dst_cls;
- H5T_soft_g[H5T_nsoft_g].func = func;
- H5T_nsoft_g++;
-
- /* Replace soft functions of all appropriate paths */
- for (i=0; i<H5T_npath_g; i++) {
- H5T_path_t *path = H5T_path_g + i;
-
- /*
- * Type conversion functions are app-level, so we need to convert the
- * data type temporarily to an object id before we query the functions
- * capabilities.
- */
- if (path->src->type!=src_cls || path->dst->type!=dst_cls) continue;
- if ((src_id = H5Aregister_atom (H5_DATATYPE, H5T_copy (path->src)))<0 ||
- (dst_id = H5Aregister_atom (H5_DATATYPE, H5T_copy (path->dst)))<0) {
- HRETURN_ERROR (H5E_DATATYPE, H5E_CANTREGISTER, FAIL,
- "unable to register data types for conv query");
- }
- if ((func)(src_id, dst_id, 0, NULL, NULL)>=0) {
- path->soft = func;
- }
- H5A_dec_ref (src_id);
- H5A_dec_ref (dst_id);
- H5ECLEAR;
- }
-
- FUNC_LEAVE (SUCCEED);
+ intn i;
+ hid_t src_id, dst_id;
+
+ FUNC_ENTER(H5Tregister_soft, FAIL);
+
+ /* Check args */
+ if (src_cls < 0 || src_cls >= H5T_NCLASSES ||
+ dst_cls < 0 || dst_cls >= H5T_NCLASSES) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
+ "illegal source or destination data type class");
+ }
+ if (!func) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL,
+ "no soft conversion function specified");
+ }
+ /* Add function to end of master list */
+ if (H5T_nsoft_g >= H5T_asoft_g) {
+ H5T_asoft_g = MAX(32, 2 * H5T_asoft_g);
+ H5T_soft_g = H5MM_xrealloc(H5T_soft_g, H5T_asoft_g * sizeof(H5T_soft_t));
+ }
+ H5T_soft_g[H5T_nsoft_g].src = src_cls;
+ H5T_soft_g[H5T_nsoft_g].dst = dst_cls;
+ H5T_soft_g[H5T_nsoft_g].func = func;
+ H5T_nsoft_g++;
+
+ /* Replace soft functions of all appropriate paths */
+ for (i = 0; i < H5T_npath_g; i++) {
+ H5T_path_t *path = H5T_path_g + i;
+
+ /*
+ * Type conversion functions are app-level, so we need to convert the
+ * data type temporarily to an object id before we query the functions
+ * capabilities.
+ */
+ if (path->src->type != src_cls || path->dst->type != dst_cls)
+ continue;
+ if ((src_id = H5Aregister_atom(H5_DATATYPE, H5T_copy(path->src))) < 0 ||
+ (dst_id = H5Aregister_atom(H5_DATATYPE, H5T_copy(path->dst))) < 0) {
+ HRETURN_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL,
+ "unable to register data types for conv query");
+ }
+ if ((func) (src_id, dst_id, 0, NULL, NULL) >= 0) {
+ path->soft = func;
+ }
+ H5A_dec_ref(src_id);
+ H5A_dec_ref(dst_id);
+ H5ECLEAR;
+ }
+
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Tunregister
+ * Function: H5Tunregister
*
- * Purpose: Removes FUNC from all conversion paths. If FUNC is
- * registered as the soft conversion function of a path then it
- * is replaced with some other soft conversion function from the
- * master soft list if one applies.
+ * Purpose: Removes FUNC from all conversion paths. If FUNC is
+ * registered as the soft conversion function of a path then it
+ * is replaced with some other soft conversion function from the
+ * master soft list if one applies.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Tuesday, January 13, 1998
*
* Modifications:
@@ -2256,82 +2175,78 @@ H5Tregister_soft (H5T_class_t src_cls, H5T_class_t dst_cls, H5T_conv_t func)
*-------------------------------------------------------------------------
*/
herr_t
-H5Tunregister (H5T_conv_t func)
+H5Tunregister(H5T_conv_t func)
{
- intn i, j;
- H5T_path_t *path = NULL;
- hid_t src_id, dst_id;
-
- FUNC_ENTER (H5Tunregister, FAIL);
-
- /* Check args */
- if (!func) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL, "no conversion function");
- }
-
- /* Remove function from master soft list */
- for (i=H5T_nsoft_g-1; i>=0; --i) {
- if (H5T_soft_g[i].func==func) {
- HDmemmove (H5T_soft_g+i, H5T_soft_g+i+1,
- (H5T_nsoft_g-(i+1))*sizeof(H5T_soft_t));
- --H5T_nsoft_g;
- }
- }
-
- /* Remove function from all conversion paths */
- for (i=0; i<H5T_npath_g; i++) {
- path = H5T_path_g + i;
-
- /* Reset hard function */
- if (path->hard==func) {
- path->hard = NULL;
- }
-
- /* Reset soft function */
- if (path->soft==func) {
- path->soft = NULL;
- for (j=H5T_nsoft_g-1; j>=0 && !path->soft; --j) {
- if (path->src->type!=H5T_soft_g[j].src ||
- path->dst->type!=H5T_soft_g[j].dst) {
- continue;
- }
-
- /*
- * Conversion functions are app-level, so temporarily create
- * object id's for the data types.
- */
- if ((src_id=H5Aregister_atom (H5_DATATYPE,
- H5T_copy (path->src)))<0 ||
- (dst_id=H5Aregister_atom (H5_DATATYPE,
- H5T_copy (path->dst)))<0) {
- HRETURN_ERROR (H5E_DATATYPE, H5E_CANTREGISTER, FAIL,
- "unable to register conv types for query");
- }
- if ((H5T_soft_g[j].func)(src_id, dst_id, 0, NULL, NULL)>=0) {
- path->soft = H5T_soft_g[j].func;
- }
- H5A_dec_ref (src_id);
- H5A_dec_ref (dst_id);
- H5ECLEAR;
- }
- }
- }
-
- FUNC_LEAVE (SUCCEED);
+ intn i, j;
+ H5T_path_t *path = NULL;
+ hid_t src_id, dst_id;
+
+ FUNC_ENTER(H5Tunregister, FAIL);
+
+ /* Check args */
+ if (!func) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no conversion function");
+ }
+ /* Remove function from master soft list */
+ for (i = H5T_nsoft_g - 1; i >= 0; --i) {
+ if (H5T_soft_g[i].func == func) {
+ HDmemmove(H5T_soft_g + i, H5T_soft_g + i + 1,
+ (H5T_nsoft_g - (i + 1)) * sizeof(H5T_soft_t));
+ --H5T_nsoft_g;
+ }
+ }
+
+ /* Remove function from all conversion paths */
+ for (i = 0; i < H5T_npath_g; i++) {
+ path = H5T_path_g + i;
+
+ /* Reset hard function */
+ if (path->hard == func) {
+ path->hard = NULL;
+ }
+ /* Reset soft function */
+ if (path->soft == func) {
+ path->soft = NULL;
+ for (j = H5T_nsoft_g - 1; j >= 0 && !path->soft; --j) {
+ if (path->src->type != H5T_soft_g[j].src ||
+ path->dst->type != H5T_soft_g[j].dst) {
+ continue;
+ }
+ /*
+ * Conversion functions are app-level, so temporarily create
+ * object id's for the data types.
+ */
+ if ((src_id = H5Aregister_atom(H5_DATATYPE,
+ H5T_copy(path->src))) < 0 ||
+ (dst_id = H5Aregister_atom(H5_DATATYPE,
+ H5T_copy(path->dst))) < 0) {
+ HRETURN_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL,
+ "unable to register conv types for query");
+ }
+ if ((H5T_soft_g[j].func) (src_id, dst_id, 0, NULL, NULL) >= 0) {
+ path->soft = H5T_soft_g[j].func;
+ }
+ H5A_dec_ref(src_id);
+ H5A_dec_ref(dst_id);
+ H5ECLEAR;
+ }
+ }
+ }
+
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5Tfind
+ * Function: H5Tfind
*
- * Purpose: Finds a conversion function that can handle a conversion from
- * type SRC_ID to type DST_ID.
+ * Purpose: Finds a conversion function that can handle a conversion from
+ * type SRC_ID to type DST_ID.
*
- * Return: Success: A pointer to a suitable conversion function.
+ * Return: Success: A pointer to a suitable conversion function.
*
- * Failure: NULL
+ * Failure: NULL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Tuesday, January 13, 1998
*
* Modifications:
@@ -2339,156 +2254,141 @@ H5Tunregister (H5T_conv_t func)
*-------------------------------------------------------------------------
*/
H5T_conv_t
-H5Tfind (hid_t src_id, hid_t dst_id)
+H5Tfind(hid_t src_id, hid_t dst_id)
{
- H5T_conv_t ret_value = NULL;
- H5T_t *src=NULL, *dst=NULL;
-
- FUNC_ENTER (H5Tfind, NULL);
-
- /* Check args */
- if (H5_DATATYPE!=H5Aatom_group (src_id) ||
- NULL==(src=H5Aatom_object (src_id)) ||
- H5_DATATYPE!=H5Aatom_group (dst_id) ||
- NULL==(dst=H5Aatom_object (dst_id))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, NULL, "not a data type");
- }
-
- /* Find it */
- if (NULL==(ret_value = H5T_find (src, dst))) {
- HRETURN_ERROR (H5E_DATATYPE, H5E_NOTFOUND, NULL,
- "conversion function not found");
- }
-
- FUNC_LEAVE (ret_value);
+ H5T_conv_t ret_value = NULL;
+ H5T_t *src = NULL, *dst = NULL;
+
+ FUNC_ENTER(H5Tfind, NULL);
+
+ /* Check args */
+ if (H5_DATATYPE != H5Aatom_group(src_id) ||
+ NULL == (src = H5Aatom_object(src_id)) ||
+ H5_DATATYPE != H5Aatom_group(dst_id) ||
+ NULL == (dst = H5Aatom_object(dst_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data type");
+ }
+ /* Find it */
+ if (NULL == (ret_value = H5T_find(src, dst))) {
+ HRETURN_ERROR(H5E_DATATYPE, H5E_NOTFOUND, NULL,
+ "conversion function not found");
+ }
+ FUNC_LEAVE(ret_value);
}
-
-
-
-
/*-------------------------------------------------------------------------
* API functions are above; library-private functions are below...
*-------------------------------------------------------------------------
*/
-
-
-
-
-
-
/*-------------------------------------------------------------------------
- * Function: H5T_create
+ * Function: H5T_create
*
- * Purpose: Creates a new data type and initializes it to reasonable
- * values. The new data type is SIZE bytes and an instance of
- * the class TYPE.
+ * Purpose: Creates a new data type and initializes it to reasonable
+ * values. The new data type is SIZE bytes and an instance of
+ * the class TYPE.
*
- * Return: Success: Pointer to the new type.
+ * Return: Success: Pointer to the new type.
*
- * Failure: NULL
+ * Failure: NULL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, December 5, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-H5T_t *
-H5T_create (H5T_class_t type, size_t size)
+H5T_t *
+H5T_create(H5T_class_t type, size_t size)
{
- H5T_t *dt = NULL;
-
- FUNC_ENTER (H5T_create, NULL);
-
- assert (size>0);
-
- switch (type) {
- case H5T_INTEGER:
- case H5T_FLOAT:
- case H5T_TIME:
- case H5T_STRING:
- case H5T_BITFIELD:
- case H5T_OPAQUE:
- HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, NULL,
- "type class is not appropriate - use H5Tcopy()");
-
- case H5T_COMPOUND:
- dt = H5MM_xcalloc (1, sizeof(H5T_t));
- dt->type = type;
- break;
-
- default:
- HRETURN_ERROR (H5E_INTERNAL, H5E_UNSUPPORTED, NULL,
- "unknown data type class");
- }
-
- dt->size = size;
- FUNC_LEAVE (dt);
+ H5T_t *dt = NULL;
+
+ FUNC_ENTER(H5T_create, NULL);
+
+ assert(size > 0);
+
+ switch (type) {
+ case H5T_INTEGER:
+ case H5T_FLOAT:
+ case H5T_TIME:
+ case H5T_STRING:
+ case H5T_BITFIELD:
+ case H5T_OPAQUE:
+ HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, NULL,
+ "type class is not appropriate - use H5Tcopy()");
+
+ case H5T_COMPOUND:
+ dt = H5MM_xcalloc(1, sizeof(H5T_t));
+ dt->type = type;
+ break;
+
+ default:
+ HRETURN_ERROR(H5E_INTERNAL, H5E_UNSUPPORTED, NULL,
+ "unknown data type class");
+ }
+
+ dt->size = size;
+ FUNC_LEAVE(dt);
}
-
/*-------------------------------------------------------------------------
- * Function: H5T_copy
+ * Function: H5T_copy
*
- * Purpose: Copies datatype OLD_DT. The resulting data type is not
- * locked.
+ * Purpose: Copies datatype OLD_DT. The resulting data type is not
+ * locked.
*
- * Return: Success: Pointer to a new copy of the OLD_DT argument.
+ * Return: Success: Pointer to a new copy of the OLD_DT argument.
*
- * Failure: NULL
+ * Failure: NULL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Thursday, December 4, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-H5T_t *
-H5T_copy (const H5T_t *old_dt)
+H5T_t *
+H5T_copy(const H5T_t *old_dt)
{
- H5T_t *new_dt = NULL;
- intn i;
- char *s;
-
- FUNC_ENTER (H5T_copy, NULL);
-
- /* check args */
- assert (old_dt);
-
- /* copy */
- new_dt = H5MM_xcalloc (1, sizeof(H5T_t));
- *new_dt = *old_dt;
- new_dt->locked = FALSE;
-
- if (H5T_COMPOUND==new_dt->type) {
- new_dt->u.compnd.memb = H5MM_xmalloc (new_dt->u.compnd.nmembs *
- sizeof(H5T_member_t));
- HDmemcpy (new_dt->u.compnd.memb, old_dt->u.compnd.memb,
- new_dt->u.compnd.nmembs * sizeof(H5T_member_t));
- for (i=0; i<new_dt->u.compnd.nmembs; i++) {
- s = new_dt->u.compnd.memb[i].name;
- new_dt->u.compnd.memb[i].name = H5MM_xstrdup (s);
- }
- }
-
- FUNC_LEAVE (new_dt);
+ H5T_t *new_dt = NULL;
+ intn i;
+ char *s;
+
+ FUNC_ENTER(H5T_copy, NULL);
+
+ /* check args */
+ assert(old_dt);
+
+ /* copy */
+ new_dt = H5MM_xcalloc(1, sizeof(H5T_t));
+ *new_dt = *old_dt;
+ new_dt->locked = FALSE;
+
+ if (H5T_COMPOUND == new_dt->type) {
+ new_dt->u.compnd.memb = H5MM_xmalloc(new_dt->u.compnd.nmembs *
+ sizeof(H5T_member_t));
+ HDmemcpy(new_dt->u.compnd.memb, old_dt->u.compnd.memb,
+ new_dt->u.compnd.nmembs * sizeof(H5T_member_t));
+ for (i = 0; i < new_dt->u.compnd.nmembs; i++) {
+ s = new_dt->u.compnd.memb[i].name;
+ new_dt->u.compnd.memb[i].name = H5MM_xstrdup(s);
+ }
+ }
+ FUNC_LEAVE(new_dt);
}
-
/*-------------------------------------------------------------------------
- * Function: H5T_close
+ * Function: H5T_close
*
- * Purpose: Frees a data type and all associated memory.
+ * Purpose: Frees a data type and all associated memory.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Monday, December 8, 1997
*
* Modifications:
@@ -2496,40 +2396,38 @@ H5T_copy (const H5T_t *old_dt)
*-------------------------------------------------------------------------
*/
herr_t
-H5T_close (H5T_t *dt)
+H5T_close(H5T_t *dt)
{
- intn i;
-
- FUNC_ENTER (H5T_close, FAIL);
-
- assert (dt);
- assert (!dt->locked);
-
- if (dt && H5T_COMPOUND==dt->type) {
- for (i=0; i<dt->u.compnd.nmembs; i++) {
- H5MM_xfree (dt->u.compnd.memb[i].name);
- }
- H5MM_xfree (dt->u.compnd.memb);
- H5MM_xfree (dt);
-
- } else if (dt) {
- H5MM_xfree (dt);
- }
-
- FUNC_LEAVE (SUCCEED);
-}
+ intn i;
+
+ FUNC_ENTER(H5T_close, FAIL);
+
+ assert(dt);
+ assert(!dt->locked);
+ if (dt && H5T_COMPOUND == dt->type) {
+ for (i = 0; i < dt->u.compnd.nmembs; i++) {
+ H5MM_xfree(dt->u.compnd.memb[i].name);
+ }
+ H5MM_xfree(dt->u.compnd.memb);
+ H5MM_xfree(dt);
+
+ } else if (dt) {
+ H5MM_xfree(dt);
+ }
+ FUNC_LEAVE(SUCCEED);
+}
/*-------------------------------------------------------------------------
- * Function: H5T_is_atomic
+ * Function: H5T_is_atomic
*
- * Purpose: Determines if a data type is an atomic type.
+ * Purpose: Determines if a data type is an atomic type.
*
- * Return: Success: TRUE, FALSE
+ * Return: Success: TRUE, FALSE
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
@@ -2537,28 +2435,27 @@ H5T_close (H5T_t *dt)
*-------------------------------------------------------------------------
*/
hbool_t
-H5T_is_atomic (const H5T_t *dt)
+H5T_is_atomic(const H5T_t *dt)
{
- FUNC_ENTER (H5T_is_atomic, FAIL);
+ FUNC_ENTER(H5T_is_atomic, FAIL);
- assert (dt);
+ assert(dt);
- FUNC_LEAVE (H5T_COMPOUND==dt->type ? FALSE : TRUE);
+ FUNC_LEAVE(H5T_COMPOUND == dt->type ? FALSE : TRUE);
}
-
/*-------------------------------------------------------------------------
- * Function: H5T_get_size
+ * Function: H5T_get_size
*
- * Purpose: Determines the total size of a data type in bytes.
+ * Purpose: Determines the total size of a data type in bytes.
*
- * Return: Success: Size of the data type in bytes. The size of
- * the data type is the size of an instance of
- * that data type.
+ * Return: Success: Size of the data type in bytes. The size of
+ * the data type is the size of an instance of
+ * that data type.
*
- * Failure: 0 (valid data types are never zero size)
+ * Failure: 0 (valid data types are never zero size)
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Tuesday, December 9, 1997
*
* Modifications:
@@ -2566,30 +2463,29 @@ H5T_is_atomic (const H5T_t *dt)
*-------------------------------------------------------------------------
*/
size_t
-H5T_get_size (const H5T_t *dt)
+H5T_get_size(const H5T_t *dt)
{
- FUNC_ENTER (H5T_get_size, 0);
+ FUNC_ENTER(H5T_get_size, 0);
- /* check args */
- assert (dt);
+ /* check args */
+ assert(dt);
- FUNC_LEAVE (dt->size);
+ FUNC_LEAVE(dt->size);
}
-
/*-------------------------------------------------------------------------
- * Function: H5T_insert
+ * Function: H5T_insert
*
- * Purpose: Adds a new MEMBER to the compound data type PARENT. The new
- * member will have a NAME that is unique within PARENT and an
- * instance of PARENT will have the member begin at byte offset
- * OFFSET from the beginning.
+ * Purpose: Adds a new MEMBER to the compound data type PARENT. The new
+ * member will have a NAME that is unique within PARENT and an
+ * instance of PARENT will have the member begin at byte offset
+ * OFFSET from the beginning.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Monday, December 8, 1997
*
* Modifications:
@@ -2597,73 +2493,71 @@ H5T_get_size (const H5T_t *dt)
*-------------------------------------------------------------------------
*/
herr_t
-H5T_insert (H5T_t *parent, const char *name, off_t offset, const H5T_t *member)
+H5T_insert(H5T_t *parent, const char *name, off_t offset, const H5T_t *member)
{
- intn i;
- H5T_t *tmp = NULL;
-
- FUNC_ENTER (H5T_insert, FAIL);
-
- /* check args */
- assert (parent && H5T_COMPOUND==parent->type);
- assert (!parent->locked);
- assert (member);
- assert (name && *name);
-
- /* Does NAME already exist in PARENT? */
- for (i=0; i<parent->u.compnd.nmembs; i++) {
- if (!HDstrcmp (parent->u.compnd.memb[i].name, name)) {
- HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINSERT, FAIL,
- "member name is not unique");
- }
- }
-
- /* Does the new member overlap any existing member ? */
- for (i=0; i<parent->u.compnd.nmembs; i++) {
- if ((offset<parent->u.compnd.memb[i].offset &&
- offset+member->size>parent->u.compnd.memb[i].offset) ||
- (parent->u.compnd.memb[i].offset<offset &&
- parent->u.compnd.memb[i].offset+
- parent->u.compnd.memb[i].type.size > offset)) {
- HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINSERT, FAIL,
- "member overlaps with another member");
- }
- }
-
- /* Increase member array if necessary */
- if (parent->u.compnd.nmembs>=parent->u.compnd.nalloc) {
- parent->u.compnd.nalloc += H5T_COMPND_INC;
- parent->u.compnd.memb = H5MM_xrealloc (parent->u.compnd.memb,
- (parent->u.compnd.nalloc*
- sizeof(H5T_member_t)));
- }
-
- /* Add member to end of member array */
- i = parent->u.compnd.nmembs;
- parent->u.compnd.memb[i].name = H5MM_xstrdup (name);
- parent->u.compnd.memb[i].offset = offset;
- parent->u.compnd.memb[i].ndims = 0; /*defaults to scalar*/
-
- tmp = H5T_copy (member);
- parent->u.compnd.memb[i].type = *tmp;
- H5MM_xfree (tmp);
-
- parent->u.compnd.nmembs++;
- FUNC_LEAVE (SUCCEED);
+ intn i;
+ H5T_t *tmp = NULL;
+
+ FUNC_ENTER(H5T_insert, FAIL);
+
+ /* check args */
+ assert(parent && H5T_COMPOUND == parent->type);
+ assert(!parent->locked);
+ assert(member);
+ assert(name && *name);
+
+ /* Does NAME already exist in PARENT? */
+ for (i = 0; i < parent->u.compnd.nmembs; i++) {
+ if (!HDstrcmp(parent->u.compnd.memb[i].name, name)) {
+ HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL,
+ "member name is not unique");
+ }
+ }
+
+ /* Does the new member overlap any existing member ? */
+ for (i = 0; i < parent->u.compnd.nmembs; i++) {
+ if ((offset < parent->u.compnd.memb[i].offset &&
+ offset + member->size > parent->u.compnd.memb[i].offset) ||
+ (parent->u.compnd.memb[i].offset < offset &&
+ parent->u.compnd.memb[i].offset +
+ parent->u.compnd.memb[i].type.size > offset)) {
+ HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINSERT, FAIL,
+ "member overlaps with another member");
+ }
+ }
+
+ /* Increase member array if necessary */
+ if (parent->u.compnd.nmembs >= parent->u.compnd.nalloc) {
+ parent->u.compnd.nalloc += H5T_COMPND_INC;
+ parent->u.compnd.memb = H5MM_xrealloc(parent->u.compnd.memb,
+ (parent->u.compnd.nalloc *
+ sizeof(H5T_member_t)));
+ }
+ /* Add member to end of member array */
+ i = parent->u.compnd.nmembs;
+ parent->u.compnd.memb[i].name = H5MM_xstrdup(name);
+ parent->u.compnd.memb[i].offset = offset;
+ parent->u.compnd.memb[i].ndims = 0; /*defaults to scalar */
+
+ tmp = H5T_copy(member);
+ parent->u.compnd.memb[i].type = *tmp;
+ H5MM_xfree(tmp);
+
+ parent->u.compnd.nmembs++;
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5T_pack
+ * Function: H5T_pack
*
- * Purpose: Recursively packs a compound data type by removing padding
- * bytes. This is done in place (that is, destructively).
+ * Purpose: Recursively packs a compound data type by removing padding
+ * bytes. This is done in place (that is, destructively).
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
@@ -2671,52 +2565,50 @@ H5T_insert (H5T_t *parent, const char *name, off_t offset, const H5T_t *member)
*-------------------------------------------------------------------------
*/
herr_t
-H5T_pack (H5T_t *dt)
+H5T_pack(H5T_t *dt)
{
- int i;
- size_t offset;
-
- FUNC_ENTER (H5T_pack, FAIL);
-
- assert (dt);
- assert (!dt->locked);
-
- if (H5T_COMPOUND==dt->type) {
- /* Recursively pack the members */
- for (i=0; i<dt->u.compnd.nmembs; i++) {
- if (H5T_pack (&(dt->u.compnd.memb[i].type))<0) {
- HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,
- "unable to pack part of a compound data type");
- }
- }
-
- /* Remove padding between members */
- H5T_sort_by_offset (dt);
- for (i=0, offset=0; i<dt->u.compnd.nmembs; i++) {
- dt->u.compnd.memb[i].offset = offset;
- offset += dt->u.compnd.memb[i].type.size;
- }
-
- /* Change total size */
- dt->size = MAX (1, offset);
- }
-
- FUNC_LEAVE (SUCCEED);
+ int i;
+ size_t offset;
+
+ FUNC_ENTER(H5T_pack, FAIL);
+
+ assert(dt);
+ assert(!dt->locked);
+
+ if (H5T_COMPOUND == dt->type) {
+ /* Recursively pack the members */
+ for (i = 0; i < dt->u.compnd.nmembs; i++) {
+ if (H5T_pack(&(dt->u.compnd.memb[i].type)) < 0) {
+ HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL,
+ "unable to pack part of a compound data type");
+ }
+ }
+
+ /* Remove padding between members */
+ H5T_sort_by_offset(dt);
+ for (i = 0, offset = 0; i < dt->u.compnd.nmembs; i++) {
+ dt->u.compnd.memb[i].offset = offset;
+ offset += dt->u.compnd.memb[i].type.size;
+ }
+
+ /* Change total size */
+ dt->size = MAX(1, offset);
+ }
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5T_sort_by_offset
+ * Function: H5T_sort_by_offset
*
- * Purpose: Sorts the members of a compound data type by their offsets.
- * This even works for locked data types since it doesn't change
- * the value of the type.
+ * Purpose: Sorts the members of a compound data type by their offsets.
+ * This even works for locked data types since it doesn't change
+ * the value of the type.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
@@ -2724,54 +2616,52 @@ H5T_pack (H5T_t *dt)
*-------------------------------------------------------------------------
*/
herr_t
-H5T_sort_by_offset (H5T_t *dt)
+H5T_sort_by_offset(H5T_t *dt)
{
- int i, j, nmembs;
- hbool_t swapped;
-
- FUNC_ENTER (H5T_sort_by_offset, FAIL);
-
- /* Check args */
- assert (dt);
- assert (H5T_COMPOUND==dt->type);
-
- /* Use a bubble sort because we can short circuit */
- nmembs = dt->u.compnd.nmembs;
- for (i=nmembs-1, swapped=TRUE; i>0 && swapped; --i) {
- for (j=0, swapped=FALSE; j<i; j++) {
- if (dt->u.compnd.memb[j].offset>dt->u.compnd.memb[j+1].offset) {
- H5T_member_t tmp = dt->u.compnd.memb[j];
- dt->u.compnd.memb[j] = dt->u.compnd.memb[j+1];
- dt->u.compnd.memb[j+1] = tmp;
- swapped = 1;
- }
- }
- }
+ int i, j, nmembs;
+ hbool_t swapped;
+
+ FUNC_ENTER(H5T_sort_by_offset, FAIL);
+
+ /* Check args */
+ assert(dt);
+ assert(H5T_COMPOUND == dt->type);
+
+ /* Use a bubble sort because we can short circuit */
+ nmembs = dt->u.compnd.nmembs;
+ for (i = nmembs - 1, swapped = TRUE; i > 0 && swapped; --i) {
+ for (j = 0, swapped = FALSE; j < i; j++) {
+ if (dt->u.compnd.memb[j].offset > dt->u.compnd.memb[j + 1].offset) {
+ H5T_member_t tmp = dt->u.compnd.memb[j];
+ dt->u.compnd.memb[j] = dt->u.compnd.memb[j + 1];
+ dt->u.compnd.memb[j + 1] = tmp;
+ swapped = 1;
+ }
+ }
+ }
#ifndef NDEBUG
- /* I never trust a sort :-) */
- for (i=0; i<dt->u.compnd.nmembs-1; i++) {
- assert (dt->u.compnd.memb[i].offset<dt->u.compnd.memb[i+1].offset);
- }
+ /* I never trust a sort :-) */
+ for (i = 0; i < dt->u.compnd.nmembs - 1; i++) {
+ assert(dt->u.compnd.memb[i].offset < dt->u.compnd.memb[i + 1].offset);
+ }
#endif
- FUNC_LEAVE (SUCCEED);
+ FUNC_LEAVE(SUCCEED);
}
-
-
/*-------------------------------------------------------------------------
- * Function: H5T_cmp
+ * Function: H5T_cmp
*
- * Purpose: Compares two data types.
+ * Purpose: Compares two data types.
*
- * Return: Success: 0 if DT1 and DT2 are equal.
- * <0 if DT1 is less than DT2.
- * >0 if DT1 is greater than DT2.
+ * Return: Success: 0 if DT1 and DT2 are equal.
+ * <0 if DT1 is less than DT2.
+ * >0 if DT1 is greater than DT2.
*
- * Failure: 0, never fails
+ * Failure: 0, never fails
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, December 10, 1997
*
* Modifications:
@@ -2779,213 +2669,264 @@ H5T_sort_by_offset (H5T_t *dt)
*-------------------------------------------------------------------------
*/
intn
-H5T_cmp (const H5T_t *dt1, const H5T_t *dt2)
+H5T_cmp(const H5T_t *dt1, const H5T_t *dt2)
{
- intn *idx1=NULL, *idx2=NULL;
- intn ret_value = 0;
- intn i, j, tmp;
- hbool_t swapped;
-
- FUNC_ENTER (H5T_equal, 0);
-
- /* check args */
- assert (dt1);
- assert (dt2);
-
- /* the easy case */
- if (dt1==dt2) HGOTO_DONE (0);
-
- /* compare */
- if (dt1->type < dt2->type) HGOTO_DONE (-1);
- if (dt1->type > dt2->type) HGOTO_DONE (1);
-
- if (dt1->size < dt2->size) HGOTO_DONE (-1);
- if (dt1->size > dt2->size) HGOTO_DONE (1);
-
- if (H5T_COMPOUND==dt1->type) {
- /*
- * Compound data types...
- */
- if (dt1->u.compnd.nmembs < dt2->u.compnd.nmembs) HGOTO_DONE (-1);
- if (dt1->u.compnd.nmembs > dt2->u.compnd.nmembs) HGOTO_DONE (1);
-
- /* Build an index for each type so the names are sorted */
- idx1 = H5MM_xmalloc (dt1->u.compnd.nmembs * sizeof(intn));
- idx2 = H5MM_xmalloc (dt1->u.compnd.nmembs * sizeof(intn));
- for (i=0; i<dt1->u.compnd.nmembs; i++) idx1[i] = idx2[i] = i;
- for (i=dt1->u.compnd.nmembs-1, swapped=TRUE; swapped && i>=0; --i) {
- for (j=0, swapped=FALSE; j<i; j++) {
- if (HDstrcmp (dt1->u.compnd.memb[idx1[j]].name,
- dt1->u.compnd.memb[idx1[j+1]].name)>0) {
- tmp = idx1[j];
- idx1[j] = idx1[j+1];
- idx1[j+1] = tmp;
- swapped = TRUE;
- }
- }
- }
- for (i=dt1->u.compnd.nmembs-1, swapped=TRUE; swapped && i>=0; --i) {
- for (j=0, swapped=FALSE; j<i; j++) {
- if (HDstrcmp (dt2->u.compnd.memb[idx2[j]].name,
- dt2->u.compnd.memb[idx2[j+1]].name)>0) {
- tmp = idx2[j];
- idx2[j] = idx2[j+1];
- idx2[j+1] = tmp;
- swapped = TRUE;
- }
- }
- }
-
+ intn *idx1 = NULL, *idx2 = NULL;
+ intn ret_value = 0;
+ intn i, j, tmp;
+ hbool_t swapped;
+
+ FUNC_ENTER(H5T_equal, 0);
+
+ /* check args */
+ assert(dt1);
+ assert(dt2);
+
+ /* the easy case */
+ if (dt1 == dt2)
+ HGOTO_DONE(0);
+
+ /* compare */
+ if (dt1->type < dt2->type)
+ HGOTO_DONE(-1);
+ if (dt1->type > dt2->type)
+ HGOTO_DONE(1);
+
+ if (dt1->size < dt2->size)
+ HGOTO_DONE(-1);
+ if (dt1->size > dt2->size)
+ HGOTO_DONE(1);
+
+ if (H5T_COMPOUND == dt1->type) {
+ /*
+ * Compound data types...
+ */
+ if (dt1->u.compnd.nmembs < dt2->u.compnd.nmembs)
+ HGOTO_DONE(-1);
+ if (dt1->u.compnd.nmembs > dt2->u.compnd.nmembs)
+ HGOTO_DONE(1);
+
+ /* Build an index for each type so the names are sorted */
+ idx1 = H5MM_xmalloc(dt1->u.compnd.nmembs * sizeof(intn));
+ idx2 = H5MM_xmalloc(dt1->u.compnd.nmembs * sizeof(intn));
+ for (i = 0; i < dt1->u.compnd.nmembs; i++)
+ idx1[i] = idx2[i] = i;
+ for (i = dt1->u.compnd.nmembs - 1, swapped = TRUE; swapped && i >= 0; --i) {
+ for (j = 0, swapped = FALSE; j < i; j++) {
+ if (HDstrcmp(dt1->u.compnd.memb[idx1[j]].name,
+ dt1->u.compnd.memb[idx1[j + 1]].name) > 0) {
+ tmp = idx1[j];
+ idx1[j] = idx1[j + 1];
+ idx1[j + 1] = tmp;
+ swapped = TRUE;
+ }
+ }
+ }
+ for (i = dt1->u.compnd.nmembs - 1, swapped = TRUE; swapped && i >= 0; --i) {
+ for (j = 0, swapped = FALSE; j < i; j++) {
+ if (HDstrcmp(dt2->u.compnd.memb[idx2[j]].name,
+ dt2->u.compnd.memb[idx2[j + 1]].name) > 0) {
+ tmp = idx2[j];
+ idx2[j] = idx2[j + 1];
+ idx2[j + 1] = tmp;
+ swapped = TRUE;
+ }
+ }
+ }
+
#ifndef NDEBUG
- /* I don't quite trust the code above yet :-) --RPM */
- for (i=0; i<dt1->u.compnd.nmembs; i++) {
- assert (HDstrcmp (dt1->u.compnd.memb[idx1[i]].name,
- dt1->u.compnd.memb[idx1[i+1]].name));
- assert (HDstrcmp (dt2->u.compnd.memb[idx2[i]].name,
- dt2->u.compnd.memb[idx2[i+1]].name));
- }
+ /* I don't quite trust the code above yet :-) --RPM */
+ for (i = 0; i < dt1->u.compnd.nmembs; i++) {
+ assert(HDstrcmp(dt1->u.compnd.memb[idx1[i]].name,
+ dt1->u.compnd.memb[idx1[i + 1]].name));
+ assert(HDstrcmp(dt2->u.compnd.memb[idx2[i]].name,
+ dt2->u.compnd.memb[idx2[i + 1]].name));
+ }
#endif
- /* Compare the members */
- for (i=0; i<dt1->u.compnd.nmembs; i++) {
- tmp = HDstrcmp (dt1->u.compnd.memb[idx1[i]].name,
- dt2->u.compnd.memb[idx2[i]].name);
- if (tmp<0) HGOTO_DONE (-1);
- if (tmp>0) HGOTO_DONE (1);
-
- if (dt1->u.compnd.memb[idx1[i]].offset <
- dt2->u.compnd.memb[idx2[i]].offset) HGOTO_DONE (-1);
- if (dt1->u.compnd.memb[idx1[i]].offset >
- dt2->u.compnd.memb[idx2[i]].offset) HGOTO_DONE (1);
-
- if (dt1->u.compnd.memb[idx1[i]].ndims <
- dt2->u.compnd.memb[idx2[i]].ndims) HGOTO_DONE (-1);
- if (dt1->u.compnd.memb[idx1[i]].ndims >
- dt2->u.compnd.memb[idx2[i]].ndims) HGOTO_DONE (1);
-
- for (j=0; j<dt1->u.compnd.memb[idx1[i]].ndims; j++) {
- if (dt1->u.compnd.memb[idx1[i]].dim[j] <
- dt2->u.compnd.memb[idx2[i]].dim[j]) HGOTO_DONE (-1);
- if (dt1->u.compnd.memb[idx1[i]].dim[j] >
- dt2->u.compnd.memb[idx2[i]].dim[j]) HGOTO_DONE (1);
- }
-
- for (j=0; j<dt1->u.compnd.memb[idx1[i]].ndims; j++) {
- if (dt1->u.compnd.memb[idx1[i]].perm[j] <
- dt2->u.compnd.memb[idx2[i]].perm[j]) HGOTO_DONE (-1);
- if (dt1->u.compnd.memb[idx1[i]].perm[j] >
- dt2->u.compnd.memb[idx2[i]].perm[j]) HGOTO_DONE (1);
- }
-
- tmp = H5T_cmp (&(dt1->u.compnd.memb[idx1[i]].type),
- &(dt2->u.compnd.memb[idx2[i]].type));
- if (tmp<0) HGOTO_DONE (-1);
- if (tmp>0) HGOTO_DONE (1);
- }
-
- } else {
- /*
- * Atomic data types...
- */
- if (dt1->u.atomic.order < dt2->u.atomic.order) HGOTO_DONE (-1);
- if (dt1->u.atomic.order > dt2->u.atomic.order) HGOTO_DONE (1);
-
- if (dt1->u.atomic.prec < dt2->u.atomic.prec) HGOTO_DONE (-1);
- if (dt1->u.atomic.prec > dt2->u.atomic.prec) HGOTO_DONE (1);
-
- if (dt1->u.atomic.offset < dt2->u.atomic.offset) HGOTO_DONE (-1);
- if (dt1->u.atomic.offset > dt2->u.atomic.offset) HGOTO_DONE (1);
-
- if (dt1->u.atomic.lsb_pad < dt2->u.atomic.lsb_pad) HGOTO_DONE (-1);
- if (dt1->u.atomic.lsb_pad > dt2->u.atomic.lsb_pad) HGOTO_DONE (1);
-
- if (dt1->u.atomic.msb_pad < dt2->u.atomic.msb_pad) HGOTO_DONE (-1);
- if (dt1->u.atomic.msb_pad > dt2->u.atomic.msb_pad) HGOTO_DONE (1);
-
- switch (dt1->type) {
- case H5T_INTEGER:
- if (dt1->u.atomic.u.i.sign < dt2->u.atomic.u.i.sign) HGOTO_DONE (-1);
- if (dt1->u.atomic.u.i.sign > dt2->u.atomic.u.i.sign) HGOTO_DONE (1);
- break;
-
- case H5T_FLOAT:
- if (dt1->u.atomic.u.f.sign < dt2->u.atomic.u.f.sign) HGOTO_DONE (-1);
- if (dt1->u.atomic.u.f.sign > dt2->u.atomic.u.f.sign) HGOTO_DONE (1);
-
- if (dt1->u.atomic.u.f.epos < dt2->u.atomic.u.f.epos) HGOTO_DONE (-1);
- if (dt1->u.atomic.u.f.epos > dt2->u.atomic.u.f.epos) HGOTO_DONE (1);
-
- if (dt1->u.atomic.u.f.esize <
- dt2->u.atomic.u.f.esize) HGOTO_DONE (-1);
- if (dt1->u.atomic.u.f.esize >
- dt2->u.atomic.u.f.esize) HGOTO_DONE (1);
-
- if (dt1->u.atomic.u.f.ebias <
- dt2->u.atomic.u.f.ebias) HGOTO_DONE (-1);
- if (dt1->u.atomic.u.f.ebias >
- dt2->u.atomic.u.f.ebias) HGOTO_DONE (1);
-
- if (dt1->u.atomic.u.f.mpos < dt2->u.atomic.u.f.mpos) HGOTO_DONE (-1);
- if (dt1->u.atomic.u.f.mpos > dt2->u.atomic.u.f.mpos) HGOTO_DONE (1);
-
- if (dt1->u.atomic.u.f.msize <
- dt2->u.atomic.u.f.msize) HGOTO_DONE (-1);
- if (dt1->u.atomic.u.f.msize >
- dt2->u.atomic.u.f.msize) HGOTO_DONE (1);
-
- if (dt1->u.atomic.u.f.norm < dt2->u.atomic.u.f.norm) HGOTO_DONE (-1);
- if (dt1->u.atomic.u.f.norm > dt2->u.atomic.u.f.norm) HGOTO_DONE (1);
-
- if (dt1->u.atomic.u.f.pad < dt2->u.atomic.u.f.pad) HGOTO_DONE (-1);
- if (dt1->u.atomic.u.f.pad > dt2->u.atomic.u.f.pad) HGOTO_DONE (1);
-
- break;
-
- case H5T_TIME:
- /*void*/
- break;
-
- case H5T_STRING:
- if (dt1->u.atomic.u.s.cset < dt1->u.atomic.u.s.cset) HGOTO_DONE (-1);
- if (dt1->u.atomic.u.s.cset > dt1->u.atomic.u.s.cset) HGOTO_DONE (1);
-
- if (dt1->u.atomic.u.s.pad < dt1->u.atomic.u.s.pad) HGOTO_DONE (-1);
- if (dt1->u.atomic.u.s.pad > dt1->u.atomic.u.s.pad) HGOTO_DONE (1);
-
- break;
-
- case H5T_BITFIELD:
- /*void*/
- break;
-
- case H5T_OPAQUE:
- /*void*/
- break;
-
- default:
- assert ("not implemented yet" && 0);
- }
- }
-
- done:
- H5MM_xfree (idx1);
- H5MM_xfree (idx2);
-
- FUNC_LEAVE (ret_value);
+ /* Compare the members */
+ for (i = 0; i < dt1->u.compnd.nmembs; i++) {
+ tmp = HDstrcmp(dt1->u.compnd.memb[idx1[i]].name,
+ dt2->u.compnd.memb[idx2[i]].name);
+ if (tmp < 0)
+ HGOTO_DONE(-1);
+ if (tmp > 0)
+ HGOTO_DONE(1);
+
+ if (dt1->u.compnd.memb[idx1[i]].offset <
+ dt2->u.compnd.memb[idx2[i]].offset)
+ HGOTO_DONE(-1);
+ if (dt1->u.compnd.memb[idx1[i]].offset >
+ dt2->u.compnd.memb[idx2[i]].offset)
+ HGOTO_DONE(1);
+
+ if (dt1->u.compnd.memb[idx1[i]].ndims <
+ dt2->u.compnd.memb[idx2[i]].ndims)
+ HGOTO_DONE(-1);
+ if (dt1->u.compnd.memb[idx1[i]].ndims >
+ dt2->u.compnd.memb[idx2[i]].ndims)
+ HGOTO_DONE(1);
+
+ for (j = 0; j < dt1->u.compnd.memb[idx1[i]].ndims; j++) {
+ if (dt1->u.compnd.memb[idx1[i]].dim[j] <
+ dt2->u.compnd.memb[idx2[i]].dim[j])
+ HGOTO_DONE(-1);
+ if (dt1->u.compnd.memb[idx1[i]].dim[j] >
+ dt2->u.compnd.memb[idx2[i]].dim[j])
+ HGOTO_DONE(1);
+ }
+
+ for (j = 0; j < dt1->u.compnd.memb[idx1[i]].ndims; j++) {
+ if (dt1->u.compnd.memb[idx1[i]].perm[j] <
+ dt2->u.compnd.memb[idx2[i]].perm[j])
+ HGOTO_DONE(-1);
+ if (dt1->u.compnd.memb[idx1[i]].perm[j] >
+ dt2->u.compnd.memb[idx2[i]].perm[j])
+ HGOTO_DONE(1);
+ }
+
+ tmp = H5T_cmp(&(dt1->u.compnd.memb[idx1[i]].type),
+ &(dt2->u.compnd.memb[idx2[i]].type));
+ if (tmp < 0)
+ HGOTO_DONE(-1);
+ if (tmp > 0)
+ HGOTO_DONE(1);
+ }
+
+ } else {
+ /*
+ * Atomic data types...
+ */
+ if (dt1->u.atomic.order < dt2->u.atomic.order)
+ HGOTO_DONE(-1);
+ if (dt1->u.atomic.order > dt2->u.atomic.order)
+ HGOTO_DONE(1);
+
+ if (dt1->u.atomic.prec < dt2->u.atomic.prec)
+ HGOTO_DONE(-1);
+ if (dt1->u.atomic.prec > dt2->u.atomic.prec)
+ HGOTO_DONE(1);
+
+ if (dt1->u.atomic.offset < dt2->u.atomic.offset)
+ HGOTO_DONE(-1);
+ if (dt1->u.atomic.offset > dt2->u.atomic.offset)
+ HGOTO_DONE(1);
+
+ if (dt1->u.atomic.lsb_pad < dt2->u.atomic.lsb_pad)
+ HGOTO_DONE(-1);
+ if (dt1->u.atomic.lsb_pad > dt2->u.atomic.lsb_pad)
+ HGOTO_DONE(1);
+
+ if (dt1->u.atomic.msb_pad < dt2->u.atomic.msb_pad)
+ HGOTO_DONE(-1);
+ if (dt1->u.atomic.msb_pad > dt2->u.atomic.msb_pad)
+ HGOTO_DONE(1);
+
+ switch (dt1->type) {
+ case H5T_INTEGER:
+ if (dt1->u.atomic.u.i.sign < dt2->u.atomic.u.i.sign)
+ HGOTO_DONE(-1);
+ if (dt1->u.atomic.u.i.sign > dt2->u.atomic.u.i.sign)
+ HGOTO_DONE(1);
+ break;
+
+ case H5T_FLOAT:
+ if (dt1->u.atomic.u.f.sign < dt2->u.atomic.u.f.sign)
+ HGOTO_DONE(-1);
+ if (dt1->u.atomic.u.f.sign > dt2->u.atomic.u.f.sign)
+ HGOTO_DONE(1);
+
+ if (dt1->u.atomic.u.f.epos < dt2->u.atomic.u.f.epos)
+ HGOTO_DONE(-1);
+ if (dt1->u.atomic.u.f.epos > dt2->u.atomic.u.f.epos)
+ HGOTO_DONE(1);
+
+ if (dt1->u.atomic.u.f.esize <
+ dt2->u.atomic.u.f.esize)
+ HGOTO_DONE(-1);
+ if (dt1->u.atomic.u.f.esize >
+ dt2->u.atomic.u.f.esize)
+ HGOTO_DONE(1);
+
+ if (dt1->u.atomic.u.f.ebias <
+ dt2->u.atomic.u.f.ebias)
+ HGOTO_DONE(-1);
+ if (dt1->u.atomic.u.f.ebias >
+ dt2->u.atomic.u.f.ebias)
+ HGOTO_DONE(1);
+
+ if (dt1->u.atomic.u.f.mpos < dt2->u.atomic.u.f.mpos)
+ HGOTO_DONE(-1);
+ if (dt1->u.atomic.u.f.mpos > dt2->u.atomic.u.f.mpos)
+ HGOTO_DONE(1);
+
+ if (dt1->u.atomic.u.f.msize <
+ dt2->u.atomic.u.f.msize)
+ HGOTO_DONE(-1);
+ if (dt1->u.atomic.u.f.msize >
+ dt2->u.atomic.u.f.msize)
+ HGOTO_DONE(1);
+
+ if (dt1->u.atomic.u.f.norm < dt2->u.atomic.u.f.norm)
+ HGOTO_DONE(-1);
+ if (dt1->u.atomic.u.f.norm > dt2->u.atomic.u.f.norm)
+ HGOTO_DONE(1);
+
+ if (dt1->u.atomic.u.f.pad < dt2->u.atomic.u.f.pad)
+ HGOTO_DONE(-1);
+ if (dt1->u.atomic.u.f.pad > dt2->u.atomic.u.f.pad)
+ HGOTO_DONE(1);
+
+ break;
+
+ case H5T_TIME:
+ /*void */
+ break;
+
+ case H5T_STRING:
+ if (dt1->u.atomic.u.s.cset < dt1->u.atomic.u.s.cset)
+ HGOTO_DONE(-1);
+ if (dt1->u.atomic.u.s.cset > dt1->u.atomic.u.s.cset)
+ HGOTO_DONE(1);
+
+ if (dt1->u.atomic.u.s.pad < dt1->u.atomic.u.s.pad)
+ HGOTO_DONE(-1);
+ if (dt1->u.atomic.u.s.pad > dt1->u.atomic.u.s.pad)
+ HGOTO_DONE(1);
+
+ break;
+
+ case H5T_BITFIELD:
+ /*void */
+ break;
+
+ case H5T_OPAQUE:
+ /*void */
+ break;
+
+ default:
+ assert("not implemented yet" && 0);
+ }
+ }
+
+ done:
+ H5MM_xfree(idx1);
+ H5MM_xfree(idx2);
+
+ FUNC_LEAVE(ret_value);
}
-
/*-------------------------------------------------------------------------
- * Function: H5T_find
+ * Function: H5T_find
*
- * Purpose: Finds a conversion function for the specified path.
+ * Purpose: Finds a conversion function for the specified path.
*
- * Return: Success: A pointer to an appropriate conversion
- * function.
+ * Return: Success: A pointer to an appropriate conversion
+ * function.
*
- * Failure: NULL
+ * Failure: NULL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, January 14, 1998
*
* Modifications:
@@ -2993,143 +2934,142 @@ H5T_cmp (const H5T_t *dt1, const H5T_t *dt2)
*-------------------------------------------------------------------------
*/
H5T_conv_t
-H5T_find (const H5T_t *src, const H5T_t *dst)
+H5T_find(const H5T_t *src, const H5T_t *dst)
{
- H5T_path_t *path = NULL;
- H5T_conv_t ret_value = NULL;
-
- FUNC_ENTER (H5T_find, NULL);
-
- /* Check args */
- assert (src);
- assert (dst);
-
- /* No-op case */
- if (0==H5T_cmp (src, dst)) HRETURN (H5T_conv_noop);
-
- /* Find it */
- if (NULL==(path=H5T_path_find (src, dst, TRUE))) {
- HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, NULL,
- "unable to create conversion path");
- }
- ret_value = path->hard;
- if (!ret_value) ret_value = path->soft;
-
- if (!ret_value) {
- HRETURN_ERROR (H5E_DATATYPE, H5E_NOTFOUND, NULL,
- "no conversion function for that path");
- }
-
- FUNC_LEAVE (ret_value);
+ H5T_path_t *path = NULL;
+ H5T_conv_t ret_value = NULL;
+
+ FUNC_ENTER(H5T_find, NULL);
+
+ /* Check args */
+ assert(src);
+ assert(dst);
+
+ /* No-op case */
+ if (0 == H5T_cmp(src, dst))
+ HRETURN(H5T_conv_noop);
+
+ /* Find it */
+ if (NULL == (path = H5T_path_find(src, dst, TRUE))) {
+ HRETURN_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL,
+ "unable to create conversion path");
+ }
+ ret_value = path->hard;
+ if (!ret_value)
+ ret_value = path->soft;
+
+ if (!ret_value) {
+ HRETURN_ERROR(H5E_DATATYPE, H5E_NOTFOUND, NULL,
+ "no conversion function for that path");
+ }
+ FUNC_LEAVE(ret_value);
}
-
/*-------------------------------------------------------------------------
- * Function: H5T_path_find
+ * Function: H5T_path_find
*
- * Purpose: Finds the path which converts type SRC_ID to type DST_ID. If
- * the path isn't found and CREATE is non-zero then a new path
- * is created.
+ * Purpose: Finds the path which converts type SRC_ID to type DST_ID. If
+ * the path isn't found and CREATE is non-zero then a new path
+ * is created.
*
- * Return: Success: Pointer to the path, valid until the path
- * database is modified.
+ * Return: Success: Pointer to the path, valid until the path
+ * database is modified.
*
- * Failure: NULL
+ * Failure: NULL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Tuesday, January 13, 1998
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-H5T_path_t *
-H5T_path_find (const H5T_t *src, const H5T_t *dst, hbool_t create)
+H5T_path_t *
+H5T_path_find(const H5T_t *src, const H5T_t *dst, hbool_t create)
{
- intn lt = 0; /*left edge (inclusive) */
- intn rt = H5T_npath_g; /*right edge (exclusive) */
- intn md = 0; /*middle */
- intn cmp = -1; /*comparison result */
- H5T_path_t *path = NULL; /*path found */
- int i;
- hid_t src_id, dst_id;
-
- FUNC_ENTER (H5T_path_find, NULL);
-
- /* Check args */
- assert (src);
- assert (dst);
-
- /* Binary search */
- while (lt<rt) {
- md = (lt+rt)/2;
-
- cmp = H5T_cmp (src, H5T_path_g[md].src);
- if (0==cmp) cmp = H5T_cmp (dst, H5T_path_g[md].dst);
-
- if (cmp<0) {
- rt = md;
- } else if (cmp>0) {
- lt = md+1;
- } else {
- HRETURN (H5T_path_g+md);
- }
- }
-
- /* Insert */
- if (create) {
- if (H5T_npath_g>=H5T_apath_g) {
- H5T_apath_g = MAX (64, 2*H5T_apath_g);
- H5T_path_g = H5MM_xrealloc (H5T_path_g,
- H5T_apath_g*sizeof(H5T_path_t));
- }
- if (cmp>0) md++;
-
- /* make room */
- HDmemmove (H5T_path_g+md+1, H5T_path_g+md,
- (H5T_npath_g-md)*sizeof(H5T_path_t));
- H5T_npath_g++;
-
- /* insert */
- path = H5T_path_g + md;
- HDmemset (path, 0, sizeof(H5T_path_t));
- path->src = H5T_copy (src);
- path->dst = H5T_copy (dst);
-
- /* Locate soft function */
- for (i=H5T_nsoft_g-1; i>=0 && !path->soft; --i) {
- if (src->type!=H5T_soft_g[i].src || dst->type!=H5T_soft_g[i].dst) {
- continue;
- }
-
- if ((src_id=H5Aregister_atom (H5_DATATYPE, H5T_copy (path->src)))<0 ||
- (dst_id=H5Aregister_atom (H5_DATATYPE, H5T_copy (path->dst)))<0) {
- HRETURN_ERROR (H5E_DATATYPE, H5E_CANTREGISTER, NULL,
- "unable to register conv types for query");
- }
- if ((H5T_soft_g[i].func)(src_id, dst_id, 0, NULL, NULL)>=0) {
- path->soft = H5T_soft_g[i].func;
- }
- H5A_dec_ref (src_id);
- H5A_dec_ref (dst_id);
- H5ECLEAR;
- }
- }
-
- FUNC_LEAVE (path);
+ intn lt = 0; /*left edge (inclusive) */
+ intn rt = H5T_npath_g; /*right edge (exclusive) */
+ intn md = 0; /*middle */
+ intn cmp = -1; /*comparison result */
+ H5T_path_t *path = NULL; /*path found */
+ int i;
+ hid_t src_id, dst_id;
+
+ FUNC_ENTER(H5T_path_find, NULL);
+
+ /* Check args */
+ assert(src);
+ assert(dst);
+
+ /* Binary search */
+ while (lt < rt) {
+ md = (lt + rt) / 2;
+
+ cmp = H5T_cmp(src, H5T_path_g[md].src);
+ if (0 == cmp)
+ cmp = H5T_cmp(dst, H5T_path_g[md].dst);
+
+ if (cmp < 0) {
+ rt = md;
+ } else if (cmp > 0) {
+ lt = md + 1;
+ } else {
+ HRETURN(H5T_path_g + md);
+ }
+ }
+
+ /* Insert */
+ if (create) {
+ if (H5T_npath_g >= H5T_apath_g) {
+ H5T_apath_g = MAX(64, 2 * H5T_apath_g);
+ H5T_path_g = H5MM_xrealloc(H5T_path_g,
+ H5T_apath_g * sizeof(H5T_path_t));
+ }
+ if (cmp > 0)
+ md++;
+
+ /* make room */
+ HDmemmove(H5T_path_g + md + 1, H5T_path_g + md,
+ (H5T_npath_g - md) * sizeof(H5T_path_t));
+ H5T_npath_g++;
+
+ /* insert */
+ path = H5T_path_g + md;
+ HDmemset(path, 0, sizeof(H5T_path_t));
+ path->src = H5T_copy(src);
+ path->dst = H5T_copy(dst);
+
+ /* Locate soft function */
+ for (i = H5T_nsoft_g - 1; i >= 0 && !path->soft; --i) {
+ if (src->type != H5T_soft_g[i].src || dst->type != H5T_soft_g[i].dst) {
+ continue;
+ }
+ if ((src_id = H5Aregister_atom(H5_DATATYPE, H5T_copy(path->src))) < 0 ||
+ (dst_id = H5Aregister_atom(H5_DATATYPE, H5T_copy(path->dst))) < 0) {
+ HRETURN_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, NULL,
+ "unable to register conv types for query");
+ }
+ if ((H5T_soft_g[i].func) (src_id, dst_id, 0, NULL, NULL) >= 0) {
+ path->soft = H5T_soft_g[i].func;
+ }
+ H5A_dec_ref(src_id);
+ H5A_dec_ref(dst_id);
+ H5ECLEAR;
+ }
+ }
+ FUNC_LEAVE(path);
}
-
/*-------------------------------------------------------------------------
- * Function: H5T_debug
+ * Function: H5T_debug
*
- * Purpose: Prints information about a data type.
+ * Purpose: Prints information about a data type.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, January 7, 1998
*
* Modifications:
@@ -3137,153 +3077,150 @@ H5T_path_find (const H5T_t *src, const H5T_t *dst, hbool_t create)
*-------------------------------------------------------------------------
*/
herr_t
-H5T_debug (H5T_t *dt, FILE *stream)
+H5T_debug(H5T_t *dt, FILE * stream)
{
- const char *s = "";
- int i, j;
- uint64 tmp;
-
- FUNC_ENTER (H5T_debug, FAIL);
-
- /* Check args */
- assert (dt);
- assert (stream);
-
- switch (dt->type) {
- case H5T_INTEGER:
- s = "int";
- break;
- case H5T_FLOAT:
- s = "float";
- break;
- case H5T_TIME:
- s = "time";
- break;
- case H5T_STRING:
- s = "str";
- break;
- case H5T_BITFIELD:
- s = "bits";
- break;
- case H5T_OPAQUE:
- s = "opaque";
- break;
- case H5T_COMPOUND:
- s = "struct";
- break;
- default:
- s = "";
- break;
- }
-
- fprintf (stream, "%s%s {nbytes=%d",
- s, dt->locked?"[!]":"", dt->size);
-
- if (H5T_is_atomic (dt)) {
- switch (dt->u.atomic.order) {
- case H5T_ORDER_BE:
- s = "BE";
- break;
- case H5T_ORDER_LE:
- s = "LE";
- break;
- case H5T_ORDER_VAX:
- s = "VAX";
- break;
- case H5T_ORDER_NONE:
- s = "NONE";
- break;
- default:
- s = "order?";
- break;
- }
- fprintf (stream, ", %s", s);
-
- if (dt->u.atomic.offset) {
- fprintf (stream, ", offset=%lu",
- (unsigned long)(dt->u.atomic.offset));
- }
- if (dt->u.atomic.prec!=8*dt->size) {
- fprintf (stream, ", prec=%lu",
- (unsigned long)(dt->u.atomic.prec));
- }
-
- switch (dt->type) {
- case H5T_INTEGER:
- switch (dt->u.atomic.u.i.sign) {
- case H5T_SGN_NONE:
- s = "unsigned";
- break;
- case H5T_SGN_2:
- s = NULL;
- break;
- default:
- s = "sign?";
- break;
- }
- if (s) fprintf (stream, ", %s", s);
- break;
-
- case H5T_FLOAT:
- switch (dt->u.atomic.u.f.norm) {
- case H5T_NORM_IMPLIED:
- s = "implied";
- break;
- case H5T_NORM_MSBSET:
- s = "msbset";
- break;
- case H5T_NORM_NONE:
- s = "no-norm";
- break;
- default:
- s = "norm?";
- break;
- }
- fprintf (stream, ", sign=%lu+1",
- (unsigned long)(dt->u.atomic.u.f.sign));
- fprintf (stream, ", mant=%lu+%lu (%s)",
- (unsigned long)(dt->u.atomic.u.f.mpos),
- (unsigned long)(dt->u.atomic.u.f.msize), s);
- fprintf (stream, ", exp=%lu+%lu",
- (unsigned long)(dt->u.atomic.u.f.epos),
- (unsigned long)(dt->u.atomic.u.f.esize));
- tmp = dt->u.atomic.u.f.ebias >> 32;
- if (tmp) {
- uintn hi = tmp;
- uintn lo = dt->u.atomic.u.f.ebias & 0xffffffff;
- fprintf (stream, " bias=0x%08x%08x", hi, lo);
- } else {
- uintn lo = dt->u.atomic.u.f.ebias & 0xffffffff;
- fprintf (stream, " bias=0x%08x", lo);
- }
- break;
-
- default:
- /* No additional info */
- break;
- }
- } else {
- for (i=0; i<dt->u.compnd.nmembs; i++) {
- fprintf (stream, "\n\"%s\" @%lu",
- dt->u.compnd.memb[i].name,
- (unsigned long)(dt->u.compnd.memb[i].offset));
- if (dt->u.compnd.memb[i].ndims) {
- fprintf (stream, "[");
- for (j=0; j<dt->u.compnd.memb[i].ndims; j++) {
- fprintf (stream, "%s%d", j?", ":"",
- dt->u.compnd.memb[i].dim[j]);
- }
- fprintf (stream, "]");
- }
- fprintf (stream, " ");
- H5T_debug (&(dt->u.compnd.memb[i].type), stream);
- }
- fprintf (stream, "\n");
- }
- fprintf (stream, "}");
-
- FUNC_LEAVE (SUCCEED);
+ const char *s = "";
+ int i, j;
+ uint64 tmp;
+
+ FUNC_ENTER(H5T_debug, FAIL);
+
+ /* Check args */
+ assert(dt);
+ assert(stream);
+
+ switch (dt->type) {
+ case H5T_INTEGER:
+ s = "int";
+ break;
+ case H5T_FLOAT:
+ s = "float";
+ break;
+ case H5T_TIME:
+ s = "time";
+ break;
+ case H5T_STRING:
+ s = "str";
+ break;
+ case H5T_BITFIELD:
+ s = "bits";
+ break;
+ case H5T_OPAQUE:
+ s = "opaque";
+ break;
+ case H5T_COMPOUND:
+ s = "struct";
+ break;
+ default:
+ s = "";
+ break;
+ }
+
+ fprintf(stream, "%s%s {nbytes=%d",
+ s, dt->locked ? "[!]" : "", dt->size);
+
+ if (H5T_is_atomic(dt)) {
+ switch (dt->u.atomic.order) {
+ case H5T_ORDER_BE:
+ s = "BE";
+ break;
+ case H5T_ORDER_LE:
+ s = "LE";
+ break;
+ case H5T_ORDER_VAX:
+ s = "VAX";
+ break;
+ case H5T_ORDER_NONE:
+ s = "NONE";
+ break;
+ default:
+ s = "order?";
+ break;
+ }
+ fprintf(stream, ", %s", s);
+
+ if (dt->u.atomic.offset) {
+ fprintf(stream, ", offset=%lu",
+ (unsigned long) (dt->u.atomic.offset));
+ }
+ if (dt->u.atomic.prec != 8 * dt->size) {
+ fprintf(stream, ", prec=%lu",
+ (unsigned long) (dt->u.atomic.prec));
+ }
+ switch (dt->type) {
+ case H5T_INTEGER:
+ switch (dt->u.atomic.u.i.sign) {
+ case H5T_SGN_NONE:
+ s = "unsigned";
+ break;
+ case H5T_SGN_2:
+ s = NULL;
+ break;
+ default:
+ s = "sign?";
+ break;
+ }
+ if (s)
+ fprintf(stream, ", %s", s);
+ break;
+
+ case H5T_FLOAT:
+ switch (dt->u.atomic.u.f.norm) {
+ case H5T_NORM_IMPLIED:
+ s = "implied";
+ break;
+ case H5T_NORM_MSBSET:
+ s = "msbset";
+ break;
+ case H5T_NORM_NONE:
+ s = "no-norm";
+ break;
+ default:
+ s = "norm?";
+ break;
+ }
+ fprintf(stream, ", sign=%lu+1",
+ (unsigned long) (dt->u.atomic.u.f.sign));
+ fprintf(stream, ", mant=%lu+%lu (%s)",
+ (unsigned long) (dt->u.atomic.u.f.mpos),
+ (unsigned long) (dt->u.atomic.u.f.msize), s);
+ fprintf(stream, ", exp=%lu+%lu",
+ (unsigned long) (dt->u.atomic.u.f.epos),
+ (unsigned long) (dt->u.atomic.u.f.esize));
+ tmp = dt->u.atomic.u.f.ebias >> 32;
+ if (tmp) {
+ uintn hi = tmp;
+ uintn lo = dt->u.atomic.u.f.ebias & 0xffffffff;
+ fprintf(stream, " bias=0x%08x%08x", hi, lo);
+ } else {
+ uintn lo = dt->u.atomic.u.f.ebias & 0xffffffff;
+ fprintf(stream, " bias=0x%08x", lo);
+ }
+ break;
+
+ default:
+ /* No additional info */
+ break;
+ }
+ } else {
+ for (i = 0; i < dt->u.compnd.nmembs; i++) {
+ fprintf(stream, "\n\"%s\" @%lu",
+ dt->u.compnd.memb[i].name,
+ (unsigned long) (dt->u.compnd.memb[i].offset));
+ if (dt->u.compnd.memb[i].ndims) {
+ fprintf(stream, "[");
+ for (j = 0; j < dt->u.compnd.memb[i].ndims; j++) {
+ fprintf(stream, "%s%d", j ? ", " : "",
+ dt->u.compnd.memb[i].dim[j]);
+ }
+ fprintf(stream, "]");
+ }
+ fprintf(stream, " ");
+ H5T_debug(&(dt->u.compnd.memb[i].type), stream);
+ }
+ fprintf(stream, "\n");
+ }
+ fprintf(stream, "}");
+
+ FUNC_LEAVE(SUCCEED);
}
-
-
-
diff --git a/src/H5Tconv.c b/src/H5Tconv.c
index 8fcfe02..739876d 100644
--- a/src/H5Tconv.c
+++ b/src/H5Tconv.c
@@ -5,29 +5,28 @@
* Programmer: Robb Matzke <robb@arborea.spizella.com>
* Tuesday, January 13, 1998
*
- * Purpose: Data type conversions.
+ * Purpose: Data type conversions.
*/
-#define H5T_PACKAGE /*suppress error about including H5Tpkg */
+#define H5T_PACKAGE /*suppress error about including H5Tpkg */
#include <H5Eprivate.h>
#include <H5Tpkg.h>
/* Interface initialization */
-static intn interface_initialize_g = FALSE;
+static intn interface_initialize_g = FALSE;
#define INTERFACE_INIT NULL
-
/*-------------------------------------------------------------------------
- * Function: H5T_conv_noop
+ * Function: H5T_conv_noop
*
- * Purpose: The no-op conversion. The library knows about this
- * conversion without it being registered.
+ * Purpose: The no-op conversion. The library knows about this
+ * conversion without it being registered.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: never fails
+ * Failure: never fails
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Wednesday, January 14, 1998
*
* Modifications:
@@ -35,27 +34,26 @@ static intn interface_initialize_g = FALSE;
*-------------------------------------------------------------------------
*/
herr_t
-H5T_conv_noop (hid_t src_id, hid_t dst_id, size_t nelmts,
- void *buf, const void *background)
+H5T_conv_noop(hid_t src_id, hid_t dst_id, size_t nelmts,
+ void *buf, const void *background)
{
- FUNC_ENTER (H5T_conv_noop, FAIL);
- FUNC_LEAVE (SUCCEED);
+ FUNC_ENTER(H5T_conv_noop, FAIL);
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5T_conv_order
+ * Function: H5T_conv_order
*
- * Purpose: Convert one type to another when byte order is the only
- * difference.
+ * Purpose: Convert one type to another when byte order is the only
+ * difference.
*
- * Note: This is a soft conversion function.
+ * Note: This is a soft conversion function.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Tuesday, January 13, 1998
*
* Modifications:
@@ -63,78 +61,74 @@ H5T_conv_noop (hid_t src_id, hid_t dst_id, size_t nelmts,
*-------------------------------------------------------------------------
*/
herr_t
-H5T_conv_order (hid_t src_id, hid_t dst_id, size_t nelmts,
- void *_buf, const void *background)
+H5T_conv_order(hid_t src_id, hid_t dst_id, size_t nelmts,
+ void *_buf, const void *background)
{
- uint8 *buf = (uint8*)_buf;
- uint8 tmp;
- H5T_t *src = NULL;
- H5T_t *dst = NULL;
- intn i, j, md;
-
- FUNC_ENTER (H5T_conv_order, FAIL);
+ uint8 *buf = (uint8 *) _buf;
+ uint8 tmp;
+ H5T_t *src = NULL;
+ H5T_t *dst = NULL;
+ intn i, j, md;
- /* Check args */
- if (H5_DATATYPE!=H5Aatom_group (src_id) ||
- NULL==(src=H5Aatom_object (src_id)) ||
- H5_DATATYPE!=H5Aatom_group (dst_id) ||
- NULL==(dst=H5Aatom_object (dst_id))) {
- HRETURN_ERROR (H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
- }
- if (background) {
- HRETURN_ERROR (H5E_ARGS, H5E_UNSUPPORTED, FAIL,
- "background values not supported in this conv path");
- }
-
- if (!buf) {
- /* Capability query */
- if (src->size!=dst->size ||
- 0!=src->u.atomic.offset ||
- 0!=dst->u.atomic.offset ||
- !((H5T_ORDER_BE==src->u.atomic.order &&
- H5T_ORDER_LE==dst->u.atomic.order) ||
- (H5T_ORDER_LE==src->u.atomic.order &&
- H5T_ORDER_BE==dst->u.atomic.order))) {
- HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "conversion not supported");
- }
-
- switch (src->type) {
- case H5T_INTEGER:
- /* nothing to check */
- break;
+ FUNC_ENTER(H5T_conv_order, FAIL);
- case H5T_FLOAT:
- if (src->u.atomic.u.f.sign!=dst->u.atomic.u.f.sign ||
- src->u.atomic.u.f.epos!=dst->u.atomic.u.f.epos ||
- src->u.atomic.u.f.esize!=dst->u.atomic.u.f.esize ||
- src->u.atomic.u.f.ebias!=dst->u.atomic.u.f.ebias ||
- src->u.atomic.u.f.mpos!=dst->u.atomic.u.f.mpos ||
- src->u.atomic.u.f.msize!=dst->u.atomic.u.f.msize ||
- src->u.atomic.u.f.norm!=dst->u.atomic.u.f.norm ||
- src->u.atomic.u.f.pad!=dst->u.atomic.u.f.pad) {
- HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "conversion not supported");
- }
- break;
+ /* Check args */
+ if (H5_DATATYPE != H5Aatom_group(src_id) ||
+ NULL == (src = H5Aatom_object(src_id)) ||
+ H5_DATATYPE != H5Aatom_group(dst_id) ||
+ NULL == (dst = H5Aatom_object(dst_id))) {
+ HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
+ }
+ if (background) {
+ HRETURN_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL,
+ "background values not supported in this conv path");
+ }
+ if (!buf) {
+ /* Capability query */
+ if (src->size != dst->size ||
+ 0 != src->u.atomic.offset ||
+ 0 != dst->u.atomic.offset ||
+ !((H5T_ORDER_BE == src->u.atomic.order &&
+ H5T_ORDER_LE == dst->u.atomic.order) ||
+ (H5T_ORDER_LE == src->u.atomic.order &&
+ H5T_ORDER_BE == dst->u.atomic.order))) {
+ HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
+ "conversion not supported");
+ }
+ switch (src->type) {
+ case H5T_INTEGER:
+ /* nothing to check */
+ break;
- default:
- HRETURN_ERROR (H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
- "conversion not supported");
- }
- HRETURN (SUCCEED);
- }
-
+ case H5T_FLOAT:
+ if (src->u.atomic.u.f.sign != dst->u.atomic.u.f.sign ||
+ src->u.atomic.u.f.epos != dst->u.atomic.u.f.epos ||
+ src->u.atomic.u.f.esize != dst->u.atomic.u.f.esize ||
+ src->u.atomic.u.f.ebias != dst->u.atomic.u.f.ebias ||
+ src->u.atomic.u.f.mpos != dst->u.atomic.u.f.mpos ||
+ src->u.atomic.u.f.msize != dst->u.atomic.u.f.msize ||
+ src->u.atomic.u.f.norm != dst->u.atomic.u.f.norm ||
+ src->u.atomic.u.f.pad != dst->u.atomic.u.f.pad) {
+ HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
+ "conversion not supported");
+ }
+ break;
- /* The conversion */
- md = src->size / 2;
- for (i=0; i<nelmts; i++, buf+=src->size) {
- for (j=0; j<md; j++) {
- tmp = buf[j];
- buf[j] = buf[src->size-(j+1)];
- buf[src->size-(j+1)] = tmp;
- }
- }
+ default:
+ HRETURN_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL,
+ "conversion not supported");
+ }
+ HRETURN(SUCCEED);
+ }
+ /* The conversion */
+ md = src->size / 2;
+ for (i = 0; i < nelmts; i++, buf += src->size) {
+ for (j = 0; j < md; j++) {
+ tmp = buf[j];
+ buf[j] = buf[src->size - (j + 1)];
+ buf[src->size - (j + 1)] = tmp;
+ }
+ }
- FUNC_LEAVE (SUCCEED);
+ FUNC_LEAVE(SUCCEED);
}
diff --git a/src/H5Tpkg.h b/src/H5Tpkg.h
index 4668db4..73f5b55 100644
--- a/src/H5Tpkg.h
+++ b/src/H5Tpkg.h
@@ -5,9 +5,9 @@
* Programmer: Robb Matzke <matzke@llnl.gov>
* Monday, December 8, 1997
*
- * Purpose: This file contains declarations which are visible only within
- * the H5T package. Source files outside the H5T package should
- * include H5Tprivate.h instead.
+ * Purpose: This file contains declarations which are visible only within
+ * the H5T package. Source files outside the H5T package should
+ * include H5Tprivate.h instead.
*/
#ifndef H5T_PACKAGE
#error "Do not include this file outside the H5T package!"
@@ -19,80 +19,80 @@
#include <H5Tprivate.h>
typedef struct H5T_atomic_t {
- H5T_order_t order; /*byte order */
- size_t prec; /*precision in bits */
- size_t offset; /*bit position of lsb of value */
- intn lsb_pad;/*type of lsb padding */
- intn msb_pad;/*type of msb padding */
- union {
- struct {
- H5T_sign_t sign; /*type of integer sign */
- } i; /*integer; integer types */
+ H5T_order_t order; /*byte order */
+ size_t prec; /*precision in bits */
+ size_t offset; /*bit position of lsb of value */
+ intn lsb_pad; /*type of lsb padding */
+ intn msb_pad; /*type of msb padding */
+ union {
+ struct {
+ H5T_sign_t sign; /*type of integer sign */
+ } i; /*integer; integer types */
- struct {
- size_t sign; /*bit position of sign bit */
- size_t epos; /*position of lsb of exponent */
- size_t esize; /*size of exponent in bits */
- uint64 ebias; /*exponent bias */
- size_t mpos; /*position of lsb of mantissa */
- size_t msize; /*size of mantissa */
- H5T_norm_t norm; /*normalization */
- intn pad; /*type of padding for internal bits */
- } f; /*floating-point types */
+ struct {
+ size_t sign; /*bit position of sign bit */
+ size_t epos; /*position of lsb of exponent */
+ size_t esize; /*size of exponent in bits */
+ uint64 ebias; /*exponent bias */
+ size_t mpos; /*position of lsb of mantissa */
+ size_t msize; /*size of mantissa */
+ H5T_norm_t norm; /*normalization */
+ intn pad; /*type of padding for internal bits */
+ } f; /*floating-point types */
- struct {
- H5T_cset_t cset; /*character set */
- H5T_str_t pad; /*space or null padding of extra bytes */
- } s;
- } u;
+ struct {
+ H5T_cset_t cset; /*character set */
+ H5T_str_t pad; /*space or null padding of extra bytes */
+ } s;
+ } u;
} H5T_atomic_t;
typedef struct H5T_compnd_t {
- intn nalloc; /*num entries allocated in MEMB array */
- intn nmembs; /*number of members defined in struct */
- struct H5T_member_t *memb; /*array of struct members */
+ intn nalloc; /*num entries allocated in MEMB array */
+ intn nmembs; /*number of members defined in struct */
+ struct H5T_member_t *memb; /*array of struct members */
} H5T_compnd_t;
struct H5T_t {
- hbool_t locked; /*if locked, then can't be modified */
- H5T_class_t type; /*which class of type is this? */
- size_t size; /*total size of an instance of this type*/
- union {
- H5T_atomic_t atomic; /*an atomic data type */
- H5T_compnd_t compnd; /*a compound data type (struct) */
- } u;
+ hbool_t locked; /*if locked, then can't be modified */
+ H5T_class_t type; /*which class of type is this? */
+ size_t size; /*total size of an instance of this type */
+ union {
+ H5T_atomic_t atomic; /*an atomic data type */
+ H5T_compnd_t compnd; /*a compound data type (struct) */
+ } u;
};
typedef struct H5T_member_t {
- char *name; /*name of this member */
- size_t offset; /*offset from beginning of struct */
- intn ndims; /*member dimensionality */
- size_t dim[4]; /*size in each dimension */
- size_t perm[4];/*index permutation */
- struct H5T_t type; /*type of this member */
+ char *name; /*name of this member */
+ size_t offset; /*offset from beginning of struct */
+ intn ndims; /*member dimensionality */
+ size_t dim[4]; /*size in each dimension */
+ size_t perm[4]; /*index permutation */
+ struct H5T_t type; /*type of this member */
} H5T_member_t;
/* The data type conversion database */
typedef struct H5T_path_t {
- H5T_t *src; /*source data type ID */
- H5T_t *dst; /*destination data type ID */
- H5T_conv_t hard; /*hard conversion function or null */
- H5T_conv_t soft; /*soft conversion function or null */
+ H5T_t *src; /*source data type ID */
+ H5T_t *dst; /*destination data type ID */
+ H5T_conv_t hard; /*hard conversion function or null */
+ H5T_conv_t soft; /*soft conversion function or null */
} H5T_path_t;
/* The master list of soft conversion functions */
typedef struct H5T_soft_t {
- H5T_class_t src; /*source data type class */
- H5T_class_t dst; /*destination data type class */
- H5T_conv_t func; /*the conversion function */
+ H5T_class_t src; /*source data type class */
+ H5T_class_t dst; /*destination data type class */
+ H5T_conv_t func; /*the conversion function */
} H5T_soft_t;
-H5T_path_t *H5T_path_find (const H5T_t *src, const H5T_t *dst, hbool_t create);
+H5T_path_t *H5T_path_find(const H5T_t *src, const H5T_t *dst, hbool_t create);
/* Conversion functions */
-herr_t H5T_conv_noop (hid_t src_id, hid_t dst_id, size_t nelmts,
- void *buf, const void *background);
-herr_t H5T_conv_order (hid_t src_id, hid_t dst_id, size_t nelmts,
- void *_buf, const void *background);
+herr_t H5T_conv_noop(hid_t src_id, hid_t dst_id, size_t nelmts,
+ void *buf, const void *background);
+herr_t H5T_conv_order(hid_t src_id, hid_t dst_id, size_t nelmts,
+ void *_buf, const void *background);
#endif
diff --git a/src/H5Tprivate.h b/src/H5Tprivate.h
index e857a91..97528dc 100644
--- a/src/H5Tprivate.h
+++ b/src/H5Tprivate.h
@@ -1,13 +1,13 @@
/****************************************************************************
- * NCSA HDF *
- * Software Development Group *
- * National Center for Supercomputing Applications *
- * University of Illinois at Urbana-Champaign *
- * 605 E. Springfield, Champaign IL 61820 *
- * *
- * For conditions of distribution and use, see the accompanying *
- * hdf/COPYING file. *
- * *
+ * NCSA HDF *
+ * Software Development Group *
+ * National Center for Supercomputing Applications *
+ * University of Illinois at Urbana-Champaign *
+ * 605 E. Springfield, Champaign IL 61820 *
+ * *
+ * For conditions of distribution and use, see the accompanying *
+ * hdf/COPYING file. *
+ * *
****************************************************************************/
/* $Id$ */
@@ -22,29 +22,28 @@
/* Private headers needed by this file */
#include <H5private.h>
-#include <H5Gprivate.h> /*for H5G_entry_t */
+#include <H5Gprivate.h> /*for H5G_entry_t */
#define H5T_RESERVED_ATOMS 8
typedef struct H5T_t H5T_t;
-herr_t H5T_init (void);
-
+herr_t H5T_init(void);
/* Private functions */
-herr_t H5T_init_interface (void);
-H5T_t *H5T_create (H5T_class_t type, size_t size);
-H5T_t *H5T_copy (const H5T_t *old_dt);
-herr_t H5T_close (H5T_t *dt);
-size_t H5T_get_size (const H5T_t *dt);
-intn H5T_cmp (const H5T_t *dt1, const H5T_t *dt2);
-hbool_t H5T_is_atomic (const H5T_t *dt);
-
-herr_t H5T_insert (H5T_t *parent, const char *name, off_t offset,
- const H5T_t *member);
-herr_t H5T_sort_by_offset (H5T_t *dt);
-herr_t H5T_pack (H5T_t *dt);
-herr_t H5T_debug (H5T_t *dt, FILE *stream);
-H5T_conv_t H5T_find (const H5T_t *src, const H5T_t *dst);
+herr_t H5T_init_interface(void);
+H5T_t *H5T_create(H5T_class_t type, size_t size);
+H5T_t *H5T_copy(const H5T_t *old_dt);
+herr_t H5T_close(H5T_t *dt);
+size_t H5T_get_size(const H5T_t *dt);
+intn H5T_cmp(const H5T_t *dt1, const H5T_t *dt2);
+hbool_t H5T_is_atomic(const H5T_t *dt);
+
+herr_t H5T_insert(H5T_t *parent, const char *name, off_t offset,
+ const H5T_t *member);
+herr_t H5T_sort_by_offset(H5T_t *dt);
+herr_t H5T_pack(H5T_t *dt);
+herr_t H5T_debug(H5T_t *dt, FILE * stream);
+H5T_conv_t H5T_find(const H5T_t *src, const H5T_t *dst);
#endif
diff --git a/src/H5Tpublic.h b/src/H5Tpublic.h
index 291282a..f310b18 100644
--- a/src/H5Tpublic.h
+++ b/src/H5Tpublic.h
@@ -25,198 +25,197 @@
/* These are the various classes of data types */
typedef enum H5T_class_t {
- H5T_NO_CLASS =-1, /*error */
- H5T_INTEGER =0, /*integer types */
- H5T_FLOAT =1, /*floating-point types */
- H5T_TIME =2, /*date and time types */
- H5T_STRING =3, /*character string types */
- H5T_BITFIELD =4, /*bit field types */
- H5T_OPAQUE =5, /*opaque types */
- H5T_COMPOUND =6, /*compound types */
-
- H5T_NCLASSES =7 /*This must be last */
+ H5T_NO_CLASS = -1, /*error */
+ H5T_INTEGER = 0, /*integer types */
+ H5T_FLOAT = 1, /*floating-point types */
+ H5T_TIME = 2, /*date and time types */
+ H5T_STRING = 3, /*character string types */
+ H5T_BITFIELD = 4, /*bit field types */
+ H5T_OPAQUE = 5, /*opaque types */
+ H5T_COMPOUND = 6, /*compound types */
+
+ H5T_NCLASSES = 7 /*This must be last */
} H5T_class_t;
/* Byte orders */
typedef enum H5T_order_t {
- H5T_ORDER_ERROR =-1, /*error */
- H5T_ORDER_LE =0, /*little endian */
- H5T_ORDER_BE =1, /*bit endian */
- H5T_ORDER_VAX =2, /*VAX mixed endian */
- H5T_ORDER_NONE =3 /*no particular order (strings, bits,..)*/
- /*H5T_ORDER_NONE must be last*/
+ H5T_ORDER_ERROR = -1, /*error */
+ H5T_ORDER_LE = 0, /*little endian */
+ H5T_ORDER_BE = 1, /*bit endian */
+ H5T_ORDER_VAX = 2, /*VAX mixed endian */
+ H5T_ORDER_NONE = 3 /*no particular order (strings, bits,..) */
+ /*H5T_ORDER_NONE must be last */
} H5T_order_t;
/* Types of integer sign schemes */
typedef enum H5T_sign_t {
- H5T_SGN_ERROR =-1, /*error */
- H5T_SGN_NONE =0, /*this is an unsigned type */
- H5T_SGN_2 =1, /*two's complement */
-
- H5T_NSGN =2 /*this must be last! */
+ H5T_SGN_ERROR = -1, /*error */
+ H5T_SGN_NONE = 0, /*this is an unsigned type */
+ H5T_SGN_2 = 1, /*two's complement */
+
+ H5T_NSGN = 2 /*this must be last! */
} H5T_sign_t;
/* Floating-point normalization schemes */
typedef enum H5T_norm_t {
- H5T_NORM_ERROR =-1, /*error */
- H5T_NORM_IMPLIED =0, /*msb of mantissa isn't stored, always 1*/
- H5T_NORM_MSBSET =1, /*msb of mantissa is always 1 */
- H5T_NORM_NONE =2 /*not normalized */
- /*H5T_NORM_NONE must be last*/
+ H5T_NORM_ERROR = -1, /*error */
+ H5T_NORM_IMPLIED = 0, /*msb of mantissa isn't stored, always 1 */
+ H5T_NORM_MSBSET = 1, /*msb of mantissa is always 1 */
+ H5T_NORM_NONE = 2 /*not normalized */
+ /*H5T_NORM_NONE must be last */
} H5T_norm_t;
/* Character set to use for text strings */
typedef enum H5T_cset_t {
- H5T_CSET_ERROR =-1, /*error */
- H5T_CSET_ASCII =0, /*US ASCII */
+ H5T_CSET_ERROR = -1, /*error */
+ H5T_CSET_ASCII = 0, /*US ASCII */
- H5T_NCSET =1 /*this must be last! */
+ H5T_NCSET = 1 /*this must be last! */
} H5T_cset_t;
/* Type of padding to use in character strings */
typedef enum H5T_str_t {
- H5T_STR_ERROR =-1, /*error */
- H5T_STR_NULL =0, /*pad with null term like in C */
- H5T_STR_SPACE =1, /*pad with spaces like in Fortran */
-
- H5T_NSTR =2 /*this must be last! */
+ H5T_STR_ERROR = -1, /*error */
+ H5T_STR_NULL = 0, /*pad with null term like in C */
+ H5T_STR_SPACE = 1, /*pad with spaces like in Fortran */
+
+ H5T_NSTR = 2 /*this must be last! */
} H5T_str_t;
/* Type of padding to use in other atomic types */
typedef enum H5T_pad_t {
- H5T_PAD_ERROR =-1, /*error */
- H5T_PAD_ZERO =0, /*always set to zero */
- H5T_PAD_ONE =1, /*always set to one */
- H5T_PAD_BACKGROUND =2, /*set to background value */
-
- H5T_NPAD =3 /*THIS MUST BE LAST */
+ H5T_PAD_ERROR = -1, /*error */
+ H5T_PAD_ZERO = 0, /*always set to zero */
+ H5T_PAD_ONE = 1, /*always set to one */
+ H5T_PAD_BACKGROUND = 2, /*set to background value */
+
+ H5T_NPAD = 3 /*THIS MUST BE LAST */
} H5T_pad_t;
/* All data type conversion functions are... */
-typedef herr_t (*H5T_conv_t)(hid_t, hid_t, size_t, void*, const void*);
+typedef herr_t (*H5T_conv_t) (hid_t, hid_t, size_t, void *, const void *);
-#define HOFFSET(S,M) ((const char*)&S.M-(const char*)&S)
-#define HPOFFSET(P,M) ((const char*)&(P->M)-(const char*)P)
+#define HOFFSET(S,M) ((const char*)&S.M-(const char*)&S)
+#define HPOFFSET(P,M) ((const char*)&(P->M)-(const char*)P)
/* The predefined types */
-#define H5T_NATIVE_CHAR (H5init(), H5T_NATIVE_CHAR_g)
-#define H5T_NATIVE_UCHAR (H5init(), H5T_NATIVE_UCHAR_g)
-#define H5T_NATIVE_SHORT (H5init(), H5T_NATIVE_SHORT_g)
-#define H5T_NATIVE_USHORT (H5init(), H5T_NATIVE_USHORT_g)
-#define H5T_NATIVE_INT (H5init(), H5T_NATIVE_INT_g)
-#define H5T_NATIVE_UINT (H5init(), H5T_NATIVE_UINT_g)
-#define H5T_NATIVE_LONG (H5init(), H5T_NATIVE_LONG_g)
-#define H5T_NATIVE_ULONG (H5init(), H5T_NATIVE_ULONG_g)
-#define H5T_NATIVE_LLONG (H5init(), H5T_NATIVE_LLONG_g)
-#define H5T_NATIVE_ULLONG (H5init(), H5T_NATIVE_ULLONG_g)
-#define H5T_NATIVE_HYPER (H5init(), H5T_NATIVE_HYPER_g)
-#define H5T_NATIVE_UHYPER (H5init(), H5T_NATIVE_UHYPER_g)
-#define H5T_NATIVE_INT8 (H5init(), H5T_NATIVE_INT8_g)
-#define H5T_NATIVE_UINT8 (H5init(), H5T_NATIVE_UINT8_g)
-#define H5T_NATIVE_INT16 (H5init(), H5T_NATIVE_INT16_g)
-#define H5T_NATIVE_UINT16 (H5init(), H5T_NATIVE_UINT16_g)
-#define H5T_NATIVE_INT32 (H5init(), H5T_NATIVE_INT32_g)
-#define H5T_NATIVE_UINT32 (H5init(), H5T_NATIVE_UINT32_g)
-#define H5T_NATIVE_INT64 (H5init(), H5T_NATIVE_INT64_g)
-#define H5T_NATIVE_UINT64 (H5init(), H5T_NATIVE_UINT64_g)
-#define H5T_NATIVE_FLOAT (H5init(), H5T_NATIVE_FLOAT_g)
-#define H5T_NATIVE_DOUBLE (H5init(), H5T_NATIVE_DOUBLE_g)
-#define H5T_NATIVE_TIME (H5init(), H5T_NATIVE_TIME_g)
-#define H5T_NATIVE_STRING (H5init(), H5T_NATIVE_STRING_g)
-#define H5T_NATIVE_BITFIELD (H5init(), H5T_NATIVE_BITFIELD_g)
-#define H5T_NATIVE_OPAQUE (H5init(), H5T_NATIVE_OPAQUE_g)
-
+#define H5T_NATIVE_CHAR (H5init(), H5T_NATIVE_CHAR_g)
+#define H5T_NATIVE_UCHAR (H5init(), H5T_NATIVE_UCHAR_g)
+#define H5T_NATIVE_SHORT (H5init(), H5T_NATIVE_SHORT_g)
+#define H5T_NATIVE_USHORT (H5init(), H5T_NATIVE_USHORT_g)
+#define H5T_NATIVE_INT (H5init(), H5T_NATIVE_INT_g)
+#define H5T_NATIVE_UINT (H5init(), H5T_NATIVE_UINT_g)
+#define H5T_NATIVE_LONG (H5init(), H5T_NATIVE_LONG_g)
+#define H5T_NATIVE_ULONG (H5init(), H5T_NATIVE_ULONG_g)
+#define H5T_NATIVE_LLONG (H5init(), H5T_NATIVE_LLONG_g)
+#define H5T_NATIVE_ULLONG (H5init(), H5T_NATIVE_ULLONG_g)
+#define H5T_NATIVE_HYPER (H5init(), H5T_NATIVE_HYPER_g)
+#define H5T_NATIVE_UHYPER (H5init(), H5T_NATIVE_UHYPER_g)
+#define H5T_NATIVE_INT8 (H5init(), H5T_NATIVE_INT8_g)
+#define H5T_NATIVE_UINT8 (H5init(), H5T_NATIVE_UINT8_g)
+#define H5T_NATIVE_INT16 (H5init(), H5T_NATIVE_INT16_g)
+#define H5T_NATIVE_UINT16 (H5init(), H5T_NATIVE_UINT16_g)
+#define H5T_NATIVE_INT32 (H5init(), H5T_NATIVE_INT32_g)
+#define H5T_NATIVE_UINT32 (H5init(), H5T_NATIVE_UINT32_g)
+#define H5T_NATIVE_INT64 (H5init(), H5T_NATIVE_INT64_g)
+#define H5T_NATIVE_UINT64 (H5init(), H5T_NATIVE_UINT64_g)
+#define H5T_NATIVE_FLOAT (H5init(), H5T_NATIVE_FLOAT_g)
+#define H5T_NATIVE_DOUBLE (H5init(), H5T_NATIVE_DOUBLE_g)
+#define H5T_NATIVE_TIME (H5init(), H5T_NATIVE_TIME_g)
+#define H5T_NATIVE_STRING (H5init(), H5T_NATIVE_STRING_g)
+#define H5T_NATIVE_BITFIELD (H5init(), H5T_NATIVE_BITFIELD_g)
+#define H5T_NATIVE_OPAQUE (H5init(), H5T_NATIVE_OPAQUE_g)
#ifdef __cplusplus
-extern "C" {
+extern "C" {
#endif
-extern hid_t H5T_NATIVE_CHAR_g;
-extern hid_t H5T_NATIVE_UCHAR_g;
-extern hid_t H5T_NATIVE_SHORT_g;
-extern hid_t H5T_NATIVE_USHORT_g;
-extern hid_t H5T_NATIVE_INT_g;
-extern hid_t H5T_NATIVE_UINT_g;
-extern hid_t H5T_NATIVE_LONG_g;
-extern hid_t H5T_NATIVE_INT8_g;
-extern hid_t H5T_NATIVE_UINT8_g;
-extern hid_t H5T_NATIVE_INT16_g;
-extern hid_t H5T_NATIVE_UINT16_g;
-extern hid_t H5T_NATIVE_INT32_g;
-extern hid_t H5T_NATIVE_UINT32_g;
-extern hid_t H5T_NATIVE_INT64_g;
-extern hid_t H5T_NATIVE_UINT64_g;
-extern hid_t H5T_NATIVE_ULONG_g;
-extern hid_t H5T_NATIVE_LLONG_g;
-extern hid_t H5T_NATIVE_ULLONG_g;
-extern hid_t H5T_NATIVE_HYPER_g;
-extern hid_t H5T_NATIVE_UHYPER_g;
-extern hid_t H5T_NATIVE_FLOAT_g;
-extern hid_t H5T_NATIVE_DOUBLE_g;
-extern hid_t H5T_NATIVE_TIME_g;
-extern hid_t H5T_NATIVE_STRING_g;
-extern hid_t H5T_NATIVE_BITFIELD_g;
-extern hid_t H5T_NATIVE_OPAQUE_g;
+ extern hid_t H5T_NATIVE_CHAR_g;
+ extern hid_t H5T_NATIVE_UCHAR_g;
+ extern hid_t H5T_NATIVE_SHORT_g;
+ extern hid_t H5T_NATIVE_USHORT_g;
+ extern hid_t H5T_NATIVE_INT_g;
+ extern hid_t H5T_NATIVE_UINT_g;
+ extern hid_t H5T_NATIVE_LONG_g;
+ extern hid_t H5T_NATIVE_INT8_g;
+ extern hid_t H5T_NATIVE_UINT8_g;
+ extern hid_t H5T_NATIVE_INT16_g;
+ extern hid_t H5T_NATIVE_UINT16_g;
+ extern hid_t H5T_NATIVE_INT32_g;
+ extern hid_t H5T_NATIVE_UINT32_g;
+ extern hid_t H5T_NATIVE_INT64_g;
+ extern hid_t H5T_NATIVE_UINT64_g;
+ extern hid_t H5T_NATIVE_ULONG_g;
+ extern hid_t H5T_NATIVE_LLONG_g;
+ extern hid_t H5T_NATIVE_ULLONG_g;
+ extern hid_t H5T_NATIVE_HYPER_g;
+ extern hid_t H5T_NATIVE_UHYPER_g;
+ extern hid_t H5T_NATIVE_FLOAT_g;
+ extern hid_t H5T_NATIVE_DOUBLE_g;
+ extern hid_t H5T_NATIVE_TIME_g;
+ extern hid_t H5T_NATIVE_STRING_g;
+ extern hid_t H5T_NATIVE_BITFIELD_g;
+ extern hid_t H5T_NATIVE_OPAQUE_g;
/* Operations defined on all data types */
-hid_t H5Tcreate (H5T_class_t type, size_t size);
-hid_t H5Tcopy (hid_t type_id);
-herr_t H5Tclose (hid_t type_id);
-hbool_t H5Tequal (hid_t type1_id, hid_t type2_id);
-herr_t H5Tlock (hid_t type_id);
+ hid_t H5Tcreate(H5T_class_t type, size_t size);
+ hid_t H5Tcopy(hid_t type_id);
+ herr_t H5Tclose(hid_t type_id);
+ hbool_t H5Tequal(hid_t type1_id, hid_t type2_id);
+ herr_t H5Tlock(hid_t type_id);
/* Operations defined on compound data types */
-herr_t H5Tinsert (hid_t parent_id, const char *name, off_t offset,
- hid_t member_id);
-herr_t H5Tpack (hid_t type_id);
+ herr_t H5Tinsert(hid_t parent_id, const char *name, off_t offset,
+ hid_t member_id);
+ herr_t H5Tpack(hid_t type_id);
/* Querying property values */
-H5T_class_t H5Tget_class (hid_t type_id);
-size_t H5Tget_size (hid_t type_id);
-H5T_order_t H5Tget_order (hid_t type_id);
-size_t H5Tget_precision (hid_t type_id);
-size_t H5Tget_offset (hid_t type_id);
-herr_t H5Tget_pad (hid_t type_id, H5T_pad_t *lsb/*out*/,
- H5T_pad_t *msb/*out*/);
-H5T_sign_t H5Tget_sign (hid_t type_id);
-herr_t H5Tget_fields (hid_t type_id, size_t *spos/*out*/,
- size_t *epos/*out*/, size_t *esize/*out*/,
- size_t *mpos/*out*/, size_t *msize/*out*/);
-size_t H5Tget_ebias (hid_t type_id);
-H5T_norm_t H5Tget_norm (hid_t type_id);
-H5T_pad_t H5Tget_inpad (hid_t type_id);
-H5T_str_t H5Tget_strpad (hid_t type_id);
-intn H5Tget_nmembers (hid_t type_id);
-char *H5Tget_member_name (hid_t type_id, int membno);
-size_t H5Tget_member_offset (hid_t type_id, int membno);
-int H5Tget_member_dims (hid_t type_id, int membno,
- int dims[]/*out*/, int perm[]/*out*/);
-hid_t H5Tget_member_type (hid_t type_id, int membno);
-H5T_cset_t H5Tget_cset (hid_t type_id);
+ H5T_class_t H5Tget_class(hid_t type_id);
+ size_t H5Tget_size(hid_t type_id);
+ H5T_order_t H5Tget_order(hid_t type_id);
+ size_t H5Tget_precision(hid_t type_id);
+ size_t H5Tget_offset(hid_t type_id);
+ herr_t H5Tget_pad(hid_t type_id, H5T_pad_t *lsb /*out */ ,
+ H5T_pad_t *msb /*out */ );
+ H5T_sign_t H5Tget_sign(hid_t type_id);
+ herr_t H5Tget_fields(hid_t type_id, size_t *spos /*out */ ,
+ size_t *epos /*out */ , size_t *esize /*out */ ,
+ size_t *mpos /*out */ , size_t *msize /*out */ );
+ size_t H5Tget_ebias(hid_t type_id);
+ H5T_norm_t H5Tget_norm(hid_t type_id);
+ H5T_pad_t H5Tget_inpad(hid_t type_id);
+ H5T_str_t H5Tget_strpad(hid_t type_id);
+ intn H5Tget_nmembers(hid_t type_id);
+ char *H5Tget_member_name(hid_t type_id, int membno);
+ size_t H5Tget_member_offset(hid_t type_id, int membno);
+ int H5Tget_member_dims(hid_t type_id, int membno,
+ int dims[] /*out */ , int perm[] /*out */ );
+ hid_t H5Tget_member_type(hid_t type_id, int membno);
+ H5T_cset_t H5Tget_cset(hid_t type_id);
/* Setting property values */
-herr_t H5Tset_size (hid_t type_id, size_t size);
-herr_t H5Tset_order (hid_t type_id, H5T_order_t order);
-herr_t H5Tset_precision (hid_t type_id, size_t prec);
-herr_t H5Tset_offset (hid_t type_id, size_t offset);
-herr_t H5Tset_pad (hid_t type_id, H5T_pad_t lsb, H5T_pad_t msb);
-herr_t H5Tset_sign (hid_t type_id, H5T_sign_t sign);
-herr_t H5Tset_fields (hid_t type_id, size_t spos, size_t epos, size_t esize,
- size_t mpos, size_t msize);
-herr_t H5Tset_ebias (hid_t type_id, size_t ebias);
-herr_t H5Tset_norm (hid_t type_id, H5T_norm_t norm);
-herr_t H5Tset_inpad (hid_t type_id, H5T_pad_t pad);
-herr_t H5Tset_cset (hid_t type_id, H5T_cset_t cset);
-herr_t H5Tset_strpad (hid_t type_id, H5T_str_t strpad);
+ herr_t H5Tset_size(hid_t type_id, size_t size);
+ herr_t H5Tset_order(hid_t type_id, H5T_order_t order);
+ herr_t H5Tset_precision(hid_t type_id, size_t prec);
+ herr_t H5Tset_offset(hid_t type_id, size_t offset);
+ herr_t H5Tset_pad(hid_t type_id, H5T_pad_t lsb, H5T_pad_t msb);
+ herr_t H5Tset_sign(hid_t type_id, H5T_sign_t sign);
+ herr_t H5Tset_fields(hid_t type_id, size_t spos, size_t epos, size_t esize,
+ size_t mpos, size_t msize);
+ herr_t H5Tset_ebias(hid_t type_id, size_t ebias);
+ herr_t H5Tset_norm(hid_t type_id, H5T_norm_t norm);
+ herr_t H5Tset_inpad(hid_t type_id, H5T_pad_t pad);
+ herr_t H5Tset_cset(hid_t type_id, H5T_cset_t cset);
+ herr_t H5Tset_strpad(hid_t type_id, H5T_str_t strpad);
/* Type conversion database */
-herr_t H5Tregister_hard (hid_t src_id, hid_t dst_id, H5T_conv_t func);
-herr_t H5Tregister_soft (H5T_class_t src, H5T_class_t dst, H5T_conv_t func);
-herr_t H5Tunregister (H5T_conv_t func);
-H5T_conv_t H5Tfind (hid_t src_id, hid_t dst_id);
+ herr_t H5Tregister_hard(hid_t src_id, hid_t dst_id, H5T_conv_t func);
+ herr_t H5Tregister_soft(H5T_class_t src, H5T_class_t dst, H5T_conv_t func);
+ herr_t H5Tunregister(H5T_conv_t func);
+ H5T_conv_t H5Tfind(hid_t src_id, hid_t dst_id);
#ifdef __cplusplus
}
-#endif
#endif
+#endif
diff --git a/src/H5V.c b/src/H5V.c
index c9c156c..6f0808b 100644
--- a/src/H5V.c
+++ b/src/H5V.c
@@ -11,34 +11,33 @@
#include <H5Oprivate.h>
#include <H5Vprivate.h>
-#define H5V_HYPER_NDIMS H5O_LAYOUT_NDIMS
-#define PABLO_MASK H5V_mask
-static hbool_t interface_initialize_g = TRUE;
-#define INTERFACE_INIT NULL
-
-static herr_t H5V_stride_optimize1 (size_t *np, size_t *elmt_size,
- size_t *size, intn *stride1);
-static herr_t H5V_stride_optimize2 (size_t *np, size_t *elmt_size,
- size_t *size, intn *stride1,
- intn *stride2);
-
+#define H5V_HYPER_NDIMS H5O_LAYOUT_NDIMS
+#define PABLO_MASK H5V_mask
+static hbool_t interface_initialize_g = TRUE;
+#define INTERFACE_INIT NULL
+
+static herr_t H5V_stride_optimize1(size_t *np, size_t *elmt_size,
+ size_t *size, intn *stride1);
+static herr_t H5V_stride_optimize2(size_t *np, size_t *elmt_size,
+ size_t *size, intn *stride1,
+ intn *stride2);
/*-------------------------------------------------------------------------
- * Function: H5V_stride_optimize1
+ * Function: H5V_stride_optimize1
*
- * Purpose: Given a stride vector which references elements of the
- * specified size, optimize the dimensionality, the stride
- * vector, and the element size to minimize the dimensionality
- * and the number of memory accesses.
+ * Purpose: Given a stride vector which references elements of the
+ * specified size, optimize the dimensionality, the stride
+ * vector, and the element size to minimize the dimensionality
+ * and the number of memory accesses.
*
- * All arguments are passed by reference and their values may be
- * modified by this function.
+ * All arguments are passed by reference and their values may be
+ * modified by this function.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Saturday, October 11, 1997
*
* Modifications:
@@ -46,48 +45,47 @@ static herr_t H5V_stride_optimize2 (size_t *np, size_t *elmt_size,
*-------------------------------------------------------------------------
*/
static herr_t
-H5V_stride_optimize1 (size_t *np, size_t *elmt_size, size_t *size,
- intn *stride1)
+H5V_stride_optimize1(size_t *np, size_t *elmt_size, size_t *size,
+ intn *stride1)
{
- FUNC_ENTER (H5V_stride_optimize1, FAIL);
-
- /*
- * This has to be true because if we optimize the dimensionality down to
- * zero we still must make one reference.
- */
- assert (1==H5V_vector_reduce_product (0, (void*)1));
-
- /*
- * Combine adjacent memory accesses
- */
- while (*np && stride1[*np-1]==*elmt_size) {
-
- *elmt_size *= size[*np-1];
- if (--*np) {
- stride1[*np-1] += size[*np] * stride1[*np];
- }
- }
-
- FUNC_LEAVE (SUCCEED);
+ FUNC_ENTER(H5V_stride_optimize1, FAIL);
+
+ /*
+ * This has to be true because if we optimize the dimensionality down to
+ * zero we still must make one reference.
+ */
+ assert(1 == H5V_vector_reduce_product(0, (void *) 1));
+
+ /*
+ * Combine adjacent memory accesses
+ */
+ while (*np && stride1[*np - 1] == *elmt_size) {
+
+ *elmt_size *= size[*np - 1];
+ if (--*np) {
+ stride1[*np - 1] += size[*np] * stride1[*np];
+ }
+ }
+
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5V_stride_optimize2
+ * Function: H5V_stride_optimize2
*
- * Purpose: Given two stride vectors which reference elements of the
- * specified size, optimize the dimensionality, the stride
- * vectors, and the element size to minimize the dimensionality
- * and the number of memory accesses.
+ * Purpose: Given two stride vectors which reference elements of the
+ * specified size, optimize the dimensionality, the stride
+ * vectors, and the element size to minimize the dimensionality
+ * and the number of memory accesses.
*
- * All arguments are passed by reference and their values may be
- * modified by this function.
+ * All arguments are passed by reference and their values may be
+ * modified by this function.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Saturday, October 11, 1997
*
* Modifications:
@@ -95,51 +93,50 @@ H5V_stride_optimize1 (size_t *np, size_t *elmt_size, size_t *size,
*-------------------------------------------------------------------------
*/
static herr_t
-H5V_stride_optimize2 (size_t *np, size_t *elmt_size, size_t *size,
- intn *stride1, intn *stride2)
+H5V_stride_optimize2(size_t *np, size_t *elmt_size, size_t *size,
+ intn *stride1, intn *stride2)
{
- FUNC_ENTER (H5V_stride_optimize2, FAIL);
-
- /*
- * This has to be true because if we optimize the dimensionality down to
- * zero we still must make one reference.
- */
- assert (1==H5V_vector_reduce_product (0, (void*)1));
-
- /*
- * Combine adjacent memory accesses
- */
- while (*np && stride1[*np-1]==*elmt_size && stride2[*np-1]==*elmt_size) {
-
- *elmt_size *= size[*np-1];
- if (--*np) {
- stride1[*np-1] += size[*np] * stride1[*np];
- stride2[*np-1] += size[*np] * stride2[*np];
- }
- }
-
- FUNC_LEAVE (SUCCEED);
+ FUNC_ENTER(H5V_stride_optimize2, FAIL);
+
+ /*
+ * This has to be true because if we optimize the dimensionality down to
+ * zero we still must make one reference.
+ */
+ assert(1 == H5V_vector_reduce_product(0, (void *) 1));
+
+ /*
+ * Combine adjacent memory accesses
+ */
+ while (*np && stride1[*np - 1] == *elmt_size && stride2[*np - 1] == *elmt_size) {
+
+ *elmt_size *= size[*np - 1];
+ if (--*np) {
+ stride1[*np - 1] += size[*np] * stride1[*np];
+ stride2[*np - 1] += size[*np] * stride2[*np];
+ }
+ }
+
+ FUNC_LEAVE(SUCCEED);
}
-
/*-------------------------------------------------------------------------
- * Function: H5V_hyper_stride
+ * Function: H5V_hyper_stride
*
- * Purpose: Given a description of a hyperslab, this function returns
- * (through STRIDE[]) the byte strides appropriate for accessing
- * all bytes of the hyperslab and the byte offset where the
- * striding will begin. The SIZE can be passed to the various
- * stride functions.
+ * Purpose: Given a description of a hyperslab, this function returns
+ * (through STRIDE[]) the byte strides appropriate for accessing
+ * all bytes of the hyperslab and the byte offset where the
+ * striding will begin. The SIZE can be passed to the various
+ * stride functions.
*
- * The stride and starting point returned will cause the
- * hyperslab elements to be referenced in C order.
+ * The stride and starting point returned will cause the
+ * hyperslab elements to be referenced in C order.
*
- * Return: Success: Byte offset from beginning of array to start
- * of striding.
+ * Return: Success: Byte offset from beginning of array to start
+ * of striding.
*
- * Failure: abort() -- should never fail
+ * Failure: abort() -- should never fail
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Saturday, October 11, 1997
*
* Modifications:
@@ -147,54 +144,52 @@ H5V_stride_optimize2 (size_t *np, size_t *elmt_size, size_t *size,
*-------------------------------------------------------------------------
*/
size_t
-H5V_hyper_stride (size_t n, const size_t *size,
- const size_t *total_size, const size_t *offset,
- intn *stride /*output arg*/)
+H5V_hyper_stride(size_t n, const size_t *size,
+ const size_t *total_size, const size_t *offset,
+ intn *stride /*output arg */ )
{
- size_t skip; /*starting point byte offset */
- size_t acc; /*accumulator */
- int i; /*counter */
-
- FUNC_ENTER (H5V_hyper_stride, (abort(),0));
-
- assert (n>=0 && n<H5V_HYPER_NDIMS);
- assert (size);
- assert (total_size);
- assert (stride);
-
- /* init */
- stride[n-1] = 1;
- skip = offset?offset[n-1]:0;
-
- /* others */
- for (i=n-2,acc=1; i>=0; --i) {
- stride[i] = acc * (total_size[i+1] - size[i+1]);
- acc *= total_size[i+1];
- skip += acc * (offset?offset[i]:0);
- }
-
- FUNC_LEAVE (skip);
-}
+ size_t skip; /*starting point byte offset */
+ size_t acc; /*accumulator */
+ int i; /*counter */
+
+ FUNC_ENTER(H5V_hyper_stride, (abort(), 0));
+
+ assert(n >= 0 && n < H5V_HYPER_NDIMS);
+ assert(size);
+ assert(total_size);
+ assert(stride);
+
+ /* init */
+ stride[n - 1] = 1;
+ skip = offset ? offset[n - 1] : 0;
+ /* others */
+ for (i = n - 2, acc = 1; i >= 0; --i) {
+ stride[i] = acc * (total_size[i + 1] - size[i + 1]);
+ acc *= total_size[i + 1];
+ skip += acc * (offset ? offset[i] : 0);
+ }
+ FUNC_LEAVE(skip);
+}
/*-------------------------------------------------------------------------
- * Function: H5V_hyper_eq
+ * Function: H5V_hyper_eq
*
- * Purpose: Determines whether two hyperslabs are equal. This function
- * assumes that both hyperslabs are relative to the same array,
- * for if not, they could not possibly be equal.
+ * Purpose: Determines whether two hyperslabs are equal. This function
+ * assumes that both hyperslabs are relative to the same array,
+ * for if not, they could not possibly be equal.
*
- * Return: Success: TRUE if the hyperslabs are equal (that is,
- * both refer to exactly the same elements of an
- * array)
+ * Return: Success: TRUE if the hyperslabs are equal (that is,
+ * both refer to exactly the same elements of an
+ * array)
*
- * FALSE otherwise.
+ * FALSE otherwise.
*
- * Failure: TRUE the rank is zero or if both hyperslabs
- * are of zero size.
+ * Failure: TRUE the rank is zero or if both hyperslabs
+ * are of zero size.
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, October 17, 1997
*
* Modifications:
@@ -202,41 +197,43 @@ H5V_hyper_stride (size_t n, const size_t *size,
*-------------------------------------------------------------------------
*/
hbool_t
-H5V_hyper_eq (size_t n,
- const size_t *offset1, const size_t *size1,
- const size_t *offset2, const size_t *size2)
+H5V_hyper_eq(size_t n,
+ const size_t *offset1, const size_t *size1,
+ const size_t *offset2, const size_t *size2)
{
- size_t nelmts1=1, nelmts2=1;
- intn i;
-
- if (n<=0) return TRUE;
-
- for (i=0; i<n; i++) {
- if ((offset1?offset1[i]:0)!=(offset2?offset2[i]:0)) {
- return FALSE;
- }
- if ((size1?size1[i]:0)!=(size2?size2[i]:0)) {
- return FALSE;
- }
- if (0==(nelmts1*=(size1?size1[i]:0))) return FALSE;
- if (0==(nelmts2*=(size2?size2[i]:0))) return FALSE;
- }
- return TRUE;
+ size_t nelmts1 = 1, nelmts2 = 1;
+ intn i;
+
+ if (n <= 0)
+ return TRUE;
+
+ for (i = 0; i < n; i++) {
+ if ((offset1 ? offset1[i] : 0) != (offset2 ? offset2[i] : 0)) {
+ return FALSE;
+ }
+ if ((size1 ? size1[i] : 0) != (size2 ? size2[i] : 0)) {
+ return FALSE;
+ }
+ if (0 == (nelmts1 *= (size1 ? size1[i] : 0)))
+ return FALSE;
+ if (0 == (nelmts2 *= (size2 ? size2[i] : 0)))
+ return FALSE;
+ }
+ return TRUE;
}
-
/*-------------------------------------------------------------------------
- * Function: H5V_hyper_disjointp
+ * Function: H5V_hyper_disjointp
*
- * Purpose: Determines if two hyperslabs are disjoint.
+ * Purpose: Determines if two hyperslabs are disjoint.
*
- * Return: Success: FALSE if they are not disjoint.
- * TRUE if they are disjoint.
+ * Return: Success: FALSE if they are not disjoint.
+ * TRUE if they are disjoint.
*
- * Failure: A hyperslab of zero size is disjoint from all
- * other hyperslabs.
+ * Failure: A hyperslab of zero size is disjoint from all
+ * other hyperslabs.
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Thursday, October 16, 1997
*
* Modifications:
@@ -244,44 +241,45 @@ H5V_hyper_eq (size_t n,
*-------------------------------------------------------------------------
*/
hbool_t
-H5V_hyper_disjointp (size_t n,
- const size_t *offset1, const size_t *size1,
- const size_t *offset2, const size_t *size2)
+H5V_hyper_disjointp(size_t n,
+ const size_t *offset1, const size_t *size1,
+ const size_t *offset2, const size_t *size2)
{
- intn i;
-
- if (!n || !size1 || !size2) return TRUE;
-
- for (i=0; i<n; i++) {
- if (0==size1[i] || 0==size2[i]) return TRUE;
- if (((offset1?offset1[i]:0)<(offset2?offset2[i]:0) &&
- (offset1?offset1[i]:0)+size1[i]<=(offset2?offset2[i]:0)) ||
- ((offset2?offset2[i]:0)<(offset1?offset1[i]:0) &&
- (offset2?offset2[i]:0)+size2[i]<=(offset1?offset1[i]:0))) {
- return TRUE;
- }
- }
- return FALSE;
+ intn i;
+
+ if (!n || !size1 || !size2)
+ return TRUE;
+
+ for (i = 0; i < n; i++) {
+ if (0 == size1[i] || 0 == size2[i])
+ return TRUE;
+ if (((offset1 ? offset1[i] : 0) < (offset2 ? offset2[i] : 0) &&
+ (offset1 ? offset1[i] : 0) + size1[i] <= (offset2 ? offset2[i] : 0)) ||
+ ((offset2 ? offset2[i] : 0) < (offset1 ? offset1[i] : 0) &&
+ (offset2 ? offset2[i] : 0) + size2[i] <= (offset1 ? offset1[i] : 0))) {
+ return TRUE;
+ }
+ }
+ return FALSE;
}
-
/*-------------------------------------------------------------------------
- * Function: H5V_hyper_fill
+ * Function: H5V_hyper_fill
*
- * Purpose: Similar to memset() except it operates on hyperslabs...
+ * Purpose: Similar to memset() except it operates on hyperslabs...
*
- * Fills a hyperslab of array BUF with some value VAL. BUF
- * is treated like a C-order array with N dimensions where the
- * size of each dimension is TOTAL_SIZE[]. The hyperslab which
- * will be filled with VAL begins at byte offset OFFSET[] from
- * the minimum corner of BUF and continues for SIZE[] bytes in
- * each dimension.
- *
- * Return: Success: SUCCEED
+ * Fills a hyperslab of array BUF with some value VAL. BUF
+ * is treated like a C-order array with N dimensions where the
+ * size of each dimension is TOTAL_SIZE[]. The hyperslab which
+ * will be filled with VAL begins at byte offset OFFSET[] from
+ * the minimum corner of BUF and continues for SIZE[] bytes in
+ * each dimension.
+ *
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, October 10, 1997
*
* Modifications:
@@ -289,77 +287,75 @@ H5V_hyper_disjointp (size_t n,
*-------------------------------------------------------------------------
*/
herr_t
-H5V_hyper_fill (size_t n, const size_t *_size,
- const size_t *total_size, const size_t *offset, void *_dst,
- uint8 fill_value)
+H5V_hyper_fill(size_t n, const size_t *_size,
+ const size_t *total_size, const size_t *offset, void *_dst,
+ uint8 fill_value)
{
- uint8 *dst = (uint8 *)_dst; /*cast for ptr arithmetic */
- size_t size[H5V_HYPER_NDIMS]; /*a modifiable copy of _size */
- intn dst_stride[H5V_HYPER_NDIMS]; /*destination stride info */
- size_t dst_start; /*byte offset to start of stride*/
- size_t elmt_size=1; /*bytes per element */
- herr_t status; /*function return status */
+ uint8 *dst = (uint8 *) _dst; /*cast for ptr arithmetic */
+ size_t size[H5V_HYPER_NDIMS]; /*a modifiable copy of _size */
+ intn dst_stride[H5V_HYPER_NDIMS]; /*destination stride info */
+ size_t dst_start; /*byte offset to start of stride */
+ size_t elmt_size = 1; /*bytes per element */
+ herr_t status; /*function return status */
#ifndef NDEBUG
- int i;
+ int i;
#endif
- FUNC_ENTER (H5V_hyper_fill, FAIL);
+ FUNC_ENTER(H5V_hyper_fill, FAIL);
- /* check args */
- assert (n>0 && n<=H5V_HYPER_NDIMS);
- assert (_size);
- assert (total_size);
- assert (dst);
+ /* check args */
+ assert(n > 0 && n <= H5V_HYPER_NDIMS);
+ assert(_size);
+ assert(total_size);
+ assert(dst);
#ifndef NDEBUG
- for (i=0; i<n; i++) {
- assert (_size[i]>0);
- assert (total_size[i]>0);
- }
+ for (i = 0; i < n; i++) {
+ assert(_size[i] > 0);
+ assert(total_size[i] > 0);
+ }
#endif
- /* Copy the size vector so we can modify it */
- H5V_vector_cpy (n, size, _size);
+ /* Copy the size vector so we can modify it */
+ H5V_vector_cpy(n, size, _size);
- /* Compute an optimal destination stride vector */
- dst_start = H5V_hyper_stride (n, size, total_size, offset, dst_stride);
- H5V_stride_optimize1 (&n, &elmt_size, size, dst_stride);
+ /* Compute an optimal destination stride vector */
+ dst_start = H5V_hyper_stride(n, size, total_size, offset, dst_stride);
+ H5V_stride_optimize1(&n, &elmt_size, size, dst_stride);
- /* Copy */
- status = H5V_stride_fill (n, elmt_size, size, dst_stride, dst+dst_start,
- fill_value);
+ /* Copy */
+ status = H5V_stride_fill(n, elmt_size, size, dst_stride, dst + dst_start,
+ fill_value);
- FUNC_LEAVE (status);
+ FUNC_LEAVE(status);
}
-
-
/*-------------------------------------------------------------------------
- * Function: H5V_hyper_copy
+ * Function: H5V_hyper_copy
*
- * Purpose: Copies a hyperslab from the source to the destination.
+ * Purpose: Copies a hyperslab from the source to the destination.
*
- * A hyperslab is a logically contiguous region of
- * multi-dimensional size SIZE of an array whose dimensionality
- * is N and whose total size is DST_TOTAL_SIZE or SRC_TOTAL_SIZE.
- * The minimum corner of the hyperslab begins at a
- * multi-dimensional offset from the minimum corner of the DST
- * (destination) or SRC (source) array. The sizes and offsets
- * are assumed to be in C order, that is, the first size/offset
- * varies the slowest while the last varies the fastest in the
- * mapping from N-dimensional space to linear space. This
- * function assumes that the array elements are single bytes (if
- * your array has multi-byte elements then add an additional
- * dimension whose size is that of your element).
+ * A hyperslab is a logically contiguous region of
+ * multi-dimensional size SIZE of an array whose dimensionality
+ * is N and whose total size is DST_TOTAL_SIZE or SRC_TOTAL_SIZE.
+ * The minimum corner of the hyperslab begins at a
+ * multi-dimensional offset from the minimum corner of the DST
+ * (destination) or SRC (source) array. The sizes and offsets
+ * are assumed to be in C order, that is, the first size/offset
+ * varies the slowest while the last varies the fastest in the
+ * mapping from N-dimensional space to linear space. This
+ * function assumes that the array elements are single bytes (if
+ * your array has multi-byte elements then add an additional
+ * dimension whose size is that of your element).
*
- * The SRC and DST array may be the same array, but the results
- * are undefined if the source hyperslab overlaps the
- * destination hyperslab.
+ * The SRC and DST array may be the same array, but the results
+ * are undefined if the source hyperslab overlaps the
+ * destination hyperslab.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, October 10, 1997
*
* Modifications:
@@ -367,75 +363,74 @@ H5V_hyper_fill (size_t n, const size_t *_size,
*-------------------------------------------------------------------------
*/
herr_t
-H5V_hyper_copy (size_t n, const size_t *_size,
-
- /*destination*/
- const size_t *dst_size, const size_t *dst_offset,
- void *_dst,
-
- /*source*/
- const size_t *src_size, const size_t *src_offset,
- const void *_src)
+H5V_hyper_copy(size_t n, const size_t *_size,
+
+ /*destination */
+ const size_t *dst_size, const size_t *dst_offset,
+ void *_dst,
+
+ /*source */
+ const size_t *src_size, const size_t *src_offset,
+ const void *_src)
{
- const uint8 *src = (const uint8 *)_src; /*cast for ptr arithmtc */
- uint8 *dst = (uint8 *)_dst; /*cast for ptr arithmtc */
- size_t size[H5V_HYPER_NDIMS]; /*a modifiable _size */
- intn src_stride[H5V_HYPER_NDIMS]; /*source stride info */
- intn dst_stride[H5V_HYPER_NDIMS]; /*dest stride info */
- size_t dst_start, src_start; /*offset to start at */
- size_t elmt_size=1; /*element size in bytes */
- herr_t status; /*return status */
+ const uint8 *src = (const uint8 *) _src; /*cast for ptr arithmtc */
+ uint8 *dst = (uint8 *) _dst; /*cast for ptr arithmtc */
+ size_t size[H5V_HYPER_NDIMS]; /*a modifiable _size */
+ intn src_stride[H5V_HYPER_NDIMS]; /*source stride info */
+ intn dst_stride[H5V_HYPER_NDIMS]; /*dest stride info */
+ size_t dst_start, src_start; /*offset to start at */
+ size_t elmt_size = 1; /*element size in bytes */
+ herr_t status; /*return status */
#ifndef NDEBUG
- intn i;
+ intn i;
#endif
- FUNC_ENTER (H5V_hyper_copy, FAIL);
+ FUNC_ENTER(H5V_hyper_copy, FAIL);
- /* check args */
- assert (n>0 && n<=H5V_HYPER_NDIMS);
- assert (_size);
- assert (dst_size);
- assert (src_size);
- assert (dst);
- assert (src);
+ /* check args */
+ assert(n > 0 && n <= H5V_HYPER_NDIMS);
+ assert(_size);
+ assert(dst_size);
+ assert(src_size);
+ assert(dst);
+ assert(src);
#ifndef NDEBUG
- for (i=0; i<n; i++) {
- assert (_size[i]>0);
- assert (dst_size[i]>0);
- assert (src_size[i]>0);
- }
+ for (i = 0; i < n; i++) {
+ assert(_size[i] > 0);
+ assert(dst_size[i] > 0);
+ assert(src_size[i] > 0);
+ }
#endif
- /* Copy the size vector so we can modify it */
- H5V_vector_cpy (n, size, _size);
+ /* Copy the size vector so we can modify it */
+ H5V_vector_cpy(n, size, _size);
- /* Compute stride vectors for source and destination */
- dst_start = H5V_hyper_stride (n, size, dst_size, dst_offset, dst_stride);
- src_start = H5V_hyper_stride (n, size, src_size, src_offset, src_stride);
+ /* Compute stride vectors for source and destination */
+ dst_start = H5V_hyper_stride(n, size, dst_size, dst_offset, dst_stride);
+ src_start = H5V_hyper_stride(n, size, src_size, src_offset, src_stride);
- /* Optimize the strides as a pair */
- H5V_stride_optimize2 (&n, &elmt_size, size, dst_stride, src_stride);
+ /* Optimize the strides as a pair */
+ H5V_stride_optimize2(&n, &elmt_size, size, dst_stride, src_stride);
- /* Perform the copy in terms of stride */
- status = H5V_stride_copy (n, elmt_size, size,
- dst_stride, dst+dst_start,
- src_stride, src+src_start);
+ /* Perform the copy in terms of stride */
+ status = H5V_stride_copy(n, elmt_size, size,
+ dst_stride, dst + dst_start,
+ src_stride, src + src_start);
- FUNC_LEAVE (status);
+ FUNC_LEAVE(status);
}
-
/*-------------------------------------------------------------------------
- * Function: H5V_stride_fill
+ * Function: H5V_stride_fill
*
- * Purpose: Fills all bytes of a hyperslab with the same value using
- * memset().
+ * Purpose: Fills all bytes of a hyperslab with the same value using
+ * memset().
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Saturday, October 11, 1997
*
* Modifications:
@@ -443,54 +438,55 @@ H5V_hyper_copy (size_t n, const size_t *_size,
*-------------------------------------------------------------------------
*/
herr_t
-H5V_stride_fill (size_t n, size_t elmt_size, const size_t *size,
- const intn *stride, void *_dst, uint8 fill_value)
+H5V_stride_fill(size_t n, size_t elmt_size, const size_t *size,
+ const intn *stride, void *_dst, uint8 fill_value)
{
- uint8 *dst = (uint8 *)_dst; /*cast for ptr arithmetic */
- size_t idx[H5V_HYPER_NDIMS]; /*1-origin indices */
- size_t nelmts; /*number of elements to fill */
- intn i, j; /*counters */
- hbool_t carry; /*subtraction carray value */
-
- FUNC_ENTER (H5V_stride_fill, FAIL);
-
- H5V_vector_cpy (n, idx, size);
- nelmts = H5V_vector_reduce_product (n, size);
- for (i=0; i<nelmts; i++) {
-
- /* Copy an element */
- HDmemset (dst, fill_value, elmt_size);
-
- /* Decrement indices and advance pointer */
- for (j=n-1, carry=TRUE; j>=0 && carry; --j) {
- dst += stride[j];
-
- if (--idx[j]) carry = FALSE;
- else idx[j] = size[j];
- }
- }
-
- FUNC_LEAVE (SUCCEED);
-}
+ uint8 *dst = (uint8 *) _dst; /*cast for ptr arithmetic */
+ size_t idx[H5V_HYPER_NDIMS]; /*1-origin indices */
+ size_t nelmts; /*number of elements to fill */
+ intn i, j; /*counters */
+ hbool_t carry; /*subtraction carray value */
+
+ FUNC_ENTER(H5V_stride_fill, FAIL);
+
+ H5V_vector_cpy(n, idx, size);
+ nelmts = H5V_vector_reduce_product(n, size);
+ for (i = 0; i < nelmts; i++) {
+ /* Copy an element */
+ HDmemset(dst, fill_value, elmt_size);
+
+ /* Decrement indices and advance pointer */
+ for (j = n - 1, carry = TRUE; j >= 0 && carry; --j) {
+ dst += stride[j];
+
+ if (--idx[j])
+ carry = FALSE;
+ else
+ idx[j] = size[j];
+ }
+ }
+
+ FUNC_LEAVE(SUCCEED);
+}
/*-------------------------------------------------------------------------
- * Function: H5V_stride_copy
+ * Function: H5V_stride_copy
*
- * Purpose: Uses DST_STRIDE and SRC_STRIDE to advance through the arrays
- * DST and SRC while copying bytes from SRC to DST. This
- * function minimizes the number of calls to memcpy() by
- * combining various strides, but it will never touch memory
- * outside the hyperslab defined by the strides.
+ * Purpose: Uses DST_STRIDE and SRC_STRIDE to advance through the arrays
+ * DST and SRC while copying bytes from SRC to DST. This
+ * function minimizes the number of calls to memcpy() by
+ * combining various strides, but it will never touch memory
+ * outside the hyperslab defined by the strides.
*
- * Note: If the src_stride is all zero and elmt_size is one, then it's
- * probably more efficient to use H5V_stride_fill() instead.
+ * Note: If the src_stride is all zero and elmt_size is one, then it's
+ * probably more efficient to use H5V_stride_fill() instead.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Saturday, October 11, 1997
*
* Modifications:
@@ -498,55 +494,55 @@ H5V_stride_fill (size_t n, size_t elmt_size, const size_t *size,
*-------------------------------------------------------------------------
*/
herr_t
-H5V_stride_copy (size_t n, size_t elmt_size, const size_t *size,
- const intn *dst_stride, void *_dst,
- const intn *src_stride, const void *_src)
+H5V_stride_copy(size_t n, size_t elmt_size, const size_t *size,
+ const intn *dst_stride, void *_dst,
+ const intn *src_stride, const void *_src)
{
-
- uint8 *dst = (uint8 *)_dst; /*cast for ptr arithmetic*/
- const uint8 *src = (const uint8 *)_src; /*cast for ptr arithmetic*/
- size_t idx[H5V_HYPER_NDIMS]; /*1-origin indices */
- size_t nelmts; /*num elements to copy */
- intn i, j; /*counters */
- hbool_t carry; /*carray for subtraction*/
-
- FUNC_ENTER (H5V_stride_copy, FAIL);
-
- H5V_vector_cpy (n, idx, size);
- nelmts = H5V_vector_reduce_product (n, size);
- for (i=0; i<nelmts; i++) {
-
- /* Copy an element */
- HDmemcpy (dst, src, elmt_size);
-
- /* Decrement indices and advance pointers */
- for (j=n-1, carry=TRUE; j>=0 && carry; --j) {
- src += src_stride[j];
- dst += dst_stride[j];
-
- if (--idx[j]) carry = FALSE;
- else idx[j] = size[j];
- }
- }
-
- FUNC_LEAVE (SUCCEED);
-}
+ uint8 *dst = (uint8 *) _dst; /*cast for ptr arithmetic */
+ const uint8 *src = (const uint8 *) _src; /*cast for ptr arithmetic */
+ size_t idx[H5V_HYPER_NDIMS]; /*1-origin indices */
+ size_t nelmts; /*num elements to copy */
+ intn i, j; /*counters */
+ hbool_t carry; /*carray for subtraction */
+
+ FUNC_ENTER(H5V_stride_copy, FAIL);
+
+ H5V_vector_cpy(n, idx, size);
+ nelmts = H5V_vector_reduce_product(n, size);
+ for (i = 0; i < nelmts; i++) {
+
+ /* Copy an element */
+ HDmemcpy(dst, src, elmt_size);
+ /* Decrement indices and advance pointers */
+ for (j = n - 1, carry = TRUE; j >= 0 && carry; --j) {
+ src += src_stride[j];
+ dst += dst_stride[j];
+
+ if (--idx[j])
+ carry = FALSE;
+ else
+ idx[j] = size[j];
+ }
+ }
+
+ FUNC_LEAVE(SUCCEED);
+}
/*-------------------------------------------------------------------------
- * Function: H5V_stride_copy2
+ * Function: H5V_stride_copy2
*
- * Purpose: Similar to H5V_stride_copy() except the source and
- * destination each have their own dimensionality and size and
- * we copy exactly NELMTS elements each of size ELMT_SIZE. The
- * size counters wrap if NELMTS is more than a size counter.
+ * Purpose: Similar to H5V_stride_copy() except the source and
+ * destination each have their own dimensionality and size and
+ * we copy exactly NELMTS elements each of size ELMT_SIZE. The
+ * size counters wrap if NELMTS is more than a size counter.
*
- * Return: Success: SUCCEED
+ * Return: Success: SUCCEED
*
- * Failure: FAIL
+ * Failure: FAIL
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Saturday, October 11, 1997
*
* Modifications:
@@ -554,46 +550,49 @@ H5V_stride_copy (size_t n, size_t elmt_size, const size_t *size,
*-------------------------------------------------------------------------
*/
herr_t
-H5V_stride_copy2 (size_t nelmts, size_t elmt_size,
+H5V_stride_copy2(size_t nelmts, size_t elmt_size,
- /* destination */
- size_t dst_n, const size_t *dst_size, const intn *dst_stride,
- void *_dst,
+ /* destination */
+ size_t dst_n, const size_t *dst_size, const intn *dst_stride,
+ void *_dst,
- /* source */
- size_t src_n, const size_t *src_size, const intn *src_stride,
- const void *_src)
+ /* source */
+ size_t src_n, const size_t *src_size, const intn *src_stride,
+ const void *_src)
{
- uint8 *dst = (uint8 *)_dst;
- const uint8 *src = (const uint8 *)_src;
- size_t dst_idx[H5V_HYPER_NDIMS];
- size_t src_idx[H5V_HYPER_NDIMS];
- intn i, j;
- hbool_t carry;
-
- FUNC_ENTER (H5V_stride_copy2, FAIL);
-
- H5V_vector_cpy (dst_n, dst_idx, dst_size);
- H5V_vector_cpy (src_n, src_idx, src_size);
-
- for (i=0; i<nelmts; i++) {
-
- /* Copy an element */
- HDmemcpy (dst, src, elmt_size);
-
- /* Decrement indices and advance pointers */
- for (j=dst_n-1, carry=TRUE; j>=0 && carry; --j) {
- dst += dst_stride[j];
- if (--dst_idx[j]) carry = FALSE;
- else dst_idx[j] = dst_size[j];
- }
- for (j=src_n-1, carry=TRUE; j>=0 && carry; --j) {
- src += src_stride[j];
- if (--src_idx[j]) carry = FALSE;
- else src_idx[j] = src_size[j];
- }
- }
-
- FUNC_LEAVE (SUCCEED);
+ uint8 *dst = (uint8 *) _dst;
+ const uint8 *src = (const uint8 *) _src;
+ size_t dst_idx[H5V_HYPER_NDIMS];
+ size_t src_idx[H5V_HYPER_NDIMS];
+ intn i, j;
+ hbool_t carry;
+
+ FUNC_ENTER(H5V_stride_copy2, FAIL);
+
+ H5V_vector_cpy(dst_n, dst_idx, dst_size);
+ H5V_vector_cpy(src_n, src_idx, src_size);
+
+ for (i = 0; i < nelmts; i++) {
+
+ /* Copy an element */
+ HDmemcpy(dst, src, elmt_size);
+
+ /* Decrement indices and advance pointers */
+ for (j = dst_n - 1, carry = TRUE; j >= 0 && carry; --j) {
+ dst += dst_stride[j];
+ if (--dst_idx[j])
+ carry = FALSE;
+ else
+ dst_idx[j] = dst_size[j];
+ }
+ for (j = src_n - 1, carry = TRUE; j >= 0 && carry; --j) {
+ src += src_stride[j];
+ if (--src_idx[j])
+ carry = FALSE;
+ else
+ src_idx[j] = src_size[j];
+ }
+ }
+
+ FUNC_LEAVE(SUCCEED);
}
-
diff --git a/src/H5Vprivate.h b/src/H5Vprivate.h
index f800a19..8afe111 100644
--- a/src/H5Vprivate.h
+++ b/src/H5Vprivate.h
@@ -18,148 +18,160 @@
#define H5V_vector_ge(N,V1,V2) (H5V_vector_cmp (N, V1, V2)>=0)
/* Other functions */
-#define H5V_vector_cpy(N,DST,SRC) { \
- if (SRC) HDmemcpy (DST, SRC, (N)*sizeof(size_t)); \
- else HDmemset (DST, 0, (N)*sizeof(size_t)); \
+#define H5V_vector_cpy(N,DST,SRC) { \
+ if (SRC) HDmemcpy (DST, SRC, (N)*sizeof(size_t)); \
+ else HDmemset (DST, 0, (N)*sizeof(size_t)); \
}
#define H5V_vector_zero(N,DST) HDmemset(DST,0,(N)*sizeof(size_t))
/* A null pointer is equivalent to a zero vector */
-#define H5V_ZERO NULL
+#define H5V_ZERO NULL
-size_t H5V_hyper_stride (size_t n, const size_t *size,
- const size_t *total_size, const size_t *offset,
- intn *stride);
-hbool_t H5V_hyper_disjointp (size_t n,
- const size_t *offset1, const size_t *size1,
- const size_t *offset2, const size_t *size2);
-hbool_t H5V_hyper_eq (size_t n, const size_t *offset1, const size_t *size1,
- const size_t *offset2, const size_t *size2);
-herr_t H5V_hyper_fill (size_t n, const size_t *total_size,
- const size_t *offset, const size_t *size,
- void *buf, uint8 val);
-herr_t H5V_hyper_copy (size_t n, const size_t *size,
- const size_t *dst_total_size, const size_t *dst_offset,
- void *_dst, const size_t *src_total_size,
- const size_t *src_offset, const void *_src);
-herr_t H5V_stride_fill (size_t n, size_t elmt_size, const size_t *size,
- const intn *stride, void *_dst, uint8 fill_value);
-herr_t H5V_stride_copy (size_t n, size_t elmt_size, const size_t *_size,
- const intn *dst_stride, void *_dst,
- const intn *src_stride, const void *_src);
-herr_t H5V_stride_copy2 (size_t nelmts, size_t elmt_size, size_t dst_n,
- const size_t *dst_size, const intn *dst_stride,
- void *_dst, size_t src_n, const size_t *src_size,
- const intn *src_stride, const void *_src);
+size_t H5V_hyper_stride(size_t n, const size_t *size,
+ const size_t *total_size, const size_t *offset,
+ intn *stride);
+hbool_t H5V_hyper_disjointp(size_t n,
+ const size_t *offset1, const size_t *size1,
+ const size_t *offset2, const size_t *size2);
+hbool_t H5V_hyper_eq(size_t n, const size_t *offset1, const size_t *size1,
+ const size_t *offset2, const size_t *size2);
+herr_t H5V_hyper_fill(size_t n, const size_t *total_size,
+ const size_t *offset, const size_t *size,
+ void *buf, uint8 val);
+herr_t H5V_hyper_copy(size_t n, const size_t *size,
+ const size_t *dst_total_size, const size_t *dst_offset,
+ void *_dst, const size_t *src_total_size,
+ const size_t *src_offset, const void *_src);
+herr_t H5V_stride_fill(size_t n, size_t elmt_size, const size_t *size,
+ const intn *stride, void *_dst, uint8 fill_value);
+herr_t H5V_stride_copy(size_t n, size_t elmt_size, const size_t *_size,
+ const intn *dst_stride, void *_dst,
+ const intn *src_stride, const void *_src);
+herr_t H5V_stride_copy2(size_t nelmts, size_t elmt_size, size_t dst_n,
+ const size_t *dst_size, const intn *dst_stride,
+ void *_dst, size_t src_n, const size_t *src_size,
+ const intn *src_stride, const void *_src);
/*-------------------------------------------------------------------------
- * Function: H5V_vector_reduce_product
+ * Function: H5V_vector_reduce_product
*
- * Purpose: Product reduction of a vector. Vector elements and return
- * value are size_t because we usually want the number of
- * elements in an array and array dimensions are always of type
- * size_t.
+ * Purpose: Product reduction of a vector. Vector elements and return
+ * value are size_t because we usually want the number of
+ * elements in an array and array dimensions are always of type
+ * size_t.
*
- * Return: Success: Product of elements
+ * Return: Success: Product of elements
*
- * Failure: 1 if N is zero
+ * Failure: 1 if N is zero
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, October 10, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-static inline size_t __attribute__ ((unused))
-H5V_vector_reduce_product (size_t n, const size_t *v)
+static inline size_t
+__attribute__((unused))
+H5V_vector_reduce_product(size_t n, const size_t *v)
{
- size_t ans=1;
+ size_t ans = 1;
- if (n && !v) return 0;
- while (n--) ans *= *v++;
- return ans;
+ if (n && !v)
+ return 0;
+ while (n--)
+ ans *= *v++;
+ return ans;
}
/*-------------------------------------------------------------------------
- * Function: H5V_vector_zerop
+ * Function: H5V_vector_zerop
*
- * Purpose: Determines if all elements of a vector are zero.
+ * Purpose: Determines if all elements of a vector are zero.
*
- * Return: Success: TRUE if all elements are zero,
- * FALSE otherwise
+ * Return: Success: TRUE if all elements are zero,
+ * FALSE otherwise
*
- * Failure: TRUE if N is zero
+ * Failure: TRUE if N is zero
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, October 10, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-static inline hbool_t __attribute__ ((unused))
-H5V_vector_zerop (size_t n, const size_t *v)
+static inline hbool_t
+__attribute__((unused))
+H5V_vector_zerop(size_t n, const size_t *v)
{
- if (!v) return TRUE;
- while (n--) if (*v++) return FALSE;
- return TRUE;
+ if (!v)
+ return TRUE;
+ while (n--)
+ if (*v++)
+ return FALSE;
+ return TRUE;
}
/*-------------------------------------------------------------------------
- * Function: H5V_vector_cmp
+ * Function: H5V_vector_cmp
*
- * Purpose: Compares two vectors of the same size and determines if V1 is
- * lexicographically less than, equal, or greater than V2.
+ * Purpose: Compares two vectors of the same size and determines if V1 is
+ * lexicographically less than, equal, or greater than V2.
*
- * Return: Success: -1 if V1 is less than V2
- * 0 if they are equal
- * 1 if V1 is greater than V2
+ * Return: Success: -1 if V1 is less than V2
+ * 0 if they are equal
+ * 1 if V1 is greater than V2
*
- * Failure: 0 if N is zero
+ * Failure: 0 if N is zero
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Friday, October 10, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-static inline intn __attribute__ ((unused))
-H5V_vector_cmp (size_t n, const size_t *v1, const size_t *v2)
+static inline intn
+__attribute__((unused))
+H5V_vector_cmp(size_t n, const size_t *v1, const size_t *v2)
{
- if (v1==v2) return 0;
- while (n--) {
- if ((v1?*v1:0) < (v2?*v2:0)) return -1;
- if ((v1?*v1:0) > (v2?*v2:0)) return 1;
- if (v1) v1++;
- if (v2) v2++;
- }
- return 0;
+ if (v1 == v2)
+ return 0;
+ while (n--) {
+ if ((v1 ? *v1 : 0) < (v2 ? *v2 : 0))
+ return -1;
+ if ((v1 ? *v1 : 0) > (v2 ? *v2 : 0))
+ return 1;
+ if (v1)
+ v1++;
+ if (v2)
+ v2++;
+ }
+ return 0;
}
-
-
/*-------------------------------------------------------------------------
- * Function: H5V_vector_inc
+ * Function: H5V_vector_inc
*
- * Purpose: Increments V1 by V2
+ * Purpose: Increments V1 by V2
*
- * Return: void
+ * Return: void
*
- * Programmer: Robb Matzke
+ * Programmer: Robb Matzke
* Monday, October 13, 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
-static inline void __attribute__ ((unused))
-H5V_vector_inc (size_t n, size_t *v1, const size_t *v2)
+static inline void
+__attribute__((unused))
+H5V_vector_inc(size_t n, size_t *v1, const size_t *v2)
{
- while (n--) *v1++ += *v2++;
+ while (n--)
+ *v1++ += *v2++;
}
-
#endif
diff --git a/src/H5detect.c b/src/H5detect.c
index a5e3cef..749618f 100644
--- a/src/H5detect.c
+++ b/src/H5detect.c
@@ -1,30 +1,30 @@
/**/
static const char *FileHeader = "\n\
/*-------------------------------------------------------------------------\n\
- * Copyright (C) 1997 National Center for Supercomputing Applications. \n\
- * All rights reserved. \n\
- * \n\
+ * Copyright (C) 1997 National Center for Supercomputing Applications. \n\
+ * All rights reserved. \n\
+ * \n\
*-------------------------------------------------------------------------";
/*
*
- * Created: H5detect.c
- * 10 Aug 1997
- * Robb Matzke
+ * Created: H5detect.c
+ * 10 Aug 1997
+ * Robb Matzke
*
- * Purpose: This code was borrowed heavily from the `detect.c'
- * program in the AIO distribution from Lawrence
- * Livermore National Laboratory.
+ * Purpose: This code was borrowed heavily from the `detect.c'
+ * program in the AIO distribution from Lawrence
+ * Livermore National Laboratory.
*
- * Detects machine byte order and floating point
- * format and generates a C source file (native.c)
- * to describe those paramters.
+ * Detects machine byte order and floating point
+ * format and generates a C source file (native.c)
+ * to describe those paramters.
*
- * Assumptions: We have an ANSI compiler. We're on a Unix like
- * system or configure has detected those Unix
- * features which aren't available. We're not
- * running on a Vax or other machine with mixed
- * endianess.
- *
+ * Assumptions: We have an ANSI compiler. We're on a Unix like
+ * system or configure has detected those Unix
+ * features which aren't available. We're not
+ * running on a Vax or other machine with mixed
+ * endianess.
+ *
* Modifications:
*
*-------------------------------------------------------------------------
@@ -51,26 +51,25 @@ static const char *FileHeader = "\n\
* was detected.
*/
typedef struct detected_t {
- const char *varname;
- int size;
- int padding;
- int perm[32];
- int sign;
- int mpos, msize, imp;
- int epos, esize, bias;
+ const char *varname;
+ int size;
+ int padding;
+ int perm[32];
+ int sign;
+ int mpos, msize, imp;
+ int epos, esize, bias;
} detected_t;
-static void print_results (int nd, detected_t *d);
-static void iprint (detected_t*);
-static void print_known_formats (detected_t*);
-static int byte_cmp (int, void*, void*);
-static int bit_cmp (int, int*, void*, void*);
-static void fix_order (int, int, int, int*, const char **);
-static void fix_padding (detected_t*);
-static int imp_bit (int, int*, void*, void*);
-static int find_bias (int, int, int, int*, void*);
-static void print_header (void);
-
+static void print_results(int nd, detected_t *d);
+static void iprint(detected_t *);
+static void print_known_formats(detected_t *);
+static int byte_cmp(int, void *, void *);
+static int bit_cmp(int, int *, void *, void *);
+static void fix_order(int, int, int, int *, const char **);
+static void fix_padding(detected_t *);
+static int imp_bit(int, int *, void *, void *);
+static int find_bias(int, int, int, int *, void *);
+static void print_header(void);
/*-------------------------------------------------------------------------
* For convenience, we place here in a table descriptions of all
@@ -79,7 +78,7 @@ static void print_header (void);
* in the VARNAME field.
*-------------------------------------------------------------------------
*/
-#define LE {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, \
+#define LE {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15, \
16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31}
#define LE_1 LE
#define LE_2 LE
@@ -93,183 +92,182 @@ static void print_header (void);
#define INTEGER 0,0,0,0,0,0,0
-static detected_t Known[] = {
+static detected_t Known[] =
+{
/* Single-byte quantities */
- {"Byte addressable",
- 1, 0, LE_1, INTEGER},
+ {"Byte addressable",
+ 1, 0, LE_1, INTEGER},
/* Little-endian integer */
- {"Little-endian",
- 2, 0, LE_2, INTEGER},
- {"Little-endian",
- 4, 0, LE_4, INTEGER},
+ {"Little-endian",
+ 2, 0, LE_2, INTEGER},
+ {"Little-endian",
+ 4, 0, LE_4, INTEGER},
/* Big-endian integer */
- {"Big-endian",
- 2, 0, BE_2, INTEGER},
- {"Big-endian",
- 4, 0, BE_4, INTEGER},
+ {"Big-endian",
+ 2, 0, BE_2, INTEGER},
+ {"Big-endian",
+ 4, 0, BE_4, INTEGER},
/* Little-endian IEEE floating-point */
- {"Little-endian IEEE",
- 4, 0, LE_4, 31, 0, 23, 1, 23, 8, 127},
- {"Little-endian IEEE",
- 8, 0, LE_8, 63, 0, 52, 1, 52, 11, 1023},
+ {"Little-endian IEEE",
+ 4, 0, LE_4, 31, 0, 23, 1, 23, 8, 127},
+ {"Little-endian IEEE",
+ 8, 0, LE_8, 63, 0, 52, 1, 52, 11, 1023},
/* Big-endian IEEE floating-point */
- {"Big-endian IEEE",
- 4, 0, BE_4, 31, 0, 23, 1, 23, 8, 127},
- {"Big-endian IEEE",
- 8, 0, BE_8, 63, 0, 52, 1, 52, 11, 1023},
+ {"Big-endian IEEE",
+ 4, 0, BE_4, 31, 0, 23, 1, 23, 8, 127},
+ {"Big-endian IEEE",
+ 8, 0, BE_8, 63, 0, 52, 1, 52, 11, 1023},
};
-
/*-------------------------------------------------------------------------
- * Function: DETECT_I
+ * Function: DETECT_I
*
- * Purpose: This macro takes a type like `int' and a base name like
- * `nati' and detects the byte order. The VAR is used to
- * construct the names of the C variables defined.
+ * Purpose: This macro takes a type like `int' and a base name like
+ * `nati' and detects the byte order. The VAR is used to
+ * construct the names of the C variables defined.
*
- * Return: void
+ * Return: void
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jun 12 1996
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jun 12 1996
*
* Modifications:
*
- * Robb Matzke, 4 Nov 1996
- * The INFO.perm now contains `-1' for bytes that aren't used and
- * are always zero. This happens on the Cray for `short' where
- * sizeof(short) is 8, but only the low-order 4 bytes are ever used.
+ * Robb Matzke, 4 Nov 1996
+ * The INFO.perm now contains `-1' for bytes that aren't used and
+ * are always zero. This happens on the Cray for `short' where
+ * sizeof(short) is 8, but only the low-order 4 bytes are ever used.
*
- * Robb Matzke, 4 Nov 1996
- * Added a `padding' field to indicate how many zero bytes appear to
- * the left (N) or right (-N) of the value.
+ * Robb Matzke, 4 Nov 1996
+ * Added a `padding' field to indicate how many zero bytes appear to
+ * the left (N) or right (-N) of the value.
*
- * Robb Matzke, 5 Nov 1996
- * Removed HFILE and CFILE arguments.
+ * Robb Matzke, 5 Nov 1996
+ * Removed HFILE and CFILE arguments.
*
*-------------------------------------------------------------------------
*/
-#define DETECT_I(TYPE,VAR,INFO) { \
- TYPE _v; \
- int _i, _j; \
- unsigned char *_x; \
- memset (&INFO, 0, sizeof(INFO)); \
- INFO.varname = #VAR; \
- INFO.size = sizeof(TYPE); \
- for (_i=sizeof(TYPE),_v=0; _i>0; --_i) _v = (_v<<8) + _i; \
- for (_i=0,_x=(unsigned char *)&_v; _i<sizeof(TYPE); _i++) { \
- _j = (*_x++)-1; \
- assert (_j<(signed)sizeof(TYPE)); \
- INFO.perm[_i] = _j; \
- } \
- fix_padding (&(INFO)); \
- INFO.sign = ('U'!=*(#VAR)); \
+#define DETECT_I(TYPE,VAR,INFO) { \
+ TYPE _v; \
+ int _i, _j; \
+ unsigned char *_x; \
+ memset (&INFO, 0, sizeof(INFO)); \
+ INFO.varname = #VAR; \
+ INFO.size = sizeof(TYPE); \
+ for (_i=sizeof(TYPE),_v=0; _i>0; --_i) _v = (_v<<8) + _i; \
+ for (_i=0,_x=(unsigned char *)&_v; _i<sizeof(TYPE); _i++) { \
+ _j = (*_x++)-1; \
+ assert (_j<(signed)sizeof(TYPE)); \
+ INFO.perm[_i] = _j; \
+ } \
+ fix_padding (&(INFO)); \
+ INFO.sign = ('U'!=*(#VAR)); \
}
-
/*-------------------------------------------------------------------------
- * Function: DETECT_F
+ * Function: DETECT_F
*
- * Purpose: This macro takes a floating point type like `double' and
- * a base name like `natd' and detects byte order, mantissa
- * location, exponent location, sign bit location, presence or
- * absence of implicit mantissa bit, and exponent bias and
- * initializes a detected_t structure with those properties.
+ * Purpose: This macro takes a floating point type like `double' and
+ * a base name like `natd' and detects byte order, mantissa
+ * location, exponent location, sign bit location, presence or
+ * absence of implicit mantissa bit, and exponent bias and
+ * initializes a detected_t structure with those properties.
*
- * Return: void
+ * Return: void
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jun 12 1996
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jun 12 1996
*
* Modifications:
*
- * Robb Matzke, 14 Aug 1996
- * The byte order detection has been changed because on the Cray
- * the last pass causes a rounding to occur that causes the least
- * significant mantissa byte to change unexpectedly.
+ * Robb Matzke, 14 Aug 1996
+ * The byte order detection has been changed because on the Cray
+ * the last pass causes a rounding to occur that causes the least
+ * significant mantissa byte to change unexpectedly.
*
- * Robb Matzke, 5 Nov 1996
- * Removed HFILE and CFILE arguments.
+ * Robb Matzke, 5 Nov 1996
+ * Removed HFILE and CFILE arguments.
*-------------------------------------------------------------------------
*/
-#define DETECT_F(TYPE,VAR,INFO) { \
- TYPE _v1, _v2, _v3; \
- int _i, _j, _first=(-1), _last=(-1); \
- char *_mesg; \
- \
- memset (&INFO, 0, sizeof(INFO)); \
- INFO.varname = #VAR; \
- INFO.size = sizeof(TYPE); \
- INFO.padding = 0; \
- \
- /* Byte Order */ \
- for (_i=0,_v1=0.0,_v2=1.0; _i<sizeof(TYPE); _i++) { \
- _v3 = _v1; _v1 += _v2; _v2 /= 256.0; \
- if ((_j=byte_cmp(sizeof(TYPE), &_v3, &_v1))>=0) { \
- if (0==_i || INFO.perm[_i-1]!=_j) { \
- INFO.perm[_i] = _j; \
- _last = _i; \
- if (_first<0) _first = _i; \
- } \
- } \
- } \
+#define DETECT_F(TYPE,VAR,INFO) { \
+ TYPE _v1, _v2, _v3; \
+ int _i, _j, _first=(-1), _last=(-1); \
+ char *_mesg; \
+ \
+ memset (&INFO, 0, sizeof(INFO)); \
+ INFO.varname = #VAR; \
+ INFO.size = sizeof(TYPE); \
+ INFO.padding = 0; \
+ \
+ /* Byte Order */ \
+ for (_i=0,_v1=0.0,_v2=1.0; _i<sizeof(TYPE); _i++) { \
+ _v3 = _v1; _v1 += _v2; _v2 /= 256.0; \
+ if ((_j=byte_cmp(sizeof(TYPE), &_v3, &_v1))>=0) { \
+ if (0==_i || INFO.perm[_i-1]!=_j) { \
+ INFO.perm[_i] = _j; \
+ _last = _i; \
+ if (_first<0) _first = _i; \
+ } \
+ } \
+ } \
fix_order (sizeof(TYPE), _first, _last, INFO.perm, (const char**)&_mesg); \
- \
- /* Implicit mantissa bit */ \
- _v1 = 0.5; \
- _v2 = 1.0; \
- INFO.imp = imp_bit (sizeof(TYPE), INFO.perm, &_v1, &_v2); \
- \
- /* Sign bit */ \
- _v1 = 1.0; \
- _v2 = -1.0; \
- INFO.sign = bit_cmp (sizeof(TYPE), INFO.perm, &_v1, &_v2); \
- \
- /* Mantissa */ \
- INFO.mpos = 0; \
- \
- _v1 = 1.0; \
- _v2 = 1.5; \
- INFO.msize = bit_cmp (sizeof(TYPE), INFO.perm, &_v1, &_v2); \
- INFO.msize += 1 + (INFO.imp?0:1) - INFO.mpos; \
- \
- /* Exponent */ \
- INFO.epos = INFO.mpos + INFO.msize; \
- \
- INFO.esize = INFO.sign - INFO.epos; \
- \
- _v1 = 1.0; \
+ \
+ /* Implicit mantissa bit */ \
+ _v1 = 0.5; \
+ _v2 = 1.0; \
+ INFO.imp = imp_bit (sizeof(TYPE), INFO.perm, &_v1, &_v2); \
+ \
+ /* Sign bit */ \
+ _v1 = 1.0; \
+ _v2 = -1.0; \
+ INFO.sign = bit_cmp (sizeof(TYPE), INFO.perm, &_v1, &_v2); \
+ \
+ /* Mantissa */ \
+ INFO.mpos = 0; \
+ \
+ _v1 = 1.0; \
+ _v2 = 1.5; \
+ INFO.msize = bit_cmp (sizeof(TYPE), INFO.perm, &_v1, &_v2); \
+ INFO.msize += 1 + (INFO.imp?0:1) - INFO.mpos; \
+ \
+ /* Exponent */ \
+ INFO.epos = INFO.mpos + INFO.msize; \
+ \
+ INFO.esize = INFO.sign - INFO.epos; \
+ \
+ _v1 = 1.0; \
INFO.bias = find_bias (INFO.epos, INFO.esize, INFO.imp, INFO.perm, &_v1); \
}
-
/*-------------------------------------------------------------------------
- * Function: print_results
+ * Function: print_results
*
- * Purpose: Prints information about the detected data types.
+ * Purpose: Prints information about the detected data types.
*
- * Return: void
+ * Return: void
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jun 14, 1996
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jun 14, 1996
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static void
-print_results (int nd, detected_t *d) {
+print_results(int nd, detected_t *d)
+{
- int i;
+ int i;
- /* Include files */
- printf ("\
+ /* Include files */
+ printf("\
#define H5T_PACKAGE /*suppress error about including H5Tpkg.h*/\n\
\n\
#include <H5private.h>\n\
@@ -280,31 +278,30 @@ print_results (int nd, detected_t *d) {
static hbool_t interface_initialize_g = FALSE;\n\
#define INTERFACE_INIT NULL\n\
\n");
-
- /* Function declaration */
- printf ("\n\
+ /* Function declaration */
+ printf("\n\
herr_t\n\
H5T_init (void)\n\
{\n\
- H5T_t *dt = NULL;\n\
- static intn ncalls = 0;\n\
+ H5T_t *dt = NULL;\n\
+ static intn ncalls = 0;\n\
\n\
FUNC_ENTER (H5T_init, FAIL);\n\
\n\
if (ncalls++) return SUCCEED; /*already initialized*/\n\
-\n");
-
- for (i=0; i<nd; i++) {
-
- /* Print a comment to describe this section of definitions. */
- printf ("\n /*\n");
- iprint (d+i);
- print_known_formats (d+i);
- printf (" */\n");
-
- /* The part common to fixed and floating types */
- printf ("\
+\n");
+
+ for (i = 0; i < nd; i++) {
+
+ /* Print a comment to describe this section of definitions. */
+ printf("\n /*\n");
+ iprint(d + i);
+ print_known_formats(d + i);
+ printf(" */\n");
+
+ /* The part common to fixed and floating types */
+ printf("\
dt = H5MM_xcalloc (1, sizeof(H5T_t));\n\
dt->locked = TRUE;\n\
dt->type = H5T_%s;\n\
@@ -313,19 +310,19 @@ H5T_init (void)\n\
dt->u.atomic.prec = %d;\n\
dt->u.atomic.lsb_pad = H5T_PAD_ZERO;\n\
dt->u.atomic.lsb_pad = H5T_PAD_ZERO;\n",
- d[i].msize?"FLOAT":"INTEGER", /*class */
- d[i].size+abs (d[i].padding), /*size */
- d[i].perm[0]?"BE":"LE", /*byte order */
- 8*d[i].size); /*precision */
-
- if (0==d[i].msize) {
- /* The part unique to fixed point types */
- printf ("\
+ d[i].msize ? "FLOAT" : "INTEGER", /*class */
+ d[i].size + abs(d[i].padding), /*size */
+ d[i].perm[0] ? "BE" : "LE", /*byte order */
+ 8 * d[i].size); /*precision */
+
+ if (0 == d[i].msize) {
+ /* The part unique to fixed point types */
+ printf("\
dt->u.atomic.u.i.sign = H5T_SGN_%s;\n",
- d[i].sign?"2":"NONE");
- } else {
- /* The part unique to floating point types */
- printf ("\
+ d[i].sign ? "2" : "NONE");
+ } else {
+ /* The part unique to floating point types */
+ printf("\
dt->u.atomic.u.f.sign = %d;\n\
dt->u.atomic.u.f.epos = %d;\n\
dt->u.atomic.u.f.esize = %d;\n\
@@ -334,470 +331,495 @@ H5T_init (void)\n\
dt->u.atomic.u.f.msize = %d;\n\
dt->u.atomic.u.f.norm = H5T_NORM_%s;\n\
dt->u.atomic.u.f.pad = H5T_PAD_ZERO;\n",
- d[i].sign, /*sign location */
- d[i].epos, /*exponent loc */
- d[i].esize, /*exponent size */
- d[i].bias, /*exponent bias */
- d[i].mpos, /*mantissa loc */
- d[i].msize, /*mantissa size */
- d[i].imp?"IMPLIED":"NONE"); /*normalization */
- }
-
- /* Atomize the type */
- printf ("\
+ d[i].sign, /*sign location */
+ d[i].epos, /*exponent loc */
+ d[i].esize, /*exponent size */
+ d[i].bias, /*exponent bias */
+ d[i].mpos, /*mantissa loc */
+ d[i].msize, /*mantissa size */
+ d[i].imp ? "IMPLIED" : "NONE"); /*normalization */
+ }
+
+ /* Atomize the type */
+ printf("\
if ((H5T_NATIVE_%s_g = H5Aregister_atom (H5_DATATYPE, dt))<0) {\n\
HRETURN_ERROR (H5E_DATATYPE, H5E_CANTINIT, FAIL,\n\
\"can't initialize type system (atom registration \"\n\
\"failure\");\n\
- }\n",
- d[i].varname);
-
- }
+ }\n",
+ d[i].varname);
- printf (" FUNC_LEAVE (SUCCEED);\n}\n");
-}
+ }
+ printf(" FUNC_LEAVE (SUCCEED);\n}\n");
+}
/*-------------------------------------------------------------------------
- * Function: iprint
+ * Function: iprint
*
- * Purpose: Prints information about the fields of a floating point
- * format.
+ * Purpose: Prints information about the fields of a floating point
+ * format.
*
- * Return: void
+ * Return: void
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jun 13, 1996
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jun 13, 1996
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static void
-iprint (detected_t *d) {
-
- int i, j, k;
-
- /*
- * Print the byte ordering above the bit fields.
- */
- printf (" * ");
- for (i=d->size-1; i>=0; --i) {
- printf ("%4d", d->perm[i]);
- if (i>0) fputs (" ", stdout);
- if (0==i%4) putchar (' ');
- }
- putchar ('\n');
-
- /*
- * Print the bit fields
- */
- printf (" * ");
- for (i=d->size-1,k=d->size*8-1; i>=0; --i) {
- for (j=7; j>=0; --j) {
- if (k==d->sign && d->msize) {
- putchar ('S');
- } else if (k>=d->epos && k<d->epos+d->esize) {
- putchar ('E');
- } else if (k>=d->mpos && k<d->mpos+d->msize) {
- putchar ('M');
- } else if (d->msize) {
- putchar ('?'); /*unknown floating point bit*/
- } else if (d->sign) {
- putchar ('I');
- } else {
- putchar ('U');
- }
- --k;
- }
- if (i>0) {
- putchar (' ');
- if (0==i%4) putchar (' ');
- }
- }
- putchar ('\n');
-
- /*
- * Is there an implicit bit in the mantissa.
- */
- if (d->msize) {
- printf (" * Implicit bit? %s\n", d->imp?"yes":"no");
- }
+iprint(detected_t *d)
+{
+
+ int i, j, k;
+
+ /*
+ * Print the byte ordering above the bit fields.
+ */
+ printf(" * ");
+ for (i = d->size - 1; i >= 0; --i) {
+ printf("%4d", d->perm[i]);
+ if (i > 0)
+ fputs(" ", stdout);
+ if (0 == i % 4)
+ putchar(' ');
+ }
+ putchar('\n');
+
+ /*
+ * Print the bit fields
+ */
+ printf(" * ");
+ for (i = d->size - 1, k = d->size * 8 - 1; i >= 0; --i) {
+ for (j = 7; j >= 0; --j) {
+ if (k == d->sign && d->msize) {
+ putchar('S');
+ } else if (k >= d->epos && k < d->epos + d->esize) {
+ putchar('E');
+ } else if (k >= d->mpos && k < d->mpos + d->msize) {
+ putchar('M');
+ } else if (d->msize) {
+ putchar('?'); /*unknown floating point bit */
+ } else if (d->sign) {
+ putchar('I');
+ } else {
+ putchar('U');
+ }
+ --k;
+ }
+ if (i > 0) {
+ putchar(' ');
+ if (0 == i % 4)
+ putchar(' ');
+ }
+ }
+ putchar('\n');
+
+ /*
+ * Is there an implicit bit in the mantissa.
+ */
+ if (d->msize) {
+ printf(" * Implicit bit? %s\n", d->imp ? "yes" : "no");
+ }
}
-
/*-------------------------------------------------------------------------
- * Function: print_known_formats
+ * Function: print_known_formats
*
- * Purpose: Prints archetecture names for the specified format
- * description, if any.
+ * Purpose: Prints archetecture names for the specified format
+ * description, if any.
*
- * Return: void
+ * Return: void
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jun 13, 1996
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jun 13, 1996
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static void
-print_known_formats (detected_t *d) {
-
- int i, j, diff;
- int n=sizeof(Known)/sizeof(Known[0]);
-
- for (i=0; i<n; i++) {
- if (d->size != Known[i].size) continue;
- for (j=diff=0; !diff && j<d->size; j++) {
- if (d->perm[j] != Known[i].perm[j]) diff = 1;
- }
- if (diff) continue;
-
- /* if (d->sign != Known[i].sign) continue;*/
- if (d->mpos != Known[i].mpos) continue;
- if (d->msize != Known[i].msize) continue;
- if (d->imp != Known[i].imp) continue;
- if (d->epos != Known[i].epos) continue;
- if (d->esize != Known[i].esize) continue;
- if (d->bias != Known[i].bias) continue;
-
- printf (" * %s\n", Known[i].varname);
- }
+print_known_formats(detected_t *d)
+{
+
+ int i, j, diff;
+ int n = sizeof(Known) / sizeof(Known[0]);
+
+ for (i = 0; i < n; i++) {
+ if (d->size != Known[i].size)
+ continue;
+ for (j = diff = 0; !diff && j < d->size; j++) {
+ if (d->perm[j] != Known[i].perm[j])
+ diff = 1;
+ }
+ if (diff)
+ continue;
+
+ /* if (d->sign != Known[i].sign) continue; */
+ if (d->mpos != Known[i].mpos)
+ continue;
+ if (d->msize != Known[i].msize)
+ continue;
+ if (d->imp != Known[i].imp)
+ continue;
+ if (d->epos != Known[i].epos)
+ continue;
+ if (d->esize != Known[i].esize)
+ continue;
+ if (d->bias != Known[i].bias)
+ continue;
+
+ printf(" * %s\n", Known[i].varname);
+ }
}
-
/*-------------------------------------------------------------------------
- * Function: byte_cmp
+ * Function: byte_cmp
*
- * Purpose: Compares two chunks of memory A and B and returns the
- * byte index into those arrays of the first byte that
- * differs between A and B.
+ * Purpose: Compares two chunks of memory A and B and returns the
+ * byte index into those arrays of the first byte that
+ * differs between A and B.
*
- * Return: Success: Index of differing byte.
+ * Return: Success: Index of differing byte.
*
- * Failure: -1 if all bytes are the same.
+ * Failure: -1 if all bytes are the same.
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jun 12, 1996
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jun 12, 1996
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static int
-byte_cmp (int n, void *_a, void *_b) {
+byte_cmp(int n, void *_a, void *_b)
+{
- register int i;
- unsigned char *a = (unsigned char *)_a;
- unsigned char *b = (unsigned char *)_b;
+ register int i;
+ unsigned char *a = (unsigned char *) _a;
+ unsigned char *b = (unsigned char *) _b;
- for (i=0; i<n; i++) if (a[i]!=b[i]) return i;
- return -1;
+ for (i = 0; i < n; i++)
+ if (a[i] != b[i])
+ return i;
+ return -1;
}
-
/*-------------------------------------------------------------------------
- * Function: bit_cmp
+ * Function: bit_cmp
*
- * Purpose: Compares two bit vectors and returns the index for the
- * first bit that differs between the two vectors. The
- * size of the vector is NBYTES. PERM is a mapping from
- * actual order to little endian.
+ * Purpose: Compares two bit vectors and returns the index for the
+ * first bit that differs between the two vectors. The
+ * size of the vector is NBYTES. PERM is a mapping from
+ * actual order to little endian.
*
- * Return: Success: Index of first differing bit.
+ * Return: Success: Index of first differing bit.
*
- * Failure: -1
+ * Failure: -1
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jun 13, 1996
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jun 13, 1996
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static int
-bit_cmp (int nbytes, int *perm, void *_a, void *_b) {
-
- int i, j;
- unsigned char *a = (unsigned char *)_a;
- unsigned char *b = (unsigned char *)_b;
- unsigned char aa, bb;
-
- for (i=0; i<nbytes; i++) {
- assert (perm[i]<nbytes);
- if ((aa=a[perm[i]]) != (bb=b[perm[i]])) {
- for (j=0; j<8; j++,aa>>=1,bb>>=1) {
- if ((aa & 1) != (bb & 1)) return i*8 + j;
- }
- assert ("INTERNAL ERROR" && 0);
- }
- }
- return -1;
+bit_cmp(int nbytes, int *perm, void *_a, void *_b)
+{
+
+ int i, j;
+ unsigned char *a = (unsigned char *) _a;
+ unsigned char *b = (unsigned char *) _b;
+ unsigned char aa, bb;
+
+ for (i = 0; i < nbytes; i++) {
+ assert(perm[i] < nbytes);
+ if ((aa = a[perm[i]]) != (bb = b[perm[i]])) {
+ for (j = 0; j < 8; j++, aa >>= 1, bb >>= 1) {
+ if ((aa & 1) != (bb & 1))
+ return i * 8 + j;
+ }
+ assert("INTERNAL ERROR" && 0);
+ }
+ }
+ return -1;
}
-
/*-------------------------------------------------------------------------
- * Function: fix_order
+ * Function: fix_order
*
- * Purpose: Given an array PERM with elements FIRST through LAST
- * initialized with zero origin byte numbers, this function
- * creates a permutation vector that maps the actual order
- * of a floating point number to little-endian.
+ * Purpose: Given an array PERM with elements FIRST through LAST
+ * initialized with zero origin byte numbers, this function
+ * creates a permutation vector that maps the actual order
+ * of a floating point number to little-endian.
*
- * This function assumes that the mantissa byte ordering
- * implies the total ordering.
+ * This function assumes that the mantissa byte ordering
+ * implies the total ordering.
*
- * Return: void
+ * Return: void
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jun 13, 1996
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jun 13, 1996
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static void
-fix_order (int n, int first, int last, int *perm, const char **mesg) {
-
- int i;
-
- if (first+1<last) {
- /*
- * We have at least three points to consider.
- */
- if (perm[last]<perm[last-1] && perm[last-1]<perm[last-2]) {
- /*
- * Little endian.
- */
- if (mesg) *mesg = "Little-endian";
- for (i=0; i<n; i++) perm[i] = i;
-
- } else if (perm[last]>perm[last-1] && perm[last-1]>perm[last-2]) {
- /*
- * Big endian.
- */
- if (mesg) *mesg = "Big-endian";
- for (i=0; i<n; i++) perm[i] = (n-1)-i;
-
- } else {
- /*
- * Bi-endian machines like VAX.
- */
- assert (0==n/2);
- if (mesg) *mesg = "VAX";
- for (i=0; i<n; i+=2) {
- perm[i] = (n-2)-i;
- perm[i+1] = (n-1)-i;
- }
- }
- } else {
- fprintf (stderr,
- "Failed to detect byte order of %d-byte floating point.\n", n);
- exit (1);
- }
+fix_order(int n, int first, int last, int *perm, const char **mesg)
+{
+
+ int i;
+
+ if (first + 1 < last) {
+ /*
+ * We have at least three points to consider.
+ */
+ if (perm[last] < perm[last - 1] && perm[last - 1] < perm[last - 2]) {
+ /*
+ * Little endian.
+ */
+ if (mesg)
+ *mesg = "Little-endian";
+ for (i = 0; i < n; i++)
+ perm[i] = i;
+
+ } else if (perm[last] > perm[last - 1] && perm[last - 1] > perm[last - 2]) {
+ /*
+ * Big endian.
+ */
+ if (mesg)
+ *mesg = "Big-endian";
+ for (i = 0; i < n; i++)
+ perm[i] = (n - 1) - i;
+
+ } else {
+ /*
+ * Bi-endian machines like VAX.
+ */
+ assert(0 == n / 2);
+ if (mesg)
+ *mesg = "VAX";
+ for (i = 0; i < n; i += 2) {
+ perm[i] = (n - 2) - i;
+ perm[i + 1] = (n - 1) - i;
+ }
+ }
+ } else {
+ fprintf(stderr,
+ "Failed to detect byte order of %d-byte floating point.\n", n);
+ exit(1);
+ }
}
-
/*-------------------------------------------------------------------------
- * Function: fix_padding
+ * Function: fix_padding
*
- * Purpose: The permutation can have negative values at the beginning
- * or end which represent zero padding. The amount of padding
- * is subtracted from the size, the negative values are removed
- * from the permutation, and the `padding' field is set to an
- * appropriate value.
+ * Purpose: The permutation can have negative values at the beginning
+ * or end which represent zero padding. The amount of padding
+ * is subtracted from the size, the negative values are removed
+ * from the permutation, and the `padding' field is set to an
+ * appropriate value.
*
- * If N bytes of padding appear to the left (lower address) of
- * the value, then `padding=N'. If N bytes of padding appear
- * to the right of the value then `padding=(-N)'.
+ * If N bytes of padding appear to the left (lower address) of
+ * the value, then `padding=N'. If N bytes of padding appear
+ * to the right of the value then `padding=(-N)'.
*
- * Return: void
+ * Return: void
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Nov 4 1996
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Nov 4 1996
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static void
-fix_padding (detected_t *d) {
-
- int i, n;
-
- if (d->perm[0]<0) {
- /*
- * Left padding.
- */
- for (n=0; n<d->size && d->perm[n]<0; n++) /*void*/;
- for (i=n; i<d->size; i++) d->perm[i-n] = d->perm[i];
- for (i=d->size-n; i<d->size; i++) d->perm[i] = 0;
- d->padding = n;
- d->size -= n;
-
- } else if (d->perm[d->size-1]<0) {
- /*
- * Right padding.
- */
- for (n=0; n<d->size && d->perm[d->size-(n+1)]; n++) /*void*/;
- for (i=d->size-n; i<d->size; i++) d->perm[i] = 0;
- d->padding = -n;
- d->size -= n;
-
- } else {
- /*
- * No padding.
- */
- d->padding = 0;
- }
+fix_padding(detected_t *d)
+{
+
+ int i, n;
+
+ if (d->perm[0] < 0) {
+ /*
+ * Left padding.
+ */
+ for (n = 0; n < d->size && d->perm[n] < 0; n++) /*void */
+ ;
+ for (i = n; i < d->size; i++)
+ d->perm[i - n] = d->perm[i];
+ for (i = d->size - n; i < d->size; i++)
+ d->perm[i] = 0;
+ d->padding = n;
+ d->size -= n;
+
+ } else if (d->perm[d->size - 1] < 0) {
+ /*
+ * Right padding.
+ */
+ for (n = 0; n < d->size && d->perm[d->size - (n + 1)]; n++) /*void */
+ ;
+ for (i = d->size - n; i < d->size; i++)
+ d->perm[i] = 0;
+ d->padding = -n;
+ d->size -= n;
+
+ } else {
+ /*
+ * No padding.
+ */
+ d->padding = 0;
+ }
}
-
/*-------------------------------------------------------------------------
- * Function: imp_bit
- *
- * Purpose: Looks for an implicit bit in the mantissa. The value
- * of _A should be 1.0 and the value of _B should be 0.5.
- * Some floating-point formats discard the most significant
- * bit of the mantissa after normalizing since it will always
- * be a one (except for 0.0). If this is true for the native
- * floating point values stored in _A and _B then the function
- * returns non-zero.
- *
- * This function assumes that the exponent occupies higher
- * order bits than the mantissa and that the most significant
- * bit of the mantissa is next to the least signficant bit
- * of the exponent.
- *
- *
- * Return: Success: Non-zero if the most significant bit
- * of the mantissa is discarded (ie, the
- * mantissa has an implicit `one' as the
- * most significant bit). Otherwise,
- * returns zero.
- *
- * Failure: exit(1)
- *
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jun 13, 1996
+ * Function: imp_bit
+ *
+ * Purpose: Looks for an implicit bit in the mantissa. The value
+ * of _A should be 1.0 and the value of _B should be 0.5.
+ * Some floating-point formats discard the most significant
+ * bit of the mantissa after normalizing since it will always
+ * be a one (except for 0.0). If this is true for the native
+ * floating point values stored in _A and _B then the function
+ * returns non-zero.
+ *
+ * This function assumes that the exponent occupies higher
+ * order bits than the mantissa and that the most significant
+ * bit of the mantissa is next to the least signficant bit
+ * of the exponent.
+ *
+ *
+ * Return: Success: Non-zero if the most significant bit
+ * of the mantissa is discarded (ie, the
+ * mantissa has an implicit `one' as the
+ * most significant bit). Otherwise,
+ * returns zero.
+ *
+ * Failure: exit(1)
+ *
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jun 13, 1996
*
* Modifications:
*
- * Robb Matzke, 6 Nov 1996
- * Fixed a bug that occurs with non-implicit architectures.
+ * Robb Matzke, 6 Nov 1996
+ * Fixed a bug that occurs with non-implicit architectures.
*
*-------------------------------------------------------------------------
*/
static int
-imp_bit (int n, int *perm, void *_a, void *_b) {
-
- unsigned char *a = (unsigned char *)_a;
- unsigned char *b = (unsigned char *)_b;
- int changed, major, minor;
- int msmb; /*most significant mantissa bit*/
-
- /*
- * Look for the least significant bit that has changed between
- * A and B. This is the least significant bit of the exponent.
- */
- changed = bit_cmp (n, perm, a, b);
- assert (changed>=0);
-
- /*
- * The bit to the right (less significant) of the changed bit should
- * be the most significant bit of the mantissa. If it is non-zero
- * then the format does not remove the leading `1' of the mantissa.
- */
- msmb = changed-1;
- major = msmb / 8;
- minor = msmb % 8;
-
- return (a[perm[major]] >> minor) & 0x01 ? 0 : 1;
+imp_bit(int n, int *perm, void *_a, void *_b)
+{
+
+ unsigned char *a = (unsigned char *) _a;
+ unsigned char *b = (unsigned char *) _b;
+ int changed, major, minor;
+ int msmb; /*most significant mantissa bit */
+
+ /*
+ * Look for the least significant bit that has changed between
+ * A and B. This is the least significant bit of the exponent.
+ */
+ changed = bit_cmp(n, perm, a, b);
+ assert(changed >= 0);
+
+ /*
+ * The bit to the right (less significant) of the changed bit should
+ * be the most significant bit of the mantissa. If it is non-zero
+ * then the format does not remove the leading `1' of the mantissa.
+ */
+ msmb = changed - 1;
+ major = msmb / 8;
+ minor = msmb % 8;
+
+ return (a[perm[major]] >> minor) & 0x01 ? 0 : 1;
}
-
/*-------------------------------------------------------------------------
- * Function: find_bias
+ * Function: find_bias
*
- * Purpose: Determines the bias of the exponent. This function should
- * be called with _A having a value of `1'.
+ * Purpose: Determines the bias of the exponent. This function should
+ * be called with _A having a value of `1'.
*
- * Return: Success: The exponent bias.
+ * Return: Success: The exponent bias.
*
- * Failure:
+ * Failure:
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jun 13, 1996
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jun 13, 1996
*
* Modifications:
*
- * Robb Matzke, 6 Nov 1996
- * Fixed a bug with non-implicit architectures returning the
- * wrong exponent bias.
+ * Robb Matzke, 6 Nov 1996
+ * Fixed a bug with non-implicit architectures returning the
+ * wrong exponent bias.
*
*-------------------------------------------------------------------------
*/
static int
-find_bias (int epos, int esize, int imp, int *perm, void *_a) {
-
+find_bias(int epos, int esize, int imp, int *perm, void *_a)
+{
- unsigned char *a = (unsigned char *)_a;
- unsigned char mask;
- unsigned long b, shift=0, nbits, bias=0;
+ unsigned char *a = (unsigned char *) _a;
+ unsigned char mask;
+ unsigned long b, shift = 0, nbits, bias = 0;
- while (esize>0) {
- nbits = MIN (esize, (8 - epos % 8));
- mask = (1<<nbits) - 1;
- b = (a[perm[epos/8]] >> (epos % 8)) & mask;
- bias |= b << shift;
+ while (esize > 0) {
+ nbits = MIN(esize, (8 - epos % 8));
+ mask = (1 << nbits) - 1;
+ b = (a[perm[epos / 8]] >> (epos % 8)) & mask;
+ bias |= b << shift;
- shift += nbits;
- esize -= nbits;
- epos += nbits;
- }
+ shift += nbits;
+ esize -= nbits;
+ epos += nbits;
+ }
- return bias - (imp?0:1);
+ return bias - (imp ? 0 : 1);
}
-
/*-------------------------------------------------------------------------
- * Function: print_header
+ * Function: print_header
*
- * Purpose: Prints the C file header for the generated file.
+ * Purpose: Prints the C file header for the generated file.
*
- * Return: void
+ * Return: void
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Mar 12 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Mar 12 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
static void
-print_header (void) {
-
- time_t now = time (NULL);
- struct tm *tm = localtime (&now);
- struct passwd *pwd = getpwuid (getuid());
- char real_name[30], *comma;
- char host_name[256];
- int i, n;
- const char *s;
- static const char *month_name[] = {
- "Jan", "Feb", "Mar", "Apr", "May", "Jun",
- "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
- static const char *purpose = "\
+print_header(void)
+{
+
+ time_t now = time(NULL);
+ struct tm *tm = localtime(&now);
+ struct passwd *pwd = getpwuid(getuid());
+ char real_name[30], *comma;
+ char host_name[256];
+ int i, n;
+ const char *s;
+ static const char *month_name[] =
+ {
+ "Jan", "Feb", "Mar", "Apr", "May", "Jun",
+ "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
+ static const char *purpose = "\
This machine-generated source code contains\n\
information about the various integer and\n\
floating point numeric formats found on this\n\
@@ -809,7 +831,7 @@ Each of the numeric formats listed below are\n\
printed from most significant bit to least\n\
significant bit even though the actual bytes\n\
might be stored in a different order in\n\
-memory. The integers above each binary byte\n\
+memory. The integers above each binary byte\n\
indicate the relative order of the bytes in\n\
memory; little-endian machines have\n\
decreasing numbers while big-endian machines\n\
@@ -820,8 +842,8 @@ letters with `S' for the mantissa sign bit,\n\
`M' for the mantissa magnitude, and `E' for\n\
the exponent. The exponent has an associated\n\
bias which can be subtracted to find the\n\
-true exponent. The radix point is assumed\n\
-to be before the first `M' bit. Any bit\n\
+true exponent. The radix point is assumed\n\
+to be before the first `M' bit. Any bit\n\
of a floating-point value not falling into one\n\
of these categories is printed as a question\n\
mark. Bits of integer types are printed as\n\
@@ -835,101 +857,118 @@ the radix point is still assumed to be\n\
before the first `M' but after the implicit\n\
bit.\n";
- /*
- * The real name is the first item from the passwd gecos field.
- */
- if (pwd) {
- if ((comma=strchr(pwd->pw_gecos,','))) {
- n = MIN (sizeof(real_name)-1, comma - pwd->pw_gecos);
- strncpy (real_name, pwd->pw_gecos, n);
- real_name[n] = '\0';
- } else {
- strncpy (real_name, pwd->pw_gecos, sizeof(real_name));
- real_name[sizeof(real_name)-1] = '\0';
- }
- } else {
- real_name[0] = '\0';
- }
-
- /*
- * The FQDM of this host or the empty string.
- */
- if (gethostname(host_name, sizeof(host_name))<0) host_name[0] = '\0';
-
-
- /*
- * The file header: warning, copyright notice, build information.
- */
- printf ("/*\n * DO NOT EDIT OR DISTRIBUTE THIS FILE -- "
- "IT IS MACHINE GENERATED!\n */\n\n");
- puts (FileHeader); /*the copyright notice--see top of this file*/
-
- printf (" *\n * Created:\t\t%s %2d, %4d\n",
- month_name[tm->tm_mon], tm->tm_mday, 1900+tm->tm_year);
- if (pwd || real_name[0] || host_name[0]) {
- printf (" *\t\t\t");
- if (real_name[0]) printf ("%s <", real_name);
- if (pwd) fputs (pwd->pw_name, stdout);
- if (host_name[0]) printf ("@%s", host_name);
- if (real_name[0]) printf (">");
- putchar ('\n');
- }
-
- printf (" *\n * Purpose:\t\t");
- for (s=purpose; *s; s++) {
- putchar (*s);
- if ('\n'==*s && s[1]) printf (" *\t\t\t");
- }
-
- printf (" *\n * Modifications:\n *\n");
- printf (" *\tDO NOT MAKE MODIFICATIONS TO THIS FILE!\n");
- printf (" *\tIt was generated by code in `H5detect.c'.\n");
-
- printf (" *\n *");
- for (i=0; i<73; i++) putchar ('-');
- printf ("\n */\n\n");
-
+ /*
+ * The real name is the first item from the passwd gecos field.
+ */
+ if (pwd) {
+ if ((comma = strchr(pwd->pw_gecos, ','))) {
+ n = MIN(sizeof(real_name) - 1, comma - pwd->pw_gecos);
+ strncpy(real_name, pwd->pw_gecos, n);
+ real_name[n] = '\0';
+ } else {
+ strncpy(real_name, pwd->pw_gecos, sizeof(real_name));
+ real_name[sizeof(real_name) - 1] = '\0';
+ }
+ } else {
+ real_name[0] = '\0';
+ }
+
+ /*
+ * The FQDM of this host or the empty string.
+ */
+ if (gethostname(host_name, sizeof(host_name)) < 0)
+ host_name[0] = '\0';
+
+ /*
+ * The file header: warning, copyright notice, build information.
+ */
+ printf("/*\n * DO NOT EDIT OR DISTRIBUTE THIS FILE -- "
+ "IT IS MACHINE GENERATED!\n */\n\n");
+ puts(FileHeader); /*the copyright notice--see top of this file */
+
+ printf(" *\n * Created:\t\t%s %2d, %4d\n",
+ month_name[tm->tm_mon], tm->tm_mday, 1900 + tm->tm_year);
+ if (pwd || real_name[0] || host_name[0]) {
+ printf(" *\t\t\t");
+ if (real_name[0])
+ printf("%s <", real_name);
+ if (pwd)
+ fputs(pwd->pw_name, stdout);
+ if (host_name[0])
+ printf("@%s", host_name);
+ if (real_name[0])
+ printf(">");
+ putchar('\n');
+ }
+ printf(" *\n * Purpose:\t\t");
+ for (s = purpose; *s; s++) {
+ putchar(*s);
+ if ('\n' == *s && s[1])
+ printf(" *\t\t\t");
+ }
+
+ printf(" *\n * Modifications:\n *\n");
+ printf(" *\tDO NOT MAKE MODIFICATIONS TO THIS FILE!\n");
+ printf(" *\tIt was generated by code in `H5detect.c'.\n");
+
+ printf(" *\n *");
+ for (i = 0; i < 73; i++)
+ putchar('-');
+ printf("\n */\n\n");
+
}
-
/*-------------------------------------------------------------------------
- * Function: main
+ * Function: main
*
- * Purpose: Main entry point.
+ * Purpose: Main entry point.
*
- * Return: Success: exit(0)
+ * Return: Success: exit(0)
*
- * Failure: exit(1)
+ * Failure: exit(1)
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jun 12, 1996
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jun 12, 1996
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
int
-main (int argc, char *argv[]) {
-
- detected_t d[MAXDETECT];
- int nd=0;
-
- print_header();
-
- DETECT_I (signed char, CHAR, d[nd]); nd++;
- DETECT_I (unsigned char, UCHAR, d[nd]); nd++;
- DETECT_I (short, SHORT, d[nd]); nd++;
- DETECT_I (unsigned short, USHORT, d[nd]); nd++;
- DETECT_I (int, INT, d[nd]); nd++;
- DETECT_I (unsigned int, UINT, d[nd]); nd++;
- DETECT_I (long, LONG, d[nd]); nd++;
- DETECT_I (unsigned long, ULONG, d[nd]); nd++;
- DETECT_I (long long, LLONG, d[nd]); nd++;
- DETECT_I (unsigned long long, ULLONG, d[nd]); nd++;
- DETECT_F (float, FLOAT, d[nd]); nd++;
- DETECT_F (double, DOUBLE, d[nd]); nd++;
-
- print_results (nd, d);
- exit (0);
+main(int argc, char *argv[])
+{
+
+ detected_t d[MAXDETECT];
+ int nd = 0;
+
+ print_header();
+
+ DETECT_I(signed char, CHAR, d[nd]);
+ nd++;
+ DETECT_I(unsigned char, UCHAR, d[nd]);
+ nd++;
+ DETECT_I(short, SHORT, d[nd]);
+ nd++;
+ DETECT_I(unsigned short, USHORT, d[nd]);
+ nd++;
+ DETECT_I(int, INT, d[nd]);
+ nd++;
+ DETECT_I(unsigned int, UINT, d[nd]);
+ nd++;
+ DETECT_I(long, LONG, d[nd]);
+ nd++;
+ DETECT_I(unsigned long, ULONG, d[nd]);
+ nd++;
+ DETECT_I(long long, LLONG, d[nd]);
+ nd++;
+ DETECT_I(unsigned long long, ULLONG, d[nd]);
+ nd++;
+ DETECT_F(float, FLOAT, d[nd]);
+ nd++;
+ DETECT_F(double, DOUBLE, d[nd]);
+ nd++;
+
+ print_results(nd, d);
+ exit(0);
}
diff --git a/src/H5private.h b/src/H5private.h
index d650c03..2bf8139 100644
--- a/src/H5private.h
+++ b/src/H5private.h
@@ -19,20 +19,20 @@
*/
#ifndef _H5private_H
#define _H5private_H
-#include <H5public.h> /* Include Public Definitions */
+#include <H5public.h> /* Include Public Definitions */
/* Version #'s of library code */
-#define HDF5_MAJOR_VERSION 5 /* For major interface changes */
-#define HDF5_MINOR_VERSION 0 /* For minor interface changes */
-#define HDF5_RELEASE_VERSION 0 /* For interface tweaks & bug-fixes */
-#define HDF5_PATCH_VERSION 0 /* For small groups of bug fixes*/
+#define HDF5_MAJOR_VERSION 5 /* For major interface changes */
+#define HDF5_MINOR_VERSION 0 /* For minor interface changes */
+#define HDF5_RELEASE_VERSION 0 /* For interface tweaks & bug-fixes */
+#define HDF5_PATCH_VERSION 0 /* For small groups of bug fixes */
/* Version #'s of the major components of the file format */
-#define HDF5_BOOTBLOCK_VERSION 0 /* of the boot block format */
-#define HDF5_SMALLOBJECT_VERSION 0 /* of the Small-Object Heap */
-#define HDF5_FREESPACE_VERSION 0 /* of the Free-Space Info */
-#define HDF5_OBJECTDIR_VERSION 0 /* of the Object Directory format */
-#define HDF5_SHAREDHEADER_VERSION 0 /* of the Shared-Header Info */
+#define HDF5_BOOTBLOCK_VERSION 0 /* of the boot block format */
+#define HDF5_SMALLOBJECT_VERSION 0 /* of the Small-Object Heap */
+#define HDF5_FREESPACE_VERSION 0 /* of the Free-Space Info */
+#define HDF5_OBJECTDIR_VERSION 0 /* of the Object Directory format */
+#define HDF5_SHAREDHEADER_VERSION 0 /* of the Shared-Header Info */
/*
* Include those things that almost all source files need.
@@ -57,17 +57,17 @@
/* Does the compiler support the __attribute__(()) syntax? */
#ifndef HAVE_ATTRIBUTE
-# define __attribute__(X) /*void*/
+# define __attribute__(X) /*void */
#endif
/* Does the compiler expand __FUNCTION__? */
#ifndef HAVE_FUNCTION
-# define __FUNCTION__ "NoFuntionName"
+# define __FUNCTION__ "NoFuntionName"
#endif
/* number of members in an array */
#ifndef NELMTS
-# define NELMTS(X) (sizeof(X)/sizeof(X[0]))
+# define NELMTS(X) (sizeof(X)/sizeof(X[0]))
#endif
/* minimum of two values */
@@ -82,10 +82,9 @@
/* maximum of three values */
#ifndef MAX3
-# define MAX3(a,b,c) MAX(MAX(a,b),c)
+# define MAX3(a,b,c) MAX(MAX(a,b),c)
#endif
-
/*
* HDF Boolean type.
*/
@@ -100,10 +99,10 @@
* File addresses.
*/
typedef struct {
- uint64 offset; /*offset within an HDF5 file */
+ uint64 offset; /*offset within an HDF5 file */
} haddr_t;
-#define NO_ADDR NULL
+#define NO_ADDR NULL
/*
* Some compilers have problems declaring auto variables that point
@@ -118,348 +117,347 @@ typedef struct {
* Redefine all the POSIX functions. We should never see a POSIX
* function (or any other non-HDF5 function) in the source!
*/
-#define HDabort() abort()
-#define HDabs(X) abs(X)
-#define HDaccess(F,M) access(F, M)
-#define HDacos(X) acos(X)
-#define HDalarm(N) alarm(N)
-#define HDasctime(T) asctime(T)
-#define HDasin(X) asin(X)
-#define HDassert(X) assert(X)
-#define HDatan(X) atan(X)
-#define HDatan2(X,Y) atan2(X,Y)
-#define HDatexit(F) atexit(F)
-#define HDatof(S) atof(S)
-#define HDatoi(S) atoi(S)
-#define HDatol(S) atol(S)
-#define HDbsearch(K,B,N,Z,F) bsearch(K,B,N,Z,F)
-#define HDcalloc(N,Z) calloc(N,Z)
-#define HDceil(X) ceil(X)
-#define HDcfgetispeed(T) cfgetispeed(T)
-#define HDcfgetospeed(T) cfgetospeed(T)
-#define HDcfsetispeed(T,S) cfsetispeed(T,S)
-#define HDcfsetospeed(T,S) cfsetospeed(T,S)
-#define HDchdir(S) chdir(S)
-#define HDchmod(S,M) chmod(S,M)
-#define HDchown(S,O,G) chown(S,O,G)
-#define HDclearerr(F) clearerr(F)
-#define HDclock() clock()
-#define HDclose(F) close(F)
-#define HDclosedir(D) closedir(D)
-#define HDcos(X) cos(X)
-#define HDcosh(X) cosh(X)
-#define HDcreat(S,M) creat(S,M)
-#define HDctermid(S) ctermid(S)
-#define HDctime(T) ctime(T)
-#define HDcuserid(S) cuserid(S)
-#define HDdifftime(X,Y) difftime(X,Y)
-#define HDdiv(X,Y) div(X,Y)
-#define HDdup(F) dup(F)
-#define HDdup2(F,I) dup2(F,I)
+#define HDabort() abort()
+#define HDabs(X) abs(X)
+#define HDaccess(F,M) access(F, M)
+#define HDacos(X) acos(X)
+#define HDalarm(N) alarm(N)
+#define HDasctime(T) asctime(T)
+#define HDasin(X) asin(X)
+#define HDassert(X) assert(X)
+#define HDatan(X) atan(X)
+#define HDatan2(X,Y) atan2(X,Y)
+#define HDatexit(F) atexit(F)
+#define HDatof(S) atof(S)
+#define HDatoi(S) atoi(S)
+#define HDatol(S) atol(S)
+#define HDbsearch(K,B,N,Z,F) bsearch(K,B,N,Z,F)
+#define HDcalloc(N,Z) calloc(N,Z)
+#define HDceil(X) ceil(X)
+#define HDcfgetispeed(T) cfgetispeed(T)
+#define HDcfgetospeed(T) cfgetospeed(T)
+#define HDcfsetispeed(T,S) cfsetispeed(T,S)
+#define HDcfsetospeed(T,S) cfsetospeed(T,S)
+#define HDchdir(S) chdir(S)
+#define HDchmod(S,M) chmod(S,M)
+#define HDchown(S,O,G) chown(S,O,G)
+#define HDclearerr(F) clearerr(F)
+#define HDclock() clock()
+#define HDclose(F) close(F)
+#define HDclosedir(D) closedir(D)
+#define HDcos(X) cos(X)
+#define HDcosh(X) cosh(X)
+#define HDcreat(S,M) creat(S,M)
+#define HDctermid(S) ctermid(S)
+#define HDctime(T) ctime(T)
+#define HDcuserid(S) cuserid(S)
+#define HDdifftime(X,Y) difftime(X,Y)
+#define HDdiv(X,Y) div(X,Y)
+#define HDdup(F) dup(F)
+#define HDdup2(F,I) dup2(F,I)
/* execl() variable arguments */
/* execle() variable arguments */
/* execlp() variable arguments */
-#define HDexecv(S,AV) execv(S,AV)
-#define HDexecve(S,AV,E) execve(S,AV,E)
-#define HDexecvp(S,AV) execvp(S,AV)
-#define HDexit(N) exit(N)
-#define HD_exit(N) _exit(N)
-#define HDexp(X) exp(X)
-#define HDfabs(X) fabs(X)
-#define HDfclose(F) fclose(F)
+#define HDexecv(S,AV) execv(S,AV)
+#define HDexecve(S,AV,E) execve(S,AV,E)
+#define HDexecvp(S,AV) execvp(S,AV)
+#define HDexit(N) exit(N)
+#define HD_exit(N) _exit(N)
+#define HDexp(X) exp(X)
+#define HDfabs(X) fabs(X)
+#define HDfclose(F) fclose(F)
/* fcntl() variable arguments */
-#define HDfdopen(N,S) fdopen(N,S)
-#define HDfeof(F) feof(F)
-#define HDferror(F) ferror(F)
-#define HDfflush(F) fflush(F)
-#define HDfgetc(F) fgetc(F)
-#define HDfgetpos(F,P) fgetpos(F,P)
-#define HDfgets(S,N,F) fgets(S,N,F)
-#define HDfileno(F) fileno(F)
-#define HDfloor(X) floor(X)
-#define HDfmod(X,Y) fmod(X,Y)
-#define HDfopen(S,M) fopen(S,M)
-#define HDfork() fork()
-#define HDfpathconf(F,N) fpathconf(F,N)
+#define HDfdopen(N,S) fdopen(N,S)
+#define HDfeof(F) feof(F)
+#define HDferror(F) ferror(F)
+#define HDfflush(F) fflush(F)
+#define HDfgetc(F) fgetc(F)
+#define HDfgetpos(F,P) fgetpos(F,P)
+#define HDfgets(S,N,F) fgets(S,N,F)
+#define HDfileno(F) fileno(F)
+#define HDfloor(X) floor(X)
+#define HDfmod(X,Y) fmod(X,Y)
+#define HDfopen(S,M) fopen(S,M)
+#define HDfork() fork()
+#define HDfpathconf(F,N) fpathconf(F,N)
/* fprintf() variable arguments */
-#define HDfputc(C,F) fputc(C,F)
-#define HDfputs(S,F) fputs(S,F)
-#define HDfread(M,Z,N,F) fread(M,Z,N,F)
-#define HDfree(M) free(M)
-#define HDfreopen(S,M,F) freopen(S,M,F)
-#define HDfrexp(X,N) frexp(X,N)
+#define HDfputc(C,F) fputc(C,F)
+#define HDfputs(S,F) fputs(S,F)
+#define HDfread(M,Z,N,F) fread(M,Z,N,F)
+#define HDfree(M) free(M)
+#define HDfreopen(S,M,F) freopen(S,M,F)
+#define HDfrexp(X,N) frexp(X,N)
/* fscanf() variable arguments */
-#define HDfseek(F,O,W) fseek(F,O,W)
-#define HDfsetpos(F,P) fsetpos(F,P)
-#define HDfstat(F,B) fstat(F,B)
-#define HDftell(F) ftell(F)
-#define HDfwrite(M,Z,N,F) fwrite(M,Z,N,F)
-#define HDgetc(F) getc(F)
-#define HDgetchar() getchar()
-#define HDgetcwd(S,Z) getcwd(S,Z)
-#define HDgetegid() getegid()
-#define HDgetenv(S) getenv(S)
-#define HDgeteuid() geteuid()
-#define HDgetgid() getgid()
-#define HDgetgrgid(G) getgrgid(G)
-#define HDgetgrnam(S) getgrnam(S)
-#define HDgetgroups(Z,G) getgroups(Z,G)
-#define HDgetlogin() getlogin()
-#define HDgetpgrp() getpgrp()
-#define HDgetpid() getpid()
-#define HDgetppid() getppid()
-#define HDgetpwnam(S) getpwnam(S)
-#define HDgetpwuid(U) getpwuid(U)
-#define HDgets(S) gets(S)
-#define HDgetuid() getuid()
-#define HDgmtime(T) gmtime(T)
-#define HDisalnum(C) isalnum(C)
-#define HDisalpha(C) isalpha(C)
-#define HDisatty(F) isatty(F)
-#define HDiscntrl(C) iscntrl(C)
-#define HDisdigit(C) isdigit(C)
-#define HDisgraph(C) isgraph(C)
-#define HDislower(C) islower(C)
-#define HDisprint(C) isprint(C)
-#define HDispunct(C) ispunct(C)
-#define HDisspace(C) isspace(C)
-#define HDisupper(C) isupper(C)
-#define HDisxdigit(C) isxdigit(C)
-#define HDkill(P,S) kill(P,S)
-#define HDlabs(X) labs(X)
-#define HDldexp(X,N) ldexp(X,N)
-#define HDldiv(X,Y) ldiv(X,Y)
-#define HDlink(OLD,NEW) link(OLD,NEW)
-#define HDlocaleconv() localeconv()
-#define HDlocaltime(T) localtime(T)
-#define HDlog(X) log(X)
-#define HDlog10(X) log10(X)
-#define HDlongjmp(J,N) longjmp(J,N)
-#define HDlseek(F,O,W) lseek(F,O,W)
-#define HDmalloc(Z) malloc(Z)
-#define HDmblen(S,N) mblen(S,N)
-#define HDmbstowcs(P,S,Z) mbstowcs(P,S,Z)
-#define HDmbtowc(P,S,Z) mbtowc(P,S,Z)
-#define HDmemchr(S,C,Z) memchr(S,C,Z)
-#define HDmemcmp(X,Y,Z) memcmp(X,Y,Z)
-#define HDmemcpy(X,Y,Z) memcpy(X,Y,Z)
-#define HDmemmove(X,Y,Z) memmove(X,Y,Z)
-#define HDmemset(X,C,Z) memset(X,C,Z)
-#define HDmkdir(S,M) mkdir(S,M)
-#define HDmkfifo(S,M) mkfifo(S,M)
-#define HDmktime(T) mktime(T)
-#define HDmodf(X,Y) modf(X,Y)
+#define HDfseek(F,O,W) fseek(F,O,W)
+#define HDfsetpos(F,P) fsetpos(F,P)
+#define HDfstat(F,B) fstat(F,B)
+#define HDftell(F) ftell(F)
+#define HDfwrite(M,Z,N,F) fwrite(M,Z,N,F)
+#define HDgetc(F) getc(F)
+#define HDgetchar() getchar()
+#define HDgetcwd(S,Z) getcwd(S,Z)
+#define HDgetegid() getegid()
+#define HDgetenv(S) getenv(S)
+#define HDgeteuid() geteuid()
+#define HDgetgid() getgid()
+#define HDgetgrgid(G) getgrgid(G)
+#define HDgetgrnam(S) getgrnam(S)
+#define HDgetgroups(Z,G) getgroups(Z,G)
+#define HDgetlogin() getlogin()
+#define HDgetpgrp() getpgrp()
+#define HDgetpid() getpid()
+#define HDgetppid() getppid()
+#define HDgetpwnam(S) getpwnam(S)
+#define HDgetpwuid(U) getpwuid(U)
+#define HDgets(S) gets(S)
+#define HDgetuid() getuid()
+#define HDgmtime(T) gmtime(T)
+#define HDisalnum(C) isalnum(C)
+#define HDisalpha(C) isalpha(C)
+#define HDisatty(F) isatty(F)
+#define HDiscntrl(C) iscntrl(C)
+#define HDisdigit(C) isdigit(C)
+#define HDisgraph(C) isgraph(C)
+#define HDislower(C) islower(C)
+#define HDisprint(C) isprint(C)
+#define HDispunct(C) ispunct(C)
+#define HDisspace(C) isspace(C)
+#define HDisupper(C) isupper(C)
+#define HDisxdigit(C) isxdigit(C)
+#define HDkill(P,S) kill(P,S)
+#define HDlabs(X) labs(X)
+#define HDldexp(X,N) ldexp(X,N)
+#define HDldiv(X,Y) ldiv(X,Y)
+#define HDlink(OLD,NEW) link(OLD,NEW)
+#define HDlocaleconv() localeconv()
+#define HDlocaltime(T) localtime(T)
+#define HDlog(X) log(X)
+#define HDlog10(X) log10(X)
+#define HDlongjmp(J,N) longjmp(J,N)
+#define HDlseek(F,O,W) lseek(F,O,W)
+#define HDmalloc(Z) malloc(Z)
+#define HDmblen(S,N) mblen(S,N)
+#define HDmbstowcs(P,S,Z) mbstowcs(P,S,Z)
+#define HDmbtowc(P,S,Z) mbtowc(P,S,Z)
+#define HDmemchr(S,C,Z) memchr(S,C,Z)
+#define HDmemcmp(X,Y,Z) memcmp(X,Y,Z)
+#define HDmemcpy(X,Y,Z) memcpy(X,Y,Z)
+#define HDmemmove(X,Y,Z) memmove(X,Y,Z)
+#define HDmemset(X,C,Z) memset(X,C,Z)
+#define HDmkdir(S,M) mkdir(S,M)
+#define HDmkfifo(S,M) mkfifo(S,M)
+#define HDmktime(T) mktime(T)
+#define HDmodf(X,Y) modf(X,Y)
/* open() variable arguments */
-#define HDopendir(S) opendir(S)
-#define HDpathconf(S,N) pathconf(S,N)
-#define HDpause() pause()
-#define HDperror(S) perror(S)
-#define HDpipe(F) pipe(F)
-#define HDpow(X,Y) pow(X,Y)
+#define HDopendir(S) opendir(S)
+#define HDpathconf(S,N) pathconf(S,N)
+#define HDpause() pause()
+#define HDperror(S) perror(S)
+#define HDpipe(F) pipe(F)
+#define HDpow(X,Y) pow(X,Y)
/* printf() variable arguments */
-#define HDputc(C,F) putc(C,F)
-#define HDputchar(C) putchar(C)
-#define HDputs(S) puts(S)
-#define HDqsort(M,N,Z,F) qsort(M,N,Z,F)
-#define HDraise(N) raise(N)
-#define HDrand() rand()
-#define HDread(F,M,Z) read(F,M,Z)
-#define HDreaddir(D) readdir(D)
-#define HDrealloc(M,Z) realloc(M,Z)
-#define HDremove(S) remove(S)
-#define HDrename(OLD,NEW) rename(OLD,NEW)
-#define HDrewind(F) rewind(F)
-#define HDrewinddir(D) rewinddir(D)
-#define HDrmdir(S) rmdir(S)
+#define HDputc(C,F) putc(C,F)
+#define HDputchar(C) putchar(C)
+#define HDputs(S) puts(S)
+#define HDqsort(M,N,Z,F) qsort(M,N,Z,F)
+#define HDraise(N) raise(N)
+#define HDrand() rand()
+#define HDread(F,M,Z) read(F,M,Z)
+#define HDreaddir(D) readdir(D)
+#define HDrealloc(M,Z) realloc(M,Z)
+#define HDremove(S) remove(S)
+#define HDrename(OLD,NEW) rename(OLD,NEW)
+#define HDrewind(F) rewind(F)
+#define HDrewinddir(D) rewinddir(D)
+#define HDrmdir(S) rmdir(S)
/* scanf() variable arguments */
-#define HDsetbuf(F,S) setbuf(F,S)
-#define HDsetgid(G) setgid(G)
-#define HDsetjmp(J) setjmp(J)
-#define HDsetlocale(N,S) setlocale(N,S)
-#define HDsetpgid(P,PG) setpgid(P,PG)
-#define HDsetsid() setsid()
-#define HDsetuid(U) setuid(U)
-#define HDsetvbuf(F,S,M,Z) setvbuf(F,S,M,Z)
-#define HDsigaction(N,A) sigaction(N,A)
-#define HDsigaddset(S,N) sigaddset(S,N)
-#define HDsigdelset(S,N) sigdelset(S,N)
-#define HDsigemptyset(S) sigemptyset(S)
-#define HDsigfillset(S) sigfillset(S)
-#define HDsigismember(S,N) sigismember(S,N)
-#define HDsiglongjmp(J,N) siglongjmp(J,N)
-#define HDsignal(N,F) signal(N,F)
-#define HDsigpending(S) sigpending(S)
-#define HDsigprocmask(H,S,O) sigprocmask(H,S,O)
-#define HDsigsetjmp(J,N) sigsetjmp(J,N)
-#define HDsigsuspend(S) sigsuspend(S)
-#define HDsin(X) sin(X)
-#define HDsinh(X) sinh(X)
-#define HDsleep(N) sleep(N)
+#define HDsetbuf(F,S) setbuf(F,S)
+#define HDsetgid(G) setgid(G)
+#define HDsetjmp(J) setjmp(J)
+#define HDsetlocale(N,S) setlocale(N,S)
+#define HDsetpgid(P,PG) setpgid(P,PG)
+#define HDsetsid() setsid()
+#define HDsetuid(U) setuid(U)
+#define HDsetvbuf(F,S,M,Z) setvbuf(F,S,M,Z)
+#define HDsigaction(N,A) sigaction(N,A)
+#define HDsigaddset(S,N) sigaddset(S,N)
+#define HDsigdelset(S,N) sigdelset(S,N)
+#define HDsigemptyset(S) sigemptyset(S)
+#define HDsigfillset(S) sigfillset(S)
+#define HDsigismember(S,N) sigismember(S,N)
+#define HDsiglongjmp(J,N) siglongjmp(J,N)
+#define HDsignal(N,F) signal(N,F)
+#define HDsigpending(S) sigpending(S)
+#define HDsigprocmask(H,S,O) sigprocmask(H,S,O)
+#define HDsigsetjmp(J,N) sigsetjmp(J,N)
+#define HDsigsuspend(S) sigsuspend(S)
+#define HDsin(X) sin(X)
+#define HDsinh(X) sinh(X)
+#define HDsleep(N) sleep(N)
/* sprintf() variable arguments */
-#define HDsqrt(X) sqrt(X)
-#define HDsrand(N) srand(N)
+#define HDsqrt(X) sqrt(X)
+#define HDsrand(N) srand(N)
/* sscanf() variable arguments */
-#define HDstat(S,B) stat(S,B)
-#define HDstrcat(X,Y) strcat(X,Y)
-#define HDstrchr(S,C) strchr(S,C)
-#define HDstrcmp(X,Y) strcmp(X,Y)
-#define HDstrcoll(X,Y) strcoll(X,Y)
-#define HDstrcpy(X,Y) strcpy(X,Y)
-#define HDstrcspn(X,Y) strcspn(X,Y)
-#define HDstrerror(N) strerror(N)
-#define HDstrftime(S,Z,F,T) strftime(S,Z,F,T)
-#define HDstrlen(S) strlen(S)
-#define HDstrncat(X,Y,Z) strncat(X,Y,Z)
-#define HDstrncmp(X,Y,Z) strncmp(X,Y,Z)
-#define HDstrncpy(X,Y,Z) strncpy(X,Y,Z)
-#define HDstrpbrk(X,Y) strpbrk(X,Y)
-#define HDstrrchr(S,C) strrchr(S,C)
-#define HDstrspn(X,Y) strspn(X,Y)
-#define HDstrstr(X,Y) strstr(X,Y)
-#define HDstrtod(S,R) strtod(S,R)
-#define HDstrtok(X,Y) strtok(X,Y)
-#define HDstrtol(S,R,N) strtol(S,R,N)
-#define HDstrtoul(S,R,N) strtoul(S,R,N)
-#define HDstrxfrm(X,Y,Z) strxfrm(X,Y,Z)
-#define HDsysconf(N) sysconf(N)
-#define HDsystem(S) system(S)
-#define HDtan(X) tan(X)
-#define HDtanh(X) tanh(X)
-#define HDtcdrain(F) tcdrain(F)
-#define HDtcflow(F,A) tcflow(F,A)
-#define HDtcflush(F,N) tcflush(F,N)
-#define HDtcgetattr(F,T) tcgetattr(F,T)
-#define HDtcgetpgrp(F) tcgetpgrp(F)
-#define HDtcsendbreak(F,N) tcsendbreak(F,N)
-#define HDtcsetattr(F,O,T) tcsetattr(F,O,T)
-#define HDtcsetpgrp(F,N) tcsetpgrp(F,N)
-#define HDtime(T) time(T)
-#define HDtimes(T) times(T)
-#define HDtmpfile() tmpfile()
-#define HDtmpnam(S) tmpnam(S)
-#define HDtolower(C) tolower(C)
-#define HDtoupper(C) toupper(C)
-#define HDttyname(F) ttyname(F)
-#define HDtzset() tzset()
-#define HDumask(N) umask(N)
-#define HDuname(S) uname(S)
-#define HDungetc(C,F) ungetc(C,F)
-#define HDunlink(S) unlink(S)
-#define HDutime(S,T) utime(S,T)
-#define HDva_arg(A,T) va_arg(A,T)
-#define HDva_end(A) va_end(A)
-#define HDva_start(A,P) va_start(A,P)
-#define HDvfprintf(F,FMT,A) vfprintf(F,FMT,A)
-#define HDvprintf(FMT,A) vprintf(FMT,A)
-#define HDvsprintf(S,FMT,A) vsprintf(S,FMT,A)
-#define HDwait(W) wait(W)
-#define HDwaitpid(P,W,O) waitpid(P,W,O)
-#define HDwcstombs(S,P,Z) wcstombs(S,P,Z)
-#define HDwctomb(S,C) wctomb(S,C)
-#define HDwrite(F,M,Z) write(F,M,Z)
+#define HDstat(S,B) stat(S,B)
+#define HDstrcat(X,Y) strcat(X,Y)
+#define HDstrchr(S,C) strchr(S,C)
+#define HDstrcmp(X,Y) strcmp(X,Y)
+#define HDstrcoll(X,Y) strcoll(X,Y)
+#define HDstrcpy(X,Y) strcpy(X,Y)
+#define HDstrcspn(X,Y) strcspn(X,Y)
+#define HDstrerror(N) strerror(N)
+#define HDstrftime(S,Z,F,T) strftime(S,Z,F,T)
+#define HDstrlen(S) strlen(S)
+#define HDstrncat(X,Y,Z) strncat(X,Y,Z)
+#define HDstrncmp(X,Y,Z) strncmp(X,Y,Z)
+#define HDstrncpy(X,Y,Z) strncpy(X,Y,Z)
+#define HDstrpbrk(X,Y) strpbrk(X,Y)
+#define HDstrrchr(S,C) strrchr(S,C)
+#define HDstrspn(X,Y) strspn(X,Y)
+#define HDstrstr(X,Y) strstr(X,Y)
+#define HDstrtod(S,R) strtod(S,R)
+#define HDstrtok(X,Y) strtok(X,Y)
+#define HDstrtol(S,R,N) strtol(S,R,N)
+#define HDstrtoul(S,R,N) strtoul(S,R,N)
+#define HDstrxfrm(X,Y,Z) strxfrm(X,Y,Z)
+#define HDsysconf(N) sysconf(N)
+#define HDsystem(S) system(S)
+#define HDtan(X) tan(X)
+#define HDtanh(X) tanh(X)
+#define HDtcdrain(F) tcdrain(F)
+#define HDtcflow(F,A) tcflow(F,A)
+#define HDtcflush(F,N) tcflush(F,N)
+#define HDtcgetattr(F,T) tcgetattr(F,T)
+#define HDtcgetpgrp(F) tcgetpgrp(F)
+#define HDtcsendbreak(F,N) tcsendbreak(F,N)
+#define HDtcsetattr(F,O,T) tcsetattr(F,O,T)
+#define HDtcsetpgrp(F,N) tcsetpgrp(F,N)
+#define HDtime(T) time(T)
+#define HDtimes(T) times(T)
+#define HDtmpfile() tmpfile()
+#define HDtmpnam(S) tmpnam(S)
+#define HDtolower(C) tolower(C)
+#define HDtoupper(C) toupper(C)
+#define HDttyname(F) ttyname(F)
+#define HDtzset() tzset()
+#define HDumask(N) umask(N)
+#define HDuname(S) uname(S)
+#define HDungetc(C,F) ungetc(C,F)
+#define HDunlink(S) unlink(S)
+#define HDutime(S,T) utime(S,T)
+#define HDva_arg(A,T) va_arg(A,T)
+#define HDva_end(A) va_end(A)
+#define HDva_start(A,P) va_start(A,P)
+#define HDvfprintf(F,FMT,A) vfprintf(F,FMT,A)
+#define HDvprintf(FMT,A) vprintf(FMT,A)
+#define HDvsprintf(S,FMT,A) vsprintf(S,FMT,A)
+#define HDwait(W) wait(W)
+#define HDwaitpid(P,W,O) waitpid(P,W,O)
+#define HDwcstombs(S,P,Z) wcstombs(S,P,Z)
+#define HDwctomb(S,C) wctomb(S,C)
+#define HDwrite(F,M,Z) write(F,M,Z)
/*
* And now for a couple non-Posix functions...
*/
-extern char *strdup (const char *s);
-#define HDstrdup(S) strdup(S)
+extern char *strdup(const char *s);
+#define HDstrdup(S) strdup(S)
/*-------------------------------------------------------------------------
- * Purpose: Register function entry for library initialization and code
- * profiling.
+ * Purpose: Register function entry for library initialization and code
+ * profiling.
*
- * Notes: Every file must have a file-scope variable called
- * `initialize_interface_g' of type hbool_t which is initialized
- * to FALSE.
+ * Notes: Every file must have a file-scope variable called
+ * `initialize_interface_g' of type hbool_t which is initialized
+ * to FALSE.
*
- * Don't use local variable initializers which contain
- * calls to other library functions since the initializer
- * would happen before the FUNC_ENTER() gets called. Don't
- * use initializers that require special cleanup code to
- * execute if FUNC_ENTER() fails since a failing FUNC_ENTER()
- * returns immediately without branching to the `done' label.
+ * Don't use local variable initializers which contain
+ * calls to other library functions since the initializer
+ * would happen before the FUNC_ENTER() gets called. Don't
+ * use initializers that require special cleanup code to
+ * execute if FUNC_ENTER() fails since a failing FUNC_ENTER()
+ * returns immediately without branching to the `done' label.
*
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
*
* Modifications:
*
- * Robb Matzke, 4 Aug 1997
- * The `interface_init_func' can be the null pointer. Changed
- * HGOTO_ERROR() to HRETURN_ERROR() since no clean-up needs to occur
- * when an error is detected at this point since this must be the
- * first executable statement in a function. This allows functions
- * to omit the `done:' label when convenient to do so.
+ * Robb Matzke, 4 Aug 1997
+ * The `interface_init_func' can be the null pointer. Changed
+ * HGOTO_ERROR() to HRETURN_ERROR() since no clean-up needs to occur
+ * when an error is detected at this point since this must be the
+ * first executable statement in a function. This allows functions
+ * to omit the `done:' label when convenient to do so.
*
- * Robb Matzke, 4 Aug 1997
- * The pablo mask comes from the constant PABLO_MASK defined on
- * a per-file basis. The `pablo_func_id' is generated from the
- * `func_name' argument by prepending an `ID_' to the name. The
+ * Robb Matzke, 4 Aug 1997
+ * The pablo mask comes from the constant PABLO_MASK defined on
+ * a per-file basis. The `pablo_func_id' is generated from the
+ * `func_name' argument by prepending an `ID_' to the name. The
* pablo function identifier should be saved in a local variable
- * so FUNC_LEAVE() can access it.
+ * so FUNC_LEAVE() can access it.
*
- * Robb Matzke, 4 Aug 1997
- * It is safe to call this function even inside various library
- * initializing functions. Infinite recursion is no longer a
- * danger.
+ * Robb Matzke, 4 Aug 1997
+ * It is safe to call this function even inside various library
+ * initializing functions. Infinite recursion is no longer a
+ * danger.
*
- * Robb Matzke, 3 Dec 1997
- * The interface initialization function is no longer passed as an
- * argument unless the `FUNC_ENTER_INIT' form is called. Instead, the
- * function comes from the `INTERFACE_INIT' constant which must be
- * defined in every source file.
+ * Robb Matzke, 3 Dec 1997
+ * The interface initialization function is no longer passed as an
+ * argument unless the `FUNC_ENTER_INIT' form is called. Instead, the
+ * function comes from the `INTERFACE_INIT' constant which must be
+ * defined in every source file.
*
*-------------------------------------------------------------------------
*/
-extern hbool_t library_initialize_g; /*good thing C's lazy about extern!*/
-extern hbool_t thread_initialize_g; /*don't decl interface_initialize_g */
+extern hbool_t library_initialize_g; /*good thing C's lazy about extern! */
+extern hbool_t thread_initialize_g; /*don't decl interface_initialize_g */
#define FUNC_ENTER(func_name,err) FUNC_ENTER_INIT(func_name,INTERFACE_INIT,err)
-#define FUNC_ENTER_INIT(func_name,interface_init_func,err) { \
- CONSTR (FUNC, #func_name); \
- PABLO_SAVE (ID_ ## func_name); \
- \
- PABLO_TRACE_ON (PABLO_MASK, pablo_func_id); \
- \
- if (!library_initialize_g) { \
- library_initialize_g = TRUE; \
- if (H5_init_library()<0) { \
- HRETURN_ERROR (H5E_FUNC, H5E_CANTINIT, err, \
- "library initialization failed"); \
- } \
- } \
- \
- if (!thread_initialize_g) { \
- thread_initialize_g = TRUE; \
- if (H5_init_thread()<0) { \
- HRETURN_ERROR (H5E_FUNC, H5E_CANTINIT, err, \
- "thread initialization failed"); \
- } \
- } \
- \
- if (!interface_initialize_g) { \
- interface_initialize_g = TRUE; \
- if (interface_init_func && \
- ((herr_t(*)(void))interface_init_func)()<0) { \
- HRETURN_ERROR (H5E_FUNC, H5E_CANTINIT, err, \
- "interface initialization failed"); \
- } \
- } \
+#define FUNC_ENTER_INIT(func_name,interface_init_func,err) { \
+ CONSTR (FUNC, #func_name); \
+ PABLO_SAVE (ID_ ## func_name); \
+ \
+ PABLO_TRACE_ON (PABLO_MASK, pablo_func_id); \
+ \
+ if (!library_initialize_g) { \
+ library_initialize_g = TRUE; \
+ if (H5_init_library()<0) { \
+ HRETURN_ERROR (H5E_FUNC, H5E_CANTINIT, err, \
+ "library initialization failed"); \
+ } \
+ } \
+ \
+ if (!thread_initialize_g) { \
+ thread_initialize_g = TRUE; \
+ if (H5_init_thread()<0) { \
+ HRETURN_ERROR (H5E_FUNC, H5E_CANTINIT, err, \
+ "thread initialization failed"); \
+ } \
+ } \
+ \
+ if (!interface_initialize_g) { \
+ interface_initialize_g = TRUE; \
+ if (interface_init_func && \
+ ((herr_t(*)(void))interface_init_func)()<0) { \
+ HRETURN_ERROR (H5E_FUNC, H5E_CANTINIT, err, \
+ "interface initialization failed"); \
+ } \
+ } \
{
-
/*-------------------------------------------------------------------------
- * Purpose: Register function exit for code profiling. This should be
- * the last statement executed by a function.
+ * Purpose: Register function exit for code profiling. This should be
+ * the last statement executed by a function.
*
- * Programmer: Quincey Koziol
+ * Programmer: Quincey Koziol
*
* Modifications:
*
- * Robb Matzke, 4 Aug 1997
- * The pablo mask comes from the constant PABLO_MASK defined on a
- * per-file basis. The pablo_func_id comes from an auto variable
- * defined by FUNC_ENTER.
+ * Robb Matzke, 4 Aug 1997
+ * The pablo mask comes from the constant PABLO_MASK defined on a
+ * per-file basis. The pablo_func_id comes from an auto variable
+ * defined by FUNC_ENTER.
*
*-------------------------------------------------------------------------
*/
@@ -470,22 +468,20 @@ extern hbool_t thread_initialize_g; /*don't decl interface_initialize_g */
* through one of these two sets of macros.
*/
#ifdef HAVE_PABLO
-# define PABLO_SAVE(func_id) intn pablo_func_id = func_id
-# define PABLO_TRACE_ON(m, f) TRACE_ON(m,f)
+# define PABLO_SAVE(func_id) intn pablo_func_id = func_id
+# define PABLO_TRACE_ON(m, f) TRACE_ON(m,f)
# define PABLO_TRACE_OFF(m, f) TRACE_OFF(m,f)
#else
-# define PABLO_SAVE(func_id) /*void*/
-# define PABLO_TRACE_ON(m, f) /*void*/
-# define PABLO_TRACE_OFF(m, f) /*void*/
+# define PABLO_SAVE(func_id) /*void */
+# define PABLO_TRACE_ON(m, f) /*void */
+# define PABLO_TRACE_OFF(m, f) /*void */
#endif
-
-
/* Private functions, not part of the publicly documented API */
-herr_t H5_init_library(void);
-void H5_term_library(void);
-herr_t H5_add_exit (void (*func)(void));
-herr_t H5_init_thread(void);
-void H5_term_thread(void);
+herr_t H5_init_library(void);
+void H5_term_library(void);
+herr_t H5_add_exit(void (*func) (void));
+herr_t H5_init_thread(void);
+void H5_term_thread(void);
#endif
diff --git a/src/H5public.h b/src/H5public.h
index 07188cd..b92d498 100644
--- a/src/H5public.h
+++ b/src/H5public.h
@@ -18,60 +18,60 @@
#ifndef _H5public_H
#define _H5public_H
-#include <H5config.h> /* From configure */
+#include <H5config.h> /* From configure */
#include <sys/types.h>
/*
* Data types
*/
-typedef void VOID;
-typedef void *VOIDP;
-typedef char char8;
-typedef signed char int8;
-typedef unsigned char uchar8, uint8;
+typedef void VOID;
+typedef void *VOIDP;
+typedef char char8;
+typedef signed char int8;
+typedef unsigned char uchar8, uint8;
#if SIZEOF_SHORT==2
-typedef short int16;
-typedef unsigned short uint16;
+typedef short int16;
+typedef unsigned short uint16;
#else
-typedef int int16; /*not really*/
-typedef unsigned uint16; /*not really*/
+typedef int int16; /*not really */
+typedef unsigned uint16; /*not really */
#endif
#if SIZEOF_INT==4
-typedef int int32;
-typedef unsigned int uint32;
+typedef int int32;
+typedef unsigned int uint32;
#elif SIZEOF_LONG==4
-typedef long int32;
-typedef unsigned long uint32;
+typedef long int32;
+typedef unsigned long uint32;
#else
-typedef int int32; /*not really*/
-typedef unsigned uint32; /*not really*/
+typedef int int32; /*not really */
+typedef unsigned uint32; /*not really */
#endif
#if SIZEOF_INT==8
-typedef int int64;
-typedef unsigned uint64;
+typedef int int64;
+typedef unsigned uint64;
#elif SIZEOF_LONG==8
-typedef long int64;
-typedef unsigned long uint64;
+typedef long int64;
+typedef unsigned long uint64;
#elif SIZEOF_LONG_LONG==8
-typedef long long int64;
+typedef long long int64;
typedef unsigned long long uint64;
#else
# error "no 64-bit integer type"
#endif
#if SIZEOF_FLOAT==4
-typedef float float32;
+typedef float float32;
#else
-typedef float float32; /*not really*/
+typedef float float32; /*not really */
#endif
#if SIZEOF_FLOAT==8
-typedef float float64;
+typedef float float64;
#elif SIZEOF_DOUBLE==8
-typedef double float64;
+typedef double float64;
#else
# error "no 64-bit floating point type"
#endif
@@ -80,8 +80,8 @@ typedef double float64;
* Define a type for generic integers. Use this instead of `int' to
* show that some thought went into the algorithm.
*/
-typedef int intn;
-typedef unsigned uintn;
+typedef int intn;
+typedef unsigned uintn;
/*
* Status return values.
@@ -92,31 +92,31 @@ typedef unsigned uintn;
* function, remember to compare against zero and not one of these two
* values.
*/
-typedef intn herr_t;
-#define SUCCEED 0
-#define FAIL (-1)
-#define UFAIL (unsigned)(-1)
+typedef intn herr_t;
+#define SUCCEED 0
+#define FAIL (-1)
+#define UFAIL (unsigned)(-1)
/*
* Boolean type.
*/
typedef enum {
- BFAIL =(-1), /*error value*/
- BFALSE =0,
- BTRUE =1
+ BFAIL = (-1), /*error value */
+ BFALSE = 0,
+ BTRUE = 1
} hbool_t;
#ifdef __cplusplus
-extern "C" {
+extern "C" {
#endif
/* Functions in H5.c */
-herr_t H5init (void);
-herr_t H5dont_atexit(void);
-herr_t H5version(uintn *majnum, uintn *minnum, uintn *relnum, uintn *patnum);
+ herr_t H5init(void);
+ herr_t H5dont_atexit(void);
+ herr_t H5version(uintn *majnum, uintn *minnum, uintn *relnum, uintn *patnum);
#ifdef __cplusplus
}
-#endif
#endif
+#endif
diff --git a/src/debug.c b/src/debug.c
index 2271460..3787318 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -1,16 +1,16 @@
/*-------------------------------------------------------------------------
- * Copyright (C) 1997 National Center for Supercomputing Applications.
+ * Copyright (C) 1997 National Center for Supercomputing Applications.
* All rights reserved.
*
*-------------------------------------------------------------------------
*
- * Created: debug.c
- * Jul 18 1997
- * Robb Matzke <matzke@llnl.gov>
+ * Created: debug.c
+ * Jul 18 1997
+ * Robb Matzke <matzke@llnl.gov>
*
- * Purpose: Debugs an existing HDF5 file at a low level.
+ * Purpose: Debugs an existing HDF5 file at a low level.
*
- * Modifications:
+ * Modifications:
*
*-------------------------------------------------------------------------
*/
@@ -21,142 +21,137 @@
#include <H5Hprivate.h>
#include <H5Oprivate.h>
-#define INDENT 3
-#define VCOL 50
-
+#define INDENT 3
+#define VCOL 50
/*-------------------------------------------------------------------------
- * Function: main
+ * Function: main
*
- * Usage: debug FILENAME [OFFSET]
+ * Usage: debug FILENAME [OFFSET]
*
- * Return: Success: exit (0)
+ * Return: Success: exit (0)
*
- * Failure: exit (non-zero)
+ * Failure: exit (non-zero)
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jul 18 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jul 18 1997
*
* Modifications:
*
*-------------------------------------------------------------------------
*/
int
-main (int argc, char *argv[])
+main(int argc, char *argv[])
{
- hid_t fid;
- H5F_t *f;
- haddr_t addr;
- uint8 sig[16];
- intn i;
- herr_t status = SUCCEED;
- haddr_t extra;
+ hid_t fid;
+ H5F_t *f;
+ haddr_t addr;
+ uint8 sig[16];
+ intn i;
+ herr_t status = SUCCEED;
+ haddr_t extra;
- /*
- * Open the file and get the file descriptor.
- */
- if ((fid = H5Fopen (argv[1], 0, 0))<0) {
- fprintf (stderr, "cannot open file\n");
- HDexit (1);
- }
- if (NULL==(f=H5Aatom_object (fid))) {
- fprintf (stderr, "cannot obtain H5F_t pointer\n");
- HDexit (2);
- }
+ /*
+ * Open the file and get the file descriptor.
+ */
+ if ((fid = H5Fopen(argv[1], 0, 0)) < 0) {
+ fprintf(stderr, "cannot open file\n");
+ HDexit(1);
+ }
+ if (NULL == (f = H5Aatom_object(fid))) {
+ fprintf(stderr, "cannot obtain H5F_t pointer\n");
+ HDexit(2);
+ }
+ /*
+ * Parse command arguments.
+ */
+ H5F_addr_reset(&addr);
+ H5F_addr_reset(&extra);
+ if (argc > 2) {
+ printf("New address: %s\n", argv[2]);
+ addr.offset = HDstrtol(argv[2], NULL, 0);
+ }
+ if (argc > 3) {
+ extra.offset = HDstrtol(argv[3], NULL, 0);
+ }
+ /*
+ * Read the signature at the specified file position.
+ */
+ printf("Reading signature at address ");
+ H5F_addr_print(stdout, &addr);
+ printf(" (rel)\n");
+ if (H5F_block_read(f, &addr, sizeof(sig), sig) < 0) {
+ fprintf(stderr, "cannot read signature\n");
+ HDexit(3);
+ }
+ if (!HDmemcmp(sig, H5F_SIGNATURE, H5F_SIGNATURE_LEN)) {
+ /*
+ * Debug the boot block.
+ */
+ status = H5F_debug(f, &addr, stdout, 0, VCOL);
- /*
- * Parse command arguments.
- */
- H5F_addr_reset (&addr);
- H5F_addr_reset (&extra);
- if (argc>2) {
- printf ("New address: %s\n", argv[2]);
- addr.offset = HDstrtol (argv[2], NULL, 0);
- }
- if (argc>3) {
- extra.offset = HDstrtol (argv[3], NULL, 0);
- }
-
- /*
- * Read the signature at the specified file position.
- */
- printf ("Reading signature at address ");
- H5F_addr_print (stdout, &addr);
- printf (" (rel)\n");
- if (H5F_block_read (f, &addr, sizeof(sig), sig)<0) {
- fprintf (stderr, "cannot read signature\n");
- HDexit (3);
- }
+ } else if (!HDmemcmp(sig, H5H_MAGIC, H5H_SIZEOF_MAGIC)) {
+ /*
+ * Debug a heap.
+ */
+ status = H5H_debug(f, &addr, stdout, 0, VCOL);
- if (!HDmemcmp (sig, H5F_SIGNATURE, H5F_SIGNATURE_LEN)) {
- /*
- * Debug the boot block.
- */
- status = H5F_debug (f, &addr, stdout, 0, VCOL);
-
- } else if (!HDmemcmp (sig, H5H_MAGIC, H5H_SIZEOF_MAGIC)) {
- /*
- * Debug a heap.
- */
- status = H5H_debug (f, &addr, stdout, 0, VCOL);
+ } else if (!HDmemcmp(sig, H5G_NODE_MAGIC, H5G_NODE_SIZEOF_MAGIC)) {
+ /*
+ * Debug a symbol table node.
+ */
+ status = H5G_node_debug(f, &addr, stdout, 0, VCOL, &extra);
- } else if (!HDmemcmp (sig, H5G_NODE_MAGIC, H5G_NODE_SIZEOF_MAGIC)) {
- /*
- * Debug a symbol table node.
- */
- status = H5G_node_debug (f, &addr, stdout, 0, VCOL, &extra);
+ } else if (!HDmemcmp(sig, H5B_MAGIC, H5B_SIZEOF_MAGIC)) {
+ /*
+ * Debug a B-tree. B-trees are debugged through the B-tree
+ * subclass. The subclass identifier is the byte immediately
+ * after the B-tree signature.
+ */
+ H5B_subid_t subtype = sig[H5B_SIZEOF_MAGIC];
+ switch (subtype) {
+ case H5B_SNODE_ID:
+ status = H5G_node_debug(f, &addr, stdout, 0, VCOL, &extra);
+ break;
- } else if (!HDmemcmp (sig, H5B_MAGIC, H5B_SIZEOF_MAGIC)) {
- /*
- * Debug a B-tree. B-trees are debugged through the B-tree
- * subclass. The subclass identifier is the byte immediately
- * after the B-tree signature.
- */
- H5B_subid_t subtype = sig[H5B_SIZEOF_MAGIC];
- switch (subtype) {
- case H5B_SNODE_ID:
- status = H5G_node_debug (f, &addr, stdout, 0, VCOL, &extra);
- break;
+ default:
+ fprintf(stderr, "Unknown B-tree subtype %u\n", (unsigned) (subtype));
+ HDexit(4);
+ }
- default:
- fprintf (stderr, "Unknown B-tree subtype %u\n", (unsigned)(subtype));
- HDexit (4);
- }
+ } else if (sig[0] == H5O_VERSION && sig[1] == H5O_ALIGNMENT) {
+ /*
+ * This could be an object header. Since they don't have a signature
+ * it's a somewhat "ify" detection.
+ */
+ status = H5O_debug(f, &addr, stdout, 0, VCOL);
- } else if (sig[0]==H5O_VERSION && sig[1]==H5O_ALIGNMENT) {
- /*
- * This could be an object header. Since they don't have a signature
- * it's a somewhat "ify" detection.
- */
- status = H5O_debug (f, &addr, stdout, 0, VCOL);
-
- } else {
- /*
- * Got some other unrecognized signature.
- */
- printf ("%-*s ", VCOL, "Signature:");
- for (i=0; i<8; i++) {
- if (sig[i]>' ' && sig[i]<='~' && '\\'!=sig[i]) {
- HDputchar (sig[i]);
- } else if ('\\'==sig[i]) {
- HDputchar ('\\');
- HDputchar ('\\');
- } else {
- printf ("\\%03o", sig[i]);
- }
- }
- HDputchar ('\n');
-
- fprintf (stderr, "unknown signature\n");
- HDexit (4);
- }
+ } else {
+ /*
+ * Got some other unrecognized signature.
+ */
+ printf("%-*s ", VCOL, "Signature:");
+ for (i = 0; i < 8; i++) {
+ if (sig[i] > ' ' && sig[i] <= '~' && '\\' != sig[i]) {
+ HDputchar(sig[i]);
+ } else if ('\\' == sig[i]) {
+ HDputchar('\\');
+ HDputchar('\\');
+ } else {
+ printf("\\%03o", sig[i]);
+ }
+ }
+ HDputchar('\n');
- if (status<0) {
- fprintf (stderr, "An error occurred\n");
- HDexit (5);
- }
+ fprintf(stderr, "unknown signature\n");
+ HDexit(4);
+ }
- H5Fclose (fid);
- HDexit (0);
+ if (status < 0) {
+ fprintf(stderr, "An error occurred\n");
+ HDexit(5);
+ }
+ H5Fclose(fid);
+ HDexit(0);
}