anyRTC-UseCase / SipRtcProxy

网关服务:Sip与Rtc互通,实现Web,Android,iOS,小程序,SIP座机,PSTN电话,手机互通。
326 stars 81 forks source link

Remove unnecessary null pointer checks #3

Open elfring opened 3 years ago

elfring commented 3 years ago

An extra null pointer check is not needed in functions like the following.

DyncEric commented 3 years ago

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.