if (vrecord != null) {
// calculate new size needed
int total = INT_SIZE + packetSize
+ INT_SIZE + (iids.length * ENTRY_SIZE);
VRFileRAF vrfile = parent.getVRFile();
synchronized (vrfile) {
if (vrecord.getDataCapacity() < total) {
vrecord.rewind();
byte data[] = new byte[INT_SIZE+packetSize];
vrecord.read(data);
// the existing one is not big enough; get another one
VRecordRAF newrecord = (VRecordRAF)vrfile.allocate(total);
// copy message
newrecord.write(data);
// free old
vrfile.free(vrecord);
// cache new
vrecord = newrecord;
}