[svn-r2583] Purpose:

Bug Fix.
Description:
    An assertion in the local heap code was mistakenly checking against too
    large of a value for the size of new local heap created.  When used with
    larger-sized (>10KB) variable-length objects, it was failing the check.
Solution:
    Corrected to check against the actual size of the heap allocated, without
    the heap header.
Platforms tested:
    FreeBSD 4.1
This commit is contained in:
Quincey Koziol 2000-09-20 14:26:18 -05:00
parent 53513a5ad2
commit 88f539bf15

View File

@ -117,6 +117,9 @@ H5HG_create (H5F_t *f, size_t size)
assert (f);
if (size<H5HG_MINSIZE) size = H5HG_MINSIZE;
size = H5HG_ALIGN(size);
#ifdef QAK
printf("%s: size=%d\n",FUNC,(int)size);
#endif /* QAK */
/* Create it */
if (HADDR_UNDEF==(addr=H5MF_alloc(f, H5FD_MEM_GHEAP, (hsize_t)size))) {
@ -160,6 +163,9 @@ H5HG_create (H5F_t *f, size_t size)
/* The freespace object */
heap->obj[0].size = size - H5HG_SIZEOF_HDR(f);
#ifdef QAK
printf("%s: heap->obj[0].size=%d, size=%d\n",FUNC,(int)heap->obj[0].size,(int)size);
#endif /* QAK */
assert(H5HG_ISALIGNED(heap->obj[0].size));
heap->obj[0].begin = p;
UINT16ENCODE(p, 0); /*object ID*/
@ -601,7 +607,14 @@ H5HG_insert (H5F_t *f, size_t size, void *obj, H5HG_t *hobj/*out*/)
}
assert (f->shared->ncwfs>0);
assert (f->shared->cwfs[0]==heap);
#ifdef QAK
printf("%s: f->shared->cwfs[0]->obj[0].size=%d, size=%d, need=%d, H5HG_SIZEOF_HDR(f)=%d\n",FUNC,(int)f->shared->cwfs[0]->obj[0].size,(int)size,(int)need,(int)H5HG_SIZEOF_HDR(f));
#endif /* QAK */
#ifdef OLD_WAY
assert (f->shared->cwfs[0]->obj[0].size >= need+H5HG_SIZEOF_HDR(f));
#else /* OLD_WAY */
assert (f->shared->cwfs[0]->obj[0].size >= need);
#endif /* OLD_WAY */
cwfsno = 0;
}