while(t.status!=REGION_VACANT||t.size<pageCount){// XXX This while loop and the boundary tag manipulation below should be factored into two submodules.
intnextPage=p->id+t.size;
releasePage(p);
p=loadPage(nextPage);
t=boundary_tag_ptr(p);
}
t->status=REGION_ZONED;
t->region_xid=xid;
t->allocation_manager=allocationManager;
if(t->size!=pageCount){
// need to split region
if(t.size!=INT_MAX){
// allocate new boundary tag.
intnewRegionSize=t->size-pageCount-1;// pageCount must be strictly less than t->size, so this is safe.
Page*new_tag=loadPage(p->id+pageCount+1);
boundaryTagInit(p);
boundary_tag_ptr(p)->size=newRegionSize;
boundary_tag_ptr(p)->prev_size=pageCount;
boundary_tag_ptr(p)->status=REGION_EPHEMERAL;// region disappears if transaction aborts; is VACANT if it succeeds. GET RID OF EPHEMERAL; just make it vacant, and merge on abort.