summaryrefslogtreecommitdiff
path: root/Lib/swig.swg
diff options
context:
space:
mode:
authorWilliam S Fulton <wsf@fultondesigns.co.uk>2012-04-13 19:29:33 +0000
committerWilliam S Fulton <wsf@fultondesigns.co.uk>2012-04-13 19:29:33 +0000
commit478496bcae15324aa68c48ebb605f9f9b9de5358 (patch)
treec76d4131b97f8210c3c7e0801f9b0695c6540e61 /Lib/swig.swg
parent5c8e5542efc17030007175a1aff162d0eb24766a (diff)
downloadswig-478496bcae15324aa68c48ebb605f9f9b9de5358.tar.gz
Apply patch #3511009 from Leif Middelschulte for slightly optimised char * variable wrappers.
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@12979 626c5289-ae23-0410-ae9c-e8d60b6d4f22
Diffstat (limited to 'Lib/swig.swg')
-rw-r--r--Lib/swig.swg12
1 files changed, 6 insertions, 6 deletions
diff --git a/Lib/swig.swg b/Lib/swig.swg
index b47d4ff2c..fdcd4e5de 100644
--- a/Lib/swig.swg
+++ b/Lib/swig.swg
@@ -359,7 +359,7 @@ namespace std {
#ifdef __cplusplus
%typemap(memberin) char * {
- if ($1) delete [] $1;
+ delete [] $1;
if ($input) {
$1 = ($1_type) (new char[strlen((const char *)$input)+1]);
strcpy((char *)$1, (const char *)$input);
@@ -376,7 +376,7 @@ namespace std {
}
}
%typemap(globalin) char * {
- if ($1) delete [] $1;
+ delete [] $1;
if ($input) {
$1 = ($1_type) (new char[strlen((const char *)$input)+1]);
strcpy((char *)$1, (const char *)$input);
@@ -394,11 +394,11 @@ namespace std {
}
#else
%typemap(memberin) char * {
- if ($1) free((char *)$1);
if ($input) {
- $1 = ($1_type) malloc(strlen((const char *)$input)+1);
+ $1 = ($1_type) realloc($1, strlen((const char *)$input)+1);
strcpy((char *)$1, (const char *)$input);
} else {
+ free($1);
$1 = 0;
}
}
@@ -411,11 +411,11 @@ namespace std {
}
}
%typemap(globalin) char * {
- if ($1) free((char *)$1);
if ($input) {
- $1 = ($1_type) malloc(strlen((const char *)$input)+1);
+ $1 = ($1_type) realloc($1, strlen((const char *)$input)+1);
strcpy((char *)$1, (const char *)$input);
} else {
+ free ($1);
$1 = 0;
}
}