2 ms·
Caller asks for a 500 megabyte downward bump allocation in a 32 bit system. Do you check for underflow or not?
by kazinator 3y ago
Caller 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.