Changes in kernel/generic/src/console/kconsole.c [4f3aa76:bab75df6] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/generic/src/console/kconsole.c
r4f3aa76 rbab75df6 219 219 const char *hint; 220 220 const char *help; 221 char *output = nfmalloc(MAX_CMDLINE); 221 222 size_t hints_to_show = MAX_TAB_HINTS - 1; 222 223 size_t total_hints_shown = 0; 223 224 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 allocation228 printf("Can't complete command, out of memory.\n");229 return 0;230 }231 225 232 226 output[0] = 0; … … 331 325 } 332 326 333 NO_TRACE static wchar_t *clever_readline(const char *prompt, indev_t *indev, 334 char *tmp) 327 NO_TRACE static wchar_t *clever_readline(const char *prompt, indev_t *indev) 335 328 { 336 329 printf("%s> ", prompt); … … 339 332 wchar_t *current = history[history_pos]; 340 333 current[0] = 0; 334 char *tmp = nfmalloc(STR_BOUNDS(MAX_CMDLINE)); 341 335 342 336 while (true) { … … 540 534 } 541 535 536 free(tmp); 542 537 return current; 543 538 } … … 814 809 printf("Type \"exit\" to leave the console.\n"); 815 810 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)); 826 812 while (true) { 827 wchar_t *tmp = clever_readline((char *) prompt, stdin , buffer);813 wchar_t *tmp = clever_readline((char *) prompt, stdin); 828 814 size_t len = wstr_length(tmp); 829 815 if (!len) … … 841 827 (void) cmd_info->func(cmd_info->argv); 842 828 } 843 free(buffer);844 829 free(cmdline); 845 830 }
Note:
See TracChangeset
for help on using the changeset viewer.