Changeset 33b8d024 in mainline for uspace/app


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/app
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bdsh/compl.c

    rd39c46e0 r33b8d024  
    6969
    7070        /** Pointer inside list of directories */
    71         const char **path;
     71        const char *const *path;
    7272        /** If not @c NULL, should be freed in the end. */
    73         const char **path_list;
     73        char **path_list;
    7474        /** Current open directory */
    7575        DIR *dir;
     
    219219                cs->path_list[0] = dirname;
    220220                cs->path_list[1] = NULL;
    221                 cs->path = cs->path_list;
     221                /* The second const ensures that we can't assign a const
     222                 * string to the non-const array. */
     223                cs->path = (const char *const *) cs->path_list;
    222224
    223225        } else if (cs->is_command) {
  • uspace/app/edit/search_impl.h

    rd39c46e0 r33b8d024  
    4343        /* Note: This structure is opaque for the user. */
    4444
    45         const wchar_t *pattern;
     45        wchar_t *pattern;
    4646        size_t pattern_length;
    4747        ssize_t *back_table;
  • uspace/app/mixerctl/mixerctl.c

    rd39c46e0 r33b8d024  
    4949static void print_levels(async_exch_t *exch)
    5050{
    51         const char* name = NULL;
     51        char* name = NULL;
    5252        unsigned count = 0;
    5353        errno_t ret = audio_mixer_get_info(exch, &name, &count);
     
    5959
    6060        for (unsigned i = 0; i < count; ++i) {
    61                 const char *name = NULL;
     61                char *name = NULL;
    6262                unsigned levels = 0, current = 0;
    6363                errno_t ret =
  • uspace/app/wavplay/dplay.c

    rd39c46e0 r33b8d024  
    353353        }
    354354
    355         const char* info = NULL;
     355        char* info = NULL;
    356356        ret = audio_pcm_get_info_str(session, &info);
    357357        if (ret != EOK) {
  • uspace/app/wavplay/drec.c

    rd39c46e0 r33b8d024  
    195195        }
    196196
    197         const char* info = NULL;
     197        char* info = NULL;
    198198        ret = audio_pcm_get_info_str(session, &info);
    199199        if (ret != EOK) {
Note: See TracChangeset for help on using the changeset viewer.