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