private void addBytesToTrackSequential(int addr, int length) {
   if (length > 0) {
     mem.memcpy(bufBytes.bufferAddr + bufBytes.writeOffset, addr, length);
     bufBytes.writeOffset += length;
     bufBytes.sizeAvailableForRead += length;
   }
 }
  public void addBytesToTrack(int addr, int length) {
    int length1 = Math.min(length, bufBytes.totalSize - bufBytes.writeOffset);
    addBytesToTrackSequential(addr, length1);

    int length2 = length - length1;
    if (length2 > 0) {
      bufBytes.writeOffset = 0;
      addBytesToTrackSequential(addr + length1, length2);
    }
  }