I have a function that returns a boolean to signal success or failure of the function and takes a long as argument, and a pointer to return the value.
The idea is to run the function, pass the the long as argument and a pointer for retrieving an object from the heap.
true = pointer has address to object
false = pointer is not usable.
this is the code:
Expand|Select|Wrap|Line Numbers
- bool BigBrother::IO::DriveManager::FindDriveToUse(long RecordId, Drive *Object) const
- {
- // Check if we have been properly initialized.
- assert(initialized == true);
- // Create a bool value to store our return value. We assume false
- // to begin with.
- bool retvalue = false;
- // Loop through the list of drives and compare the RecordID against
- // the JumpPoint of that drive. Also check if the drive is usable.
- for(unsigned int i = 0; i < drives.size(); ++i)
- {
- // Check if the RecordID is smaller then upcoming jump point.
- // And check if the drive is usable.
- if((RecordId < CalculateNextJumpPoint(i)) && (drives[i]->GetUsable() == true))
- {
- // The drive that matches these conditions is found. Take it's
- // address and assign it to our out pointer.
- Object = drives.at(i);
- // Set the return value to true.
- retvalue = true;
- // break the for loop
- break;
- }
- }
- // return the retval variable
- return retvalue;
- }
I don't like warnings , so i'm kinda curious on how to solve this properly...