h = FORWARDED_ADDR(h, hhdr);
hhdr = HDR(h);
}
- }
- if (IS_FORWARDING_ADDR_OR_NIL(hhdr)) {
+ } else if (IS_FORWARDING_ADDR_OR_NIL(hhdr)) {
goto fail;
}
sz = hhdr -> hb_sz;
offset = pdispl % sz;
if ((sz > MAXOBJBYTES && (word)p >= (word)h + sz)
|| !GC_valid_offsets[offset]
- || (word)p - offset + sz > (word)(h + 1)) {
+ || ((word)p + (sz - offset) > (word)(h + 1)
+ && !IS_FORWARDING_ADDR_OR_NIL(HDR(h + 1)))) {
goto fail;
}
return(p);
} else {
/* p points to the heap. */
word descr;
- ptr_t base = (ptr_t)GC_base(p); /* Should be manually inlined? */
+ ptr_t base = (ptr_t)GC_base(p);
+ /* TODO: should GC_base be manually inlined? */
- if (base == 0) goto fail;
- if (HBLKPTR(base) != HBLKPTR(p)) hhdr = HDR((word)p);
+ if (NULL == base) goto fail;
+ if (HBLKPTR(base) != HBLKPTR(p))
+ hhdr = HDR(base);
descr = hhdr -> hb_descr;
retry:
switch(descr & GC_DS_TAGS) {