Changeset 4f3aa76 in mainline
- Timestamp:
- 2018-11-09T22:03:24Z (6 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ba9a150
- Parents:
- b389f95
- git-author:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-11-08 01:26:04)
- git-committer:
- Jiří Zárevúcky <zarevucky.jiri@…> (2018-11-09 22:03:24)
- Location:
- kernel
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/genarch/src/mm/asid_fifo.c
rb389f95 r4f3aa76 65 65 #if (!FIFO_STATIC) 66 66 fifo_create(free_asids); 67 if (!free_asids.fifo) 68 panic("Not enough memory to allocate ASID FIFO"); 69 // TODO: There really is no reason not to statically allocate it 70 // except to keep binary size low. Once kernel is a regular ELF 71 // binary supporting .bss section (wip as of the late 2018), 72 // the dynamic option should be removed. 67 73 #endif 68 74 -
kernel/genarch/src/ofw/ofw_tree.c
rb389f95 r4f3aa76 386 386 static void ofw_tree_node_sysinfo(ofw_tree_node_t *node, const char *path) 387 387 { 388 char *cur_path = (char *) nfmalloc(PATH_MAX_LEN); 388 char *cur_path = malloc(PATH_MAX_LEN); 389 if (!cur_path) 390 panic("Not enough memory to process OFW tree."); 389 391 390 392 for (ofw_tree_node_t *cur = node; cur; cur = cur->peer) { -
kernel/generic/include/adt/fifo.h
rb389f95 r4f3aa76 115 115 */ 116 116 #define fifo_create(name) \ 117 name.fifo = nfmalloc(sizeof(*name.fifo) * name.items)117 name.fifo = malloc(sizeof(*name.fifo) * name.items) 118 118 119 119 #endif -
kernel/generic/include/mm/slab.h
rb389f95 r4f3aa76 146 146 extern void free(void *); 147 147 148 extern void *nfmalloc(size_t)149 __attribute__((malloc, returns_nonnull));150 151 148 #endif 152 149 -
kernel/generic/src/console/kconsole.c
rb389f95 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 } -
kernel/generic/src/lib/str.c
rb389f95 r4f3aa76 635 635 { 636 636 size_t size = str_size(src) + 1; 637 char *dest = nfmalloc(size); 638 assert(dest); 637 char *dest = malloc(size); 638 if (!dest) 639 return NULL; 639 640 640 641 str_cpy(dest, size, src); … … 668 669 size = n; 669 670 670 char *dest = nfmalloc(size + 1); 671 assert(dest); 671 char *dest = malloc(size + 1); 672 if (!dest) 673 return NULL; 672 674 673 675 str_ncpy(dest, size + 1, src, size); -
kernel/generic/src/mm/slab.c
rb389f95 r4f3aa76 954 954 } 955 955 956 static void *_malloc(size_t size, unsigned int flags)956 void *malloc(size_t size) 957 957 { 958 958 assert(_slab_initialized); … … 964 964 uint8_t idx = fnzb(size - 1) - SLAB_MIN_MALLOC_W + 1; 965 965 966 return slab_alloc(malloc_caches[idx], flags); 967 } 968 969 void *malloc(size_t size) 970 { 971 return _malloc(size, FRAME_ATOMIC); 972 } 973 974 /** Non-failing malloc. 975 * Never returns NULL, but may block forever if no memory is available. 976 */ 977 void *nfmalloc(size_t size) 978 { 979 return _malloc(size, 0); 980 } 981 982 static void *_realloc(void *ptr, size_t size, unsigned int flags) 966 return slab_alloc(malloc_caches[idx], FRAME_ATOMIC); 967 } 968 969 void *realloc(void *ptr, size_t size) 983 970 { 984 971 assert(_slab_initialized); … … 992 979 uint8_t idx = fnzb(size - 1) - SLAB_MIN_MALLOC_W + 1; 993 980 994 new_ptr = slab_alloc(malloc_caches[idx], flags);981 new_ptr = slab_alloc(malloc_caches[idx], FRAME_ATOMIC); 995 982 } else 996 983 new_ptr = NULL; … … 1007 994 } 1008 995 1009 void *realloc(void *ptr, size_t size)1010 {1011 return _realloc(ptr, size, FRAME_ATOMIC);1012 }1013 1014 996 void free(void *ptr) 1015 997 { -
kernel/generic/src/sysinfo/sysinfo.c
rb389f95 r4f3aa76 685 685 return ret; 686 686 687 char *path = (char *) nfmalloc(size + 1); 688 assert(path); 687 // TODO: Change this so that allocation is not needed. 688 char *path = malloc(size + 1); 689 if (!path) 690 return ret; 689 691 690 692 if ((copy_from_uspace(path, ptr, size + 1) == 0) && … … 794 796 return ret; 795 797 796 char *path = (char *) nfmalloc(size + 1); 797 assert(path); 798 // TODO: Change this so that allocation is not needed. 799 char *path = malloc(size + 1); 800 if (!path) 801 return ret; 798 802 799 803 if ((copy_from_uspace(path, ptr, size + 1) == 0) &&
Note:
See TracChangeset
for help on using the changeset viewer.