Re:Tell HN: C Experts Panel – Ask us anything about C
by SAI_Peregrinus on Tuesday April 14, 2020 @08:35PM
(#22873136)
Not just embedded systems, also OSes. C's standard library should generally work without the existence of a heap. After all, you have to create the heap using C before you can allocate from it.
[ Parent
| on HN ]
Re:Tell HN: C Experts Panel – Ask us anything about C
by saagarjha on Tuesday April 14, 2020 @09:51PM
(#22873647)
malloc is a required part of ISO C, though.
Re:Tell HN: C Experts Panel – Ask us anything about C
by flatfinger on Friday April 17, 2020 @04:54PM
(#22902891)
Functions like malloc are only required for hosted implementations. Many operating systems are built using freestanding implementations.
Further, on many platforms, one should avoid using malloc() unless portability is more important than performance or safety. Some operating systems support useful features like the ability to allocate objects with different expected lifetimes in different heaps, so as to help avoid fragmentation, or arrange to have allocations a program can survive without fail while there is still enough memory to handle critical allocations. Any library that insists upon using "malloc()" will be less than ideal for use with any such operating system.