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:
parent
74aa9cef17
commit
4fe414504f
2 changed files with 6 additions and 5 deletions
|
|
@ -64,7 +64,6 @@ static int String_dump(DOH *so, DOH *out) {
|
|||
* ----------------------------------------------------------------------------- */
|
||||
|
||||
static DOH *CopyString(DOH *so) {
|
||||
int max;
|
||||
String *str;
|
||||
String *s = (String *) ObjData(so);
|
||||
str = (String *) DohMalloc(sizeof(String));
|
||||
|
|
@ -74,10 +73,9 @@ static DOH *CopyString(DOH *so) {
|
|||
str->file = s->file;
|
||||
if (str->file)
|
||||
Incref(str->file);
|
||||
max = s->maxsize;
|
||||
str->str = (char *) DohMalloc(max + 1);
|
||||
memmove(str->str, s->str, max);
|
||||
str->maxsize = max;
|
||||
str->str = (char *) DohMalloc(s->len + 1);
|
||||
memcpy(str->str, s->str, s->len);
|
||||
str->maxsize = s->len;
|
||||
str->len = s->len;
|
||||
str->str[str->len] = 0;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue