Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • kernel/generic/src/console/kconsole.c

    r4f3aa76 rbab75df6  
    219219        const char *hint;
    220220        const char *help;
     221        char *output = nfmalloc(MAX_CMDLINE);
    221222        size_t hints_to_show = MAX_TAB_HINTS - 1;
    222223        size_t total_hints_shown = 0;
    223224        bool continue_showing_hints = true;
    224 
    225         char *output = malloc(MAX_CMDLINE);
    226         if (!output) {
    227                 // TODO: fix the function so that it does not need allocation
    228                 printf("Can't complete command, out of memory.\n");
    229                 return 0;
    230         }
    231225
    232226        output[0] = 0;
     
    331325}
    332326
    333 NO_TRACE static wchar_t *clever_readline(const char *prompt, indev_t *indev,
    334     char *tmp)
     327NO_TRACE static wchar_t *clever_readline(const char *prompt, indev_t *indev)
    335328{
    336329        printf("%s> ", prompt);
     
    339332        wchar_t *current = history[history_pos];
    340333        current[0] = 0;
     334        char *tmp = nfmalloc(STR_BOUNDS(MAX_CMDLINE));
    341335
    342336        while (true) {
     
    540534        }
    541535
     536        free(tmp);
    542537        return current;
    543538}
     
    814809                printf("Type \"exit\" to leave the console.\n");
    815810
    816         char *buffer = malloc(STR_BOUNDS(MAX_CMDLINE));
    817         char *cmdline = malloc(STR_BOUNDS(MAX_CMDLINE));
    818         if (!buffer || !cmdline) {
    819                 // TODO: fix the function so that it does not need allocations
    820                 printf("Can't start console, out of memory.\n");
    821                 free(buffer);
    822                 free(cmdline);
    823                 return;
    824         }
    825 
     811        char *cmdline = nfmalloc(STR_BOUNDS(MAX_CMDLINE));
    826812        while (true) {
    827                 wchar_t *tmp = clever_readline((char *) prompt, stdin, buffer);
     813                wchar_t *tmp = clever_readline((char *) prompt, stdin);
    828814                size_t len = wstr_length(tmp);
    829815                if (!len)
     
    841827                (void) cmd_info->func(cmd_info->argv);
    842828        }
    843         free(buffer);
    844829        free(cmdline);
    845830}
Note: See TracChangeset for help on using the changeset viewer.