←back to thread

237 points ekr____ | 1 comments | | HN request time: 1.329s | source
Show context
sylware ◴[] No.42724824[source]
Avoid as much as you can the C standard lib allocator, go directly to mmap system call with your own allocator if you know you won't use CPU without a MMU.

If you write a library, let the user code install its own allocator.

replies(3): >>42725907 #>>42729438 #>>42743433 #
jeffbee ◴[] No.42725907[source]
"malloc" is a weakly-bound symbol that can be overridden, on every system I've used. I don't know if some standard defines it to be weak. Anyway the point is that malloc is not necessarily a call to the C standard library function. It can be anything.
replies(2): >>42727384 #>>42732861 #
1. kevin_thibedeau ◴[] No.42732861[source]
The linker doesn't try to resolve symbols it's already seen while static linking. This doesn't require a weak linkage flag for overriding system library functions since libc is linked at the end by default when static linking or at runtime when dynamic.