Created
September 18, 2013 00:34
-
-
Save zorgiepoo/6602809 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <typename T, typename P> | |
void ZGSearchWithFunctionHelperRegular(T *searchValue, bool (*comparisonFunction)(ZGSearchData *, T *, T *), ZGSearchData * __unsafe_unretained searchData, ZGMemorySize dataIndex, ZGMemorySize dataAlignment, ZGMemorySize endLimit, P pointerSize, NSMutableData * __unsafe_unretained resultSet, ZGMemoryAddress address, void *bytes) | |
{ | |
const ZGMemorySize maxSteps = 4096; | |
while (dataIndex <= endLimit) | |
{ | |
ZGMemorySize numberOfVariablesFound = 0; | |
P memoryAddresses[maxSteps]; | |
ZGMemorySize numberOfStepsToTake = MIN(maxSteps, (endLimit + dataAlignment - dataIndex) / dataAlignment); | |
for (ZGMemorySize stepIndex = 0; stepIndex < numberOfStepsToTake; stepIndex++) | |
{ | |
if (comparisonFunction(searchData, (T *)((int8_t *)bytes + dataIndex), searchValue)) | |
{ | |
memoryAddresses[numberOfVariablesFound] = (P)(address + dataIndex); | |
numberOfVariablesFound++; | |
} | |
dataIndex += dataAlignment; | |
} | |
[resultSet appendBytes:memoryAddresses length:sizeof(P) * numberOfVariablesFound]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment