private void buildFreeIndexList(int firstFreeBufferIndex) throws IOException {

		ArrayList<Integer> freeIndexList = new ArrayList<>();
		int nextIndex = firstFreeBufferIndex;
		while (nextIndex >= 0) {

			// Push index on stack
			freeIndexList.add(nextIndex);

			// Read block to get next index
			seekBufferBlock(nextIndex);

			// Read version 1 buffer prefix and next empty index
			byte flags = raf.readByte();
			if ((flags & EMPTY_BUFFER) == 0) {
				throw new IOException("Corrupt file");
			}
			nextIndex = raf.readInt();
		}

		int[] newFreeIndexes = new int[freeIndexList.size()];
		for (int i = 0; i < newFreeIndexes.length; i++) {
			newFreeIndexes[i] = freeIndexList.get(i).intValue();
		}
		setFreeIndexes(newFreeIndexes);
	}
Build free index stack from file.
Ghidra/Framework/DB/src/main/java/db/buffers/LocalBufferFile.java