Skip to content

Commit 3584755

Browse files
authored
fix usage of reverse iterators
1 parent ea8cd30 commit 3584755

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

driverapi/src/librecuda.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -760,9 +760,9 @@ libreCudaStatus_t gpuFree(LibreCUcontext ctx, NvU64 virtualAddress) {
760760
va_to_mem_handle.erase(virtualAddress);
761761
// iterate in reverse order to exploit the fact that we use a bump allocator
762762
// and the insertion position is indicative of the address magnitude
763-
for (auto it = hostMappedPtrs.end(); it >= hostMappedPtrs.begin(); --it) {
763+
for (auto it = hostMappedPtrs.rbegin(); it != hostMappedPtrs.rend(); ++it) {
764764
if (virtualAddress < it->second && virtualAddress >= it->first) {
765-
hostMappedPtrs.erase(it);
765+
hostMappedPtrs.erase(std::next(it).base());
766766
break;
767767
}
768768
}
@@ -841,7 +841,7 @@ bool isHostMappedPtr(void *ptr) {
841841

842842
// iterate in reverse order to exploit the fact that we use a bump allocator
843843
// and the insertion position is indicative of the address magnitude
844-
for (auto it = hostMappedPtrs.end(); it >= hostMappedPtrs.begin(); --it) {
844+
for (auto it = hostMappedPtrs.rbegin(); it != hostMappedPtrs.rend(); ++it) {
845845
if (va < it->second && va >= it->first) {
846846
return true;
847847
}

0 commit comments

Comments
 (0)