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
|
|
@ -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
|
||||
%{}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue