Remove unnecessary null pointer checks
elfring opened this issue · 1 comments
An extra null pointer check is not needed in functions like the following.
Thanks, it's will be modified soon.
Free(NULL); same as delete NULL;
I didn't think about it before.
**Description
The C library function void free(void ptr) deallocates the memory previously allocated by a call to calloc, malloc, or realloc.
Declaration
Following is the declaration for free() function.
void free(void ptr)
Parameters
ptr —— This is the pointer to a memory block previously allocated with malloc, calloc or realloc to be deallocated. If a null pointer is passed as argument, no action occurs.
Return Value
This function does not return any value.
**Description
The C++ language guarantees that delete p will do nothing if p is null. Since you might get the test backwards, and since most testing methodologies force you to explicitly test every branch point, you should not put in the redundant if test.