mfunyu / malloc

Find out the workings behind optimum memory management and recode it, as well as free and realloc.
2 stars 0 forks source link

[fix] realloc over different size zone #38

Closed mfunyu closed 1 year ago

mfunyu commented 1 year ago
    /*
     * If the new size suits the tiny allocator and the pointer being resized
     * belongs to a tiny region, try to reallocate in-place.
     */
    if ((new_size + TINY_QUANTUM - 1) <= (NUM_TINY_SLOTS - 1) * TINY_QUANTUM) {
    if (tiny_region_for_ptr_no_lock(szone, ptr) != NULL) {
        if (tiny_try_realloc_in_place(szone, ptr, old_size, new_size)) {
        return ptr;
        }
    }