libjxl icon indicating copy to clipboard operation
libjxl copied to clipboard

Remove an unnecessary null pointer check

Open elfring opened this issue 3 years ago • 3 comments

An extra null pointer check is not needed in a function like the destructor for the class “QuantEncoding”.

elfring avatar May 20 '22 09:05 elfring

In fact that FAQ is very strange and wrong because it can be NULL only if the allocation of memory happens (or if you somehow managed to assign NULL by hand losing the memory 🤡) but that fails the same moment new fails.

As for what they described, both free() and delete check internally for NULL, of course (in glibc source code that is). That is mandated by the standard. Now, in practice implementions of memory allocators (freeing too) that do not check for NULL do exist.

ValZapod avatar May 20 '22 14:05 ValZapod

:crystal_ball: Would you like to add any software build checks (for standard-incompliant C++ delete operators)?

elfring avatar May 20 '22 16:05 elfring

Oh, you are the same guy. https://github.com/uclouvain/openjpeg/issues/589

BTW, here mode == kQuantModeRAW is shot curcuiting. So if it false...

ValZapod avatar May 20 '22 16:05 ValZapod