private long getNumToSearch(Program program, AddressSetView searchSet) {
		long numAddresses = 0;
		MemoryBlock[] blocks = program.getMemory().getBlocks();
		for (MemoryBlock block : blocks) {
			// check if entire block has anything that is searchable
			if (!block.isInitialized()) {
				continue;
			}
			if (doExecutableBlocksOnly && !block.isExecute()) {
				continue;
			}
			if (searchSet != null && !searchSet.isEmpty() &&
				!searchSet.intersects(block.getStart(), block.getEnd())) {
				continue;
			}
			numAddresses += block.getSize();
		}
		return numAddresses;
	}
Search initialized memory blocks for all patterns(bytes/mask/action).
Call associated action for each pattern matched.

@param program to be searched
@param searchSet set of bytes to restrict search, if null or empty then search all memory blocks
@param monitor allow canceling and reporting of progress

@throws CancelledException if canceled
Ghidra/Features/Base/src/main/java/ghidra/util/bytesearch/MemoryBytePatternSearcher.java