MCPcopy Create free account
hub / github.com/GJDuck/e9patch / calculateBounds

Function calculateBounds

src/e9patch/e9mapping.cpp:179–199  ·  view source on GitHub ↗

* Calculate the occupancy bounds of a mapping. */

Source from the content-addressed store, hash-verified

177 * Calculate the occupancy bounds of a mapping.
178 */
179static Bounds calculateBounds(const Mapping *mapping)
180{
181 intptr_t lb = INTPTR_MAX, ub = INTPTR_MIN;
182 const size_t SIZE = mapping->size;
183 const intptr_t BASE = mapping->base;
184 const intptr_t END = BASE + SIZE;
185 auto iend = Allocator::end();
186 for (auto i = mapping->i; i != iend; ++i)
187 {
188 const Alloc *a = *i;
189 if (a->lb >= END)
190 break;
191 if (a->T == nullptr)
192 continue;
193 intptr_t lb1 = (a->lb < BASE? 0: a->lb - BASE);
194 intptr_t ub1 = (a->ub > END ? END - BASE: a->ub - BASE);
195 lb = std::min(lb, lb1);
196 ub = std::max(ub, ub1);
197 }
198 return {lb, ub};
199}
200
201/*
202 * Calculate the protections of a mapping.

Callers 1

saveMappingFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected