Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/mm/malloc.c

    ra22c62f r0a2c96c  
    3434#include <bitops.h>
    3535#include <mm/slab.h>
    36 #include <memw.h>
     36#include <mem.h>
    3737#include <main/main.h> // malloc_init()
    3838#include <macros.h>
     
    190190                return NULL;
    191191
    192         void *obj = mem_alloc(alignof(max_align_t), size + _offset);
    193         if (!obj)
    194                 return NULL;
    195 
    196         obj += _offset;
     192        void *obj = mem_alloc(alignof(max_align_t), size + _offset) + _offset;
    197193
    198194        /* Remember the allocation size just before the object. */
     
    209205         * slab_free() will detect it and panic.
    210206         */
    211         if (obj) {
    212                 size_t size = ((size_t *) obj)[-1];
    213                 mem_free(obj - _offset, alignof(max_align_t), size + _offset);
    214         }
     207        size_t size = ((size_t *) obj)[-1];
     208        mem_free(obj - _offset, alignof(max_align_t), size + _offset);
    215209}
    216210
    217211void *realloc(void *old_obj, size_t new_size)
    218212{
    219         if (new_size == 0)
    220                 new_size = 1;
    221 
    222213        if (!old_obj)
    223214                return malloc(new_size);
Note: See TracChangeset for help on using the changeset viewer.