Update of /cvsroot/swig/SWIG/Source/Swig In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18999/Source/Swig Modified Files: cwrap.c fragment.c include.c naming.c parms.c stype.c symbol.c typemap.c typeobj.c typesys.c Log Message: remove many memory leaks and cleanup Index: typeobj.c =================================================================== RCS file: /cvsroot/swig/SWIG/Source/Swig/typeobj.c,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** typeobj.c 28 Nov 2005 17:32:56 -0000 1.13 --- typeobj.c 29 Nov 2005 01:47:10 -0000 1.14 *************** *** 720,723 **** --- 720,724 ---- if (pp) { set_nextSibling(pp,p); + Delete(p); } pp = p; Index: include.c =================================================================== RCS file: /cvsroot/swig/SWIG/Source/Swig/include.c,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** include.c 28 Nov 2005 17:32:56 -0000 1.21 --- include.c 29 Nov 2005 01:47:10 -0000 1.22 *************** *** 168,171 **** --- 168,172 ---- Append(slist,filename); } + Delete(filename); } if (syspath) { Index: naming.c =================================================================== RCS file: /cvsroot/swig/SWIG/Source/Swig/naming.c,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** naming.c 28 Nov 2005 17:32:56 -0000 1.26 --- naming.c 29 Nov 2005 01:47:10 -0000 1.27 *************** *** 402,405 **** --- 402,406 ---- n = NewHash(); Setattr(namehash,name,n); + Delete(n); } /* Add an object based on the declarator value */ *************** *** 407,411 **** Setattr(n,"*",object); } else { ! Setattr(n,Copy(decl),object); } } --- 408,414 ---- Setattr(n,"*",object); } else { ! SwigType *cd = Copy(decl); ! Setattr(n,cd,object); ! Delete(cd); } } *************** *** 556,560 **** if (!features) return; for (ki = First(features); ki.key; ki = Next(ki)) { ! Setattr(n,ki.key,Copy(ki.item)); } } --- 559,565 ---- if (!features) return; for (ki = First(features); ki.key; ki = Next(ki)) { ! String *ci = Copy(ki.item); ! Setattr(n,ki.key,ci); ! Delete(ci); } } *************** *** 684,687 **** --- 689,693 ---- n = NewHash(); Setattr(features,name,n); + Delete(n); } if (!decl) { *************** *** 690,693 **** --- 696,700 ---- fhash = NewHash(); Setattr(n,"*",fhash); + Delete(fhash); } } else { *************** *** 696,699 **** --- 703,707 ---- fhash = NewHash(); Setattr(n,Copy(decl),fhash); + Delete(fhash); } } Index: typesys.c =================================================================== RCS file: /cvsroot/swig/SWIG/Source/Swig/typesys.c,v retrieving revision 1.42 retrieving revision 1.43 diff -C2 -d -r1.42 -r1.43 *** typesys.c 28 Nov 2005 17:32:56 -0000 1.42 --- typesys.c 29 Nov 2005 01:47:10 -0000 1.43 *************** *** 859,863 **** int i,len; if (!typedef_qualified_cache) typedef_qualified_cache = NewHash(); ! result = Getattr(typedef_qualified_cache,t); if (result) { String *rc = Copy(result); --- 859,863 ---- int i,len; if (!typedef_qualified_cache) typedef_qualified_cache = NewHash(); ! result = HashGetAttr(typedef_qualified_cache,t); if (result) { String *rc = Copy(result); *************** *** 1404,1407 **** --- 1404,1408 ---- SwigType *qr; String *tkey; + String *cd; if (!r_mangled) { *************** *** 1420,1425 **** tkey = Copy(t); ! Setattr(r_remembered, tkey, clientdata ? NewString(clientdata) : (void *) ""); Delete(tkey); mt = SwigType_manglestr(t); /* Create mangled string */ --- 1421,1428 ---- tkey = Copy(t); ! cd = clientdata ? NewString(clientdata) : NewStringEmpty(); ! Setattr(r_remembered, tkey, cd); Delete(tkey); + Delete(cd); mt = SwigType_manglestr(t); /* Create mangled string */ Index: typemap.c =================================================================== RCS file: /cvsroot/swig/SWIG/Source/Swig/typemap.c,v retrieving revision 1.52 retrieving revision 1.53 diff -C2 -d -r1.52 -r1.53 *** typemap.c 28 Nov 2005 17:32:56 -0000 1.52 --- typemap.c 29 Nov 2005 01:47:10 -0000 1.53 *************** *** 561,569 **** /* Clear typemaps that match our signature */ Iterator ki, ki2; ! for (ki = First(tm); ki.key; ki = Next(ki)) { ! if (Strncmp(ki.key,"tmap:",5) == 0) { int na = count_args(ki.key); ! if ((na == narg) && Strstr(ki.key,tsig)) { Hash *h = ki.item; for (ki2 = First(h); ki2.key; ki2 = Next(ki2)) { --- 561,570 ---- /* Clear typemaps that match our signature */ Iterator ki, ki2; ! char *ctsig = Char(tsig); for (ki = First(tm); ki.key; ki = Next(ki)) { ! char *ckey = Char(ki.key); ! if (strncmp(ckey,"tmap:",5) == 0) { int na = count_args(ki.key); ! if ((na == narg) && strstr(ckey,ctsig)) { Hash *h = ki.item; for (ki2 = First(h); ki2.key; ki2 = Next(ki2)) { *************** *** 1256,1260 **** st = Getattr(node,"sym:symtab"); qsn = st ? Swig_symbol_qualifiedscopename(st) : 0; ! if (qsn && Len(qsn)) { /* look qualified names first, such as --- 1257,1261 ---- st = Getattr(node,"sym:symtab"); qsn = st ? Swig_symbol_qualifiedscopename(st) : 0; ! if (qsn && StringLen(qsn)) { /* look qualified names first, such as *************** *** 1541,1544 **** --- 1542,1546 ---- /* increase argnum to consider numinputs */ argnum += nmatch - 1; + Delete(s); } } *************** *** 1567,1571 **** args = NewList(); ! c = Strstr(s,"("); c++; --- 1569,1573 ---- args = NewList(); ! c = strstr(Char(s),"("); c++; *************** *** 1606,1610 **** char *c; ! eq = Strstr(s,"="); if (!eq) { *name = 0; --- 1608,1612 ---- char *c; ! eq = strstr(Char(s),"="); if (!eq) { *name = 0; *************** *** 1631,1638 **** static void replace_embedded_typemap(String *s) { char *start = 0; ! while (start = strstr(Char(s),"$TYPEMAP(")) { /* Gather the argument */ ! char *start, *end=0,*c; int level = 0; String *tmp; --- 1633,1640 ---- static void replace_embedded_typemap(String *s) { char *start = 0; ! while ((start = strstr(Char(s),"$TYPEMAP("))) { /* Gather the argument */ ! char *end=0,*c; int level = 0; String *tmp; Index: parms.c =================================================================== RCS file: /cvsroot/swig/SWIG/Source/Swig/parms.c,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** parms.c 28 Nov 2005 17:32:56 -0000 1.16 --- parms.c 29 Nov 2005 01:47:10 -0000 1.17 *************** *** 196,203 **** while(p) { String *pstr = SwigType_str(Getattr(p,"type"), Getattr(p,"name")); ! Append(out,pstr); p = nextSibling(p); if (p) { ! Append(out,","); } Delete(pstr); --- 196,203 ---- while(p) { String *pstr = SwigType_str(Getattr(p,"type"), Getattr(p,"name")); ! StringAppend(out,pstr); p = nextSibling(p); if (p) { ! StringAppend(out,","); } Delete(pstr); *************** *** 217,221 **** String *value = Getattr(p,"value"); String *pstr = SwigType_str(Getattr(p,"type"), Getattr(p,"name")); ! Append(out,pstr); if (value) { Printf(out,"=%s", value); --- 217,221 ---- String *value = Getattr(p,"value"); String *pstr = SwigType_str(Getattr(p,"type"), Getattr(p,"name")); ! StringAppend(out,pstr); if (value) { Printf(out,"=%s", value); *************** *** 223,227 **** p = nextSibling(p); if (p) { ! Append(out,","); } Delete(pstr); --- 223,227 ---- p = nextSibling(p); if (p) { ! StringAppend(out,","); } Delete(pstr); *************** *** 243,250 **** } else { String *pstr = SwigType_str(Getattr(p,"type"), 0); ! Append(out,pstr); p = nextSibling(p); if (p) { ! Append(out,","); } Delete(pstr); --- 243,250 ---- } else { String *pstr = SwigType_str(Getattr(p,"type"), 0); ! StringAppend(out,pstr); p = nextSibling(p); if (p) { ! StringAppend(out,","); } Delete(pstr); Index: fragment.c =================================================================== RCS file: /cvsroot/swig/SWIG/Source/Swig/fragment.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** fragment.c 27 Nov 2005 02:58:24 -0000 1.8 --- fragment.c 29 Nov 2005 01:47:10 -0000 1.9 *************** *** 44,49 **** Delete(mangle); Delete(rtype); } - if (debug) Printf(stdout,"register fragment %s %s\n",name,type); if (!fragments) { fragments = NewHash(); --- 44,49 ---- Delete(mangle); Delete(rtype); + if (debug) Printf(stdout,"register fragment %s %s\n",name,type); } if (!fragments) { fragments = NewHash(); *************** *** 55,61 **** Setmeta(ccode,"section",section); if (kwargs) { - kwargs = Copy(kwargs); Setmeta(ccode,"kwargs",kwargs); - Delete(kwargs); } Setattr(fragments,name,ccode); --- 55,59 ---- *************** *** 64,67 **** --- 62,66 ---- Delete(ccode); } + Delete(name); } } *************** *** 141,144 **** --- 140,144 ---- if (pc) *pc = 0; } + Delete(name); } Delete(t); Index: symbol.c =================================================================== RCS file: /cvsroot/swig/SWIG/Source/Swig/symbol.c,v retrieving revision 1.35 retrieving revision 1.36 diff -C2 -d -r1.35 -r1.36 *** symbol.c 28 Nov 2005 17:32:56 -0000 1.35 --- symbol.c 29 Nov 2005 01:47:10 -0000 1.36 *************** *** 237,241 **** void Swig_symbol_init() { ! empty_string = NewStringEmpty(); k_allowstypedef = NewString("allows_typedef"); k_cdecl = NewString("cdecl"); --- 237,241 ---- void Swig_symbol_init() { ! empty_string = NewString(""); k_allowstypedef = NewString("allows_typedef"); k_cdecl = NewString("cdecl"); Index: cwrap.c =================================================================== RCS file: /cvsroot/swig/SWIG/Source/Swig/cwrap.c,v retrieving revision 1.67 retrieving revision 1.68 diff -C2 -d -r1.67 -r1.68 *** cwrap.c 28 Nov 2005 17:32:56 -0000 1.67 --- cwrap.c 29 Nov 2005 01:47:10 -0000 1.68 *************** *** 81,87 **** String *lcaststr = SwigType_lcaststr(t,value); String *lstr = SwigType_lstr(t,0); ! Printf(decl,"%s = (%s) %s", SwigType_lstr(t,name), lstr, lcaststr); Delete(lcaststr); Delete(lstr); } else { String *lstrname = SwigType_lstr(t,name); --- 81,89 ---- String *lcaststr = SwigType_lcaststr(t,value); String *lstr = SwigType_lstr(t,0); ! String *lstrn = SwigType_lstr(t,name); ! Printf(decl,"%s = (%s) %s", lstrn, lstr, lcaststr); Delete(lcaststr); Delete(lstr); + Delete(lstrn); } else { String *lstrname = SwigType_lstr(t,name); *************** *** 195,199 **** if (tycode != T_USER) { /* plain primitive type, we copy the the def value */ ! defvalue = NewStringf("%s = %s", SwigType_lstr(tvalue,defname),qvalue); } else { /* user type, we copy the reference value */ --- 197,203 ---- if (tycode != T_USER) { /* plain primitive type, we copy the the def value */ ! String *lstr = SwigType_lstr(tvalue,defname); ! defvalue = NewStringf("%s = %s", lstr,qvalue); ! Delete(lstr); } else { /* user type, we copy the reference value */ *************** *** 240,246 **** case T_VOID: break; ! case T_REFERENCE: ! Printf(fcall,"{\n"); ! Printf(fcall,"%s = ", SwigType_str(t,"_result_ref")); break; case T_USER: --- 244,254 ---- case T_VOID: break; ! case T_REFERENCE: ! { ! String *str = SwigType_str(t,"_result_ref"); ! Printf(fcall,"{\n"); ! Printf(fcall,"%s = ", str); ! Delete(str); ! } break; case T_USER: *************** *** 250,254 **** default: /* Normal return value */ ! Printf(fcall,"%s = (%s)", name, SwigType_lstr(t,0)); break; } --- 258,266 ---- default: /* Normal return value */ ! { ! String *lstr = SwigType_lstr(t,0); ! Printf(fcall,"%s = (%s)", name, lstr); ! Delete(lstr); ! } break; } *************** *** 312,316 **** Printf(func,"%s(", nname); } ! while (p) { --- 324,328 ---- Printf(func,"%s(", nname); } ! Delete(nname); while (p) { *************** *** 771,775 **** /* Generate action code for the access */ if (!(flags & CWRAP_EXTEND)) { ! Setattr(n,"wrap:action", Swig_cresult(Getattr(n,"type"),"result", Swig_cmethod_call(name,p,self))); } else { /* Methods with default arguments are wrapped with additional methods for each default argument, --- 783,791 ---- /* Generate action code for the access */ if (!(flags & CWRAP_EXTEND)) { ! String *call = Swig_cmethod_call(name,p,self); ! String *result = Swig_cresult(Getattr(n,"type"),"result", call); ! Setattr(n,"wrap:action", result); ! Delete(call); ! Delete(result); } else { /* Methods with default arguments are wrapped with additional methods for each default argument, Index: stype.c =================================================================== RCS file: /cvsroot/swig/SWIG/Source/Swig/stype.c,v retrieving revision 1.63 retrieving revision 1.64 diff -C2 -d -r1.63 -r1.64 *** stype.c 28 Nov 2005 17:32:56 -0000 1.63 --- stype.c 29 Nov 2005 01:47:10 -0000 1.64 *************** *** 890,894 **** if (SwigType_isarray(s)) { ! Printf(result,"(%s)%s", SwigType_lstr(s,0),name); } else if (SwigType_isreference(s)) { String *str = SwigType_str(s,0); --- 890,896 ---- if (SwigType_isarray(s)) { ! String *lstr = SwigType_lstr(s,0); ! Printf(result,"(%s)%s", lstr,name); ! Delete(lstr); } else if (SwigType_isreference(s)) { String *str = SwigType_str(s,0); *************** *** 896,905 **** Delete(str); if (name) ! Append(result,name); } else if (SwigType_isqualifier(s)) { ! Printf(result,"(%s)%s", SwigType_lstr(s,0),name); } else { if (name) ! Append(result,name); } return result; --- 898,909 ---- Delete(str); if (name) ! StringAppend(result,name); } else if (SwigType_isqualifier(s)) { ! String *lstr = SwigType_lstr(s,0); ! Printf(result,"(%s)%s", lstr,name); ! Delete(lstr); } else { if (name) ! StringAppend(result,name); } return result; *************** *** 1008,1015 **** int j; String *nt = SwigType_templateprefix(e); ! Append(nt,"<("); for (j = 0; j < Len(tparms); j++) { SwigType_typename_replace(Getitem(tparms,j), pat, rep); ! Append(nt,Getitem(tparms,j)); if (j < (Len(tparms)-1)) Putc(',',nt); } --- 1012,1019 ---- int j; String *nt = SwigType_templateprefix(e); ! StringAppend(nt,"<("); for (j = 0; j < Len(tparms); j++) { SwigType_typename_replace(Getitem(tparms,j), pat, rep); ! StringAppend(nt,Getitem(tparms,j)); if (j < (Len(tparms)-1)) Putc(',',nt); } *************** *** 1018,1022 **** Delete(tsuffix); Clear(e); ! Append(e,nt); Delete(nt); Delete(tparms); --- 1022,1026 ---- Delete(tsuffix); Clear(e); ! StringAppend(e,nt); Delete(nt); Delete(tparms); *************** *** 1037,1052 **** List *fparms = SwigType_parmlist(e); Clear(e); ! Append(e,"f("); for (j = 0; j < Len(fparms); j++) { SwigType_typename_replace(Getitem(fparms,j), pat, rep); ! Append(e,Getitem(fparms,j)); if (j < (Len(fparms)-1)) Putc(',',e); } ! Append(e,")."); Delete(fparms); } else if (SwigType_isarray(e)) { Replace(e,pat,rep, DOH_REPLACE_ID); } ! Append(nt,e); } Clear(t); --- 1041,1056 ---- List *fparms = SwigType_parmlist(e); Clear(e); ! StringAppend(e,"f("); for (j = 0; j < Len(fparms); j++) { SwigType_typename_replace(Getitem(fparms,j), pat, rep); ! StringAppend(e,Getitem(fparms,j)); if (j < (Len(fparms)-1)) Putc(',',e); } ! StringAppend(e,")."); Delete(fparms); } else if (SwigType_isarray(e)) { Replace(e,pat,rep, DOH_REPLACE_ID); } ! StringAppend(nt,e); } Clear(t); *************** *** 1068,1076 **** t1 = SwigType_strip_qualifiers(t); t2 = SwigType_prefix(t1); ! r = Cmp(t2,decl); Delete(t); Delete(t1); Delete(t2); ! if (r == 0) return 1; ! return 0; } --- 1072,1079 ---- t1 = SwigType_strip_qualifiers(t); t2 = SwigType_prefix(t1); ! r = Equal(t2,decl); Delete(t); Delete(t1); Delete(t2); ! return r == 1; } |