mirror of
https://github.com/GrapheneOS/hardened_malloc.git
synced 2024-10-01 01:36:01 -04:00
split out allocate_large function
This commit is contained in:
parent
3d18fb8074
commit
ce36d0c826
10
h_malloc.c
10
h_malloc.c
@ -1127,11 +1127,7 @@ static size_t get_guard_size(struct random_state *state, size_t size) {
|
|||||||
return (get_random_u64_uniform(state, size / PAGE_SIZE / GUARD_SIZE_DIVISOR) + 1) * PAGE_SIZE;
|
return (get_random_u64_uniform(state, size / PAGE_SIZE / GUARD_SIZE_DIVISOR) + 1) * PAGE_SIZE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void *allocate(size_t size) {
|
static void *allocate_large(size_t size) {
|
||||||
if (size <= max_slab_size_class) {
|
|
||||||
return allocate_small(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
struct region_allocator *ra = ro.region_allocator;
|
struct region_allocator *ra = ro.region_allocator;
|
||||||
|
|
||||||
mutex_lock(&ra->lock);
|
mutex_lock(&ra->lock);
|
||||||
@ -1157,6 +1153,10 @@ static void *allocate(size_t size) {
|
|||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static inline void *allocate(size_t size) {
|
||||||
|
return size <= max_slab_size_class ? allocate_small(size) : allocate_large(size);
|
||||||
|
}
|
||||||
|
|
||||||
static void deallocate_large(void *p, const size_t *expected_size) {
|
static void deallocate_large(void *p, const size_t *expected_size) {
|
||||||
enforce_init();
|
enforce_init();
|
||||||
thread_unseal_metadata();
|
thread_unseal_metadata();
|
||||||
|
Loading…
Reference in New Issue
Block a user