3 ms·
I think the lesson is "safety comes at a cost. If you bump downwards you can avoid those safety checks" I don't think the lesson is "let's just write unsafe co
by wrsh07 3y ago
I think the lesson is "safety comes at a cost. If you bump downwards you can avoid those safety checks"
I don't think the lesson is "let's just write unsafe code"
- kazinator 3y agoCaller asks for a 500 megabyte downward bump allocation in a 32 bit system. Do you check for underflow or not?
- bitwize 3y agoYou check to make sure the size requested is less than or equal to current pointer - chunk start and fail if it is bigger. Let's face facts, the allocator, even with this additional check, is still going to be blazing fast compared to malloc() or whatever. If you're allocating so much that the handful of extra instructions is going to be a significant slowdown, maybe structure your allocations differently?
- saagarjha 3y agoMost allocators will do this, yes.