Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 71fb5ac in mainline for kernel/generic/src/mm/malloc.c


Ignore:
Timestamp:
2018-11-13T16:48:08Z (3 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master
Children:
fdc190f
Parents:
b60615b
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-11-11 17:49:01)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-11-13 16:48:08)
Message:

Swap ordering of alignment and size, to match standard aligned_alloc()

File:
1 edited

Legend:

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

    rb60615b r71fb5ac  
    8282}
    8383
    84 static void _check_sizes(size_t *size, size_t *alignment)
     84static void _check_sizes(size_t *alignment, size_t *size)
    8585{
    8686        assert(size);
     
    121121static void *mem_alloc(size_t, size_t) __attribute__((malloc));
    122122
    123 static void *mem_alloc(size_t size, size_t alignment)
     123static void *mem_alloc(size_t alignment, size_t size)
    124124{
    125         _check_sizes(&size, &alignment);
     125        _check_sizes(&alignment, &size);
    126126
    127127        if (size > (1 << SLAB_MAX_MALLOC_W)) {
     
    141141 * @param alignment  Alignment used to call mem_alloc().
    142142 */
    143 static void mem_free(void *ptr, size_t size, size_t alignment)
     143static void mem_free(void *ptr, size_t alignment, size_t size)
    144144{
    145145        if (!ptr)
    146146                return;
    147147
    148         _check_sizes(&size, &alignment);
     148        _check_sizes(&alignment, &size);
    149149
    150150        if (size > (1 << SLAB_MAX_MALLOC_W)) {
     
    160160void *malloc(size_t size)
    161161{
    162         void *obj = mem_alloc(size + _offset, alignof(max_align_t)) + _offset;
     162        void *obj = mem_alloc(alignof(max_align_t), size + _offset) + _offset;
    163163
    164164        /* Remember the allocation size just before the object. */
     
    176176         */
    177177        size_t size = ((size_t *) obj)[-1];
    178         mem_free(obj - _offset, size + _offset, alignof(max_align_t));
     178        mem_free(obj - _offset, alignof(max_align_t), size + _offset);
    179179}
    180180
Note: See TracChangeset for help on using the changeset viewer.