4 ms·
You don't need a library to allocate memory in C. For example on Linux, use sbrk() system call to grow the heap, then start using it. But your larger point sti
by benlorenzetti 9y ago
You don't need a library to allocate memory in C. For example on Linux, use sbrk() system call to grow the heap, then start using it.
But your larger point still stands.
- camgunz 9y agoAha yeah, fair point :)
- Sharlin 9y agoI think that the point was more that heap allocation is not a standard language primitive in C. And indeed, it would be ludicruous to require dynamic allocation support from freestanding implementations (no standard library because typically your platform doesn't even have an OS).
- benlorenzetti 9y agoAh sorry camgunz I interpreted the counter example as claiming malloc() was a dependency. referencing the wrong subject!
- Sprocklem 9y agoFor what it's worth, C++ can have freestanding implementations and it provides dynamic allocation support at a syntactic level. Freestanding applications, however, need to provide an "operator new" function (with the appropriate memory allocation code) if they want to use it.