range: pass const pointer where possible

If there are no changes, let's use a const pointer.

Backports commit d56978f41b357cc84f2d3fe7d5fef2ae9cddfa61 from qemu
This commit is contained in:
David Hildenbrand 2018-12-11 20:35:12 -05:00 committed by Lioncash
parent c53f666160
commit d783407cff
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7

View file

@ -41,7 +41,7 @@ struct Range {
uint64_t upb; /* inclusive upper bound */ uint64_t upb; /* inclusive upper bound */
}; };
static inline void range_invariant(Range *range) static inline void range_invariant(const Range *range)
{ {
assert(range->lob <= range->upb || range->lob == range->upb + 1); assert(range->lob <= range->upb || range->lob == range->upb + 1);
} }
@ -51,14 +51,14 @@ static inline void range_invariant(Range *range)
//#define range_empty ((Range){ .lob = 0, .upb = 0 }) //#define range_empty ((Range){ .lob = 0, .upb = 0 })
/* Is @range empty? */ /* Is @range empty? */
static inline bool range_is_empty(Range *range) static inline bool range_is_empty(const Range *range)
{ {
range_invariant(range); range_invariant(range);
return range->lob > range->upb; return range->lob > range->upb;
} }
/* Does @range contain @val? */ /* Does @range contain @val? */
static inline bool range_contains(Range *range, uint64_t val) static inline bool range_contains(const Range *range, uint64_t val)
{ {
return val >= range->lob && val <= range->upb; return val >= range->lob && val <= range->upb;
} }