Changeset 33b8d024 in mainline for uspace/lib/c/include/malloc.h


Ignore:
Timestamp:
2018-01-16T20:38:46Z (7 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
2467b41
Parents:
d39c46e0
Message:

Remove const qualifier from the argument of free() and realloc(),
as well as in numerous other variables that hold ownership of memory.

By convention, a pointer that holds ownership is _never_ qualified by const.
This is reflected in the standard type signature of free() and realloc().
Allowing const pointers to hold ownership may seem superficially convenient,
but is actually quite confusing to experienced C programmers.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/include/malloc.h

    rd39c46e0 r33b8d024  
    3838#include <stddef.h>
    3939
    40 extern void *malloc(const size_t size)
     40extern void *malloc(size_t size)
    4141    __attribute__((malloc));
    42 extern void *calloc(const size_t nmemb, const size_t size)
     42extern void *calloc(size_t nmemb, size_t size)
    4343    __attribute__((malloc));
    44 extern void *memalign(const size_t align, const size_t size)
     44extern void *memalign(size_t align, size_t size)
    4545    __attribute__((malloc));
    46 extern void *realloc(const void *addr, const size_t size)
     46extern void *realloc(void *addr, size_t size)
    4747    __attribute__((warn_unused_result));
    48 extern void free(const void *addr);
     48extern void free(void *addr);
    4949extern void *heap_check(void);
    5050
Note: See TracChangeset for help on using the changeset viewer.