MCPcopy Create free account
hub / github.com/devkitPro/libctru / mappableFindAddressWithin

Function mappableFindAddressWithin

libctru/source/allocator/mappable.c:14–36  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

12}
13
14static u32 mappableFindAddressWithin(u32 start, u32 end, u32 size)
15{
16 MemInfo info;
17 PageInfo pgInfo;
18
19 u32 addr = start;
20 while (addr >= start && (addr + size) < end && (addr + size) >= addr)
21 {
22 if (R_FAILED(svcQueryMemory(&info, &pgInfo, addr)))
23 return 0;
24
25 if (info.state == MEMSTATE_FREE)
26 {
27 u32 sz = info.size - (addr - info.base_addr); // a free block might cover all the memory, etc.
28 if (sz >= size)
29 return addr;
30 }
31
32 addr = info.base_addr + info.size;
33 }
34
35 return 0;
36}
37
38void* mappableAlloc(size_t size)
39{

Callers 1

mappableAllocFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected