diff options
| author | ptitSeb <seebastien.chev@gmail.com> | 2023-10-27 09:57:34 +0200 |
|---|---|---|
| committer | ptitSeb <seebastien.chev@gmail.com> | 2023-10-27 09:57:34 +0200 |
| commit | f8d65a831e6f92314513ab2603e74627bbc1711f (patch) | |
| tree | 9ab42aeb8f8da14cd9aca9ad4cf60d7aefe90abf /src/custommem.c | |
| parent | a1ac21af75b0fae21981830e660cc31527f9f0f0 (diff) | |
| download | box64-f8d65a831e6f92314513ab2603e74627bbc1711f.tar.gz box64-f8d65a831e6f92314513ab2603e74627bbc1711f.zip | |
Another fix to wrapped mmap (should fix #1031, hopefully not creating more regression)
Diffstat (limited to 'src/custommem.c')
| -rw-r--r-- | src/custommem.c | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/src/custommem.c b/src/custommem.c index a5f4cf61..1a5da272 100644 --- a/src/custommem.c +++ b/src/custommem.c @@ -1571,6 +1571,24 @@ void* find47bitBlockNearHint(void* hint, size_t size) return NULL; } +int isBlockFree(void* hint, size_t size) +{ + mapmem_t* m = mapmem; + uintptr_t h = (uintptr_t)hint; + if(h>0x800000000000LL) + return 0; // no tracking there + while(m && m->end<0x800000000000LL) { + uintptr_t addr = (m->end+1+0xffff)&~0xffff; + uintptr_t end = (m->next)?(m->next->begin-1):0xffffffffffffffffLL; + if(addr<=h && end>=h && end-h+1>=size) + return 1; + if(addr>h) + return 0; + m = m->next; + } + return 0; +} + int unlockCustommemMutex() { int ret = 0; |