public static Address getNextAvailableAddress(Program program) {
		Address maxAddress = null;
		for (MemoryBlock block : program.getMemory().getBlocks()) {
			if (block.isOverlay()) {
				continue;
			}
			if (maxAddress == null || block.getEnd().compareTo(maxAddress) > 0) {
				maxAddress = block.getEnd();
			}
		}
		if (maxAddress == null) {
			return program.getAddressFactory().getDefaultAddressSpace().getAddress(0x1000);
		}
		long maxAddr = maxAddress.getOffset();
		long remainder = maxAddr % 0x1000;
		return maxAddress.getNewAddress(maxAddr + 0x1000 - remainder);
	}
Gets the next available {@link Address} in the {@link Program}

@param program The {@link Program}
@return The next available {@link Address} in the {@link Program}
Ghidra/Features/Base/src/main/java/ghidra/app/util/opinion/MachoProgramUtils.java