String copying patch from Josh Cherry reducing memory consumption by about 25%.

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk@9657 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
William S Fulton 2007-03-23 22:12:10 +00:00
commit 4fe414504f
2 changed files with 6 additions and 5 deletions

View file

@ -1,6 +1,9 @@
Version 1.3.32 (in progress) Version 1.3.32 (in progress)
============================ ============================
03/23/2007: wsfulton
String copying patch from Josh Cherry reducing memory consumption by about 25%.
03/21/2007: wsfulton 03/21/2007: wsfulton
[Java] Apply patch #1631987 from Ulrik Peterson - bool INOUT typemaps [Java] Apply patch #1631987 from Ulrik Peterson - bool INOUT typemaps
fail on big endian machines. fail on big endian machines.

View file

@ -64,7 +64,6 @@ static int String_dump(DOH *so, DOH *out) {
* ----------------------------------------------------------------------------- */ * ----------------------------------------------------------------------------- */
static DOH *CopyString(DOH *so) { static DOH *CopyString(DOH *so) {
int max;
String *str; String *str;
String *s = (String *) ObjData(so); String *s = (String *) ObjData(so);
str = (String *) DohMalloc(sizeof(String)); str = (String *) DohMalloc(sizeof(String));
@ -74,10 +73,9 @@ static DOH *CopyString(DOH *so) {
str->file = s->file; str->file = s->file;
if (str->file) if (str->file)
Incref(str->file); Incref(str->file);
max = s->maxsize; str->str = (char *) DohMalloc(s->len + 1);
str->str = (char *) DohMalloc(max + 1); memcpy(str->str, s->str, s->len);
memmove(str->str, s->str, max); str->maxsize = s->len;
str->maxsize = max;
str->len = s->len; str->len = s->len;
str->str[str->len] = 0; str->str[str->len] = 0;