I
Ian Collins
I can easily provide a "safe malloc" that aborts on allocation
failure. If for some reason we don't want it to be dependent on
malloc, the user can pass it a memory area from which to do
allocations.
I can't provide a gc_malloc. The problem is you have to do periodic
sweeps of the memory managed by the program, to detect pointers to
allocated blocks. You then put any orphaned blocks back on the free
list. There's no way of doing that without altering the compiler
itself.
There is, it's called a library. If I compile with
cc x.c
The executable uses malloc from libC.
If I compile with
cc x.c -lgc
The executable uses malloc from libgc. Loading initialises the sweeper
thread.