Changeset 33b8d024 in mainline for uspace/lib/c


Ignore:
Timestamp:
2018-01-16T20:38:46Z (8 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.

Location:
uspace/lib/c
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/malloc.c

    rd39c46e0 r33b8d024  
    874874 *
    875875 */
    876 void *realloc(const void *addr, const size_t size)
     876void *realloc(void * const addr, const size_t size)
    877877{
    878878        if (size == 0) {
     
    988988 *
    989989 */
    990 void free(const void *addr)
     990void free(void * const addr)
    991991{
    992992        if (addr == NULL)
  • uspace/lib/c/include/ipc/devman.h

    rd39c46e0 r33b8d024  
    7474        /** Id of device model.
    7575         */
    76         const char *id;
     76        char *id;
    7777        /** Relevancy of device-to-driver match.
    7878         * The higher is the product of scores specified for the device by the bus driver and by the leaf driver,
  • 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.