private void updateBufferMap() throws IOException {

		int maxOffset = bufferSize - BUFFER_MAP_ENTRY_SIZE;
		
		// Save new map entries
		int cnt = newMapIds.size();
		for (int i = 0; i < cnt; i++) {
			
			int origIndex = newMapIds.get(i);
			int verIndex;
			try {
				verIndex = bufferIndexMap.get(origIndex);
			} catch (NoValueException e) {
				throw new AssertException();
			}

			if (nextMapEntryOffset > maxOffset) {
				int nextIndex = vfIndexProvider.allocateIndex();
				lastMapBuffer.putInt(NEXT_BUFFER_INDEX_OFFSET, nextIndex);
				versionFile.put(lastMapBuffer, lastMapIndex);

				nextMapEntryOffset = FIRST_ENTRY_OFFSET;
				lastMapIndex = nextIndex;
				lastMapBuffer.setId(lastMapIndex);
			}
			
			// Save map entry as single integer
			nextMapEntryOffset = lastMapBuffer.putInt(nextMapEntryOffset, origIndex);
			nextMapEntryOffset = lastMapBuffer.putInt(nextMapEntryOffset, verIndex);
		}
		
		// Mark end of list
		if (nextMapEntryOffset > maxOffset) {
			int nextIndex = vfIndexProvider.allocateIndex();
			lastMapBuffer.putInt(NEXT_BUFFER_INDEX_OFFSET, nextIndex);
			versionFile.put(lastMapBuffer, lastMapIndex);

			nextMapEntryOffset = FIRST_ENTRY_OFFSET;
			lastMapIndex = nextIndex;
			lastMapBuffer.setId(lastMapIndex);
		}
		lastMapBuffer.putInt(nextMapEntryOffset, -1);
		
		// Make sure last buffer is saved
		lastMapBuffer.putInt(NEXT_BUFFER_INDEX_OFFSET, -1);
		versionFile.put(lastMapBuffer, lastMapIndex);
		
		newMapIds.clear();
	}
Reopen version file as read-only
@throws IOException
Ghidra/Framework/DB/src/main/java/db/buffers/VersionFile.java