if ( writeBuffer == null || spaceRequired > writeBuffer.remaining() )
{
// Too big. Have flushed buffering if buffering.
inAllocWrite = true ;
ByteBuffer bb = ByteBuffer.allocate(bytesSpace) ;
allocBlock = new Block(filesize, bb) ;
allocLocation = -1 ;
//log.info("AW:"+state()+"-> ----") ;
return allocBlock ;
}
// Will fit.
inAllocWrite = true ;
int start = writeBuffer.position() ;
// Old values for restoration
oldBufferPosn = start ;
oldBufferLimit = writeBuffer.limit() ;
// id (but don't tell the caller yet).
allocLocation = filesize+start ;
// Slice it.
writeBuffer.putInt(bytesSpace) ;
writeBuffer.position(start + SizeOfInt) ;
writeBuffer.limit(start+spaceRequired) ;
ByteBuffer bb = writeBuffer.slice() ;
allocBlock = new Block(allocLocation, bb) ;
if ( logging )
log("AW: %s->0x%X", state(), allocLocation) ;
return allocBlock ;
}