2 ms·
You don't have to "create a new memory object". C doesn't say how malloc() is implemented. It is perfectly valid to have a statically defined array and have mal
by kevin_thibedeau 6y ago
You don't have to "create a new memory object". C doesn't say how malloc() is implemented. It is perfectly valid to have a statically defined array and have malloc() pull from that. The majority of the computers in the world do this. You're conflating limitations imposed by layers of OS infrastructure with limitations of C.
- astrange 6y agoI'm not talking about any OS concept, but about the concept of how memory works in the virtual machine defined by the C standard. That implementation isn't compliant just because it works; if an undefined behavior checker could see into the malloc implementation, it would see that it's returning pointers inside the same object, which conflicts with the (impossible to implement) rule that malloc returns pointers to different objects. The practical consequence of this is malloc is kept in a different library and not inlined into callers, and asan doesn't work with custom allocators unless you tell it they behave like malloc.