Fixed wraparound problem in compare_regions()

This commit is contained in:
2021-04-13 00:25:34 -05:00
parent e6a417c822
commit 4900febfd9

View File

@@ -5,11 +5,13 @@ int compare_regions(struct memory_region_t *lhs, struct memory_region_t *rhs)
{
if(lhs->location == rhs->location)
{
return lhs->size - rhs->size;
return lhs->size > rhs->size ? 1
: (lhs->size == rhs->size ? 0
: -1);
}
else
{
return lhs->location - rhs->location;
return lhs->location > rhs->location ? 1 : -1;
}
}