diff --git a/h_malloc.c b/h_malloc.c index 54f129a..db32fc2 100644 --- a/h_malloc.c +++ b/h_malloc.c @@ -784,15 +784,6 @@ static void regions_quarantine_deallocate_pages(void *p, size_t size, size_t gua } } -static size_t hash_page(const void *p) { - uintptr_t u = (uintptr_t)p >> PAGE_SHIFT; - size_t sum = u; - sum = (sum << 7) - sum + (u >> 16); - sum = (sum << 7) - sum + (u >> 32); - sum = (sum << 7) - sum + (u >> 48); - return sum; -} - static int regions_grow(void) { struct region_allocator *ra = ro.region_allocator; diff --git a/pages.h b/pages.h index d91b58d..f0943cb 100644 --- a/pages.h +++ b/pages.h @@ -3,6 +3,7 @@ #include #include +#include #define PAGE_SHIFT 12 #ifndef PAGE_SIZE @@ -14,4 +15,13 @@ void *allocate_pages(size_t usable_size, size_t guard_size, bool unprotect, cons void *allocate_pages_aligned(size_t usable_size, size_t alignment, size_t guard_size, const char *name); void deallocate_pages(void *usable, size_t usable_size, size_t guard_size); +static inline size_t hash_page(const void *p) { + uintptr_t u = (uintptr_t)p >> PAGE_SHIFT; + size_t sum = u; + sum = (sum << 7) - sum + (u >> 16); + sum = (sum << 7) - sum + (u >> 32); + sum = (sum << 7) - sum + (u >> 48); + return sum; +} + #endif