1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-19 00:25:07 +00:00

AK: Add global FlatPtr typedef. It's u32 or u64, based on sizeof(void*)

Use this instead of uintptr_t throughout the codebase. This makes it
possible to pass a FlatPtr to something that has u32 and u64 overloads.
This commit is contained in:
Andreas Kling 2020-03-08 10:36:51 +01:00
parent b98d8ad5b0
commit b1058b33fb
36 changed files with 164 additions and 161 deletions

View file

@ -294,7 +294,7 @@ static void free_impl(void* ptr)
LOCKER(malloc_lock());
void* block_base = (void*)((uintptr_t)ptr & block_mask);
void* block_base = (void*)((FlatPtr)ptr & block_mask);
size_t magic = *(size_t*)block_base;
if (magic == MAGIC_BIGALLOC_HEADER) {
@ -372,14 +372,14 @@ void* malloc(size_t size)
{
void* ptr = malloc_impl(size);
if (s_profiling)
perf_event(PERF_EVENT_MALLOC, size, reinterpret_cast<uintptr_t>(ptr));
perf_event(PERF_EVENT_MALLOC, size, reinterpret_cast<FlatPtr>(ptr));
return ptr;
}
void free(void* ptr)
{
if (s_profiling)
perf_event(PERF_EVENT_FREE, reinterpret_cast<uintptr_t>(ptr), 0);
perf_event(PERF_EVENT_FREE, reinterpret_cast<FlatPtr>(ptr), 0);
free_impl(ptr);
}
@ -396,7 +396,7 @@ size_t malloc_size(void* ptr)
if (!ptr)
return 0;
LOCKER(malloc_lock());
void* page_base = (void*)((uintptr_t)ptr & block_mask);
void* page_base = (void*)((FlatPtr)ptr & block_mask);
auto* header = (const CommonHeader*)page_base;
auto size = header->m_size;
if (header->m_magic == MAGIC_BIGALLOC_HEADER)