summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/H5B.c25
-rw-r--r--src/H5D.c12
-rw-r--r--src/H5Distore.c9
-rw-r--r--src/H5F.c6
-rw-r--r--src/H5Farray.c8
-rw-r--r--src/H5Ffamily.c67
-rw-r--r--src/H5Fistore.c9
-rw-r--r--src/H5Flow.c7
-rw-r--r--src/H5Fprivate.h18
-rw-r--r--src/H5Fsec2.c6
-rw-r--r--src/H5Fstdio.c8
-rw-r--r--src/H5G.c4
-rw-r--r--src/H5Gnode.c4
-rw-r--r--src/H5H.c1082
-rw-r--r--src/H5Hprivate.h45
-rw-r--r--src/H5O.c1679
-rw-r--r--src/H5Ocont.c36
-rw-r--r--src/H5Odtype.c41
-rw-r--r--src/H5Oefl.c46
-rw-r--r--src/H5Olayout.c50
-rw-r--r--src/H5Oname.c43
-rw-r--r--src/H5Onull.c24
-rw-r--r--src/H5Oprivate.h175
-rw-r--r--src/H5Osdspace.c60
-rw-r--r--src/H5Ostab.c56
-rw-r--r--src/H5P.c35
-rw-r--r--src/H5Pprivate.h2
-rw-r--r--src/H5T.c13
-rw-r--r--src/H5Tconv.c18
-rw-r--r--src/H5Tpkg.h2
-rw-r--r--src/H5Tpublic.h2
-rw-r--r--src/H5V.c8
-rw-r--r--src/H5Vprivate.h6
-rw-r--r--src/H5detect.c62
-rw-r--r--src/H5private.h4
-rw-r--r--src/debug.c4
-rw-r--r--test/cmpd_dset.c2
-rw-r--r--test/dsets.c3
-rw-r--r--test/dtypes.c9
-rw-r--r--test/extend.c2
-rw-r--r--test/hyperslab.c41
-rw-r--r--test/istore.c5
-rw-r--r--test/testhdf5.c4
-rw-r--r--test/th5p.c2
-rw-r--r--test/theap.c2
45 files changed, 1903 insertions, 1843 deletions
diff --git a/src/H5B.c b/src/H5B.c
index 31cb075..4ab57ca 100644
--- a/src/H5B.c
+++ b/src/H5B.c
@@ -752,14 +752,21 @@ herr_t
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;
+ /*
+ * These are defined this way to satisfy alignment constraints.
+ */
+ uint64 _lt_key[128], _md_key[128], _rt_key[128];
+ uint8 *lt_key=(uint8*)_lt_key;
+ uint8 *md_key=(uint8*)_md_key;
+ uint8 *rt_key=(uint8*)_rt_key;
+
+ 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);
@@ -768,7 +775,7 @@ H5B_insert(H5F_t *f, const H5B_class_t *type, const haddr_t *addr,
*/
assert(f);
assert(type);
- assert(type->sizeof_nkey <= sizeof lt_key);
+ 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,
diff --git a/src/H5D.c b/src/H5D.c
index 70d512c..28a3d2e 100644
--- a/src/H5D.c
+++ b/src/H5D.c
@@ -742,7 +742,6 @@ H5D_create(H5F_t *f, const char *name, const H5T_t *type, const H5P_t *space,
{
H5D_t *new_dset = NULL;
H5D_t *ret_value = NULL;
- size_t nbytes;
intn i;
FUNC_ENTER(H5D_create, NULL);
@@ -776,7 +775,6 @@ H5D_create(H5F_t *f, const char *name, const H5T_t *type, const H5P_t *space,
}
/* 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));
@@ -1037,7 +1035,6 @@ H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5P_t *mem_space,
assert(buf);
if (!file_space) file_space = dataset->space;
if (!mem_space) mem_space = file_space;
- assert (H5P_get_npoints (mem_space)==H5P_get_npoints (file_space));
/*
* Convert data types to atoms because the conversion functions are
@@ -1069,6 +1066,10 @@ H5D_read(H5D_t *dataset, const H5T_t *mem_type, const H5P_t *mem_space,
} else {
HDmemset (&numbering, 0, sizeof numbering);
}
+ if (H5P_get_npoints (mem_space)!=H5P_get_npoints (file_space)) {
+ HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,
+ "src and dest data spaces have different sizes");
+ }
/*
* Compute the size of the request and allocate scratch buffers.
@@ -1177,7 +1178,6 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5P_t *mem_space,
assert(buf);
if (!file_space) file_space = dataset->space;
if (!mem_space) mem_space = file_space;
- assert (H5P_get_npoints (mem_space)==H5P_get_npoints (file_space));
/*
* Convert data types to atoms because the conversion functions are
@@ -1209,6 +1209,10 @@ H5D_write(H5D_t *dataset, const H5T_t *mem_type, const H5P_t *mem_space,
} else {
HDmemset (&numbering, 0, sizeof numbering);
}
+ if (H5P_get_npoints (mem_space)!=H5P_get_npoints (file_space)) {
+ HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL,
+ "src and dest data spaces have different sizes");
+ }
/*
* Compute the size of the request and allocate scratch buffers.
diff --git a/src/H5Distore.c b/src/H5Distore.c
index c188b95..eeed99c 100644
--- a/src/H5Distore.c
+++ b/src/H5Distore.c
@@ -155,8 +155,8 @@ static herr_t
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;
+ intn i;
+ intn ndims = (intn)(bt->sizeof_rkey / 8);
FUNC_ENTER(H5F_istore_decode_key, FAIL);
@@ -199,7 +199,7 @@ static herr_t
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 ndims = (intn)(bt->sizeof_rkey / 8);
intn i;
FUNC_ENTER(H5F_istore_encode_key, FAIL);
@@ -624,9 +624,6 @@ H5F_istore_copy_hyperslab(H5F_t *f, const H5O_layout_t *layout, H5F_isop_t op,
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]);
diff --git a/src/H5F.c b/src/H5F.c
index 4b7d669..7f83eb6 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -1216,8 +1216,10 @@ H5F_flush(H5F_t *f, hbool_t invalidate)
*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);
+ assert (H5F_SIZEOF_ADDR(f)<=255);
+ *p++ = (uint8)H5F_SIZEOF_ADDR(f);
+ assert (H5F_SIZEOF_SIZE(f)<=255);
+ *p++ = (uint8)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]);
diff --git a/src/H5Farray.c b/src/H5Farray.c
index c0e6ad6..cfe79d9 100644
--- a/src/H5Farray.c
+++ b/src/H5Farray.c
@@ -122,7 +122,7 @@ H5F_arr_read (H5F_t *f, const struct H5O_layout_t *layout,
size_t idx[H5O_LAYOUT_NDIMS]; /*multi-dim counter */
size_t mem_start, file_start; /*byte offsets to start */
size_t elmt_size = 1; /*bytes per element */
- intn nelmts; /*number of elements */
+ size_t nelmts, z; /*number of elements */
intn ndims; /*stride dimensionality */
haddr_t addr; /*address in file */
intn i, j; /*counters */
@@ -173,7 +173,7 @@ H5F_arr_read (H5F_t *f, const struct H5O_layout_t *layout,
* Now begin to walk through the array, copying data from disk to
* memory.
*/
- for (i=0; i<nelmts; i++) {
+ for (z=0; z<nelmts; z++) {
/* Read from file */
if (H5F_block_read (f, &addr, elmt_size, buf)<0) {
@@ -256,7 +256,7 @@ H5F_arr_write (H5F_t *f, const struct H5O_layout_t *layout,
size_t idx[H5O_LAYOUT_NDIMS]; /*multi-dim counter */
size_t mem_start, file_start; /*byte offsets to start */
size_t elmt_size = 1; /*bytes per element */
- intn nelmts; /*number of elements */
+ size_t nelmts, z; /*number of elements */
intn ndims; /*dimensionality */
haddr_t addr; /*address in file */
intn i, j; /*counters */
@@ -308,7 +308,7 @@ H5F_arr_write (H5F_t *f, const struct H5O_layout_t *layout,
* Now begin to walk through the array, copying data from memory to
* disk.
*/
- for (i=0; i<nelmts; i++) {
+ for (z=0; z<nelmts; z++) {
/* Write to file */
if (H5F_block_write (f, &addr, elmt_size, buf)<0) {
diff --git a/src/H5Ffamily.c b/src/H5Ffamily.c
index a72f6bf..025039c 100644
--- a/src/H5Ffamily.c
+++ b/src/H5Ffamily.c
@@ -41,29 +41,28 @@ static hbool_t interface_initialize_g = FALSE;
#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_OFFSET(ADDR,N) ((off_t)((ADDR)->offset & H5F_FAM_MASK(N)))
+#define H5F_FAM_MEMBNO(ADDR,N) ((intn)((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
@@ -495,13 +494,14 @@ H5F_fam_flush(H5F_low_t *lf)
static hbool_t
H5F_fam_access(const char *name, int mode, H5F_search_t *key /*out */ )
{
- intn membno;
- char member_name[4096];
- hbool_t status;
+ intn membno;
+ char member_name[4096];
+ hbool_t status;
+ hbool_t ret_value = FALSE;
FUNC_ENTER(H5F_fam_access, FAIL);
- for (membno = 0; /*void */ ; membno++) {
+ for (membno=0; /*void*/; membno++) {
sprintf(member_name, name, membno);
status = H5F_low_access(H5F_LOW_DFLT, member_name, mode,
0 == membno ? key : NULL);
@@ -513,18 +513,23 @@ H5F_fam_access(const char *name, int mode, H5F_search_t *key /*out */ )
* of the family. As long as we found the first member(s) the
* family exists.
*/
- HRETURN(membno > 0 ? TRUE : FALSE);
+ ret_value = membno > 0 ? TRUE : FALSE;
+ break;
+
} 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);
+ ret_value = FALSE;
+ break;
+
} else {
/*
* The file doesn't exist because we got to the end of the
* family.
*/
- HRETURN(TRUE);
+ ret_value = TRUE;
+ break;
}
}
if (status < 0) {
@@ -533,5 +538,5 @@ H5F_fam_access(const char *name, int mode, H5F_search_t *key /*out */ )
}
}
- FUNC_LEAVE(TRUE);
+ FUNC_LEAVE(ret_value);
}
diff --git a/src/H5Fistore.c b/src/H5Fistore.c
index c188b95..eeed99c 100644
--- a/src/H5Fistore.c
+++ b/src/H5Fistore.c
@@ -155,8 +155,8 @@ static herr_t
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;
+ intn i;
+ intn ndims = (intn)(bt->sizeof_rkey / 8);
FUNC_ENTER(H5F_istore_decode_key, FAIL);
@@ -199,7 +199,7 @@ static herr_t
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 ndims = (intn)(bt->sizeof_rkey / 8);
intn i;
FUNC_ENTER(H5F_istore_encode_key, FAIL);
@@ -624,9 +624,6 @@ H5F_istore_copy_hyperslab(H5F_t *f, const H5O_layout_t *layout, H5F_isop_t op,
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]);
diff --git a/src/H5Flow.c b/src/H5Flow.c
index bf3a182..edafc1f 100644
--- a/src/H5Flow.c
+++ b/src/H5Flow.c
@@ -18,7 +18,7 @@
#include <sys/types.h>
#include <sys/stat.h>
-#define addr_defined(X) ((-1!=(X)->offset && (X)->offset>=0) ? TRUE : FALSE)
+#define addr_defined(X) (((uint64)(-1)!=(X)->offset) ? TRUE : FALSE)
#define PABLO_MASK H5F_low
static hbool_t interface_initialize_g = FALSE;
@@ -620,7 +620,7 @@ H5F_addr_encode(H5F_t *f, uint8 **pp, const haddr_t *addr)
if (addr_defined(addr)) {
tmp = *addr;
for (i = 0; i < H5F_SIZEOF_ADDR(f); i++) {
- *(*pp)++ = tmp.offset & 0xff;
+ *(*pp)++ = (uint8)(tmp.offset & 0xff);
tmp.offset >>= 8;
}
assert("overflow" && 0 == tmp.offset);
@@ -742,7 +742,6 @@ H5F_addr_print(FILE * stream, const haddr_t *addr)
void
H5F_addr_pow2(uintn n, haddr_t *addr /*out */ )
{
- assert(n >= 0);
assert(addr);
assert(n < 8 * sizeof(addr->offset));
@@ -817,5 +816,5 @@ H5F_addr_hash(const haddr_t *addr, uintn mod)
assert(addr && addr_defined(addr));
assert(mod > 0);
- return addr->offset % mod; /*ignore file number */
+ return (unsigned)(addr->offset % mod); /*ignore file number */
}
diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h
index 3f71055..7550165 100644
--- a/src/H5Fprivate.h
+++ b/src/H5Fprivate.h
@@ -100,10 +100,10 @@
# define INT64ENCODE(p, n) { \
int64 _n = (n); \
- intn _i; \
+ size_t _i; \
uint8 *_p = (uint8*)(p); \
for (_i=0; _i<sizeof(int64); _i++, _n>>=8) { \
- *_p++ = _n & 0xff; \
+ *_p++ = (uint8)(_n & 0xff); \
} \
for (/*void*/; _i<8; _i++) { \
*_p++ = (n)<0 ? 0xff : 0; \
@@ -113,10 +113,10 @@
# define UINT64ENCODE(p, n) { \
uint64 _n = (n); \
- intn _i; \
+ size_t _i; \
uint8 *_p = (uint8*)(p); \
for (_i=0; _i<sizeof(uint64); _i++, _n>>=8) { \
- *_p++ = _n & 0xff; \
+ *_p++ = (uint8)(_n & 0xff); \
} \
for (/*void*/; _i<8; _i++) { \
*_p++ = 0; \
@@ -150,7 +150,7 @@
# define INT64DECODE(p, n) { \
/* WE DON'T CHECK FOR OVERFLOW! */ \
- intn _i; \
+ size_t _i; \
n = 0; \
(p) += 8; \
for (_i=0; _i<sizeof(int64); _i++, n<<=8) { \
@@ -161,7 +161,7 @@
# define UINT64DECODE(p, n) { \
/* WE DON'T CHECK FOR OVERFLOW! */ \
- intn _i; \
+ size_t _i; \
n = 0; \
(p) += 8; \
for (_i=0; _i<sizeof(uint64); _i++, n<<=8) { \
@@ -399,18 +399,12 @@ typedef struct H5F_t {
break; \
}
-#ifdef NOT_YET
-#define H5F_encode_length(f,p,l) (H5F_SIZEOF_SIZE(f)==4 ? UINT32ENCODE(p,l) \
- : 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; \
}
-#endif
#define H5F_decode_length(f,p,l) \
switch(H5F_SIZEOF_SIZE(f)) { \
diff --git a/src/H5Fsec2.c b/src/H5Fsec2.c
index f97372b..5fb3b08 100644
--- a/src/H5Fsec2.c
+++ b/src/H5Fsec2.c
@@ -160,7 +160,7 @@ H5F_sec2_read(H5F_low_t *lf, const haddr_t *addr, size_t size, uint8 *buf)
FUNC_ENTER(H5F_sec2_read, FAIL);
/* Check for overflow */
- offset = addr->offset;
+ offset = addr->offset; /*FIX_ME*/
assert("address overflowed" && offset == addr->offset);
assert("overflow" && offset + size >= offset);
@@ -242,7 +242,7 @@ H5F_sec2_write(H5F_low_t *lf, const haddr_t *addr, size_t size,
FUNC_ENTER(H5F_sec2_write, FAIL);
/* Check for overflow */
- offset = addr->offset;
+ offset = addr->offset; /*FIX_ME*/
assert("address overflowed" && offset == addr->offset);
assert("overflow" && offset + size >= offset);
@@ -270,7 +270,7 @@ H5F_sec2_write(H5F_low_t *lf, const haddr_t *addr, size_t size,
* Update the file position.
*/
lf->u.sec2.op = H5F_OP_WRITE;
- lf->u.sec2.cur = offset + size;
+ lf->u.sec2.cur = offset + size; /*FIX_ME*/
assert("address overflowed" && lf->u.sec2.cur >= offset);
FUNC_LEAVE(SUCCEED);
diff --git a/src/H5Fstdio.c b/src/H5Fstdio.c
index f4e076d..a7cb096 100644
--- a/src/H5Fstdio.c
+++ b/src/H5Fstdio.c
@@ -184,7 +184,7 @@ H5F_stdio_read(H5F_low_t *lf, const haddr_t *addr, size_t size, uint8 *buf)
FUNC_ENTER(H5F_stdio_read, FAIL);
/* Check for overflow */
- offset = addr->offset;
+ offset = addr->offset; /*FIX_ME*/
assert("address overflowed" && offset == addr->offset);
assert("overflow" && offset + size >= offset);
@@ -230,7 +230,7 @@ H5F_stdio_read(H5F_low_t *lf, const haddr_t *addr, size_t size, uint8 *buf)
* Update the file position data.
*/
lf->u.stdio.op = H5F_OP_READ;
- lf->u.stdio.cur = offset + n;
+ lf->u.stdio.cur = offset + n; /*FIX_ME*/
FUNC_LEAVE(SUCCEED);
}
@@ -264,7 +264,7 @@ H5F_stdio_write(H5F_low_t *lf, const haddr_t *addr, size_t size,
FUNC_ENTER(H5F_stdio_write, FAIL);
/* Check for overflow */
- offset = addr->offset;
+ offset = addr->offset; /*FIX_ME*/
assert("address overflowed" && offset == addr->offset);
assert("overflow" && offset + size >= offset);
@@ -292,7 +292,7 @@ H5F_stdio_write(H5F_low_t *lf, const haddr_t *addr, size_t size,
* Update seek optimizing data.
*/
lf->u.stdio.op = H5F_OP_WRITE;
- lf->u.stdio.cur = offset + size;
+ lf->u.stdio.cur = offset + size; /*FIX_ME*/
FUNC_LEAVE(SUCCEED);
}
diff --git a/src/H5G.c b/src/H5G.c
index dcd3fd3..fd6f130 100644
--- a/src/H5G.c
+++ b/src/H5G.c
@@ -182,13 +182,11 @@ H5Gopen(hid_t file_id, const char *name)
herr_t
H5Gclose(hid_t grp_id)
{
- H5G_t *grp = NULL;
-
FUNC_ENTER(H5Gclose, FAIL);
/* Check args */
if (H5_GROUP != H5A_group(grp_id) ||
- NULL == (grp = H5A_object(grp_id))) {
+ NULL == H5A_object(grp_id)) {
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group");
}
/*
diff --git a/src/H5Gnode.c b/src/H5Gnode.c
index 851510e..59bfd1c 100644
--- a/src/H5Gnode.c
+++ b/src/H5Gnode.c
@@ -706,7 +706,6 @@ H5G_node_insert(H5F_t *f, const haddr_t *addr,
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);
@@ -796,13 +795,11 @@ H5G_node_insert(H5F_t *f, const haddr_t *addr,
/* 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 {
@@ -810,7 +807,6 @@ H5G_node_insert(H5F_t *f, const haddr_t *addr,
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;
diff --git a/src/H5H.c b/src/H5H.c
index 3d0f8a2..244d49c 100644
--- a/src/H5H.c
+++ b/src/H5H.c
@@ -1,127 +1,127 @@
/*-------------------------------------------------------------------------
- * Copyright (C) 1997 National Center for Supercomputing Applications.
- * All rights reserved.
+ * 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
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 */ )
+ 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);
/* 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");
-#endif
+ if (H5H_GLOBAL == heap_type) {
+ fprintf(stderr, "H5H_create: a local heap is used as the global "
+ "heap\n");
}
+#endif
+
if (size_hint && size_hint < H5H_SIZEOF_FREE(f)) {
- 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");
+ 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;
@@ -132,51 +132,51 @@ H5H_create(H5F_t *f, H5H_type_t heap_type, size_t 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;
+ 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;
+ 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");
+ 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 *
+static H5H_t *
H5H_load(H5F_t *f, const haddr_t *addr, const void *udata1, void *udata2)
{
- uint8 hdr[52];
- 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;
+ uint8 hdr[52];
+ 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);
@@ -188,19 +188,22 @@ H5H_load(H5F_t *f, const haddr_t *addr, const void *udata1, void *udata2)
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");
+ 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");
+ HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL,
+ "bad heap signature");
}
p += H5H_SIZEOF_MAGIC;
+ /* Reserved */
+ p += 4;
+
/* heap data size */
H5F_decode_length(f, p, heap->disk_alloc);
heap->mem_alloc = heap->disk_alloc;
@@ -208,71 +211,71 @@ H5H_load(H5F_t *f, const haddr_t *addr, const void *udata1, void *udata2)
/* 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");
+ 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");
+ 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");
- }
+ 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);
- }
+ 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:
*
@@ -281,9 +284,9 @@ H5H_load(H5F_t *f, const haddr_t *addr, const void *udata1, void *udata2)
static herr_t
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;
+ uint8 *p = heap->chunk;
+ H5H_free_t *fl = heap->freelist;
+ haddr_t hdr_end_addr;
FUNC_ENTER(H5H_flush, FAIL);
@@ -293,193 +296,197 @@ H5H_flush(H5F_t *f, hbool_t destroy, const haddr_t *addr, H5H_t *heap)
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;
+ /*
+ * 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;
+ *p++ = 0; /*reserved*/
+ *p++ = 0; /*reserved*/
+ *p++ = 0; /*reserved*/
+ *p++ = 0; /*reserved*/
+ 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) {
+ assert (fl->offset == H5H_ALIGN (fl->offset));
+ 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);
+ 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 *
+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);
/* check arguments */
assert(f);
- if (!addr)
- addr = &(f->shared->smallobj_addr);
+ if (!addr) addr = &(f->shared->smallobj_addr);
assert(H5F_addr_defined(addr));
if (NULL == (heap = H5AC_find(f, H5AC_HEAP, addr, NULL, NULL))) {
- HRETURN_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL,
- "unable to load heap");
+ 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);
+ if (!buf) buf = H5MM_xmalloc(size);
HDmemcpy(buf, heap->chunk + H5H_SIZEOF_HDR(f) + offset, size);
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 *
+const void *
H5H_peek(H5F_t *f, const haddr_t *addr, size_t offset)
{
- H5H_t *heap = NULL;
- const void *retval = NULL;
+ H5H_t *heap = NULL;
+ const void *retval = NULL;
FUNC_ENTER(H5H_peek, NULL);
/* check arguments */
assert(f);
- if (!addr)
- addr = &(f->shared->smallobj_addr);
+ if (!addr) addr = &(f->shared->smallobj_addr);
assert(H5F_addr_defined(addr));
if (NULL == (heap = H5AC_find(f, H5AC_HEAP, addr, NULL, NULL))) {
- HRETURN_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL,
- "unable to load heap");
+ HRETURN_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL,
+ "unable to load heap");
}
assert(offset < heap->mem_alloc);
@@ -488,49 +495,46 @@ H5H_peek(H5F_t *f, const haddr_t *addr, size_t offset)
}
/*-------------------------------------------------------------------------
- * 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 *
+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) fl->prev->next = fl->next;
+ if (fl->next) fl->next->prev = fl->prev;
- if (!fl->prev)
- heap->freelist = fl->next;
+ 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: (size_t)(-1)
+ * Failure: (size_t)(-1)
*
- * Programmer: Robb Matzke
- * matzke@llnl.gov
- * Jul 17 1997
+ * Programmer: Robb Matzke
+ * matzke@llnl.gov
+ * Jul 17 1997
*
* Modifications:
*
@@ -539,13 +543,13 @@ H5H_remove_free(H5H_t *heap, H5H_free_t *fl)
size_t
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 int nmessages = 0;
+ static int nmessages = 0;
#endif
FUNC_ENTER(H5H_insert, (size_t)(-1));
@@ -558,8 +562,8 @@ H5H_insert(H5F_t *f, const haddr_t *addr, size_t buf_size, const void *buf)
assert(buf);
if (NULL == (heap = H5AC_find(f, H5AC_HEAP, addr, NULL, NULL))) {
- HRETURN_ERROR(H5E_HEAP, H5E_CANTLOAD, (size_t)(-1),
- "unable to load heap");
+ HRETURN_ERROR(H5E_HEAP, H5E_CANTLOAD, (size_t)(-1),
+ "unable to load heap");
}
heap->dirty += 1;
@@ -574,101 +578,105 @@ H5H_insert(H5F_t *f, const haddr_t *addr, size_t buf_size, const void *buf)
* 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 &&
+ 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;
- }
+ /* a bigger free block was found */
+ offset = fl->offset;
+ fl->offset += need_size;
+ fl->size -= need_size;
+ assert (fl->offset==H5H_ALIGN (fl->offset));
+ assert (fl->size==H5H_ALIGN (fl->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
+ * 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==FALSE) {
-
- 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)) {
+ 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;
+ assert (max_fl->offset==H5H_ALIGN (max_fl->offset));
+ assert (max_fl->size==H5H_ALIGN (max_fl->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 "
+ 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;
+ assert (fl->offset==H5H_ALIGN (fl->offset));
+ assert (fl->size==H5H_ALIGN (fl->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);
+ 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);
+ /* 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
@@ -678,26 +686,26 @@ H5H_insert(H5F_t *f, const haddr_t *addr, size_t buf_size, const void *buf)
}
/*-------------------------------------------------------------------------
- * 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:
*
@@ -705,22 +713,22 @@ H5H_insert(H5F_t *f, const haddr_t *addr, size_t buf_size, const void *buf)
*/
herr_t
H5H_write(H5F_t *f, const haddr_t *addr, size_t offset, size_t size,
- const void *buf)
+ const void *buf)
{
- H5H_t *heap = NULL;
+ H5H_t *heap = NULL;
FUNC_ENTER(H5H_write, FAIL);
/* check arguments */
assert(f);
- if (!addr)
- addr = &(f->shared->smallobj_addr);
+ if (!addr) addr = &(f->shared->smallobj_addr);
assert(H5F_addr_defined(addr));
assert(buf);
+ assert (offset==H5H_ALIGN (offset));
if (NULL == (heap = H5AC_find(f, H5AC_HEAP, addr, NULL, NULL))) {
- HRETURN_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL,
- "unable to load heap");
+ HRETURN_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL,
+ "unable to load heap");
}
assert(offset < heap->mem_alloc);
assert(offset + size <= heap->mem_alloc);
@@ -732,31 +740,31 @@ H5H_write(H5F_t *f, const haddr_t *addr, size_t offset, size_t size,
}
/*-------------------------------------------------------------------------
- * 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:
*
@@ -765,24 +773,25 @@ H5H_write(H5F_t *f, const haddr_t *addr, size_t offset, size_t size,
herr_t
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);
+ if (!addr) addr = &(f->shared->smallobj_addr);
assert(H5F_addr_defined(addr));
assert(size > 0);
+ assert (offset==H5H_ALIGN (offset));
+ size = H5H_ALIGN (size);
if (NULL == (heap = H5AC_find(f, H5AC_HEAP, addr, NULL, NULL))) {
- HRETURN_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL,
- "unable to load heap");
+ HRETURN_ERROR(H5E_HEAP, H5E_CANTLOAD, FAIL,
+ "unable to load heap");
}
assert(offset < heap->mem_alloc);
assert(offset + size <= heap->mem_alloc);
@@ -795,49 +804,55 @@ H5H_remove(H5F_t *f, const haddr_t *addr, size_t offset, size_t size)
* 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;
+ if (offset + size == fl->offset) {
+ fl->offset = offset;
+ fl->size += size;
+ assert (fl->offset==H5H_ALIGN (fl->offset));
+ assert (fl->size==H5H_ALIGN (fl->size));
+ fl2 = fl->next;
+ while (fl2) {
+ if (fl2->offset + fl2->size == fl->offset) {
+ fl->offset = fl2->offset;
+ fl->size += fl2->size;
+ assert (fl->offset==H5H_ALIGN (fl->offset));
+ assert (fl->size==H5H_ALIGN (fl->size));
+ fl2 = H5H_remove_free(heap, fl2);
+ HRETURN(SUCCEED);
+ }
+ }
+ HRETURN(SUCCEED);
+
+ } else if (fl->offset + fl->size == offset) {
+ fl->size += size;
+ fl2 = fl->next;
+ assert (fl->size==H5H_ALIGN (fl->size));
+ while (fl2) {
+ if (fl->offset + fl->size == fl2->offset) {
+ fl->size += fl2->size;
+ assert (fl->size==H5H_ALIGN (fl->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
+ * 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);
+ HRETURN(SUCCEED);
}
/*
* Add an entry to the free list.
@@ -845,30 +860,31 @@ H5H_remove(H5F_t *f, const haddr_t *addr, size_t offset, size_t size)
fl = H5MM_xmalloc(sizeof(H5H_free_t));
fl->offset = offset;
fl->size = size;
+ assert (fl->offset==H5H_ALIGN (fl->offset));
+ assert (fl->size==H5H_ALIGN (fl->size));
fl->prev = NULL;
fl->next = heap->freelist;
- if (heap->freelist)
- heap->freelist->prev = fl;
+ 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:
*
@@ -876,40 +892,40 @@ 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)
+ 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;
+ 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);
+ 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");
+ 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));
+ "Dirty:",
+ (int) (h->dirty));
fprintf(stream, "%*s%-*s %lu\n", indent, "", fwidth,
- "Data bytes allocated on disk:",
- (unsigned long) (h->disk_alloc));
+ "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));
+ "Data bytes allocated in core:",
+ (unsigned long) (h->mem_alloc));
/*
* Traverse the free list and check that all free blocks fall within
@@ -918,69 +934,69 @@ H5H_debug(H5F_t *f, const haddr_t *addr, FILE * stream, intn indent,
*/
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;
- }
- }
+ 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));
+ 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, "");
+ 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);
+ 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);
diff --git a/src/H5Hprivate.h b/src/H5Hprivate.h
index aef6e48..c852e6d 100644
--- a/src/H5Hprivate.h
+++ b/src/H5Hprivate.h
@@ -1,12 +1,12 @@
/*-------------------------------------------------------------------------
- * Copyright (C) 1997 National Center for Supercomputing Applications.
- * All rights reserved.
+ * 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:
*
@@ -23,37 +23,40 @@
#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_ALIGN(X) (((X)+7)&~0x07) /*align on 8-byte boundary */
-#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_ALIGN(H5H_SIZEOF_MAGIC + /*heap signature */ \
+ 4 + /*reserved */ \
+ H5F_SIZEOF_SIZE (F) + /*data size */ \
+ H5F_SIZEOF_SIZE (F) + /*free list head */ \
+ H5F_SIZEOF_ADDR (F)) /*data address */
+
+#define H5H_SIZEOF_FREE(F) \
+ H5H_ALIGN(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*/);
+ haddr_t *addr/*out*/);
void *H5H_read (H5F_t *f, const haddr_t *addr, size_t offset, size_t size,
- void *buf);
+ 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);
+ const void *buf);
herr_t H5H_write (H5F_t *f, const haddr_t *addr, size_t offset, size_t size,
- const void *buf);
+ 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);
+ intn fwidth);
#endif
diff --git a/src/H5O.c b/src/H5O.c
index d3b9f08..5f21eb4 100644
--- a/src/H5O.c
+++ b/src/H5O.c
@@ -1,16 +1,16 @@
/*-------------------------------------------------------------------------
- * Copyright (C) 1997 National Center for Supercomputing Applications.
- * All rights reserved.
+ * 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,55 +22,52 @@
#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 */
};
/*
@@ -78,21 +75,21 @@ 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
- * Tuesday, January 6, 1998
+ * Programmer: Robb Matzke
+ * Tuesday, January 6, 1998
*
* Modifications:
*
@@ -112,33 +109,33 @@ H5O_init_interface(void)
}
/*-------------------------------------------------------------------------
- * 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;
+ size_t size; /*total size of object header */
+ H5O_t *oh = NULL;
+ haddr_t tmp_addr;
FUNC_ENTER(H5O_create, FAIL);
@@ -146,21 +143,19 @@ H5O_create(H5F_t *f, size_t size_hint, H5G_entry_t *ent /*out */ )
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);
+ size_hint = H5O_ALIGN (MAX (H5O_MIN_SIZE, size_hint));
/* 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");
+ 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 */
@@ -183,36 +178,37 @@ H5O_create(H5F_t *f, size_t size_hint, H5G_entry_t *ent /*out */ )
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].raw = oh->chunk[0].image + H5O_SIZEOF_MSGHDR(f);
+ oh->mesg[0].raw_size = size_hint - H5O_SIZEOF_MSGHDR(f);
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");
+ 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");
+ 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
- * Monday, January 5, 1998
+ * Programmer: Robb Matzke
+ * Monday, January 5, 1998
*
* Modifications:
*
@@ -240,16 +236,16 @@ H5O_open(H5F_t *f, H5G_entry_t *obj_ent)
}
/*-------------------------------------------------------------------------
- * 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
- * Monday, January 5, 1998
+ * Programmer: Robb Matzke
+ * Monday, January 5, 1998
*
* Modifications:
*
@@ -273,7 +269,7 @@ H5O_close(H5G_entry_t *obj_ent)
* pending then close the file.
*/
if (0 == obj_ent->file->nopen && obj_ent->file->close_pending) {
- H5F_close(obj_ent->file);
+ H5F_close(obj_ent->file);
}
#ifdef H5O_DEBUG
fprintf(stderr, "<");
@@ -285,41 +281,41 @@ H5O_close(H5G_entry_t *obj_ent)
}
/*-------------------------------------------------------------------------
- * 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 *
+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? */
+ H5O_t *oh = NULL;
+ H5O_t *ret_value = NULL;
+ 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);
@@ -335,23 +331,21 @@ H5O_load(H5F_t *f, const haddr_t *addr, const void *_udata1, void *_udata2)
/* 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");
+ 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");
+ HGOTO_ERROR(H5E_OHDR, H5E_VERSION, NULL,
+ "bad object header version number");
}
+
+ /* reserved */
+ p++;
+
/* decode number of messages */
UINT16DECODE(p, nmesgs);
@@ -370,126 +364,131 @@ H5O_load(H5F_t *f, const haddr_t *addr, const void *_udata1, void *_udata2)
/* 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 */
- }
- }
+ /* 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);
+ assert (mesg_size==H5O_ALIGN (mesg_size));
+ p += 4; /*reserved*/
+
+ /*
+ * 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 += H5O_SIZEOF_MSGHDR(f) + 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 */
+ }
+ }
}
+ ret_value = oh;
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);
+ /*
+ * 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);
+ FUNC_LEAVE(ret_value);
}
/*-------------------------------------------------------------------------
- * 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)
{
- uint8 buf[16], *p;
- intn i, id;
- H5O_cont_t *cont = NULL;
+ uint8 buf[16], *p;
+ intn i, id;
+ H5O_cont_t *cont = NULL;
FUNC_ENTER(H5O_flush, FAIL);
@@ -500,125 +499,134 @@ H5O_flush(H5F_t *f, hbool_t destroy, const haddr_t *addr, H5O_t *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;
+ p = buf;
+
+ /* encode version */
+ *p++ = oh->version;
+
+ /* reserved */
+ *p++ = 0;
+
+ /* 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 - H5O_SIZEOF_MSGHDR(f);
+
+ /* 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);
+ *p++ = 0; /*reserved*/
+ *p++ = 0; /*reserved*/
+ *p++ = 0; /*reserved*/
+ *p++ = 0; /*reserved*/
+
+ 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_size ==
+ H5O_ALIGN (oh->mesg[i].raw_size));
+ 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);
+ /* 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:
*
@@ -630,31 +638,31 @@ 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);
- }
+ 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:
*
@@ -663,8 +671,8 @@ H5O_reset(const H5O_class_t *type, void *native)
intn
H5O_link(H5G_entry_t *ent, intn adjust)
{
- H5O_t *oh = NULL;
- intn ret_value = FAIL;
+ H5O_t *oh = NULL;
+ intn ret_value = FAIL;
FUNC_ENTER(H5O_link, FAIL);
@@ -675,19 +683,20 @@ H5O_link(H5G_entry_t *ent, intn adjust)
/* 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");
+ 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;
+ 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->nlink += adjust;
}
oh->dirty = TRUE;
@@ -695,41 +704,41 @@ H5O_link(H5G_entry_t *ent, intn adjust)
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");
+ 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 *
+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;
+ H5O_t *oh = NULL;
+ void *retval = NULL;
+ intn idx;
+ H5G_cache_t *cache = NULL;
+ H5G_type_t cache_type;
FUNC_ENTER(H5O_read, NULL);
@@ -743,50 +752,52 @@ H5O_read(H5G_entry_t *ent, const H5O_class_t *type, intn sequence, void *mesg)
/* 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 */
+ 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");
+ 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");
+ 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");
+ 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");
+ 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:
*
@@ -794,10 +805,10 @@ H5O_read(H5G_entry_t *ent, const H5O_class_t *type, intn sequence, void *mesg)
*/
static intn
H5O_find_in_ohdr(H5F_t *f, const haddr_t *addr, const H5O_class_t **type_p,
- intn sequence)
+ intn sequence)
{
- H5O_t *oh = NULL;
- int i;
+ H5O_t *oh = NULL;
+ int i;
FUNC_ENTER(H5O_find_in_ohdr, FAIL);
@@ -808,31 +819,33 @@ H5O_find_in_ohdr(H5F_t *f, const haddr_t *addr, const H5O_class_t **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");
+ 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 (*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");
+ 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");
- }
+ assert(oh->mesg[i].type->decode);
+ assert (oh->mesg[i].raw_size==H5O_ALIGN (oh->mesg[i].raw_size));
+ 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;
@@ -840,50 +853,50 @@ H5O_find_in_ohdr(H5F_t *f, const haddr_t *addr, const H5O_class_t **type_p,
}
/*-------------------------------------------------------------------------
- * 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)
+ uintn flags, const void *mesg)
{
- H5O_t *oh = NULL;
- intn idx, sequence;
- intn ret_value = FAIL;
- size_t size;
+ H5O_t *oh = NULL;
+ intn idx, sequence;
+ intn ret_value = FAIL;
+ size_t size;
FUNC_ENTER(H5O_modify, FAIL);
@@ -895,49 +908,49 @@ H5O_modify(H5G_entry_t *ent, const H5O_class_t *type, intn overwrite,
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");
+ 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;
+ 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");
- }
+ (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++;
+ /* Allocate space for the new message */
+ size = (type->raw_size) (ent->file, mesg);
+ size = H5O_ALIGN(size);
+ 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");
+ 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");
+ 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;
@@ -946,45 +959,45 @@ H5O_modify(H5G_entry_t *ent, const H5O_class_t *type, intn overwrite,
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");
+ 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_t *oh = NULL;
- intn i, seq, nfailed = 0;
- herr_t ret_value = FAIL;
+ H5O_t *oh = NULL;
+ intn i, seq, nfailed = 0;
+ herr_t ret_value = FAIL;
FUNC_ENTER(H5O_remove, FAIL);
@@ -996,68 +1009,67 @@ H5O_remove(H5G_entry_t *ent, const H5O_class_t *type, intn sequence)
/* 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");
+ 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;
- }
+ 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)");
+ 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");
+ 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:
*
@@ -1066,9 +1078,9 @@ H5O_remove(H5G_entry_t *ent, const H5O_class_t *type, intn sequence)
static intn
H5O_alloc_extend_chunk(H5O_t *oh, intn chunkno, size_t size)
{
- intn idx, i;
- size_t delta;
- uint8 *old_addr;
+ intn idx, i;
+ size_t delta;
+ uint8 *old_addr;
FUNC_ENTER(H5O_alloc_extend_chunk, FAIL);
@@ -1076,97 +1088,101 @@ H5O_alloc_extend_chunk(H5O_t *oh, intn chunkno, size_t size)
assert(oh);
assert(chunkno >= 0 && chunkno < oh->nchunks);
assert(size > 0);
+ assert (size==H5O_ALIGN (size));
if (H5F_addr_defined(&(oh->chunk[chunkno].addr))) {
- HRETURN_ERROR(H5E_OHDR, H5E_NOSPACE, FAIL, "chunk is on disk");
+ 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);
- }
+ 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);
+ assert (delta=H5O_ALIGN (delta));
+ 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));
+ 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);
+ delta = MAX(H5O_MIN_SIZE, size+H5O_SIZEOF_MSGHDR(f));
+ delta = H5O_ALIGN(delta);
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].raw = oh->chunk[chunkno].image +
+ oh->chunk[chunkno].size +
+ H5O_SIZEOF_MSGHDR(f);
+ oh->mesg[idx].raw_size = delta - H5O_SIZEOF_MSGHDR(f);
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);
+ 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);
- }
- }
+ 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:
*
@@ -1175,19 +1191,20 @@ 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)
{
- 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;
+ 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);
+ assert (oh);
+ assert (size > 0);
+ assert (size == H5O_ALIGN (size));
/*
* Find the smallest null message that will hold an object
@@ -1195,24 +1212,25 @@ H5O_alloc_new_chunk(H5F_t *f, H5O_t *oh, size_t size)
* 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;
- }
+ cont_size = H5O_ALIGN (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);
@@ -1222,23 +1240,23 @@ H5O_alloc_new_chunk(H5F_t *f, H5O_t *oh, size_t size)
* other message.
*/
if (found_null < 0)
- size += 4 + oh->mesg[found_other].raw_size;
+ size += H5O_SIZEOF_MSGHDR(f) + 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
+ * 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);
+ size = MAX(H5O_MIN_SIZE, size + H5O_SIZEOF_MSGHDR(f));
+ assert (size == H5O_ALIGN (size));
/*
* 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));
+ 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;
@@ -1251,34 +1269,35 @@ H5O_alloc_new_chunk(H5F_t *f, H5O_t *oh, size_t size)
* 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));
+ 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;
+ 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 + H5O_SIZEOF_MSGHDR(f);
+ oh->mesg[found_other].chunkno = chunkno;
+ p += H5O_SIZEOF_MSGHDR(f) + oh->mesg[found_other].raw_size;
+ size -= H5O_SIZEOF_MSGHDR(f) + 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].raw = p + H5O_SIZEOF_MSGHDR(f);
+ oh->mesg[idx].raw_size = size - H5O_SIZEOF_MSGHDR(f);
oh->mesg[idx].chunkno = chunkno;
/*
@@ -1287,17 +1306,21 @@ H5O_alloc_new_chunk(H5F_t *f, H5O_t *oh, size_t size)
* 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;
+ 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 +
+ H5O_SIZEOF_MSGHDR(f);
+ oh->mesg[i].raw_size = oh->mesg[found_null].raw_size -
+ (cont_size + H5O_SIZEOF_MSGHDR(f));
+ 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.
*/
@@ -1313,17 +1336,17 @@ H5O_alloc_new_chunk(H5F_t *f, H5O_t *oh, size_t size)
}
/*-------------------------------------------------------------------------
- * 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:
*
@@ -1332,29 +1355,29 @@ H5O_alloc_new_chunk(H5F_t *f, H5O_t *oh, size_t size)
static intn
H5O_alloc(H5F_t *f, H5O_t *oh, const H5O_class_t *type, size_t size)
{
- intn chunkno;
- intn idx;
- intn null_idx;
+ intn chunkno;
+ intn idx;
+ intn null_idx;
FUNC_ENTER(H5O_alloc, FAIL);
/* check args */
- assert(oh);
- assert(type);
- H5O_ALIGN(size, oh->alignment);
+ assert (oh);
+ assert (type);
+ assert (size == H5O_ALIGN (size));
/* 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;
+ 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
+ * programmers :-) This isn't a high priority because when an
* object header is read from disk the null messages are combined
* anyway.
*/
@@ -1362,44 +1385,48 @@ H5O_alloc(H5F_t *f, H5O_t *oh, const H5O_class_t *type, size_t size)
/* 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");
- }
- }
+ /*
+ * 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;
+ assert(oh->mesg[idx].raw_size - size >= H5O_SIZEOF_MSGHDR(f));
+
+ 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 +
+ H5O_SIZEOF_MSGHDR(f);
+ oh->mesg[null_idx].raw_size = oh->mesg[idx].raw_size -
+ (size + H5O_SIZEOF_MSGHDR(f));
+ oh->mesg[null_idx].chunkno = oh->mesg[idx].chunkno;
+ oh->mesg[idx].raw_size = size;
}
/* initialize the new message */
oh->mesg[idx].type = type;
@@ -1411,17 +1438,17 @@ H5O_alloc(H5F_t *f, H5O_t *oh, const H5O_class_t *type, size_t size)
}
/*-------------------------------------------------------------------------
- * 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:
*
@@ -1429,14 +1456,14 @@ H5O_alloc(H5F_t *f, H5O_t *oh, const H5O_class_t *type, size_t size)
*/
herr_t
H5O_debug(H5F_t *f, const haddr_t *addr, FILE * stream, intn indent,
- intn fwidth)
+ 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;
+ 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);
@@ -1448,119 +1475,117 @@ H5O_debug(H5F_t *f, const haddr_t *addr, FILE * stream, intn indent,
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");
+ 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));
+ "Dirty:",
+ (int) (oh->dirty));
fprintf(stream, "%*s%-*s %d\n", indent, "", fwidth,
- "Alignment:",
- (int) (oh->alignment));
+ "Version:",
+ (int) (oh->version));
fprintf(stream, "%*s%-*s %d\n", indent, "", fwidth,
- "Number of links:",
- (int) (oh->nlink));
+ "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));
+ "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));
+ "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));
+ for (i=0, 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, "");
- }
+ for (i=0, mesg_total=0; i<oh->nmesgs; i++) {
+ mesg_total += H5O_SIZEOF_MSGHDR(f) + 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");
+ 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");
+ 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 058075d..b3226e2 100644
--- a/src/H5Ocont.c
+++ b/src/H5Ocont.c
@@ -25,26 +25,24 @@
#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,
+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 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;
@@ -76,7 +74,7 @@ H5O_cont_decode(H5F_t *f, size_t raw_size, const uint8 *p)
/* check args */
assert(f);
- assert(raw_size == H5F_SIZEOF_ADDR(f) + H5F_SIZEOF_SIZE(f));
+ assert(raw_size == H5O_ALIGN (H5F_SIZEOF_ADDR(f) + H5F_SIZEOF_SIZE(f)));
assert(p);
/* decode */
@@ -113,7 +111,7 @@ H5O_cont_encode(H5F_t *f, size_t size, uint8 *p, const void *_mesg)
/* check args */
assert(f);
- assert(size == H5F_SIZEOF_ADDR(f) + H5F_SIZEOF_SIZE(f));
+ assert(size == H5O_ALIGN (H5F_SIZEOF_ADDR(f) + H5F_SIZEOF_SIZE(f)));
assert(p);
assert(cont);
diff --git a/src/H5Odtype.c b/src/H5Odtype.c
index 9b3777b..776dd86 100644
--- a/src/H5Odtype.c
+++ b/src/H5Odtype.c
@@ -202,10 +202,11 @@ H5O_dtype_decode_helper(const uint8 **pp, H5T_t *dt)
static herr_t
H5O_dtype_encode_helper(uint8 **pp, const H5T_t *dt)
{
- uintn flags = 0;
- uintn perm_word;
- char *hdr = (char *)*pp;
- intn i, j, n;
+ uintn flags = 0;
+ uintn perm_word;
+ char *hdr = (char *)*pp;
+ intn i, j;
+ size_t n, z;
FUNC_ENTER(H5O_dtype_encode_helper, FAIL);
@@ -336,10 +337,14 @@ H5O_dtype_encode_helper(uint8 **pp, const H5T_t *dt)
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;
+ assert (dt->u.atomic.u.f.epos<=255);
+ *(*pp)++ = (uint8)(dt->u.atomic.u.f.epos);
+ assert (dt->u.atomic.u.f.esize<=255);
+ *(*pp)++ = (uint8)(dt->u.atomic.u.f.esize);
+ assert (dt->u.atomic.u.f.mpos<=255);
+ *(*pp)++ = (uint8)(dt->u.atomic.u.f.mpos);
+ assert (dt->u.atomic.u.f.msize<=255);
+ *(*pp)++ = (uint8)(dt->u.atomic.u.f.msize);
UINT32ENCODE(*pp, dt->u.atomic.u.f.ebias);
break;
@@ -349,10 +354,10 @@ H5O_dtype_encode_helper(uint8 **pp, const H5T_t *dt)
*/
flags = dt->u.compnd.nmembs & 0xffff;
for (i = 0; i < dt->u.compnd.nmembs; i++) {
- HDstrcpy (*pp, dt->u.compnd.memb[i].name);
+ HDstrcpy ((char*)(*pp), dt->u.compnd.memb[i].name);
n = strlen(dt->u.compnd.memb[i].name);
- for (j=n+1; j%8; j++) (*pp)[j] = '\0';
- *pp += j;
+ for (z=n+1; z%8; z++) (*pp)[z] = '\0';
+ *pp += z;
UINT32ENCODE(*pp, dt->u.compnd.memb[i].offset);
*(*pp)++ = dt->u.compnd.memb[i].ndims;
assert(dt->u.compnd.memb[i].ndims <= 4);
@@ -366,7 +371,7 @@ H5O_dtype_encode_helper(uint8 **pp, const H5T_t *dt)
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) {
+ 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");
}
@@ -423,7 +428,7 @@ H5O_dtype_decode(H5F_t *f, size_t raw_size, const uint8 *p)
HRETURN_ERROR(H5E_DATATYPE, H5E_CANTDECODE, NULL,
"can't decode type");
}
- assert(raw_size == H5O_dtype_size(f, (void *) dt));
+ assert(raw_size == H5O_ALIGN (H5O_dtype_size(f, (void *) dt)));
FUNC_LEAVE(dt);
}
@@ -454,7 +459,7 @@ H5O_dtype_encode(H5F_t *f, size_t raw_size, uint8 *p, const void *mesg)
/* check args */
assert(f);
- assert(raw_size == H5O_dtype_size(f, mesg));
+ assert(raw_size == H5O_ALIGN (H5O_dtype_size(f, mesg)));
assert(p);
assert(dt);
@@ -674,22 +679,22 @@ H5O_dtype_debug(H5F_t *f, const void *mesg, FILE * stream,
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),
+ 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),
+ 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),
+ 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),
+ 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 ? ", " : "",
diff --git a/src/H5Oefl.c b/src/H5Oefl.c
index 8f8f0b1..49c6c44 100644
--- a/src/H5Oefl.c
+++ b/src/H5Oefl.c
@@ -13,32 +13,30 @@
#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;
+static hbool_t interface_initialize_g = FALSE;
#define INTERFACE_INIT NULL
/*-------------------------------------------------------------------------
@@ -58,7 +56,7 @@ static hbool_t interface_initialize_g = FALSE;
*
*-------------------------------------------------------------------------
*/
-static void *
+static void *
H5O_efl_decode(H5F_t *f, size_t raw_size, const uint8 *p)
{
H5O_efl_t *mesg = NULL;
@@ -113,7 +111,7 @@ H5O_efl_encode(H5F_t *f, size_t raw_size, uint8 *p, const void *_mesg)
/* check args */
assert(f);
assert(mesg);
- assert(raw_size == H5O_efl_size(f, _mesg));
+ assert(raw_size == H5O_ALIGN (H5O_efl_size(f, _mesg)));
assert(p);
/* encode */
diff --git a/src/H5Olayout.c b/src/H5Olayout.c
index a3d66d6..5972cca 100644
--- a/src/H5Olayout.c
+++ b/src/H5Olayout.c
@@ -14,33 +14,32 @@
#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;
+static hbool_t interface_initialize_g = FALSE;
#define INTERFACE_INIT NULL
+
/*-------------------------------------------------------------------------
* Function: H5O_layout_decode
@@ -75,7 +74,7 @@ H5O_layout_decode(H5F_t *f, size_t raw_size, const uint8 *p)
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));
+ assert(raw_size == H5O_ALIGN (H5O_layout_size(f, mesg)));
/* Layout class */
mesg->type = *p++;
@@ -120,7 +119,7 @@ H5O_layout_encode(H5F_t *f, size_t raw_size, uint8 *p, const void *_mesg)
assert(f);
assert(mesg);
assert(mesg->ndims > 0 && mesg->ndims <= H5O_LAYOUT_NDIMS);
- assert(raw_size == H5O_layout_size(f, _mesg));
+ assert(raw_size == H5O_ALIGN (H5O_layout_size(f, _mesg)));
assert(p);
/* data or B-tree address */
@@ -161,7 +160,7 @@ H5O_layout_encode(H5F_t *f, size_t raw_size, uint8 *p, const void *_mesg)
*
*-------------------------------------------------------------------------
*/
-static void *
+static void *
H5O_layout_copy(const void *_mesg, void *_dest)
{
const H5O_layout_t *mesg = (const H5O_layout_t *) _mesg;
@@ -171,8 +170,7 @@ H5O_layout_copy(const void *_mesg, void *_dest)
/* check args */
assert(mesg);
- if (!dest)
- dest = H5MM_xcalloc(1, sizeof(H5O_layout_t));
+ if (!dest) dest = H5MM_xcalloc(1, sizeof(H5O_layout_t));
/* copy */
*dest = *mesg;
diff --git a/src/H5Oname.c b/src/H5Oname.c
index 51fddc2..c8e6a57 100644
--- a/src/H5Oname.c
+++ b/src/H5Oname.c
@@ -22,33 +22,32 @@
#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;
+static hbool_t interface_initialize_g = FALSE;
#define INTERFACE_INIT NULL
+
/*-------------------------------------------------------------------------
* Function: H5O_name_decode
diff --git a/src/H5Onull.c b/src/H5Onull.c
index 9fdc53c..57cec41 100644
--- a/src/H5Onull.c
+++ b/src/H5Onull.c
@@ -20,16 +20,14 @@
#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 2ad1a0a..0cd671a 100644
--- a/src/H5Oprivate.h
+++ b/src/H5Oprivate.h
@@ -1,14 +1,14 @@
/*-------------------------------------------------------------------------
- * Copyright (C) 1997 National Center for Supercomputing Applications.
- * All rights reserved.
+ * 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:
*
@@ -26,77 +26,94 @@
#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 */
+/*
+ * Align messages on 8-byte boundaries because we would like to copy the
+ * object header chunks directly into memory and operate on them there, even
+ * on 64-bit architectures. This allows us to reduce the number of disk I/O
+ * requests with a minimum amount of mem-to-mem copies.
+ */
+#define H5O_ALIGN(X) (8*(((X)+8-1)/8))
+
+#define H5O_MIN_SIZE H5O_ALIGN(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_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_FLAG_CONSTANT 0x8000
+#define H5O_FLAG_BITS 0x8000
+#define H5O_VERSION 1
+
+/*
+ * Size of object header header.
+ */
+#define H5O_SIZEOF_HDR(F) \
+ H5O_ALIGN(1 + /*version number */ \
+ 1 + /*alignment */ \
+ 2 + /*number of messages */ \
+ 4 + /*reference count */ \
+ 4) /*header data size */
+
+/*
+ * Size of message header
+ */
+#define H5O_SIZEOF_MSGHDR(F) \
+ H5O_ALIGN(2 + /*message type */ \
+ 2 + /*sizeof message data */ \
+ 4) /*reserved */
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 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 */
@@ -104,7 +121,7 @@ extern const H5O_class_t H5O_SDSPACE[1];
/*
* 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 */
@@ -112,66 +129,66 @@ extern const H5O_class_t H5O_DTYPE[1];
/*
* 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 */
+ 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 *_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*/);
@@ -179,11 +196,11 @@ 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);
+ void *mesg);
intn H5O_modify (H5G_entry_t *ent, const H5O_class_t *type, intn overwrite,
- uintn flags, const void *mesg);
+ 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);
+ intn fwidth);
#endif
diff --git a/src/H5Osdspace.c b/src/H5Osdspace.c
index 55c71a8..561eb5a 100644
--- a/src/H5Osdspace.c
+++ b/src/H5Osdspace.c
@@ -25,29 +25,29 @@ static char RcsId[] = "@(#)$Revision$";
#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
/*--------------------------------------------------------------------------
@@ -68,18 +68,18 @@ static hbool_t interface_initialize_g = FALSE;
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 *
+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 */
+ H5P_simple_t *sdim = NULL;/* New simple dimensionality structure */
+ uintn u; /* local counting variable */
uintn flags;
FUNC_ENTER(H5O_sdspace_decode, NULL);
/* check args */
assert(f);
- assert(raw_size >= 8); /* at least the rank and flags must be present */
+ assert(raw_size >= 8); /* at least the rank and flags must be present */
assert(p);
/* decode */
@@ -94,21 +94,21 @@ H5O_sdspace_decode(H5F_t *f, size_t raw_size, const uint8 *p)
sdim->max = H5MM_xmalloc(sizeof(uint32) * sdim->rank);
for (u = 0; u < sdim->rank; u++)
UINT32DECODE(p, sdim->max[u]);
- } /* end if */
+ }
if (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:
#endif /* LATER */
if (sdim == NULL) { /* Error condition cleanup */
- } /* end if */
+ }
/* Normal function cleanup */
FUNC_LEAVE(sdim);
}
@@ -158,12 +158,12 @@ H5O_sdspace_encode(H5F_t *f, size_t raw_size, uint8 *p, const void *mesg)
if (flags & 0x01) {
for (u = 0; u < sdim->rank; u++)
UINT32ENCODE(p, sdim->max[u]);
- } /* end if */
+ }
if (flags & 0x02) {
for (u = 0; u < sdim->rank; u++)
UINT32ENCODE(p, sdim->perm[u]);
- } /* end if */
- } /* end if */
+ }
+ }
FUNC_LEAVE(SUCCEED);
}
diff --git a/src/H5Ostab.c b/src/H5Ostab.c
index e1a5d0a..7600f47 100644
--- a/src/H5Ostab.c
+++ b/src/H5Ostab.c
@@ -23,31 +23,29 @@
#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;
+static hbool_t interface_initialize_g = FALSE;
#define INTERFACE_INIT NULL
/*-------------------------------------------------------------------------
@@ -68,7 +66,7 @@ static hbool_t interface_initialize_g = FALSE;
*
*-------------------------------------------------------------------------
*/
-static void *
+static void *
H5O_stab_decode(H5F_t *f, size_t raw_size, const uint8 *p)
{
H5O_stab_t *stab;
@@ -77,7 +75,7 @@ H5O_stab_decode(H5F_t *f, size_t raw_size, const uint8 *p)
/* check args */
assert(f);
- assert(raw_size == 2 * H5F_SIZEOF_ADDR(f));
+ assert(raw_size == H5O_ALIGN (2 * H5F_SIZEOF_ADDR(f)));
assert(p);
/* decode */
@@ -114,7 +112,7 @@ H5O_stab_encode(H5F_t *f, size_t raw_size, uint8 *p, const void *_mesg)
/* check args */
assert(f);
- assert(raw_size == 2 * H5F_SIZEOF_ADDR(f));
+ assert(raw_size == H5O_ALIGN (2 * H5F_SIZEOF_ADDR(f)));
assert(p);
assert(stab);
@@ -144,7 +142,7 @@ H5O_stab_encode(H5F_t *f, size_t raw_size, uint8 *p, const void *_mesg)
*
*-------------------------------------------------------------------------
*/
-void *
+void *
H5O_stab_fast(const H5G_cache_t *cache, const H5O_class_t *type, void *_mesg)
{
H5O_stab_t *stab = NULL;
@@ -156,10 +154,8 @@ H5O_stab_fast(const H5G_cache_t *cache, const H5O_class_t *type, void *_mesg)
assert(type);
if (H5O_STAB == type) {
- if (_mesg)
- stab = (H5O_stab_t *) _mesg;
- else
- stab = H5MM_xcalloc(1, sizeof(H5O_stab_t));
+ 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;
}
@@ -184,7 +180,7 @@ H5O_stab_fast(const H5G_cache_t *cache, const H5O_class_t *type, void *_mesg)
*
*-------------------------------------------------------------------------
*/
-static void *
+static void *
H5O_stab_copy(const void *_mesg, void *_dest)
{
const H5O_stab_t *stab = (const H5O_stab_t *) _mesg;
diff --git a/src/H5P.c b/src/H5P.c
index f27b137..2d39edf 100644
--- a/src/H5P.c
+++ b/src/H5P.c
@@ -491,7 +491,7 @@ int
H5Pget_ndims(hid_t space_id)
{
H5P_t *ds = NULL;
- size_t ret_value = 0;
+ intn ret_value = 0;
FUNC_ENTER(H5Pget_ndims, FAIL);
@@ -577,7 +577,7 @@ H5Pget_dims(hid_t space_id, size_t dims[]/*out*/)
{
H5P_t *ds = NULL;
- size_t ret_value = 0;
+ intn ret_value = 0;
FUNC_ENTER(H5Pget_dims, FAIL);
@@ -1020,7 +1020,7 @@ herr_t
H5Pset_hyperslab(hid_t sid, const int *start, const size_t *count, const size_t *stride)
{
H5P_t *space = NULL; /* dataspace to modify */
- intn *tmp_stride=NULL; /* temp. copy of stride */
+ size_t *tmp_stride=NULL; /* temp. copy of stride */
intn u; /* local counting variable */
herr_t ret_value = SUCCEED;
@@ -1039,39 +1039,38 @@ H5Pset_hyperslab(hid_t sid, const int *start, const size_t *count, const size_t
"unknown dataspace type");
/* Set up stride values for later use */
- tmp_stride= H5MM_xmalloc(space->u.simple.rank*sizeof(intn));
+ tmp_stride= H5MM_xmalloc(space->u.simple.rank*sizeof(tmp_stride[0]));
for (u=0; u<space->u.simple.rank; u++) {
tmp_stride[u] = stride ? stride[u] : 1;
}
/* Range check arguments */
for (u=0; u<space->u.simple.rank; u++) {
- if (start[u]<0 || start[u]>=space->u.simple.size[u])
+ if (start[u]<0 || start[u]>=space->u.simple.size[u]) {
HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL,
"hyperslab bounds out of range");
- if (start[u]+(SIGN(count[u])*(ABS(count[u])-1)*tmp_stride[u])<0 ||
- (start[u]+(SIGN(count[u])*(ABS(count[u])-1)*tmp_stride[u])>=
- space->u.simple.size[u]))
+ }
+ if (start[u]<0 ||
+ start[u]+(count[u]*tmp_stride[u])>space->u.simple.size[u]) {
HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL,
"hyperslab bounds out of range");
- } /* end for */
+ }
+ }
/* Allocate space for the hyperslab information */
if (NULL==space->h.start) {
- space->h.start= H5MM_xcalloc(space->u.simple.rank,sizeof(size_t));
+ space->h.start= H5MM_xcalloc(space->u.simple.rank,sizeof(intn));
space->h.count= H5MM_xcalloc(space->u.simple.rank,sizeof(size_t));
space->h.stride= H5MM_xcalloc(space->u.simple.rank,sizeof(size_t));
}
/* Build hyperslab */
- for(u=0; u<space->u.simple.rank; u++)
- {
- /* copy "normalized" (i.e. strictly increasing) values for hyperslab parameters */
- space->h.start[u]=MIN(start[u],start[u]+((ABS(count[u])-1)*tmp_stride[u]));
- space->h.count[u]=ABS(count[u]);
- space->h.stride[u]=ABS(tmp_stride[u]);
- } /* end for */
- space->hslab_def=TRUE;
+ for(u=0; u<space->u.simple.rank; u++) {
+ space->h.start[u] = start[u];
+ space->h.count[u] = count[u];
+ space->h.stride[u] = tmp_stride[u];
+ }
+ space->hslab_def=TRUE;
done:
if (ret_value == FAIL) { /* Error condition cleanup */
diff --git a/src/H5Pprivate.h b/src/H5Pprivate.h
index d91dfc4..0ac73b3 100644
--- a/src/H5Pprivate.h
+++ b/src/H5Pprivate.h
@@ -30,7 +30,7 @@
#define H5P_VALID_PERM 0x02
typedef struct H5P_hyperslab_t {
- size_t *start; /* Location of start of hyperslab */
+ intn *start; /* Location of start of hyperslab */
size_t *count; /* Number of elements in hyperslab */
size_t *stride; /* Packing of values of hyperslab */
} H5P_hyperslab_t;
diff --git a/src/H5T.c b/src/H5T.c
index 4506569..49a0019 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -1894,7 +1894,7 @@ 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 */ )
+ size_t dims[]/*out*/, int perm[]/*out*/)
{
H5T_t *dt = NULL;
intn ndims, i;
@@ -3312,12 +3312,13 @@ H5T_debug(H5T_t *dt, FILE * stream)
(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);
+ size_t hi = tmp;
+ size_t lo = dt->u.atomic.u.f.ebias & 0xffffffff;
+ fprintf(stream, " bias=0x%08lx%08lx",
+ (unsigned long)hi, (unsigned long)lo);
} else {
- uintn lo = dt->u.atomic.u.f.ebias & 0xffffffff;
- fprintf(stream, " bias=0x%08x", lo);
+ size_t lo = dt->u.atomic.u.f.ebias & 0xffffffff;
+ fprintf(stream, " bias=0x%08lx", (unsigned long)lo);
}
break;
diff --git a/src/H5Tconv.c b/src/H5Tconv.c
index 0368fcb..5ef27ed 100644
--- a/src/H5Tconv.c
+++ b/src/H5Tconv.c
@@ -100,11 +100,11 @@ herr_t
H5T_conv_order(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
void *_buf, void *background)
{
- uint8 *buf = (uint8 *) _buf;
- uint8 tmp;
- H5T_t *src = NULL;
- H5T_t *dst = NULL;
- intn i, j, md;
+ uint8 *buf = (uint8 *) _buf;
+ uint8 tmp;
+ H5T_t *src = NULL;
+ H5T_t *dst = NULL;
+ size_t i, j, md;
FUNC_ENTER(H5T_conv_order, FAIL);
@@ -161,11 +161,11 @@ H5T_conv_order(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts,
HRETURN_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data type");
}
md = src->size / 2;
- for (i = 0; i < nelmts; i++, buf += src->size) {
- for (j = 0; j < md; j++) {
+ 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;
+ buf[j] = buf[src->size-(j+1)];
+ buf[src->size-(j+1)] = tmp;
}
}
break;
diff --git a/src/H5Tpkg.h b/src/H5Tpkg.h
index f1679bb..7484c92 100644
--- a/src/H5Tpkg.h
+++ b/src/H5Tpkg.h
@@ -75,7 +75,7 @@ typedef struct H5T_member_t {
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 */
+ intn perm[4]; /*index permutation */
struct H5T_t type; /*type of this member */
} H5T_member_t;
diff --git a/src/H5Tpublic.h b/src/H5Tpublic.h
index 1515206..665295a 100644
--- a/src/H5Tpublic.h
+++ b/src/H5Tpublic.h
@@ -209,7 +209,7 @@ 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 H5Tget_member_dims (hid_t type_id, int membno, size_t 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);
diff --git a/src/H5V.c b/src/H5V.c
index 6b092a5..41ed33a 100644
--- a/src/H5V.c
+++ b/src/H5V.c
@@ -49,7 +49,7 @@ H5V_stride_optimize1(intn *np, size_t *elmt_size, size_t *size,
* 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));
+ assert(1 == H5V_vector_reduce_product(0, NULL));
/*
* Combine adjacent memory accesses
@@ -96,7 +96,7 @@ H5V_stride_optimize2(intn *np, size_t *elmt_size, size_t *size,
* 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));
+ assert(1 == H5V_vector_reduce_product(0, NULL));
/*
* Combine adjacent memory accesses
@@ -164,7 +164,9 @@ H5V_hyper_stride(intn n, const size_t *size,
/* others */
for (i = n - 2, acc = 1; i >= 0; --i) {
- stride[i] = acc * (total_size[i + 1] - size[i + 1]);
+ size_t tmp = acc * (total_size[i+1] - size[i+1]);
+ assert (tmp<((size_t)1<<(8*sizeof(intn)-1)));
+ stride[i] = (intn)tmp;
acc *= total_size[i + 1];
skip += acc * (offset ? offset[i] : 0);
}
diff --git a/src/H5Vprivate.h b/src/H5Vprivate.h
index 870b415..f0cda44 100644
--- a/src/H5Vprivate.h
+++ b/src/H5Vprivate.h
@@ -81,10 +81,8 @@ H5V_vector_reduce_product(size_t n, const size_t *v)
{
size_t ans = 1;
- if (n && !v)
- return 0;
- while (n--)
- ans *= *v++;
+ if (n && !v) return 0;
+ while (n--) ans *= *v++;
return ans;
}
diff --git a/src/H5detect.c b/src/H5detect.c
index 242613d..b8e6fb9 100644
--- a/src/H5detect.c
+++ b/src/H5detect.c
@@ -51,25 +51,26 @@ 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;
+ unsigned long 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 unsigned long find_bias(int, int, int, int *, void *);
+static void print_header(void);
/*-------------------------------------------------------------------------
* For convenience, we place here in a table descriptions of all
@@ -327,7 +328,7 @@ H5T_init (void)\n\
dt->u.atomic.u.f.sign = %d;\n\
dt->u.atomic.u.f.epos = %d;\n\
dt->u.atomic.u.f.esize = %d;\n\
- dt->u.atomic.u.f.ebias = 0x%08x;\n\
+ dt->u.atomic.u.f.ebias = 0x%08lx;\n\
dt->u.atomic.u.f.mpos = %d;\n\
dt->u.atomic.u.f.msize = %d;\n\
dt->u.atomic.u.f.norm = H5T_NORM_%s;\n\
@@ -335,7 +336,7 @@ H5T_init (void)\n\
d[i].sign, /*sign location */
d[i].epos, /*exponent loc */
d[i].esize, /*exponent size */
- d[i].bias, /*exponent bias */
+ (unsigned long)(d[i].bias), /*exponent bias */
d[i].mpos, /*mantissa loc */
d[i].msize, /*mantissa size */
d[i].imp ? "IMPLIED" : "NONE"); /*normalization */
@@ -768,7 +769,7 @@ imp_bit(int n, int *perm, void *_a, void *_b)
*
*-------------------------------------------------------------------------
*/
-static int
+static unsigned long
find_bias(int epos, int esize, int imp, int *perm, void *_a)
{
@@ -809,18 +810,19 @@ 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[] =
+ 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;
+ size_t 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 = "\
+ 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\
@@ -971,5 +973,5 @@ main(int argc, char *argv[])
nd++;
print_results(nd, d);
- exit(0);
+ return 0;
}
diff --git a/src/H5private.h b/src/H5private.h
index a2d5d49..850a2e1 100644
--- a/src/H5private.h
+++ b/src/H5private.h
@@ -473,8 +473,8 @@ extern hbool_t thread_initialize_g; /*don't decl interface_initialize_g */
} \
\
/* Clear thread error stack entering public functions */ \
- if (H5E_clearable_g && '_'!=#func_name[2] && '_'!=#func_name[3] && \
- (!#func_name[4] || '_'!=#func_name[4])) { \
+ if (H5E_clearable_g && '_'!=FUNC[2] && '_'!=FUNC[3] && \
+ (!FUNC[4] || '_'!=FUNC[4])) { \
PRINT (55, #func_name); \
H5Eclear (H5E_thrdid_g); \
} \
diff --git a/src/debug.c b/src/debug.c
index 1dbcb17..b5ea511 100644
--- a/src/debug.c
+++ b/src/debug.c
@@ -121,7 +121,7 @@ main(int argc, char *argv[])
HDexit(4);
}
- } else if (sig[0] == H5O_VERSION && sig[1] == H5O_ALIGNMENT) {
+ } else if (sig[0] == H5O_VERSION) {
/*
* This could be an object header. Since they don't have a signature
* it's a somewhat "ify" detection.
@@ -154,5 +154,5 @@ main(int argc, char *argv[])
HDexit(5);
}
H5Fclose(fid);
- HDexit(0);
+ return 0;
}
diff --git a/test/cmpd_dset.c b/test/cmpd_dset.c
index c8afe38..f146bf2 100644
--- a/test/cmpd_dset.c
+++ b/test/cmpd_dset.c
@@ -567,5 +567,5 @@ STEP 11: Write an array back to the middle third of the dataset to\n\
H5Dclose (dataset);
H5Fclose (file);
- exit (0);
+ return 0;
}
diff --git a/test/dsets.c b/test/dsets.c
index 783ace3..937160f 100644
--- a/test/dsets.c
+++ b/test/dsets.c
@@ -17,6 +17,7 @@
#ifndef HAVE_FUNCTION
+#undef __FUNCTION__
#define __FUNCTION__ ""
#endif
#define AT() printf (" at %s:%d in %s()...\n", \
@@ -398,5 +399,5 @@ main(void)
status = H5close ();
assert (status>=0);
- exit(0);
+ return 0;
}
diff --git a/test/dtypes.c b/test/dtypes.c
index 707fe29..da0076a 100644
--- a/test/dtypes.c
+++ b/test/dtypes.c
@@ -15,6 +15,7 @@
#include <H5Tprivate.h>
#ifndef HAVE_FUNCTION
+#undef __FUNCTION__
#define __FUNCTION__ ""
#endif
#define AT() printf (" at %s:%d in %s()...\n", \
@@ -44,11 +45,9 @@ typedef struct complex_t {
static herr_t
test_classes(void)
{
- H5T_class_t type_class;
-
printf("%-70s", "Testing H5Tget_class()");
- if (H5T_INTEGER != (type_class = H5Tget_class(H5T_NATIVE_INT))) {
+ if (H5T_INTEGER != H5Tget_class(H5T_NATIVE_INT)) {
puts("*FAILED*");
if (!isatty(1)) {
AT();
@@ -56,7 +55,7 @@ test_classes(void)
}
goto error;
}
- if (H5T_FLOAT != (type_class = H5Tget_class(H5T_NATIVE_DOUBLE))) {
+ if (H5T_FLOAT != H5Tget_class(H5T_NATIVE_DOUBLE)) {
puts("*FAILED*");
if (!isatty(1)) {
AT();
@@ -234,5 +233,5 @@ main(void)
exit(1);
}
printf("All data type tests passed.\n");
- exit(0);
+ return 0;
}
diff --git a/test/extend.c b/test/extend.c
index b5f2ecc..7f899ee 100644
--- a/test/extend.c
+++ b/test/extend.c
@@ -124,7 +124,7 @@ main (void)
H5Dclose (dataset);
H5Fclose (file);
- exit (0);
+ return 0;
}
diff --git a/test/hyperslab.c b/test/hyperslab.c
index 82f78c4..2cc7660 100644
--- a/test/hyperslab.c
+++ b/test/hyperslab.c
@@ -16,6 +16,7 @@
#include <H5Vprivate.h>
#ifndef HAVE_FUNCTION
+#undef __FUNCTION__
#define __FUNCTION__ ""
#endif
#define AT() printf (" at %s:%d in %s()\n",__FILE__,__LINE__,__FUNCTION__);
@@ -147,16 +148,17 @@ test_fill(size_t nx, size_t ny, size_t nz,
size_t di, size_t dj, size_t dk,
size_t ddx, size_t ddy, size_t ddz)
{
- uint8 *dst = NULL; /*destination array */
- size_t hs_size[3]; /*hyperslab size */
- size_t dst_size[3]; /*destination total size */
- size_t dst_offset[3]; /*offset of hyperslab in dest */
- uintn ref_value; /*reference value */
- uintn acc; /*accumulator */
- int i, j, k, dx, dy, dz, u, v, w; /*counters */
- int ndims; /*hyperslab dimensionality */
- char dim[64], s[256]; /*temp string */
- uintn fill_value; /*fill value */
+ uint8 *dst = NULL; /*destination array */
+ size_t hs_size[3]; /*hyperslab size */
+ size_t dst_size[3]; /*destination total size */
+ size_t dst_offset[3]; /*offset of hyperslab in dest */
+ uintn ref_value; /*reference value */
+ uintn acc; /*accumulator */
+ int i, j, k, dx, dy, dz; /*counters */
+ size_t u, v, w;
+ int ndims; /*hyperslab dimensionality */
+ char dim[64], s[256]; /*temp string */
+ uintn fill_value; /*fill value */
/*
* Dimensionality.
@@ -311,7 +313,8 @@ test_copy(int mode,
size_t src_offset[3]; /*offset of hyperslab in source */
uintn ref_value; /*reference value */
uintn acc; /*accumulator */
- int i, j, k, dx, dy, dz, u, v, w; /*counters */
+ int i, j, k, dx, dy, dz; /*counters */
+ size_t u, v, w;
int ndims; /*hyperslab dimensionality */
char dim[64], s[256]; /*temp string */
const char *sub;
@@ -761,7 +764,7 @@ test_transpose(size_t nx, size_t ny)
src = H5MM_xmalloc(nx * ny * sizeof(*src));
for (i = 0; i < nx; i++) {
for (j = 0; j < ny; j++) {
- src[i * ny + j] = i * ny + j;
+ src[i * ny + j] = (intn)(i * ny + j);
}
}
dst = H5MM_xcalloc(nx * ny, sizeof(*dst));
@@ -771,8 +774,8 @@ test_transpose(size_t nx, size_t ny)
size[1] = ny;
src_stride[0] = 0;
src_stride[1] = sizeof(*src);
- dst_stride[0] = (1 - nx * ny) * sizeof(*src);
- dst_stride[1] = nx * sizeof(*src);
+ dst_stride[0] = (intn)((1 - nx * ny) * sizeof(*src));
+ dst_stride[1] = (intn)(nx * sizeof(*src));
/* Copy and transpose */
if (nx == ny) {
@@ -872,7 +875,7 @@ test_sub_super(size_t nx, size_t ny)
/* Setup */
size[0] = nx;
size[1] = ny;
- src_stride[0] = 2 * ny;
+ src_stride[0] = (intn)(2 * ny);
src_stride[1] = 2;
dst_stride[0] = 0;
dst_stride[1] = 1;
@@ -919,9 +922,9 @@ test_sub_super(size_t nx, size_t ny)
src_stride[1] = 1;
src_stride[2] = 0;
src_stride[3] = 0;
- dst_stride[0] = 2 * ny;
- dst_stride[1] = 2 * sizeof(uint8) - 4 * ny;
- dst_stride[2] = 2 * ny - 2 * sizeof(uint8);
+ dst_stride[0] = (intn)(2 * ny);
+ dst_stride[1] = (intn)(2 * sizeof(uint8) - 4 * ny);
+ dst_stride[2] = (intn)(2 * ny - 2 * sizeof(uint8));
dst_stride[3] = sizeof(uint8);
/* Copy */
@@ -1161,5 +1164,5 @@ main(int argc, char *argv[])
exit(1);
}
printf("All hyperslab tests passed.\n");
- exit(0);
+ return 0;
}
diff --git a/test/istore.c b/test/istore.c
index aef85a4..4aca884 100644
--- a/test/istore.c
+++ b/test/istore.c
@@ -33,6 +33,7 @@
#define TEST_LARGE 0x0004
#ifndef HAVE_FUNCTION
+#undef __FUNCTION__
#define __FUNCTION__ ""
#endif
#define AT() printf (" at %s:%d in %s()...\n", \
@@ -99,7 +100,7 @@ print_array(uint8 *array, size_t nx, size_t ny, size_t nz)
*-------------------------------------------------------------------------
*/
static int
-new_object(H5F_t *f, const char *name, size_t ndims, H5G_entry_t *ent/*out*/)
+new_object(H5F_t *f, const char *name, intn ndims, H5G_entry_t *ent/*out*/)
{
H5O_layout_t layout;
intn i;
@@ -659,5 +660,5 @@ main(int argc, char *argv[])
exit(1);
}
printf("All i-store tests passed.\n");
- exit(0);
+ return 0;
}
diff --git a/test/testhdf5.c b/test/testhdf5.c
index cf713f9..b122606 100644
--- a/test/testhdf5.c
+++ b/test/testhdf5.c
@@ -192,8 +192,10 @@ main(int argc, char *argv[])
CleanUp = 0;
if ((argc > CLLoop) && ((HDstrcmp(argv[CLLoop], "-nocache") == 0) ||
- (HDstrcmp(argv[CLLoop], "-n") == 0)))
+ (HDstrcmp(argv[CLLoop], "-n") == 0))) {
Cache = 0;
+ printf ("Cache = %d\n", Cache);
+ }
if ((argc > CLLoop + 1) && ((HDstrcmp(argv[CLLoop], "-exclude") == 0) ||
(HDstrcmp(argv[CLLoop], "-x") == 0))) {
diff --git a/test/th5p.c b/test/th5p.c
index e969219..af9100a 100644
--- a/test/th5p.c
+++ b/test/th5p.c
@@ -63,7 +63,7 @@ test_h5p_basic(void)
{SPACE1_DIM1, SPACE1_DIM2, SPACE1_DIM3}, /* dataspace dim sizes */
dims2[] =
{SPACE2_DIM1, SPACE2_DIM2, SPACE2_DIM3, SPACE2_DIM4}, tdims[4]; /* Dimension array to test with */
- uintn n; /* number of dataspace elements */
+ size_t n; /* number of dataspace elements */
herr_t ret; /* Generic return value */
/* Output message about test being performed */
diff --git a/test/theap.c b/test/theap.c
index ad0ee75..cad0c3b 100644
--- a/test/theap.c
+++ b/test/theap.c
@@ -72,7 +72,7 @@ test_heap(void)
buf[j] = '\0';
obj[i] = H5H_insert(f, &heap_addr, strlen(buf) + 1, buf);
- CHECK_I(obj[i], "H5H_insert");
+ assert ((size_t)(-1)!=obj[i]);
}
/* Flush the cache and invalidate everything */