Hacker News new | past | comments | ask | show | jobs | submit login

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.




I 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).


For 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.


Ah sorry camgunz I interpreted the counter example as claiming malloc() was a dependency. referencing the wrong subject!


Aha yeah, fair point :)




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: