Ignore:
Timestamp:
2018-01-16T20:38:46Z (6 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/drv/bus/usb/vhc/hub/virthub.c

    rd39c46e0 r33b8d024  
    156156        dev->descriptors = &descriptors;
    157157        dev->address = 0;
    158         dev->name = str_dup(name);
    159         if (!dev->name)
     158
     159        char *n = str_dup(name);
     160        if (!n)
    160161                return ENOMEM;
    161162
    162163        hub_t *hub = malloc(sizeof(hub_t));
    163164        if (hub == NULL) {
    164                 free(dev->name);
     165                free(n);
    165166                return ENOMEM;
    166167        }
    167168
     169        dev->name = n;
    168170        hub_init(hub);
    169171        dev->device_data = hub;
Note: See TracChangeset for help on using the changeset viewer.