summaryrefslogtreecommitdiffstats
path: root/src/H5HG.c
diff options
context:
space:
mode:
authorRobb Matzke <matzke@llnl.gov>1999-02-15 17:38:04 (GMT)
committerRobb Matzke <matzke@llnl.gov>1999-02-15 17:38:04 (GMT)
commitc22bac0d207abbdd81123c35681f0558f75de488 (patch)
tree98db51d9303724a07f13558a7490881e89c6e6ad /src/H5HG.c
parentf6272d42929093a81aa2da79f150333793de49e0 (diff)
downloadhdf5-c22bac0d207abbdd81123c35681f0558f75de488.zip
hdf5-c22bac0d207abbdd81123c35681f0558f75de488.tar.gz
hdf5-c22bac0d207abbdd81123c35681f0558f75de488.tar.bz2
[svn-r1065] Changes since 19990121
---------------------- ./configure.in ./acconfig.h ./configure [REGENERATED] ./src/H5config.h.in [REGENERATED] ./src/H5public.h ./src/H5Omtime.c Check for <stddef.h> Checks for `__tm_gmtoff' in `struct tm' because old versions of GNU libc are different than recent versions. This fixes the failing mtime test. ./bin/config.guess ./config/freebsd2.2.7 [REMOVED] ./config/freebsd [ADDED] Changed the name so it works with all versions of FreeBSD. ./src/H5.c Moved H5F after H5T and H5G in H5_term_library() to satisfy dependencies. ./src/H5G.c Fixed a bug that caused H5Gcreate() to fail if the group name had trailing slashes. ./src/H5Gpublic.h Changed `group_name' to `name' in a prototype. ./src/Makefile.in Dynamic library on Linux, but needs for work to be generally useful. ./src/H5HG.c ./src/H5HGprivate.h Fixed alignment problems when using old GCC compilers (like the one shipped with RedHad Linux). ./tools/h5ls.c Fixed a bug where the contents of the root group could be listed twice if there was a link back to the root group. Similarly for groups that are mentioned on the command line. Fixed a bug where unknown types were printed with a random type class number. ./src/H5T.c ./src/H5Tconv.c ./src/H5Tprivate.h Fixed O(log N) conversion bugs.
Diffstat (limited to 'src/H5HG.c')
-rw-r--r--src/H5HG.c28
1 files changed, 22 insertions, 6 deletions
diff --git a/src/H5HG.c b/src/H5HG.c
index e046fe6..e6cdf66 100644
--- a/src/H5HG.c
+++ b/src/H5HG.c
@@ -96,6 +96,7 @@ H5HG_create (H5F_t *f, size_t size)
H5HG_heap_t *ret_value = NULL;
uint8_t *p = NULL;
haddr_t addr;
+ size_t n;
FUNC_ENTER (H5HG_create, NULL);
@@ -135,8 +136,18 @@ H5HG_create (H5F_t *f, size_t size)
*p++ = 0; /*reserved*/
H5F_encode_length (f, p, size);
+ /*
+ * Padding so free space object is aligned. If malloc returned memory
+ * which was always at least H5HG_ALIGNMENT aligned then we could just
+ * align the pointer, but this might not be the case.
+ */
+ n = H5HG_ALIGN(p-heap->chunk) - (p-heap->chunk);
+ memset(p, 0, n);
+ p += n;
+
/* The freespace object */
heap->obj[0].size = size - H5HG_SIZEOF_HDR(f);
+ assert(H5HG_ISALIGNED(heap->obj[0].size));
heap->obj[0].begin = p;
UINT16ENCODE(p, 0); /*object ID*/
UINT16ENCODE(p, 0); /*reference count*/
@@ -301,7 +312,7 @@ H5HG_load (H5F_t *f, const haddr_t *addr, const void __unused__ *udata1,
* size is never padded and already includes the object header.
*/
if (idx>0) {
- need = H5HG_ALIGN(H5HG_SIZEOF_OBJHDR(f) + heap->obj[idx].size);
+ need = H5HG_SIZEOF_OBJHDR(f) + H5HG_ALIGN(heap->obj[idx].size);
} else {
need = heap->obj[idx].size;
}
@@ -309,7 +320,7 @@ H5HG_load (H5F_t *f, const haddr_t *addr, const void __unused__ *udata1,
}
}
assert(p==heap->chunk+heap->size);
- assert(heap->obj[0].size==H5HG_ALIGN(heap->obj[0].size));
+ assert(H5HG_ISALIGNED(heap->obj[0].size));
/*
* Add the new heap to the CWFS list, removing some other entry if
@@ -434,7 +445,7 @@ H5HG_alloc (H5F_t *f, H5HG_heap_t *heap, int cwfsno, size_t size)
{
int idx;
uint8_t *p = NULL;
- size_t need = H5HG_ALIGN(H5HG_SIZEOF_OBJHDR(f) + size);
+ size_t need = H5HG_SIZEOF_OBJHDR(f) + H5HG_ALIGN(size);
FUNC_ENTER (H5HG_alloc, FAIL);
@@ -487,6 +498,7 @@ H5HG_alloc (H5F_t *f, H5HG_heap_t *heap, int cwfsno, size_t size)
UINT16ENCODE(p, 0); /*nrefs*/
UINT32ENCODE(p, 0); /*reserved*/
H5F_encode_length (f, p, heap->obj[0].size);
+ assert(H5HG_ISALIGNED(heap->obj[0].size));
} else {
/*
@@ -495,6 +507,7 @@ H5HG_alloc (H5F_t *f, H5HG_heap_t *heap, int cwfsno, size_t size)
*/
heap->obj[0].size -= need;
heap->obj[0].begin += need;
+ assert(H5HG_ISALIGNED(heap->obj[0].size));
}
heap->dirty = 1;
@@ -546,7 +559,7 @@ H5HG_insert (H5F_t *f, size_t size, void *obj, H5HG_t *hobj/*out*/)
}
/* Find a large enough collection on the CWFS list */
- need = H5HG_ALIGN(size + H5HG_SIZEOF_OBJHDR(f));
+ need = H5HG_SIZEOF_OBJHDR(f) + H5HG_ALIGN(size);
for (cwfsno=0; cwfsno<f->shared->ncwfs; cwfsno++) {
if (f->shared->cwfs[cwfsno]->obj[0].size>=need) {
/*
@@ -819,8 +832,11 @@ H5HG_remove (H5F_t *f, H5HG_t *hobj)
assert (hobj->idx>0 && hobj->idx<heap->nalloc);
assert (heap->obj[hobj->idx].begin);
obj_start = heap->obj[hobj->idx].begin;
- need = H5HG_ALIGN(heap->obj[hobj->idx].size);
-
+ need = H5HG_ALIGN(heap->obj[hobj->idx].size); /*
+ * should this include the
+ * object header size? -rpm
+ */
+
/* Move the new free space to the end of the heap */
for (i=0; i<heap->nalloc; i++) {
if (heap->obj[i].begin > heap->obj[hobj->idx].begin) {