News for hackers. Stuff that matters.
Re:Can I use a system call? by ablob on Wednesday September 21, 2022 @11:46AM (#32926804)
If you know how much memory you need, you can just have a section of zero-initialized-data for that, which the allocator then handles. The allocator serves also as a proxy, as in: only the allocator needs to know how to request heap space. Portable in that case probably means that you have little to no code change required for a port.

Something else to consider is that there may not even be an operating system the program was run on.

Re:Can I use a system call? by l33t233372 on Wednesday September 21, 2022 @12:39PM (#32927703)
> there may not even be an operating system the program was run on.

Sure, in this case you can just implement malloc the same way a kernel implements me. My failure of understanding is when there _is_ a kernel that your program needs to interact with.

Re:Can I use a system call? by wongarsu on Wednesday September 21, 2022 @01:08PM (#32928123)
In the executable file you can specify that the operating system should give you a writable space of a given size, initialized with whatever you want. I think that's frequently used to initialize static variables, so you might get the desired result by just telling the compiler you want a large static array.