mirror of
https://github.com/GrapheneOS/hardened_malloc.git
synced 2024-10-01 01:36:01 -04:00
optimize size calculation for 16 byte spaced sizes
This commit is contained in:
parent
2d6ad18aa4
commit
7a404ddbf2
5
malloc.c
5
malloc.c
@ -85,7 +85,10 @@ static inline struct size_info get_size_info(size_t size) {
|
||||
if (size == 0) {
|
||||
return (struct size_info){16, 0};
|
||||
}
|
||||
for (unsigned class = 1; class < N_SIZE_CLASSES; class++) {
|
||||
if (size <= 128) {
|
||||
return (struct size_info){(size + 15) & ~15, ((size - 1) >> 4) + 1};
|
||||
}
|
||||
for (unsigned class = 9; class < N_SIZE_CLASSES; class++) {
|
||||
size_t real_size = size_classes[class];
|
||||
if (size <= real_size) {
|
||||
return (struct size_info){real_size, class};
|
||||
|
Loading…
Reference in New Issue
Block a user