moya-lang / Allocator

Ultra fast C++11 allocator for STL containers.
BSD 2-Clause "Simplified" License
273 stars 25 forks source link

Do not delete null pointer in Allocator destructor #1

Closed pavlosantoniou closed 6 years ago

pavlosantoniou commented 6 years ago

Since defaultAllocator is not allocated in all scenarios, a null check may be introduced in the Allocator's destructor

moya-mmoczala commented 6 years ago

Hi, thank you very much for your interest! I really appreciate it. According to the C++ standard the delete operation internally performs check if specified expression (pointer) is not null. Therefore, in this case this check is unnecessary.

pavlosantoniou commented 6 years ago

Thanks for your comment! I have seen such null checks before delete being used in various codebases as an indication to the programmer that the pointer might be null in this execution path.