diff options
author | Olly Betts <olly@survex.com> | 2022-01-29 22:03:48 +1300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-01-29 22:03:48 +1300 |
commit | 7ec2f89fe241e3aabd988d3aa6fe17e4878516dc (patch) | |
tree | e07b8a2f41f61cdec1275edd5850f2fad637fb7c /Lib/cpointer.i | |
parent | 5a10e103992c49b8b402745b294fcdd4ca48e705 (diff) | |
download | swig-7ec2f89fe241e3aabd988d3aa6fe17e4878516dc.tar.gz |
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/
Diffstat (limited to 'Lib/cpointer.i')
-rw-r--r-- | Lib/cpointer.i | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/Lib/cpointer.i b/Lib/cpointer.i index 881c511fc..6eb509d7e 100644 --- a/Lib/cpointer.i +++ b/Lib/cpointer.i @@ -55,14 +55,14 @@ NAME() { return new TYPE(); } ~NAME() { - if ($self) delete $self; + delete $self; } #else NAME() { return (TYPE *) calloc(1,sizeof(TYPE)); } ~NAME() { - if ($self) free($self); + free($self); } #endif } @@ -134,9 +134,9 @@ static TYPE *copy_##NAME(TYPE value) { %} static void delete_##NAME(TYPE *obj) { %} #ifdef __cplusplus -%{ if (obj) delete obj; %} +%{ delete obj; %} #else -%{ if (obj) free(obj); %} +%{ free(obj); %} #endif %{} |