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:
Olly Betts 2022-01-29 22:03:48 +13:00 • committed by GitHub
commit 7ec2f89fe2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
17 changed files with 44 additions and 51 deletions

View file

@ -55,7 +55,7 @@ typedef struct {
return %new_instance(TYPE);
}
~NAME() {
if ($self) %delete($self);
%delete($self);
}
}
@ -114,7 +114,7 @@ typedef struct {
}
static void delete_##NAME(TYPE *obj) {
if (obj) %delete(obj);
%delete(obj);
}
static void NAME ##_assign(TYPE *obj, TYPE value) {