code: func (ms *FileMsgStore) processBufferedMsgs(fslice *fileSlice) error {
  	idxBufferSize := len(ms.bufferedMsgs) * msgIndexRecSize
  	ms.tmpMsgBuf = util.EnsureBufBigEnough(ms.tmpMsgBuf, idxBufferSize)
  	bufOffset := 0
  	for _, pseq := range ms.bufferedSeqs {
  		bm := ms.bufferedMsgs[pseq]
  		if bm != nil {
  			mindex := bm.index
  			// We add the index info for this flushed message
  			ms.addIndex(ms.tmpMsgBuf[bufOffset:], pseq, mindex.offset,
  				mindex.timestamp, int(mindex.msgSize))
  			bufOffset += msgIndexRecSize
  			delete(ms.bufferedMsgs, pseq)
  		}
  	}
  	if bufOffset > 0 {
  		if _, err := fslice.idxFile.handle.Write(ms.tmpMsgBuf[:bufOffset]); err != nil {
  			return err
  		}
  	}
  	ms.bufferedSeqs = ms.bufferedSeqs[:0]
  	return nil
  }
docs: // processBufferedMsgs adds message index records in the given buffer
  // for every pending buffered messages.