Garbage Collection and gamedev - tl;dr Yes we want it, so let's solve it
pjmlp at progtools.org
Mon Nov 23 06:57:31 UTC 2020
On Sunday, 22 November 2020 at 20:49:19 UTC, random wrote:
> On Sunday, 22 November 2020 at 19:54:14 UTC, Ethan wrote:
>> One of the things I mentioned is that I don't get why library
>> solutions are pursued for handling memory allocations/garbage
>> collecting when the runtime already exists and can be used for
>> the same purpose.
> A benefit of the library solution is that the user can always
> create their own
> implementation when needed.
> You can write your own malloc in C, which is useful if you want
> to program an os... (for example)
Actually no, you cannot not, at least not with pure ISO C.
Allocating from a global static buffer yes, but for something
like a proper malloc() taking from a OS wide memory pool, either
inline Assembly, external Assembly or compiler intrisics are
required to interface with the memory management hardware.
If we are talking about GCC C, clang C, MSVC, TI C, aCC, xlC,...
then yeah C can do it.
This is one of my trick questions, how to implement malloc() in
ISO C on bare metal.
More information about the Digitalmars-d