Remove redundant check for NULL in char * typemaps
No need to check for NULL before calling delete/free. Anyone using typemaps_string_alloc with custom allocators and deallocators need to ensure the custom allocators behave in the same way as the standard deallocators in this respect.
This commit is contained in:
parent
0e0f283e48
commit
5a4baece4f
1 changed files with 3 additions and 3 deletions
|
|
@ -79,7 +79,7 @@
|
||||||
if (!SWIG_IsOK(res)) {
|
if (!SWIG_IsOK(res)) {
|
||||||
%variable_fail(res,"$type","$name");
|
%variable_fail(res,"$type","$name");
|
||||||
}
|
}
|
||||||
if ($1) SWIG_DeleteCharArray($1);
|
SWIG_DeleteCharArray($1);
|
||||||
if (alloc == SWIG_NEWOBJ) {
|
if (alloc == SWIG_NEWOBJ) {
|
||||||
$1 = cptr;
|
$1 = cptr;
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -109,7 +109,7 @@
|
||||||
/* memberin */
|
/* memberin */
|
||||||
|
|
||||||
%typemap(memberin,noblock=1) Char * {
|
%typemap(memberin,noblock=1) Char * {
|
||||||
if ($1) SWIG_DeleteCharArray($1);
|
SWIG_DeleteCharArray($1);
|
||||||
if ($input) {
|
if ($input) {
|
||||||
size_t size = SWIG_CharPtrLen(%reinterpret_cast($input, const Char *)) + 1;
|
size_t size = SWIG_CharPtrLen(%reinterpret_cast($input, const Char *)) + 1;
|
||||||
$1 = ($1_type)SWIG_NewCopyCharArray(%reinterpret_cast($input, const Char *), size, Char);
|
$1 = ($1_type)SWIG_NewCopyCharArray(%reinterpret_cast($input, const Char *), size, Char);
|
||||||
|
|
@ -130,7 +130,7 @@
|
||||||
/* globalin */
|
/* globalin */
|
||||||
|
|
||||||
%typemap(globalin,noblock=1) Char * {
|
%typemap(globalin,noblock=1) Char * {
|
||||||
if ($1) SWIG_DeleteCharArray($1);
|
SWIG_DeleteCharArray($1);
|
||||||
if ($input) {
|
if ($input) {
|
||||||
size_t size = SWIG_CharPtrLen(%reinterpret_cast(%reinterpret_cast($input, const Char *), const Char *)) + 1;
|
size_t size = SWIG_CharPtrLen(%reinterpret_cast(%reinterpret_cast($input, const Char *), const Char *)) + 1;
|
||||||
$1 = ($1_type)SWIG_NewCopyCharArray($input, size, Char);
|
$1 = ($1_type)SWIG_NewCopyCharArray($input, size, Char);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue