Remove redundant NULL checks before free()/delete (#2184)
Remove redundant NULL checks before free()/delete The ISO C and C++ standards guarantee that it's safe to call these on a NULL pointer, so it's not necessary for the calling code to also check. Fixes https://sourceforge.net/p/swig/feature-requests/70/
This commit is contained in:
parent
5a10e10399
commit
7ec2f89fe2
17 changed files with 44 additions and 51 deletions
|
|
@ -994,7 +994,7 @@ int JSEmitter::emitDtor(Node *n) {
|
|||
{
|
||||
SWIG_PRV_DATA* t = (SWIG_PRV_DATA*)JSObjectGetPrivate(thisObject);
|
||||
if(t && t->swigCMemOwn) free ((${type}*)t->swigCObject);
|
||||
if(t) free(t);
|
||||
free(t);
|
||||
}
|
||||
%}
|
||||
|
||||
|
|
@ -1007,7 +1007,7 @@ int JSEmitter::emitDtor(Node *n) {
|
|||
${type}* arg1 = (${type}*)t->swigCObject;
|
||||
${destructor_action}
|
||||
}
|
||||
if(t) free(t);
|
||||
free(t);
|
||||
|
||||
Based on what I saw in the Lua and Ruby modules, I use Getattr(n, "wrap:action")
|
||||
to decide if the user has a preferred destructor action.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue