fix many/many memory leaks
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/trunk/SWIG@7904 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
parent
fff0f6007b
commit
645f95d633
23 changed files with 627 additions and 251 deletions
|
|
@ -332,6 +332,7 @@ class Allocate : public Dispatcher {
|
|||
if (!nabstract) {
|
||||
nabstract = NewList();
|
||||
Setattr(n,"abstract",nabstract);
|
||||
Delete(nabstract);
|
||||
}
|
||||
Append(nabstract,nn);
|
||||
if (!Getattr(n,"abstract:firstnode")) {
|
||||
|
|
@ -557,6 +558,7 @@ public:
|
|||
List *abstract = NewList();
|
||||
Append(abstract,na);
|
||||
Setattr(n,"abstract",abstract);
|
||||
Delete(abstract);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -482,4 +482,5 @@ void emit_action(Node *n, Wrapper *f) {
|
|||
Printv(f->code,tm,"\n",NIL);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -956,7 +956,11 @@ Language::globalfunctionHandler(Node *n) {
|
|||
Delete(cbname);
|
||||
}
|
||||
Setattr(n,"parms",nonvoid_parms(parms));
|
||||
Setattr(n,"wrap:action", Swig_cresult(type,"result", Swig_cfunction_call(name,parms)));
|
||||
String *call = Swig_cfunction_call(name,parms);
|
||||
String *cres = Swig_cresult(type,"result", call);
|
||||
Setattr(n,"wrap:action", cres);
|
||||
Delete(cres);
|
||||
Delete(call);
|
||||
functionWrapper(n);
|
||||
}
|
||||
Swig_restore(n);
|
||||
|
|
@ -1207,11 +1211,10 @@ Language::membervariableHandler(Node *n) {
|
|||
}
|
||||
|
||||
if (!AttributeFunctionGet) {
|
||||
|
||||
String *mrename_get, *mrename_set;
|
||||
|
||||
mrename_get = Swig_name_get(Swig_name_member(ClassPrefix, symname));
|
||||
mrename_set = Swig_name_set(Swig_name_member(ClassPrefix, symname));
|
||||
String *mname = Swig_name_member(ClassPrefix, symname);
|
||||
String *mrename_get = Swig_name_get(mname);
|
||||
String *mrename_set = Swig_name_set(mname);
|
||||
Delete(mname);
|
||||
|
||||
/* Create a function to set the value of the variable */
|
||||
|
||||
|
|
@ -1234,10 +1237,14 @@ Language::membervariableHandler(Node *n) {
|
|||
String *base = Getattr(sn,"name");
|
||||
target = NewStringf("%s::%s", base,name);
|
||||
} else {
|
||||
target = NewStringf("(*%s)->%s",Swig_cparm_name(0,0),name);
|
||||
String *pname = Swig_cparm_name(0,0);
|
||||
target = NewStringf("(*%s)->%s",pname,name);
|
||||
Delete(pname);
|
||||
}
|
||||
} else {
|
||||
target = NewStringf("%s->%s", Swig_cparm_name(0,0),name);
|
||||
String *pname = Swig_cparm_name(0,0);
|
||||
target = NewStringf("%s->%s", pname,name);
|
||||
Delete(pname);
|
||||
}
|
||||
tm = Swig_typemap_lookup_new("memberin",n,target,0);
|
||||
}
|
||||
|
|
@ -1254,12 +1261,16 @@ Language::membervariableHandler(Node *n) {
|
|||
make_set_wrapper = 0;
|
||||
}
|
||||
} else {
|
||||
Replace(tm,"$source", Swig_cparm_name(0,1), DOH_REPLACE_ANY);
|
||||
String *pname0 = Swig_cparm_name(0,0);
|
||||
String *pname1 = Swig_cparm_name(0,1);
|
||||
Replace(tm,"$source", pname1, DOH_REPLACE_ANY);
|
||||
Replace(tm,"$target", target, DOH_REPLACE_ANY);
|
||||
Replace(tm,"$input",Swig_cparm_name(0,1),DOH_REPLACE_ANY);
|
||||
Replace(tm,"$self",Swig_cparm_name(0,0),DOH_REPLACE_ANY);
|
||||
Replace(tm,"$input",pname1,DOH_REPLACE_ANY);
|
||||
Replace(tm,"$self",pname0,DOH_REPLACE_ANY);
|
||||
Setattr(n,"wrap:action", tm);
|
||||
Delete(tm);
|
||||
Delete(pname0);
|
||||
Delete(pname1);
|
||||
}
|
||||
Delete(target);
|
||||
}
|
||||
|
|
@ -1307,7 +1318,7 @@ Language::membervariableHandler(Node *n) {
|
|||
cpp_member_func(Char(gname),Char(gname),type,0);
|
||||
Delete(ActionFunc);
|
||||
} else {
|
||||
String *cname = Copy(Swig_name_get(name));
|
||||
String *cname = Swig_name_get(name);
|
||||
cpp_member_func(Char(cname),Char(gname),type,0);
|
||||
Delete(cname);
|
||||
}
|
||||
|
|
@ -1320,7 +1331,7 @@ Language::membervariableHandler(Node *n) {
|
|||
cpp_member_func(Char(gname),Char(gname),vty,p);
|
||||
Delete(ActionFunc);
|
||||
} else {
|
||||
String *cname = Copy(Swig_name_set(name));
|
||||
String *cname = Swig_name_set(name);
|
||||
cpp_member_func(Char(cname),Char(gname),vty,p);
|
||||
Delete(cname);
|
||||
}
|
||||
|
|
@ -2459,8 +2470,9 @@ int Language::variableWrapper(Node *n) {
|
|||
String *tm = Swig_typemap_lookup_new("globalin", n, name, 0);
|
||||
|
||||
Swig_VarsetToFunction(n);
|
||||
|
||||
Setattr(n,"sym:name", Swig_name_set(symname));
|
||||
String *sname = Swig_name_set(symname);
|
||||
Setattr(n,"sym:name", sname);
|
||||
Delete(sname);
|
||||
|
||||
/* String *tm = Swig_typemap_lookup((char *) "globalin",type,name,name,Swig_cparm_name(0,0),name,0);*/
|
||||
|
||||
|
|
@ -2471,11 +2483,13 @@ int Language::variableWrapper(Node *n) {
|
|||
make_set_wrapper = 0;
|
||||
}
|
||||
} else {
|
||||
Replace(tm,"$source", Swig_cparm_name(0,0), DOH_REPLACE_ANY);
|
||||
String *pname0 = Swig_cparm_name(0,0);
|
||||
Replace(tm,"$source", pname0, DOH_REPLACE_ANY);
|
||||
Replace(tm,"$target", name, DOH_REPLACE_ANY);
|
||||
Replace(tm,"$input",Swig_cparm_name(0,0),DOH_REPLACE_ANY);
|
||||
Replace(tm,"$input",pname0,DOH_REPLACE_ANY);
|
||||
Setattr(n,"wrap:action", tm);
|
||||
Delete(tm);
|
||||
Delete(pname0);
|
||||
}
|
||||
if (make_set_wrapper) {
|
||||
functionWrapper(n);
|
||||
|
|
@ -2493,7 +2507,9 @@ int Language::variableWrapper(Node *n) {
|
|||
}
|
||||
}
|
||||
Swig_VargetToFunction(n);
|
||||
Setattr(n,"sym:name", Swig_name_get(symname));
|
||||
String *gname = Swig_name_get(symname);
|
||||
Setattr(n,"sym:name", gname);
|
||||
Delete(gname);
|
||||
functionWrapper(n);
|
||||
Swig_restore(n);
|
||||
return SWIG_OK;
|
||||
|
|
|
|||
|
|
@ -185,8 +185,9 @@ static void install_opts(int argc, char *argv[]) {
|
|||
}
|
||||
if (!noopt) {
|
||||
/* Printf(stdout,"%s\n", opt); */
|
||||
Delete(Preprocessor_define(opt, 0));
|
||||
Preprocessor_define(opt, 0);
|
||||
}
|
||||
Delete(opt);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -337,6 +338,7 @@ static void SWIG_dump_runtime() {
|
|||
Delete(s);
|
||||
|
||||
Close(runtime);
|
||||
Delete(runtime);
|
||||
SWIG_exit(EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
|
|
@ -357,9 +359,10 @@ void SWIG_getoptions(int argc, char *argv[])
|
|||
includefiles[includecount++] = Swig_copy_string(argv[i]+2);
|
||||
Swig_mark_arg(i);
|
||||
} else if (strncmp(argv[i],"-D",2) == 0) {
|
||||
DOH *d = NewString(argv[i]+2);
|
||||
String *d = NewString(argv[i]+2);
|
||||
Replace(d,(char*)"=",(char*)" ", DOH_REPLACE_ANY | DOH_REPLACE_FIRST);
|
||||
Delete(Preprocessor_define((DOH *) d,0));
|
||||
Preprocessor_define((DOH *) d,0);
|
||||
Delete(d);
|
||||
// Create a symbol
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i],"-E") == 0) {
|
||||
|
|
@ -374,7 +377,7 @@ void SWIG_getoptions(int argc, char *argv[])
|
|||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i],"-c++") == 0) {
|
||||
CPlusPlus=1;
|
||||
Delete(Preprocessor_define((DOH *) "__cplusplus __cplusplus", 0));
|
||||
Preprocessor_define((DOH *) "__cplusplus __cplusplus", 0);
|
||||
Swig_cparse_cplusplus(1);
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i],"-fcompact") == 0) {
|
||||
|
|
@ -461,8 +464,8 @@ void SWIG_getoptions(int argc, char *argv[])
|
|||
if (!outfile_name_h) {
|
||||
Printf(basename, ".%s", hpp_extension);
|
||||
outfile_name_h = Swig_copy_string(Char(basename));
|
||||
Delete(basename);
|
||||
}
|
||||
Delete(basename);
|
||||
}
|
||||
Swig_mark_arg(i+1);
|
||||
i++;
|
||||
|
|
@ -651,13 +654,13 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
// Set up some default symbols (available in both SWIG interface files
|
||||
// and C files)
|
||||
|
||||
Delete(Preprocessor_define((DOH *) "SWIG 1", 0));
|
||||
Delete(Preprocessor_define((DOH *) "__STDC__", 0));
|
||||
Preprocessor_define((DOH *) "SWIG 1", 0);
|
||||
Preprocessor_define((DOH *) "__STDC__", 0);
|
||||
#ifdef MACSWIG
|
||||
Delete(Preprocessor_define((DOH *) "SWIGMAC 1", 0));
|
||||
Preprocessor_define((DOH *) "SWIGMAC 1", 0);
|
||||
#endif
|
||||
#ifdef SWIGWIN32
|
||||
Delete(Preprocessor_define((DOH *) "SWIGWIN32 1", 0));
|
||||
Preprocessor_define((DOH *) "SWIGWIN32 1", 0);
|
||||
#endif
|
||||
|
||||
// Set the SWIG version value in format 0xAABBCC from package version expected to be in format A.B.C
|
||||
|
|
@ -678,7 +681,7 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
/* Turn on contracts */
|
||||
|
||||
Swig_contract_mode_set(1);
|
||||
Delete(Preprocessor_define(vers,0));
|
||||
Preprocessor_define(vers,0);
|
||||
|
||||
/* Turn off directors mode */
|
||||
Wrapper_director_mode_set(0);
|
||||
|
|
@ -715,7 +718,7 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
|
||||
// Define the __cplusplus symbol
|
||||
if (CPlusPlus)
|
||||
Delete(Preprocessor_define((DOH *) "__cplusplus __cplusplus", 0));
|
||||
Preprocessor_define((DOH *) "__cplusplus __cplusplus", 0);
|
||||
|
||||
// Parse language dependent options
|
||||
lang->main(argc,argv);
|
||||
|
|
@ -827,6 +830,7 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
}
|
||||
Seek(fs,0,SEEK_SET);
|
||||
cpps = Preprocessor_parse(fs);
|
||||
Delete(fs);
|
||||
} else {
|
||||
df = Swig_open(input_file);
|
||||
cpps = NewFileFromFile(df);
|
||||
|
|
@ -965,9 +969,15 @@ int SWIG_main(int argc, char *argv[], Language *l) {
|
|||
if (dump_xml) {
|
||||
Swig_print_xml(top, xmlout);
|
||||
}
|
||||
Delete(top);
|
||||
}
|
||||
if (tm_debug) Swig_typemap_debug();
|
||||
if (memory_debug) DohMemoryDebug();
|
||||
|
||||
// Deletes
|
||||
Delete(libfiles);
|
||||
Preprocessor_delete();
|
||||
|
||||
while (freeze);
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -423,6 +423,7 @@ Swig_overload_dispatch(Node *n, const String_or_char *fmt, int *maxargs) {
|
|||
for (/* empty */; num_braces > 0; num_braces--)
|
||||
Printf(f, "}\n");
|
||||
Printf(f,"}\n"); /* braces closes "if" for this method */
|
||||
Delattr(ni,"wrap:parms");
|
||||
}
|
||||
Delete(dispatch);
|
||||
return f;
|
||||
|
|
|
|||
|
|
@ -164,7 +164,7 @@ public:
|
|||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i],"-nortti") == 0) {
|
||||
/* Turn on no RTTI mode */
|
||||
Delete(Preprocessor_define((DOH *) "SWIG_NORTTI", 0));
|
||||
Preprocessor_define((DOH *) "SWIG_NORTTI", 0);
|
||||
Swig_mark_arg(i);
|
||||
} else if (strcmp(argv[i],"-modern") == 0) {
|
||||
apply = 0;
|
||||
|
|
@ -189,11 +189,11 @@ public:
|
|||
}
|
||||
|
||||
if (cppcast) {
|
||||
Delete(Preprocessor_define((DOH *) "SWIG_CPLUSPLUS_CAST", 0));
|
||||
Preprocessor_define((DOH *) "SWIG_CPLUSPLUS_CAST", 0);
|
||||
}
|
||||
|
||||
if (!global_name) global_name = NewString("cvar");
|
||||
Delete(Preprocessor_define("SWIGPYTHON 1", 0));
|
||||
Preprocessor_define("SWIGPYTHON 1", 0);
|
||||
SWIG_typemap_lang("python");
|
||||
SWIG_config_file("python.swg");
|
||||
allow_overloading();
|
||||
|
|
@ -2304,6 +2304,7 @@ public:
|
|||
if (!shadow_list) {
|
||||
shadow_list = NewList();
|
||||
Setattr(getCurrentClass(),"shadow_methods", shadow_list);
|
||||
Delete(shadow_list);
|
||||
}
|
||||
Append(shadow_list, symname);
|
||||
} else {
|
||||
|
|
@ -2560,27 +2561,29 @@ public:
|
|||
Language::membervariableHandler(n);
|
||||
shadow = oldshadow;
|
||||
|
||||
String *mname = Swig_name_member(class_name,symname);
|
||||
String *sname = Swig_name_set(mname);
|
||||
String *gname = Swig_name_get(mname);
|
||||
if (shadow) {
|
||||
int assignable = is_assignable(n);
|
||||
if (!modern) {
|
||||
if (assignable) {
|
||||
Printv(f_shadow, tab4, "__swig_setmethods__[\"", symname, "\"] = ", module, ".", Swig_name_set(Swig_name_member(class_name,symname)), "\n", NIL);
|
||||
Printv(f_shadow, tab4, "__swig_setmethods__[\"", symname, "\"] = ", module, ".", sname, "\n", NIL);
|
||||
}
|
||||
Printv(f_shadow, tab4, "__swig_getmethods__[\"", symname, "\"] = ", module, ".", Swig_name_get(Swig_name_member(class_name,symname)),"\n", NIL);
|
||||
Printv(f_shadow, tab4, "__swig_getmethods__[\"", symname, "\"] = ", module, ".", gname,"\n", NIL);
|
||||
}
|
||||
if (!classic) {
|
||||
if (!assignable) {
|
||||
Printv(f_shadow,tab4, modern ? "" : "if _newclass:",
|
||||
symname," = property(", module, ".",
|
||||
Swig_name_get(Swig_name_member(class_name,symname)),")\n", NIL);
|
||||
Printv(f_shadow, tab4, modern ? "" : "if _newclass:", symname," = property(", module, ".", gname,")\n", NIL);
|
||||
} else {
|
||||
Printv(f_shadow,tab4, modern ? "" : "if _newclass:",
|
||||
symname," = property(",
|
||||
module, ".", Swig_name_get(Swig_name_member(class_name,symname)),", ",
|
||||
module, ".", Swig_name_set(Swig_name_member(class_name,symname)),")\n", NIL);
|
||||
Printv(f_shadow, tab4, modern ? "" : "if _newclass:", symname," = property(", module, ".", gname,", ", module, ".", sname,")\n", NIL);
|
||||
}
|
||||
}
|
||||
}
|
||||
Delete(mname);
|
||||
Delete(sname);
|
||||
Delete(gname);
|
||||
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
@ -2597,7 +2600,9 @@ public:
|
|||
t = Getattr(n,"type");
|
||||
symname = Getattr(n,"sym:name");
|
||||
if (SwigType_isconst(t) && !Getattr(n, "value")) {
|
||||
Printf(f_shadow_stubs,"%s.%s = %s.%s.%s\n", class_name, symname, module, global_name, Swig_name_member(class_name,symname));
|
||||
String *mname = Swig_name_member(class_name,symname);
|
||||
Printf(f_shadow_stubs,"%s.%s = %s.%s.%s\n", class_name, symname, module, global_name, mname);
|
||||
Delete(mname);
|
||||
}
|
||||
}
|
||||
return SWIG_OK;
|
||||
|
|
|
|||
|
|
@ -2041,10 +2041,11 @@ public:
|
|||
|
||||
String *freefunc = NewString("");
|
||||
String *freebody = NewString("");
|
||||
String *pname0 = Swig_cparm_name(0,0);
|
||||
|
||||
Printv(freefunc, "free_", klass->mname, NIL);
|
||||
Printv(freebody, "SWIGINTERN void\n",
|
||||
freefunc, "(", klass->type, " *", Swig_cparm_name(0,0), ") {\n",
|
||||
freefunc, "(", klass->type, " *", pname0, ") {\n",
|
||||
tab4, NIL);
|
||||
|
||||
if (Extend) {
|
||||
|
|
@ -2052,7 +2053,7 @@ public:
|
|||
if (wrap) {
|
||||
Printv(f_wrappers, wrap, NIL);
|
||||
}
|
||||
/* Printv(freebody, Swig_name_destroy(name), "(", Swig_cparm_name(0,0), ")", NIL); */
|
||||
/* Printv(freebody, Swig_name_destroy(name), "(", pname0, ")", NIL); */
|
||||
Printv(freebody,Getattr(n,"wrap:action"), NIL);
|
||||
} else {
|
||||
String *action = Getattr(n,"wrap:action");
|
||||
|
|
@ -2061,14 +2062,14 @@ public:
|
|||
} else {
|
||||
/* In the case swig emits no destroy function. */
|
||||
if (CPlusPlus)
|
||||
Printf(freebody, "delete %s;\n", Swig_cparm_name(0,0));
|
||||
Printf(freebody, "delete %s;\n", pname0);
|
||||
else
|
||||
Printf(freebody, "free((char*) %s);\n", Swig_cparm_name(0,0));
|
||||
Printf(freebody, "free((char*) %s);\n", pname0);
|
||||
}
|
||||
}
|
||||
|
||||
if (GetFlag(n,"feature:trackobjects")) {
|
||||
Printf(freebody, " SWIG_RubyRemoveTracking(%s);\n", Swig_cparm_name(0,0));
|
||||
Printf(freebody, " SWIG_RubyRemoveTracking(%s);\n", pname0);
|
||||
}
|
||||
Printv(freebody, "}\n\n", NIL);
|
||||
|
||||
|
|
@ -2078,6 +2079,7 @@ public:
|
|||
current = NO_CPP;
|
||||
Delete(freefunc);
|
||||
Delete(freebody);
|
||||
Delete(pname0);
|
||||
return SWIG_OK;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -198,6 +198,8 @@ int main(int margc, char **margv) {
|
|||
dl = (fac)();
|
||||
}
|
||||
}
|
||||
return SWIG_main(argc,argv,dl);
|
||||
int res = SWIG_main(argc,argv,dl);
|
||||
delete dl;
|
||||
return res;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ class TypePass : private Dispatcher {
|
|||
|
||||
if (first == cls) return; /* The Marcelo check */
|
||||
if (!cls) cls = first;
|
||||
|
||||
List *alist = 0;
|
||||
List *ilist = Getattr(cls,bases);
|
||||
if (!ilist) {
|
||||
List *nlist = Getattr(cls,baselist);
|
||||
|
|
@ -184,7 +184,7 @@ class TypePass : private Dispatcher {
|
|||
bcls = 0;
|
||||
} else {
|
||||
if (Getattr(bcls,"typepass:visit")) {
|
||||
if (!ilist) ilist = NewList();
|
||||
if (!ilist) ilist = alist = NewList();
|
||||
Append(ilist,bcls);
|
||||
} else {
|
||||
Swig_warning(WARN_TYPE_UNDEFINED_CLASS,Getfile(cls),Getline(cls),"Base class '%s' undefined.\n", bname);
|
||||
|
|
@ -214,6 +214,8 @@ class TypePass : private Dispatcher {
|
|||
Setattr(cls,bases,ilist);
|
||||
}
|
||||
}
|
||||
if (alist) Delete(alist);
|
||||
|
||||
if (!ilist) return;
|
||||
int len = Len(ilist);
|
||||
int i;
|
||||
|
|
@ -269,9 +271,8 @@ class TypePass : private Dispatcher {
|
|||
append_list(allbases,Getattr(cls,"privatebases"));
|
||||
if (Len(allbases)) {
|
||||
Setattr(cls,"allbases",allbases);
|
||||
} else {
|
||||
Delete(allbases);
|
||||
}
|
||||
Delete(allbases);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue