Skip to content

Conversation

@penneryu
Copy link

@penneryu penneryu commented May 6, 2025

On some memory allocators, such as hardened_malloc, realloc(0) will allocate a minimum unit of memory (16 bytes)

The hardened_malloc is used on grapheneos, a common operating system on android.

h_malloc.c

static inline void *allocate_small(unsigned arena, size_t requested_size) {
    struct size_info info = get_size_info(requested_size);
    size_t size = likely(info.size) ? info.size : 16;

    struct size_class *c = &ro.size_class_metadata[arena][info.class];
    size_t slots = get_slots(info.class);
    size_t slab_size = get_slab_size(slots, size);
    ...
@penneryu penneryu reopened this May 6, 2025
@penneryu penneryu closed this May 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant