I know std::free (nullptr) is perfectly okay, but it could there will be an superflous lock (at least i suspect windows to do that)
It would be great for a non-allocated HeapBlock on the stack there is a principle guarantee that nothing under the hood will happen-
if (data) data::free (data);
Could you please add a check for the pointer?
it could there will be an superflous lock (at least i suspect windows to do that)
Have you seen this occur in practice? The standard states:
ptr is a null pointer, the function does nothing.
The standard doesn’t say something about the runtime behaviour, I only saw that the windows debug version at least is locking something, maybe I just worry too much
Can you provide a test case which demonstrates it locking? MSVC’s STL implementation is open source and it looks like it just relies on the version of
free in the system
stdlib.h. I would be very surprised if that wasn’t standard-conformant: