I am writing this code that one function calls itself recursively. But I am stuck in an infinite loop because it seems when the function returns it doesn’t return to the end bracket of the while loop but it returns to where int o is define.. any idea where the problem could be?
ErrorCode QuadTree::PartialSearchHelper(Key *key, const uint64_t QInternal, Iterator ** records,int l[], int pow) {
try {
uint64_t temp=(&indexVec[QInternal])->Firstchild;
uint64_t ch = (&indexVec[QInternal])->Firstchild;
for (int i = 0; i < pow; i++) {
while (!(&indexVec[temp + l[i]])->isLeaf) {
int o= l[i]; //it returns here after finishing recursion call!!!!!!!!!
PartialSearchHelper(key, temp + l[i], records, l, pow);
}
((&indexVec[temp + l[i]]))->findPartial(key, records);
}
} catch (std::bad_alloc &e) {
throw (kErrorOutOfMemory);
} catch (ErrorCode &e) {
throw (e);
} catch (...) {
throw (kErrorGenericFailure);
}
return kOk;
}
You are not changing any value inside the while, so it just restarts the while, in the lower level call