3 ms·
> Though malloc is defined as part of the C language, it can be implemented as an ordinary library function requiring no special support from the compiler. Thi
by astrange 12y ago
> Though malloc is defined as part of the C language, it can be implemented as an ordinary library function requiring no special support from the compiler.
This is actually not true, but happens by accident in most C implementations since they're being nice to you.
C gives some functions like malloc() and pthread_mutex_lock() magic properties, but you can't write your own function from scratch that has those. As long as you don't try to optimize all that hard, or don't let the compiler try to inline your malloc, it won't go /that/ badly, but…
- dth 12y agoHa, interesting. Can you elaborate on what these "magic properties" of malloc() and pthread_mutex_lock() are? I'm curious.